File tree Expand file tree Collapse file tree 2 files changed +11
-1
lines changed Expand file tree Collapse file tree 2 files changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -124,4 +124,12 @@ export class TypeScriptInternals {
124124 }
125125 return resolver ;
126126 }
127+
128+ /**
129+ * Returns whether a variable has the const declaration
130+ */
131+ public static isVarConst ( node : ts . VariableDeclaration | ts . VariableDeclarationList ) : boolean {
132+ // Compiler internal: https://github.com/microsoft/TypeScript/blob/71286e3d49c10e0e99faac360a6bbd40f12db7b6/src/compiler/utilities.ts#L925
133+ return ( ts as any ) . isVarConst ( node ) ;
134+ }
127135}
Original file line number Diff line number Diff line change @@ -44,6 +44,8 @@ import { AstNamespaceImport } from '../analyzer/AstNamespaceImport';
4444import { AstEntity } from '../analyzer/AstEntity' ;
4545import { AstModule } from '../analyzer/AstModule' ;
4646
47+ import { TypeScriptInternals } from '../analyzer/TypeScriptInternals' ;
48+
4749export class ApiModelGenerator {
4850 private readonly _collector : Collector ;
4951 private readonly _apiModel : ApiModel ;
@@ -1064,6 +1066,6 @@ export class ApiModelGenerator {
10641066 return ( astDeclaration . modifierFlags & ( ts . ModifierFlags . Readonly + ts . ModifierFlags . Const ) ) !== 0
10651067 || ( docComment !== undefined && docComment . modifierTagSet . hasTagName ( '@readonly' ) )
10661068 || ( declarationMetadata . ancillaryDeclarations . length === 0 && astDeclaration . declaration . kind === ts . SyntaxKind . GetAccessor )
1067- || ( ts . getCombinedNodeFlags ( astDeclaration . declaration ) & ts . NodeFlags . Const ) !== 0 ;
1069+ || ts . isVariableDeclaration ( astDeclaration . declaration ) && TypeScriptInternals . isVarConst ( astDeclaration . declaration )
10681070 }
10691071}
You can’t perform that action at this time.
0 commit comments