Skip to content

Instantly share code, notes, and snippets.

@nicksteffens
Created July 9, 2020 18:53
Show Gist options
  • Save nicksteffens/f5b21123fcdcaa9cf47e9f57d7706d7d to your computer and use it in GitHub Desktop.
Save nicksteffens/f5b21123fcdcaa9cf47e9f57d7706d7d to your computer and use it in GitHub Desktop.
// Typescript Generics
class MyMap<T extends Error> {
value: T;
getVal() {
return this.value;
}
constructor(val: T) {
this.value = val;
}
}
const map1 = new MyMap(new Error('message'));
const value = map1.getVal();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment