Skip to content

Instantly share code, notes, and snippets.

@tswistak
Created January 16, 2019 10:34
Show Gist options
  • Save tswistak/ce4063932a8155323a1419e82a5e3063 to your computer and use it in GitHub Desktop.
Save tswistak/ce4063932a8155323a1419e82a5e3063 to your computer and use it in GitHub Desktop.
Avoiding any in TypeScript, listing 7
type C = { a: string; b: string; c: boolean; d: string; }
type D = { b: string; c: boolean; }
type pickCkeys = Pick<C, 'c'>
type pickCD = Pick<C, keyof D>;
const c: pickCkeys = { c: true }; // a, b, d doesn't exist
const d: pickCD = { b: 'a', c: true }; // a, d doesn't exist
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment