Last active
July 22, 2019 07:55
-
-
Save alphakevin/39a34ce47c6a752086b206679f4b0087 to your computer and use it in GitHub Desktop.
Typescript: extending tree interface
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
// 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