Skip to content

Commit e2ca662

Browse files
committed
fix(43359): emit default exports with named exports that have the same names with types
1 parent a15030f commit e2ca662

19 files changed

+139
-2
lines changed

src/compiler/checker.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40202,7 +40202,7 @@ namespace ts {
4020240202
}
4020340203

4020440204
function isAliasResolvedToValue(symbol: Symbol): boolean {
40205-
const target = resolveAlias(symbol);
40205+
const target = getExportSymbolOfValueSymbolIfExported(resolveAlias(symbol));
4020640206
if (target === unknownSymbol) {
4020740207
return true;
4020840208
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
//// [defaultNamedExportWithType1.ts]
2+
type Foo = number;
3+
export const Foo = 1;
4+
export default Foo;
5+
6+
7+
//// [defaultNamedExportWithType1.js]
8+
export const Foo = 1;
9+
export default Foo;
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
=== tests/cases/compiler/defaultNamedExportWithType1.ts ===
2+
type Foo = number;
3+
>Foo : Symbol(Foo, Decl(defaultNamedExportWithType1.ts, 0, 0), Decl(defaultNamedExportWithType1.ts, 1, 12))
4+
5+
export const Foo = 1;
6+
>Foo : Symbol(Foo, Decl(defaultNamedExportWithType1.ts, 1, 12))
7+
8+
export default Foo;
9+
>Foo : Symbol(Foo, Decl(defaultNamedExportWithType1.ts, 0, 0), Decl(defaultNamedExportWithType1.ts, 1, 12))
10+
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
=== tests/cases/compiler/defaultNamedExportWithType1.ts ===
2+
type Foo = number;
3+
>Foo : number
4+
5+
export const Foo = 1;
6+
>Foo : 1
7+
>1 : 1
8+
9+
export default Foo;
10+
>Foo : number
11+
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
//// [defaultNamedExportWithType2.ts]
2+
type Foo = number;
3+
const Foo = 1;
4+
export default Foo;
5+
6+
7+
//// [defaultNamedExportWithType2.js]
8+
const Foo = 1;
9+
export default Foo;
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
=== tests/cases/compiler/defaultNamedExportWithType2.ts ===
2+
type Foo = number;
3+
>Foo : Symbol(Foo, Decl(defaultNamedExportWithType2.ts, 0, 0), Decl(defaultNamedExportWithType2.ts, 1, 5))
4+
5+
const Foo = 1;
6+
>Foo : Symbol(Foo, Decl(defaultNamedExportWithType2.ts, 0, 0), Decl(defaultNamedExportWithType2.ts, 1, 5))
7+
8+
export default Foo;
9+
>Foo : Symbol(Foo, Decl(defaultNamedExportWithType2.ts, 0, 0), Decl(defaultNamedExportWithType2.ts, 1, 5))
10+
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
=== tests/cases/compiler/defaultNamedExportWithType2.ts ===
2+
type Foo = number;
3+
>Foo : number
4+
5+
const Foo = 1;
6+
>Foo : 1
7+
>1 : 1
8+
9+
export default Foo;
10+
>Foo : number
11+
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
//// [defaultNamedExportWithType3.ts]
2+
interface Foo {}
3+
export const Foo = {};
4+
export default Foo;
5+
6+
7+
//// [defaultNamedExportWithType3.js]
8+
export const Foo = {};
9+
export default Foo;
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
=== tests/cases/compiler/defaultNamedExportWithType3.ts ===
2+
interface Foo {}
3+
>Foo : Symbol(Foo, Decl(defaultNamedExportWithType3.ts, 0, 0), Decl(defaultNamedExportWithType3.ts, 1, 12))
4+
5+
export const Foo = {};
6+
>Foo : Symbol(Foo, Decl(defaultNamedExportWithType3.ts, 1, 12))
7+
8+
export default Foo;
9+
>Foo : Symbol(Foo, Decl(defaultNamedExportWithType3.ts, 0, 0), Decl(defaultNamedExportWithType3.ts, 1, 12))
10+
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
=== tests/cases/compiler/defaultNamedExportWithType3.ts ===
2+
interface Foo {}
3+
export const Foo = {};
4+
>Foo : {}
5+
>{} : {}
6+
7+
export default Foo;
8+
>Foo : Foo
9+

0 commit comments

Comments
 (0)