@@ -6,12 +6,22 @@ type Declaration = ts.InterfaceDeclaration | ts.ClassDeclaration | ts.TypeAliasD
66type ImportDeclaration = ts . ImportEqualsDeclaration | ts . ImportOrExportSpecifier | ts . ImportClause ;
77
88export namespace TypescriptHelper {
9- export function IsLiteralOrPrimitive ( typeNode : ts . Node ) : boolean {
10- return ts . isLiteralTypeNode ( typeNode ) ||
11- typeNode . kind === ts . SyntaxKind . StringKeyword ||
12- typeNode . kind === ts . SyntaxKind . BooleanKeyword ||
13- typeNode . kind === ts . SyntaxKind . NumberKeyword ||
14- typeNode . kind === ts . SyntaxKind . ArrayType ;
9+ export interface PrimitiveTypeNode extends ts . TypeNode {
10+ kind : ts . SyntaxKind . LiteralType | ts . SyntaxKind . NumberKeyword | ts . SyntaxKind . ObjectKeyword | ts . SyntaxKind . BooleanKeyword | ts . SyntaxKind . StringKeyword | ts . SyntaxKind . ArrayType ;
11+ }
12+
13+ export function IsLiteralOrPrimitive ( typeNode : ts . Node ) : typeNode is PrimitiveTypeNode {
14+ switch ( typeNode . kind ) {
15+ case ts . SyntaxKind . LiteralType :
16+ case ts . SyntaxKind . NumberKeyword :
17+ case ts . SyntaxKind . ObjectKeyword :
18+ case ts . SyntaxKind . BooleanKeyword :
19+ case ts . SyntaxKind . StringKeyword :
20+ case ts . SyntaxKind . ArrayType :
21+ return true ;
22+ }
23+
24+ return false ;
1525 }
1626
1727 export function GetDeclarationFromNode ( node : ts . Node ) : ts . Declaration {
@@ -119,22 +129,6 @@ export namespace TypescriptHelper {
119129 return ! ! ( ( symbol . flags & ts . SymbolFlags . Alias ) || ( symbol . flags & ts . SymbolFlags . AliasExcludes ) ) ;
120130 }
121131
122- export interface RuntimeTypeNode extends ts . TypeNode {
123- kind : ts . SyntaxKind . NumberKeyword | ts . SyntaxKind . ObjectKeyword | ts . SyntaxKind . BooleanKeyword | ts . SyntaxKind . StringKeyword | ts . SyntaxKind . UndefinedKeyword ;
124- }
125-
126- export function isLiteralRuntimeTypeNode ( typeNode : ts . TypeNode ) : typeNode is RuntimeTypeNode {
127- switch ( typeNode . kind ) {
128- case ts . SyntaxKind . NumberKeyword :
129- case ts . SyntaxKind . ObjectKeyword :
130- case ts . SyntaxKind . BooleanKeyword :
131- case ts . SyntaxKind . StringKeyword :
132- return true ;
133- }
134-
135- return false ;
136- }
137-
138132 function isImportExportDeclaration ( declaration : ts . Declaration ) : declaration is ImportDeclaration {
139133 return ts . isImportEqualsDeclaration ( declaration ) || ts . isImportOrExportSpecifier ( declaration ) || ts . isImportClause ( declaration ) ;
140134 }
0 commit comments