Type Helper to select fields

Hello there ! A picture is worth a thousands words. I'm trying to write this helper, but it breaks inference. Does anyone know of something that could work ?
export type Select<T> = {
[P in keyof T]?: boolean;
};
export type Select<T> = {
[P in keyof T]?: boolean;
};
No description
3 Replies
DoronT
DoronT2y ago
any news about the solution for this?
Angelelz
Angelelz2y ago
The problem here is that there is no connection between the Select helper and the columns type Typescript is not able to bridge the connection there, typescript just sees that Select is some Record<string, boolean>
DoronT
DoronT2y ago
There is a solution here https://discord.com/channels/1043890932593987624/1129395697200939038 but there are still cases where is not perfect

Did you find this page helpful?