Created
March 7, 2024 23:34
-
-
Save justinhj/d3cdd85fcdc27a458effa548d2da242c to your computer and use it in GitHub Desktop.
Weird use of Omit
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 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