Created
January 16, 2019 10:35
-
-
Save tswistak/3478f32cb1023ac6f1d93d036859dfce to your computer and use it in GitHub Desktop.
Avoiding any in TypeScript, listing 8
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
type E = { a: string; b: string; } | |
function withPick<K extends keyof E>(state: Pick<E, K>): void { return; } | |
function withPartial<E>(state: Partial<E>) { return; } | |
withPick({ a: null }); // 'null' is not assignable to type string | |
withPartial({ a: null }); // no error |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment