Skip to content

Instantly share code, notes, and snippets.

@another-guy
Created October 6, 2017 05:56
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 another-guy/e459cea9430d66519b08769e6a2e639d to your computer and use it in GitHub Desktop.
Save another-guy/e459cea9430d66519b08769e6a2e639d to your computer and use it in GitHub Desktop.
export class Mammal {
mammalName: string;
}
export class Dog extends Mammal {
dogName: string;
}
export class Cat extends Mammal {
catName: string;
}
const cat: Cat = { catName: 'kitty' };
const dog: Dog = { dogName: 'doggo' };
export function compare<T>(a: T, b: T): number {
// ... implementation
}
// Guess what is the inferred type of `T` here
const comparationResult = comparator(cat, dog);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment