Created
October 23, 2018 04:23
-
-
Save Sammons/3dc5110dc7d7611ac6a1fbfec441fe34 to your computer and use it in GitHub Desktop.
This file contains 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
addNode<NodeName extends string, ReturnType extends AddNodeName<this, NodeName>>( | |
nodeName: Exclude<NodeName, NodeNames>, | |
builderCb: (b: NodeBuilder<this>) => NodeBuilder<this> | |
): ReturnType { | |
// Yes you can totally infer the result type of builderCb and stick it in a RootBuilder generic param, | |
// but I am not covering that here. ask if you want samples :) | |
const result = builderCb(); | |
return this as RootBuilder as ReturnType | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment