Skip to content

Commit 719ab0b

Browse files
authored
fix(43359): emit default exports with named exports that have the same names with types (#44718)
1 parent fe3e117 commit 719ab0b

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
@@ -41589,7 +41589,7 @@ namespace ts {
4158941589
if (!symbol) {
4159041590
return false;
4159141591
}
41592-
const target = resolveAlias(symbol);
41592+
const target = getExportSymbolOfValueSymbolIfExported(resolveAlias(symbol));
4159341593
if (target === unknownSymbol) {
4159441594
return true;
4159541595
}
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)