@@ -31280,6 +31280,7 @@ namespace ts {
31280
31280
let duplicateFunctionDeclaration = false;
31281
31281
let multipleConstructorImplementation = false;
31282
31282
let hasNonAmbientClass = false;
31283
+ const functionDeclarations = [] as Declaration[];
31283
31284
for (const current of declarations) {
31284
31285
const node = <SignatureDeclaration | ClassDeclaration | ClassExpression>current;
31285
31286
const inAmbientContext = node.flags & NodeFlags.Ambient;
@@ -31300,25 +31301,27 @@ namespace ts {
31300
31301
}
31301
31302
31302
31303
if (node.kind === SyntaxKind.FunctionDeclaration || node.kind === SyntaxKind.MethodDeclaration || node.kind === SyntaxKind.MethodSignature || node.kind === SyntaxKind.Constructor) {
31304
+ functionDeclarations.push(node);
31303
31305
const currentNodeFlags = getEffectiveDeclarationFlags(node, flagsToCheck);
31304
31306
someNodeFlags |= currentNodeFlags;
31305
31307
allNodeFlags &= currentNodeFlags;
31306
31308
someHaveQuestionToken = someHaveQuestionToken || hasQuestionToken(node);
31307
31309
allHaveQuestionToken = allHaveQuestionToken && hasQuestionToken(node);
31310
+ const bodyIsPresent = nodeIsPresent((node as FunctionLikeDeclaration).body);
31308
31311
31309
- if (nodeIsPresent((node as FunctionLikeDeclaration).body) && bodyDeclaration) {
31312
+ if (bodyIsPresent && bodyDeclaration) {
31310
31313
if (isConstructor) {
31311
31314
multipleConstructorImplementation = true;
31312
31315
}
31313
31316
else {
31314
31317
duplicateFunctionDeclaration = true;
31315
31318
}
31316
31319
}
31317
- else if (previousDeclaration && previousDeclaration .parent === node.parent && previousDeclaration.end !== node.pos) {
31320
+ else if (previousDeclaration? .parent === node.parent && previousDeclaration.end !== node.pos) {
31318
31321
reportImplementationExpectedError(previousDeclaration);
31319
31322
}
31320
31323
31321
- if (nodeIsPresent((node as FunctionLikeDeclaration).body) ) {
31324
+ if (bodyIsPresent ) {
31322
31325
if (!bodyDeclaration) {
31323
31326
bodyDeclaration = node as FunctionLikeDeclaration;
31324
31327
}
@@ -31336,14 +31339,14 @@ namespace ts {
31336
31339
}
31337
31340
31338
31341
if (multipleConstructorImplementation) {
31339
- forEach(declarations , declaration => {
31342
+ forEach(functionDeclarations , declaration => {
31340
31343
error(declaration, Diagnostics.Multiple_constructor_implementations_are_not_allowed);
31341
31344
});
31342
31345
}
31343
31346
31344
31347
if (duplicateFunctionDeclaration) {
31345
- forEach(declarations , declaration => {
31346
- error(getNameOfDeclaration(declaration), Diagnostics.Duplicate_function_implementation);
31348
+ forEach(functionDeclarations , declaration => {
31349
+ error(getNameOfDeclaration(declaration) || declaration , Diagnostics.Duplicate_function_implementation);
31347
31350
});
31348
31351
}
31349
31352
0 commit comments