Merge pull request #5230 from Microsoft/ambient-class-merges-overloads-with-interface
Ambient class merges overloads with interface
This commit is contained in:
Коммит
a8aa48e73f
|
@ -11046,7 +11046,13 @@ namespace ts {
|
|||
|
||||
function getEffectiveDeclarationFlags(n: Node, flagsToCheck: NodeFlags): NodeFlags {
|
||||
let flags = getCombinedNodeFlags(n);
|
||||
if (n.parent.kind !== SyntaxKind.InterfaceDeclaration && isInAmbientContext(n)) {
|
||||
|
||||
// children of classes (even ambient classes) should not be marked as ambient or export
|
||||
// because those flags have no useful semantics there.
|
||||
if (n.parent.kind !== SyntaxKind.InterfaceDeclaration &&
|
||||
n.parent.kind !== SyntaxKind.ClassDeclaration &&
|
||||
n.parent.kind !== SyntaxKind.ClassExpression &&
|
||||
isInAmbientContext(n)) {
|
||||
if (!(flags & NodeFlags.Ambient)) {
|
||||
// It is nested in an ambient context, which means it is automatically exported
|
||||
flags |= NodeFlags.Export;
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
//// [ambientClassMergesOverloadsWithInterface.ts]
|
||||
declare class C {
|
||||
baz(): any;
|
||||
foo(n: number): any;
|
||||
}
|
||||
interface C {
|
||||
foo(n: number): any;
|
||||
bar(): any;
|
||||
}
|
||||
|
||||
|
||||
//// [ambientClassMergesOverloadsWithInterface.js]
|
|
@ -0,0 +1,22 @@
|
|||
=== tests/cases/compiler/ambientClassMergesOverloadsWithInterface.ts ===
|
||||
declare class C {
|
||||
>C : Symbol(C, Decl(ambientClassMergesOverloadsWithInterface.ts, 0, 0), Decl(ambientClassMergesOverloadsWithInterface.ts, 3, 1))
|
||||
|
||||
baz(): any;
|
||||
>baz : Symbol(baz, Decl(ambientClassMergesOverloadsWithInterface.ts, 0, 17))
|
||||
|
||||
foo(n: number): any;
|
||||
>foo : Symbol(foo, Decl(ambientClassMergesOverloadsWithInterface.ts, 1, 15), Decl(ambientClassMergesOverloadsWithInterface.ts, 4, 13))
|
||||
>n : Symbol(n, Decl(ambientClassMergesOverloadsWithInterface.ts, 2, 8))
|
||||
}
|
||||
interface C {
|
||||
>C : Symbol(C, Decl(ambientClassMergesOverloadsWithInterface.ts, 0, 0), Decl(ambientClassMergesOverloadsWithInterface.ts, 3, 1))
|
||||
|
||||
foo(n: number): any;
|
||||
>foo : Symbol(foo, Decl(ambientClassMergesOverloadsWithInterface.ts, 1, 15), Decl(ambientClassMergesOverloadsWithInterface.ts, 4, 13))
|
||||
>n : Symbol(n, Decl(ambientClassMergesOverloadsWithInterface.ts, 5, 8))
|
||||
|
||||
bar(): any;
|
||||
>bar : Symbol(bar, Decl(ambientClassMergesOverloadsWithInterface.ts, 5, 24))
|
||||
}
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
=== tests/cases/compiler/ambientClassMergesOverloadsWithInterface.ts ===
|
||||
declare class C {
|
||||
>C : C
|
||||
|
||||
baz(): any;
|
||||
>baz : () => any
|
||||
|
||||
foo(n: number): any;
|
||||
>foo : { (n: number): any; (n: number): any; }
|
||||
>n : number
|
||||
}
|
||||
interface C {
|
||||
>C : C
|
||||
|
||||
foo(n: number): any;
|
||||
>foo : { (n: number): any; (n: number): any; }
|
||||
>n : number
|
||||
|
||||
bar(): any;
|
||||
>bar : () => any
|
||||
}
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
declare class C {
|
||||
baz(): any;
|
||||
foo(n: number): any;
|
||||
}
|
||||
interface C {
|
||||
foo(n: number): any;
|
||||
bar(): any;
|
||||
}
|
Загрузка…
Ссылка в новой задаче