@@ -26276,8 +26276,9 @@ namespace ts {
26276
26276
26277
26277
let duplicateFunctionDeclaration = false;
26278
26278
let multipleConstructorImplementation = false;
26279
+ let hasNonAmbientClass = false;
26279
26280
for (const current of declarations) {
26280
- const node = <SignatureDeclaration>current;
26281
+ const node = <SignatureDeclaration | ClassDeclaration | ClassExpression >current;
26281
26282
const inAmbientContext = node.flags & NodeFlags.Ambient;
26282
26283
const inAmbientContextOrInterface = node.parent.kind === SyntaxKind.InterfaceDeclaration || node.parent.kind === SyntaxKind.TypeLiteral || inAmbientContext;
26283
26284
if (inAmbientContextOrInterface) {
@@ -26291,6 +26292,10 @@ namespace ts {
26291
26292
previousDeclaration = undefined;
26292
26293
}
26293
26294
26295
+ if ((node.kind === SyntaxKind.ClassDeclaration || node.kind === SyntaxKind.ClassExpression) && !inAmbientContext) {
26296
+ hasNonAmbientClass = true;
26297
+ }
26298
+
26294
26299
if (node.kind === SyntaxKind.FunctionDeclaration || node.kind === SyntaxKind.MethodDeclaration || node.kind === SyntaxKind.MethodSignature || node.kind === SyntaxKind.Constructor) {
26295
26300
const currentNodeFlags = getEffectiveDeclarationFlags(node, flagsToCheck);
26296
26301
someNodeFlags |= currentNodeFlags;
@@ -26339,6 +26344,16 @@ namespace ts {
26339
26344
});
26340
26345
}
26341
26346
26347
+ if (hasNonAmbientClass && !isConstructor && symbol.flags & SymbolFlags.Function) {
26348
+ // A non-ambient class cannot be an implementation for a non-constructor function/class merge
26349
+ // TODO: The below just replicates our older error from when classes and functions were
26350
+ // entirely unable to merge - a more helpful message like "Class declaration cannot implement overload list"
26351
+ // might be warranted. :shrug:
26352
+ forEach(declarations, declaration => {
26353
+ addDuplicateDeclarationError(getNameOfDeclaration(declaration) || declaration, Diagnostics.Duplicate_identifier_0, symbolName(symbol), filter(declarations, d => d !== declaration));
26354
+ });
26355
+ }
26356
+
26342
26357
// Abstract methods can't have an implementation -- in particular, they don't need one.
26343
26358
if (lastSeenNonAmbientDeclaration && !lastSeenNonAmbientDeclaration.body &&
26344
26359
!hasModifier(lastSeenNonAmbientDeclaration, ModifierFlags.Abstract) && !lastSeenNonAmbientDeclaration.questionToken) {
@@ -31650,7 +31665,7 @@ namespace ts {
31650
31665
if (!symbol || !(symbol.flags & SymbolFlags.Function)) {
31651
31666
return false;
31652
31667
}
31653
- return !!forEachEntry(getExportsOfSymbol(symbol), p => p.flags & SymbolFlags.Value && isPropertyAccessExpression(p.valueDeclaration));
31668
+ return !!forEachEntry(getExportsOfSymbol(symbol), p => p.flags & SymbolFlags.Value && p.valueDeclaration && isPropertyAccessExpression(p.valueDeclaration));
31654
31669
}
31655
31670
31656
31671
function getPropertiesOfContainerFunction(node: Declaration): Symbol[] {
0 commit comments