Skip to content

Instantly share code, notes, and snippets.

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