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 @@ -17,6 +17,22 @@ export namespace TypescriptHelper {
1717 | ts . SyntaxKind . UndefinedKeyword ;
1818 }
1919
20+ export function ExtractFirstIdentifier ( bindingName : ts . BindingName ) : ts . Identifier {
21+ let identifier : ts . BindingName = bindingName ;
22+ let saneSearchLimit : number = 10 ;
23+
24+ while ( ! ts . isIdentifier ( identifier ) ) {
25+ const [ bindingElement ] : Array < ts . BindingElement | undefined > = ( identifier . elements as ts . NodeArray < ts . ArrayBindingElement > ) . filter ( ts . isBindingElement ) ;
26+ if ( ! bindingElement || ! -- saneSearchLimit ) {
27+ throw new Error ( 'Failed to find an identifier for the primary declaration!' ) ;
28+ }
29+
30+ identifier = bindingElement . name ;
31+ }
32+
33+ return identifier ;
34+ }
35+
2036 export function IsLiteralOrPrimitive ( typeNode : ts . Node ) : typeNode is PrimitiveTypeNode {
2137 switch ( typeNode . kind ) {
2238 case ts . SyntaxKind . LiteralType :
You can’t perform that action at this time.
0 commit comments