@@ -227,12 +227,13 @@ namespace ts {
227
227
// Should not be called on a declaration with a computed property name,
228
228
// unless it is a well known Symbol.
229
229
function getDeclarationName ( node : Declaration ) : string {
230
- if ( node . name ) {
230
+ const name = getNameOfDeclaration ( node ) ;
231
+ if ( name ) {
231
232
if ( isAmbientModule ( node ) ) {
232
- return isGlobalScopeAugmentation ( < ModuleDeclaration > node ) ? "__global" : `"${ ( < LiteralExpression > node . name ) . text } "` ;
233
+ return isGlobalScopeAugmentation ( < ModuleDeclaration > node ) ? "__global" : `"${ ( < LiteralExpression > name ) . text } "` ;
233
234
}
234
- if ( node . name . kind === SyntaxKind . ComputedPropertyName ) {
235
- const nameExpression = ( < ComputedPropertyName > node . name ) . expression ;
235
+ if ( name . kind === SyntaxKind . ComputedPropertyName ) {
236
+ const nameExpression = ( < ComputedPropertyName > name ) . expression ;
236
237
// treat computed property names where expression is string/numeric literal as just string/numeric literal
237
238
if ( isStringOrNumericLiteral ( nameExpression ) ) {
238
239
return nameExpression . text ;
@@ -241,7 +242,7 @@ namespace ts {
241
242
Debug . assert ( isWellKnownSymbolSyntactically ( nameExpression ) ) ;
242
243
return getPropertyNameForKnownSymbolName ( ( < PropertyAccessExpression > nameExpression ) . name . text ) ;
243
244
}
244
- return ( < Identifier | LiteralExpression > node . name ) . text ;
245
+ return ( < Identifier | LiteralExpression > name ) . text ;
245
246
}
246
247
switch ( node . kind ) {
247
248
case SyntaxKind . Constructor :
@@ -303,7 +304,7 @@ namespace ts {
303
304
}
304
305
305
306
function getDisplayName ( node : Declaration ) : string {
306
- return node . name ? declarationNameToString ( node . name ) : getDeclarationName ( node ) ;
307
+ return ( node as NamedDeclaration ) . name ? declarationNameToString ( ( node as NamedDeclaration ) . name ) : getDeclarationName ( node ) ;
307
308
}
308
309
309
310
/**
@@ -366,8 +367,8 @@ namespace ts {
366
367
symbolTable . set ( name , symbol = createSymbol ( SymbolFlags . None , name ) ) ;
367
368
}
368
369
else {
369
- if ( node . name ) {
370
- node . name . parent = node ;
370
+ if ( ( node as NamedDeclaration ) . name ) {
371
+ ( node as NamedDeclaration ) . name . parent = node ;
371
372
}
372
373
373
374
// Report errors every position with duplicate declaration
@@ -396,9 +397,9 @@ namespace ts {
396
397
}
397
398
398
399
forEach ( symbol . declarations , declaration => {
399
- file . bindDiagnostics . push ( createDiagnosticForNode ( declaration . name || declaration , message , getDisplayName ( declaration ) ) ) ;
400
+ file . bindDiagnostics . push ( createDiagnosticForNode ( getNameOfDeclaration ( declaration ) || declaration , message , getDisplayName ( declaration ) ) ) ;
400
401
} ) ;
401
- file . bindDiagnostics . push ( createDiagnosticForNode ( node . name || node , message , getDisplayName ( node ) ) ) ;
402
+ file . bindDiagnostics . push ( createDiagnosticForNode ( getNameOfDeclaration ( node ) || node , message , getDisplayName ( node ) ) ) ;
402
403
403
404
symbol = createSymbol ( SymbolFlags . None , name ) ;
404
405
}
@@ -439,9 +440,9 @@ namespace ts {
439
440
// and this case is specially handled. Module augmentations should only be merged with original module definition
440
441
// and should never be merged directly with other augmentation, and the latter case would be possible if automatic merge is allowed.
441
442
const isJSDocTypedefInJSDocNamespace = node . kind === SyntaxKind . JSDocTypedefTag &&
442
- node . name &&
443
- node . name . kind === SyntaxKind . Identifier &&
444
- ( < Identifier > node . name ) . isInJSDocNamespace ;
443
+ ( node as JSDocTypedefTag ) . name &&
444
+ ( node as JSDocTypedefTag ) . name . kind === SyntaxKind . Identifier &&
445
+ ( ( node as JSDocTypedefTag ) . name as Identifier ) . isInJSDocNamespace ;
445
446
if ( ( ! isAmbientModule ( node ) && ( hasExportModifier || container . flags & NodeFlags . ExportContext ) ) || isJSDocTypedefInJSDocNamespace ) {
446
447
const exportKind =
447
448
( symbolFlags & SymbolFlags . Value ? SymbolFlags . ExportValue : 0 ) |
0 commit comments