mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-06-10 18:04:18 -05:00
fix(59484): Constructor overload still present in emitted JS (#59491)
This commit is contained in:
@@ -1985,10 +1985,15 @@ export function createNodeFactory(flags: NodeFactoryFlags, baseFactory: BaseNode
|
||||
node.parameters = createNodeArray(parameters);
|
||||
node.body = body;
|
||||
|
||||
node.transformFlags = propagateChildrenFlags(node.modifiers) |
|
||||
propagateChildrenFlags(node.parameters) |
|
||||
(propagateChildFlags(node.body) & ~TransformFlags.ContainsPossibleTopLevelAwait) |
|
||||
TransformFlags.ContainsES2015;
|
||||
if (!node.body) {
|
||||
node.transformFlags = TransformFlags.ContainsTypeScript;
|
||||
}
|
||||
else {
|
||||
node.transformFlags = propagateChildrenFlags(node.modifiers) |
|
||||
propagateChildrenFlags(node.parameters) |
|
||||
(propagateChildFlags(node.body) & ~TransformFlags.ContainsPossibleTopLevelAwait) |
|
||||
TransformFlags.ContainsES2015;
|
||||
}
|
||||
|
||||
node.typeParameters = undefined; // initialized by parser for grammar errors
|
||||
node.type = undefined; // initialized by parser for grammar errors
|
||||
|
||||
19
tests/baselines/reference/constructorOverloads9.js
Normal file
19
tests/baselines/reference/constructorOverloads9.js
Normal file
@@ -0,0 +1,19 @@
|
||||
//// [tests/cases/compiler/constructorOverloads9.ts] ////
|
||||
|
||||
//// [constructorOverloads9.ts]
|
||||
export class C {
|
||||
a;
|
||||
constructor();
|
||||
constructor(x = '') {
|
||||
this.a = x;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//// [constructorOverloads9.js]
|
||||
export class C {
|
||||
a;
|
||||
constructor(x = '') {
|
||||
this.a = x;
|
||||
}
|
||||
}
|
||||
21
tests/baselines/reference/constructorOverloads9.symbols
Normal file
21
tests/baselines/reference/constructorOverloads9.symbols
Normal file
@@ -0,0 +1,21 @@
|
||||
//// [tests/cases/compiler/constructorOverloads9.ts] ////
|
||||
|
||||
=== constructorOverloads9.ts ===
|
||||
export class C {
|
||||
>C : Symbol(C, Decl(constructorOverloads9.ts, 0, 0))
|
||||
|
||||
a;
|
||||
>a : Symbol(C.a, Decl(constructorOverloads9.ts, 0, 16))
|
||||
|
||||
constructor();
|
||||
constructor(x = '') {
|
||||
>x : Symbol(x, Decl(constructorOverloads9.ts, 3, 16))
|
||||
|
||||
this.a = x;
|
||||
>this.a : Symbol(C.a, Decl(constructorOverloads9.ts, 0, 16))
|
||||
>this : Symbol(C, Decl(constructorOverloads9.ts, 0, 0))
|
||||
>a : Symbol(C.a, Decl(constructorOverloads9.ts, 0, 16))
|
||||
>x : Symbol(x, Decl(constructorOverloads9.ts, 3, 16))
|
||||
}
|
||||
}
|
||||
|
||||
30
tests/baselines/reference/constructorOverloads9.types
Normal file
30
tests/baselines/reference/constructorOverloads9.types
Normal file
@@ -0,0 +1,30 @@
|
||||
//// [tests/cases/compiler/constructorOverloads9.ts] ////
|
||||
|
||||
=== constructorOverloads9.ts ===
|
||||
export class C {
|
||||
>C : C
|
||||
> : ^
|
||||
|
||||
a;
|
||||
>a : any
|
||||
|
||||
constructor();
|
||||
constructor(x = '') {
|
||||
>x : string
|
||||
> : ^^^^^^
|
||||
>'' : ""
|
||||
> : ^^
|
||||
|
||||
this.a = x;
|
||||
>this.a = x : string
|
||||
> : ^^^^^^
|
||||
>this.a : any
|
||||
>this : this
|
||||
> : ^^^^
|
||||
>a : any
|
||||
> : ^^^
|
||||
>x : string
|
||||
> : ^^^^^^
|
||||
}
|
||||
}
|
||||
|
||||
8
tests/cases/compiler/constructorOverloads9.ts
Normal file
8
tests/cases/compiler/constructorOverloads9.ts
Normal file
@@ -0,0 +1,8 @@
|
||||
// @target: esnext
|
||||
export class C {
|
||||
a;
|
||||
constructor();
|
||||
constructor(x = '') {
|
||||
this.a = x;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user