File tree Expand file tree Collapse file tree 1 file changed +16
-0
lines changed
src/transformer/descriptor/helper Expand file tree Collapse file tree 1 file changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -10,6 +10,22 @@ export namespace TypescriptHelper {
1010 kind : ts . SyntaxKind . LiteralType | ts . SyntaxKind . NumberKeyword | ts . SyntaxKind . ObjectKeyword | ts . SyntaxKind . BooleanKeyword | ts . SyntaxKind . StringKeyword | ts . SyntaxKind . ArrayType ;
1111 }
1212
13+ export function ExtractFirstIdentifier ( bindingName : ts . BindingName ) : ts . Identifier {
14+ let identifier : ts . BindingName = bindingName ;
15+ let saneSearchLimit : number = 10 ;
16+
17+ while ( ! ts . isIdentifier ( identifier ) ) {
18+ const [ bindingElement ] : Array < ts . BindingElement | undefined > = ( identifier . elements as ts . NodeArray < ts . ArrayBindingElement > ) . filter ( ts . isBindingElement ) ;
19+ if ( ! bindingElement || ! -- saneSearchLimit ) {
20+ throw new Error ( 'Failed to find an identifier for the primary declaration!' ) ;
21+ }
22+
23+ identifier = bindingElement . name ;
24+ }
25+
26+ return identifier ;
27+ }
28+
1329 export function IsLiteralOrPrimitive ( typeNode : ts . Node ) : typeNode is PrimitiveTypeNode {
1430 switch ( typeNode . kind ) {
1531 case ts . SyntaxKind . LiteralType :
You can’t perform that action at this time.
0 commit comments