Skip to content

Instantly share code, notes, and snippets.

@justinhj
Created March 7, 2024 23:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save justinhj/d3cdd85fcdc27a458effa548d2da242c to your computer and use it in GitHub Desktop.
Save justinhj/d3cdd85fcdc27a458effa548d2da242c to your computer and use it in GitHub Desktop.
Weird use of Omit
type Species = 'hobbit' | 'orc' | 'elf' | 'man';
interface MiddleEarthDenizen {
name: string
species: Species
}
interface Hobbit extends Omit<MiddleEarthDenizen, 'species'> {
burrow: string
species: 'hobbit'
}
let h1: Hobbit = {name: 'Bilbo', burrow: 'Bag End', species: 'hobbit'};
function showMiddleEarthDenizen(denizen: MiddleEarthDenizen) {
console.log(h1);
}
showMiddleEarthDenizen(h1);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment