Defer checks of accessor bodies in object literals
This commit is contained in:
parent
383cbf06c4
commit
7fe811e6b2
1 changed files with 24 additions and 4 deletions
|
@ -11297,6 +11297,8 @@ namespace ts {
|
|||
// Grammar checking accessors
|
||||
checkGrammarFunctionLikeDeclaration(node) || checkGrammarAccessor(node) || checkGrammarComputedPropertyName(node.name);
|
||||
|
||||
checkDecorators(node);
|
||||
checkSignatureDeclaration(node);
|
||||
if (node.kind === SyntaxKind.GetAccessor) {
|
||||
if (!isInAmbientContext(node) && nodeIsPresent(node.body) && (node.flags & NodeFlags.HasImplicitReturn)) {
|
||||
if (node.flags & NodeFlags.HasExplicitReturn) {
|
||||
|
@ -11309,7 +11311,12 @@ namespace ts {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Do not use hasDynamicName here, because that returns false for well known symbols.
|
||||
// We want to perform checkComputedPropertyName for all computed properties, including
|
||||
// well known symbols.
|
||||
if (node.name.kind === SyntaxKind.ComputedPropertyName) {
|
||||
checkComputedPropertyName(<ComputedPropertyName>node.name);
|
||||
}
|
||||
if (!hasDynamicName(node)) {
|
||||
// TypeScript 1.0 spec (April 2014): 8.4.3
|
||||
// Accessors for the same member name must specify the same accessibility.
|
||||
|
@ -11333,8 +11340,16 @@ namespace ts {
|
|||
}
|
||||
getTypeOfAccessors(getSymbolOfNode(node));
|
||||
}
|
||||
if (node.parent.kind !== SyntaxKind.ObjectLiteralExpression) {
|
||||
checkSourceElement(node.body);
|
||||
}
|
||||
}
|
||||
|
||||
checkFunctionLikeDeclaration(node);
|
||||
function checkObjectLiteralAccessorBody(node: AccessorDeclaration) {
|
||||
if (node.body) {
|
||||
checkSourceElement(node.body);
|
||||
checkFunctionAndClassExpressionBodies(node.body);
|
||||
}
|
||||
}
|
||||
|
||||
function checkMissingDeclaration(node: Node) {
|
||||
|
@ -14379,11 +14394,16 @@ namespace ts {
|
|||
}
|
||||
break;
|
||||
case SyntaxKind.Constructor:
|
||||
case SyntaxKind.GetAccessor:
|
||||
case SyntaxKind.SetAccessor:
|
||||
case SyntaxKind.FunctionDeclaration:
|
||||
forEach((<FunctionLikeDeclaration>node).parameters, checkFunctionAndClassExpressionBodies);
|
||||
break;
|
||||
case SyntaxKind.GetAccessor:
|
||||
case SyntaxKind.SetAccessor:
|
||||
forEach((<FunctionLikeDeclaration>node).parameters, checkFunctionAndClassExpressionBodies);
|
||||
if (node.parent.kind === SyntaxKind.ObjectLiteralExpression) {
|
||||
checkObjectLiteralAccessorBody(<AccessorDeclaration>node);
|
||||
}
|
||||
break;
|
||||
case SyntaxKind.WithStatement:
|
||||
checkFunctionAndClassExpressionBodies((<WithStatement>node).expression);
|
||||
break;
|
||||
|
|
Loading…
Reference in a new issue