@@ -3892,7 +3892,7 @@ namespace ts {
3892
3892
if (!links.declaredType) {
3893
3893
const enumType = <EnumType>getDeclaredTypeOfEnum(getParentOfSymbol(symbol));
3894
3894
links.declaredType = enumType.flags & TypeFlags.Union ?
3895
- enumType.memberTypes[getEnumMemberValue(<EnumDeclaration >symbol.valueDeclaration)] :
3895
+ enumType.memberTypes[getEnumMemberValue(<EnumMember >symbol.valueDeclaration)] :
3896
3896
enumType;
3897
3897
}
3898
3898
return links.declaredType;
@@ -6075,7 +6075,7 @@ namespace ts {
6075
6075
return !node.typeParameters && areAllParametersUntyped && !isNullaryArrow;
6076
6076
}
6077
6077
6078
- function isContextSensitiveFunctionOrObjectLiteralMethod(func: Node): func is FunctionExpression | MethodDeclaration {
6078
+ function isContextSensitiveFunctionOrObjectLiteralMethod(func: Node): func is FunctionExpression | ArrowFunction | MethodDeclaration {
6079
6079
return (isFunctionExpressionOrArrowFunction(func) || isObjectLiteralMethod(func)) && isContextSensitiveFunctionLikeDeclaration(func);
6080
6080
}
6081
6081
@@ -9271,7 +9271,7 @@ namespace ts {
9271
9271
}
9272
9272
9273
9273
function findFirstSuperCall(n: Node): Node {
9274
- if (isSuperCallExpression (n)) {
9274
+ if (isSuperCall (n)) {
9275
9275
return n;
9276
9276
}
9277
9277
else if (isFunctionLike(n)) {
@@ -9780,7 +9780,7 @@ namespace ts {
9780
9780
// corresponding set accessor has a type annotation, return statements in the function are contextually typed
9781
9781
if (functionDecl.type ||
9782
9782
functionDecl.kind === SyntaxKind.Constructor ||
9783
- functionDecl.kind === SyntaxKind.GetAccessor && getSetAccessorTypeAnnotationNode(<AccessorDeclaration >getDeclarationOfKind(functionDecl.symbol, SyntaxKind.SetAccessor))) {
9783
+ functionDecl.kind === SyntaxKind.GetAccessor && getSetAccessorTypeAnnotationNode(<SetAccessorDeclaration >getDeclarationOfKind(functionDecl.symbol, SyntaxKind.SetAccessor))) {
9784
9784
return getReturnTypeOfSignature(getSignatureFromDeclaration(functionDecl));
9785
9785
}
9786
9786
@@ -10049,7 +10049,7 @@ namespace ts {
10049
10049
}
10050
10050
}
10051
10051
10052
- function isFunctionExpressionOrArrowFunction(node: Node): node is FunctionExpression {
10052
+ function isFunctionExpressionOrArrowFunction(node: Node): node is FunctionExpression | ArrowFunction {
10053
10053
return node.kind === SyntaxKind.FunctionExpression || node.kind === SyntaxKind.ArrowFunction;
10054
10054
}
10055
10055
@@ -10060,7 +10060,7 @@ namespace ts {
10060
10060
: undefined;
10061
10061
}
10062
10062
10063
- function getContextualTypeForFunctionLikeDeclaration(node: FunctionExpression | MethodDeclaration) {
10063
+ function getContextualTypeForFunctionLikeDeclaration(node: FunctionExpression | ArrowFunction | MethodDeclaration) {
10064
10064
return isObjectLiteralMethod(node) ?
10065
10065
getContextualTypeForObjectLiteralMethod(node) :
10066
10066
getApparentTypeOfContextualType(node);
@@ -10071,7 +10071,7 @@ namespace ts {
10071
10071
// If the contextual type is a union type, get the signature from each type possible and if they are
10072
10072
// all identical ignoring their return type, the result is same signature but with return type as
10073
10073
// union type of return types from these signatures
10074
- function getContextualSignature(node: FunctionExpression | MethodDeclaration): Signature {
10074
+ function getContextualSignature(node: FunctionExpression | ArrowFunction | MethodDeclaration): Signature {
10075
10075
Debug.assert(node.kind !== SyntaxKind.MethodDeclaration || isObjectLiteralMethod(node));
10076
10076
const type = getContextualTypeForFunctionLikeDeclaration(node);
10077
10077
if (!type) {
@@ -11423,7 +11423,7 @@ namespace ts {
11423
11423
argCount = getEffectiveArgumentCount(node, /*args*/ undefined, signature);
11424
11424
}
11425
11425
else {
11426
- const callExpression = <CallExpression>node;
11426
+ const callExpression = <CallExpression | NewExpression >node;
11427
11427
if (!callExpression.arguments) {
11428
11428
// This only happens when we have something of the form: 'new C'
11429
11429
Debug.assert(callExpression.kind === SyntaxKind.NewExpression);
@@ -11434,7 +11434,7 @@ namespace ts {
11434
11434
argCount = signatureHelpTrailingComma ? args.length + 1 : args.length;
11435
11435
11436
11436
// If we are missing the close paren, the call is incomplete.
11437
- callIsIncomplete = (<CallExpression> callExpression) .arguments.end === callExpression.end;
11437
+ callIsIncomplete = callExpression.arguments.end === callExpression.end;
11438
11438
11439
11439
typeArguments = callExpression.typeArguments;
11440
11440
spreadArgIndex = getSpreadArgumentIndex(args);
@@ -12521,7 +12521,7 @@ namespace ts {
12521
12521
* @param node The call/new expression to be checked.
12522
12522
* @returns On success, the expression's signature's return type. On failure, anyType.
12523
12523
*/
12524
- function checkCallExpression(node: CallExpression): Type {
12524
+ function checkCallExpression(node: CallExpression | NewExpression ): Type {
12525
12525
// Grammar checking; stop grammar-checking if checkGrammarTypeArguments return true
12526
12526
checkGrammarTypeArguments(node, node.typeArguments) || checkGrammarArguments(node, node.arguments);
12527
12527
@@ -12979,7 +12979,7 @@ namespace ts {
12979
12979
}
12980
12980
}
12981
12981
12982
- if (produceDiagnostics && node.kind !== SyntaxKind.MethodDeclaration && node.kind !== SyntaxKind.MethodSignature ) {
12982
+ if (produceDiagnostics && node.kind !== SyntaxKind.MethodDeclaration) {
12983
12983
checkCollisionWithCapturedSuperVariable(node, (<FunctionExpression>node).name);
12984
12984
checkCollisionWithCapturedThisVariable(node, (<FunctionExpression>node).name);
12985
12985
}
@@ -14441,7 +14441,7 @@ namespace ts {
14441
14441
}
14442
14442
14443
14443
function containsSuperCall(n: Node): boolean {
14444
- if (isSuperCallExpression (n)) {
14444
+ if (isSuperCall (n)) {
14445
14445
return true;
14446
14446
}
14447
14447
else if (isFunctionLike(n)) {
@@ -14497,7 +14497,7 @@ namespace ts {
14497
14497
let superCallStatement: ExpressionStatement;
14498
14498
14499
14499
for (const statement of statements) {
14500
- if (statement.kind === SyntaxKind.ExpressionStatement && isSuperCallExpression ((<ExpressionStatement>statement).expression)) {
14500
+ if (statement.kind === SyntaxKind.ExpressionStatement && isSuperCall ((<ExpressionStatement>statement).expression)) {
14501
14501
superCallStatement = <ExpressionStatement>statement;
14502
14502
break;
14503
14503
}
@@ -16457,7 +16457,7 @@ namespace ts {
16457
16457
}
16458
16458
16459
16459
function isGetAccessorWithAnnotatedSetAccessor(node: FunctionLikeDeclaration) {
16460
- return !!(node.kind === SyntaxKind.GetAccessor && getSetAccessorTypeAnnotationNode(<AccessorDeclaration >getDeclarationOfKind(node.symbol, SyntaxKind.SetAccessor)));
16460
+ return !!(node.kind === SyntaxKind.GetAccessor && getSetAccessorTypeAnnotationNode(<SetAccessorDeclaration >getDeclarationOfKind(node.symbol, SyntaxKind.SetAccessor)));
16461
16461
}
16462
16462
16463
16463
function isUnwrappedReturnTypeVoidOrAny(func: FunctionLikeDeclaration, returnType: Type): boolean {
@@ -17449,9 +17449,12 @@ namespace ts {
17449
17449
}
17450
17450
}
17451
17451
17452
- checkCollisionWithCapturedThisVariable(node, node.name);
17453
- checkCollisionWithRequireExportsInGeneratedCode(node, node.name);
17454
- checkCollisionWithGlobalPromiseInGeneratedCode(node, node.name);
17452
+ if (isIdentifier(node.name)) {
17453
+ checkCollisionWithCapturedThisVariable(node, node.name);
17454
+ checkCollisionWithRequireExportsInGeneratedCode(node, node.name);
17455
+ checkCollisionWithGlobalPromiseInGeneratedCode(node, node.name);
17456
+ }
17457
+
17455
17458
checkExportsOnMergedDeclarations(node);
17456
17459
const symbol = getSymbolOfNode(node);
17457
17460
@@ -19073,15 +19076,15 @@ namespace ts {
19073
19076
return undefined;
19074
19077
}
19075
19078
19076
- function isLiteralConstDeclaration(node: VariableDeclaration): boolean {
19079
+ function isLiteralConstDeclaration(node: VariableDeclaration | PropertyDeclaration | PropertySignature | ParameterDeclaration ): boolean {
19077
19080
if (isConst(node)) {
19078
19081
const type = getTypeOfSymbol(getSymbolOfNode(node));
19079
19082
return !!(type.flags & TypeFlags.StringOrNumberLiteral && type.flags & TypeFlags.FreshLiteral);
19080
19083
}
19081
19084
return false;
19082
19085
}
19083
19086
19084
- function writeLiteralConstValue(node: VariableDeclaration, writer: SymbolWriter) {
19087
+ function writeLiteralConstValue(node: VariableDeclaration | PropertyDeclaration | PropertySignature | ParameterDeclaration , writer: SymbolWriter) {
19085
19088
const type = getTypeOfSymbol(getSymbolOfNode(node));
19086
19089
writer.writeStringLiteral(literalTypeToString(<LiteralType>type));
19087
19090
}
@@ -19818,7 +19821,7 @@ namespace ts {
19818
19821
checkGrammarForAtLeastOneTypeArgument(node, typeArguments);
19819
19822
}
19820
19823
19821
- function checkGrammarForOmittedArgument(node: CallExpression, args: NodeArray<Expression>): boolean {
19824
+ function checkGrammarForOmittedArgument(node: CallExpression | NewExpression , args: NodeArray<Expression>): boolean {
19822
19825
if (args) {
19823
19826
const sourceFile = getSourceFileOfNode(node);
19824
19827
for (const arg of args) {
@@ -19829,7 +19832,7 @@ namespace ts {
19829
19832
}
19830
19833
}
19831
19834
19832
- function checkGrammarArguments(node: CallExpression, args: NodeArray<Expression>): boolean {
19835
+ function checkGrammarArguments(node: CallExpression | NewExpression , args: NodeArray<Expression>): boolean {
19833
19836
return checkGrammarForOmittedArgument(node, args);
19834
19837
}
19835
19838
@@ -19951,8 +19954,7 @@ namespace ts {
19951
19954
19952
19955
for (const prop of node.properties) {
19953
19956
const name = prop.name;
19954
- if (prop.kind === SyntaxKind.OmittedExpression ||
19955
- name.kind === SyntaxKind.ComputedPropertyName) {
19957
+ if (name.kind === SyntaxKind.ComputedPropertyName) {
19956
19958
// If the name is not a ComputedPropertyName, the grammar checking will skip it
19957
19959
checkGrammarComputedPropertyName(<ComputedPropertyName>name);
19958
19960
}
@@ -19999,7 +20001,7 @@ namespace ts {
19999
20001
currentKind = SetAccessor;
20000
20002
}
20001
20003
else {
20002
- Debug.fail("Unexpected syntax kind:" + prop.kind);
20004
+ Debug.fail("Unexpected syntax kind:" + (<Node> prop) .kind);
20003
20005
}
20004
20006
20005
20007
const effectiveName = getPropertyNameForPropertyNameNode(name);
0 commit comments