Skip to content

Instantly share code, notes, and snippets.

@bennycode
Last active May 16, 2022 20:59
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 bennycode/66dd8b173cdd830c2f52152b346ad0f9 to your computer and use it in GitHub Desktop.
Save bennycode/66dd8b173cdd830c2f52152b346ad0f9 to your computer and use it in GitHub Desktop.
Generic Classes in TypeScript
class KeyValuePair<KeyType, ValueType> {
key: KeyType;
value: ValueType;
constructor(key: KeyType, value: ValueType) {
this.key = key;
this.value = value;
}
}
const {key, value} = new KeyValuePair<string, number>('age', 34);
console.log(key, value);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment