@@ -221,18 +221,19 @@ namespace ts {
221
221
// other kinds of value declarations take precedence over modules
222
222
symbol . valueDeclaration = node ;
223
223
}
224
- }
224
+ }
225
225
}
226
226
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
@@ -389,16 +390,16 @@ namespace ts {
389
390
// 1. multiple export default of class declaration or function declaration by checking NodeFlags.Default
390
391
// 2. multiple export default of export assignment. This one doesn't have NodeFlags.Default on (as export default doesn't considered as modifiers)
391
392
if ( symbol . declarations && symbol . declarations . length &&
392
- ( isDefaultExport || ( node . kind === SyntaxKind . ExportAssignment && ! ( < ExportAssignment > node ) . isExportEquals ) ) ) {
393
- message = Diagnostics . A_module_cannot_have_multiple_default_exports ;
394
- }
393
+ ( isDefaultExport || ( node . kind === SyntaxKind . ExportAssignment && ! ( < ExportAssignment > node ) . isExportEquals ) ) ) {
394
+ message = Diagnostics . A_module_cannot_have_multiple_default_exports ;
395
+ }
395
396
}
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 ) |
@@ -1414,7 +1415,7 @@ namespace ts {
1414
1415
if ( isObjectLiteralOrClassExpressionMethod ( node ) ) {
1415
1416
return ContainerFlags . IsContainer | ContainerFlags . IsControlFlowContainer | ContainerFlags . HasLocals | ContainerFlags . IsFunctionLike | ContainerFlags . IsObjectLiteralOrClassExpressionMethod ;
1416
1417
}
1417
- // falls through
1418
+ // falls through
1418
1419
case SyntaxKind . Constructor :
1419
1420
case SyntaxKind . FunctionDeclaration :
1420
1421
case SyntaxKind . MethodSignature :
@@ -1716,7 +1717,7 @@ namespace ts {
1716
1717
declareModuleMember ( node , symbolFlags , symbolExcludes ) ;
1717
1718
break ;
1718
1719
}
1719
- // falls through
1720
+ // falls through
1720
1721
default :
1721
1722
if ( ! blockScopeContainer . locals ) {
1722
1723
blockScopeContainer . locals = createMap < Symbol > ( ) ;
@@ -2010,7 +2011,7 @@ namespace ts {
2010
2011
bindBlockScopedDeclaration ( < Declaration > parentNode , SymbolFlags . TypeAlias , SymbolFlags . TypeAliasExcludes ) ;
2011
2012
break ;
2012
2013
}
2013
- // falls through
2014
+ // falls through
2014
2015
case SyntaxKind . ThisKeyword :
2015
2016
if ( currentFlow && ( isExpression ( node ) || parent . kind === SyntaxKind . ShorthandPropertyAssignment ) ) {
2016
2017
node . flowNode = currentFlow ;
@@ -2186,7 +2187,7 @@ namespace ts {
2186
2187
if ( ! isFunctionLike ( node . parent ) ) {
2187
2188
return ;
2188
2189
}
2189
- // falls through
2190
+ // falls through
2190
2191
case SyntaxKind . ModuleBlock :
2191
2192
return updateStrictModeStatementList ( ( < Block | ModuleBlock > node ) . statements ) ;
2192
2193
}
@@ -2211,7 +2212,7 @@ namespace ts {
2211
2212
}
2212
2213
2213
2214
function bindSourceFileAsExternalModule ( ) {
2214
- bindAnonymousDeclaration ( file , SymbolFlags . ValueModule , `"${ removeFileExtension ( file . fileName ) } "` ) ;
2215
+ bindAnonymousDeclaration ( file , SymbolFlags . ValueModule , `"${ removeFileExtension ( file . fileName ) } "` ) ;
2215
2216
}
2216
2217
2217
2218
function bindExportAssignment ( node : ExportAssignment | BinaryExpression ) {
@@ -2504,7 +2505,7 @@ namespace ts {
2504
2505
}
2505
2506
2506
2507
function bindParameter ( node : ParameterDeclaration ) {
2507
- if ( inStrictMode ) {
2508
+ if ( inStrictMode && ! isInAmbientContext ( node ) ) {
2508
2509
// It is a SyntaxError if the identifier eval or arguments appears within a FormalParameterList of a
2509
2510
// strict mode FunctionLikeDeclaration or FunctionExpression(13.1)
2510
2511
checkStrictModeEvalOrArguments ( node , node . name ) ;
0 commit comments