@@ -11255,7 +11255,7 @@ namespace ts {
11255
11255
checkGrammarMethod(node) || checkGrammarComputedPropertyName(node.name);
11256
11256
11257
11257
// Grammar checking for modifiers is done inside the function checkGrammarFunctionLikeDeclaration
11258
- checkFunctionLikeDeclaration (node);
11258
+ checkFunctionOrMethodDeclaration (node);
11259
11259
11260
11260
// Abstract methods cannot have an implementation.
11261
11261
// Extra checks are to avoid reporting multiple errors relating to the "abstractness" of the node.
@@ -11382,6 +11382,8 @@ namespace ts {
11382
11382
// Grammar checking accessors
11383
11383
checkGrammarFunctionLikeDeclaration(node) || checkGrammarAccessor(node) || checkGrammarComputedPropertyName(node.name);
11384
11384
11385
+ checkDecorators(node);
11386
+ checkSignatureDeclaration(node);
11385
11387
if (node.kind === SyntaxKind.GetAccessor) {
11386
11388
if (!isInAmbientContext(node) && nodeIsPresent(node.body) && (node.flags & NodeFlags.HasImplicitReturn)) {
11387
11389
if (node.flags & NodeFlags.HasExplicitReturn) {
@@ -11394,7 +11396,12 @@ namespace ts {
11394
11396
}
11395
11397
}
11396
11398
}
11397
-
11399
+ // Do not use hasDynamicName here, because that returns false for well known symbols.
11400
+ // We want to perform checkComputedPropertyName for all computed properties, including
11401
+ // well known symbols.
11402
+ if (node.name.kind === SyntaxKind.ComputedPropertyName) {
11403
+ checkComputedPropertyName(<ComputedPropertyName>node.name);
11404
+ }
11398
11405
if (!hasDynamicName(node)) {
11399
11406
// TypeScript 1.0 spec (April 2014): 8.4.3
11400
11407
// Accessors for the same member name must specify the same accessibility.
@@ -11418,8 +11425,16 @@ namespace ts {
11418
11425
}
11419
11426
getTypeOfAccessors(getSymbolOfNode(node));
11420
11427
}
11428
+ if (node.parent.kind !== SyntaxKind.ObjectLiteralExpression) {
11429
+ checkSourceElement(node.body);
11430
+ }
11431
+ }
11421
11432
11422
- checkFunctionLikeDeclaration(node);
11433
+ function checkObjectLiteralAccessorBody(node: AccessorDeclaration) {
11434
+ if (node.body) {
11435
+ checkSourceElement(node.body);
11436
+ checkFunctionAndClassExpressionBodies(node.body);
11437
+ }
11423
11438
}
11424
11439
11425
11440
function checkMissingDeclaration(node: Node) {
@@ -12277,15 +12292,15 @@ namespace ts {
12277
12292
12278
12293
function checkFunctionDeclaration(node: FunctionDeclaration): void {
12279
12294
if (produceDiagnostics) {
12280
- checkFunctionLikeDeclaration (node) || checkGrammarForGenerator(node);
12295
+ checkFunctionOrMethodDeclaration (node) || checkGrammarForGenerator(node);
12281
12296
12282
12297
checkCollisionWithCapturedSuperVariable(node, node.name);
12283
12298
checkCollisionWithCapturedThisVariable(node, node.name);
12284
12299
checkCollisionWithRequireExportsInGeneratedCode(node, node.name);
12285
12300
}
12286
12301
}
12287
12302
12288
- function checkFunctionLikeDeclaration (node: FunctionLikeDeclaration ): void {
12303
+ function checkFunctionOrMethodDeclaration (node: FunctionDeclaration | MethodDeclaration ): void {
12289
12304
checkDecorators(node);
12290
12305
checkSignatureDeclaration(node);
12291
12306
const isAsync = isAsyncFunctionLike(node);
@@ -12332,7 +12347,7 @@ namespace ts {
12332
12347
}
12333
12348
12334
12349
checkSourceElement(node.body);
12335
- if (!isAccessor(node.kind) && ! node.asteriskToken) {
12350
+ if (!node.asteriskToken) {
12336
12351
const returnOrPromisedType = node.type && (isAsync ? checkAsyncFunctionReturnType(node) : getTypeFromTypeNode(node.type));
12337
12352
checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, returnOrPromisedType);
12338
12353
}
@@ -14483,10 +14498,15 @@ namespace ts {
14483
14498
}
14484
14499
break;
14485
14500
case SyntaxKind.Constructor:
14501
+ case SyntaxKind.FunctionDeclaration:
14502
+ forEach((<FunctionLikeDeclaration>node).parameters, checkFunctionAndClassExpressionBodies);
14503
+ break;
14486
14504
case SyntaxKind.GetAccessor:
14487
14505
case SyntaxKind.SetAccessor:
14488
- case SyntaxKind.FunctionDeclaration:
14489
14506
forEach((<FunctionLikeDeclaration>node).parameters, checkFunctionAndClassExpressionBodies);
14507
+ if (node.parent.kind === SyntaxKind.ObjectLiteralExpression) {
14508
+ checkObjectLiteralAccessorBody(<AccessorDeclaration>node);
14509
+ }
14490
14510
break;
14491
14511
case SyntaxKind.WithStatement:
14492
14512
checkFunctionAndClassExpressionBodies((<WithStatement>node).expression);
0 commit comments