Skip to content

Instantly share code, notes, and snippets.

@alphakevin
Last active July 22, 2019 07:55
Show Gist options
  • Save alphakevin/39a34ce47c6a752086b206679f4b0087 to your computer and use it in GitHub Desktop.
Save alphakevin/39a34ce47c6a752086b206679f4b0087 to your computer and use it in GitHub Desktop.
Typescript: extending tree interface
// basic tree interface
interface Tree {
name: string;
value: string;
children?: Tree[];
}
// base tree interface with more properties
interface TreeLike<T extends Tree> extends Tree {
children?: T[];
}
// example usage of above
interface TreeWithDescription extends TreeLike<TreeWithDescription> {
description: string;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment