Created
October 1, 2025 20:11
-
-
Save serjKim/474e066be42791db0d32b4cd3fbc2178 to your computer and use it in GitHub Desktop.
Test data infer
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| interface Data { | |
| age?: number; | |
| a: string | null; | |
| c: string; | |
| } | |
| function f<T extends Partial<Data>>(d?: T & { [K in keyof T]: K extends keyof Data ? T[K] : never }): Pick<Data & T, keyof Data> { | |
| return { | |
| c: 'default', | |
| a: 'asd', | |
| ...d, | |
| }; | |
| } | |
| const x = f({ | |
| a: 'asd', | |
| age: 100 | |
| }); | |
| x.age.toFixed(); | |
| x.a.charAt(1); | |
| x.c.toString(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment