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

+1-1
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
}
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;
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+
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+
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;
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+
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+
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;
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+
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+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
//// [defaultNamedExportWithType4.ts]
2+
interface Foo {}
3+
const Foo = {};
4+
export default Foo;
5+
6+
7+
//// [defaultNamedExportWithType4.js]
8+
const Foo = {};
9+
export default Foo;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
=== tests/cases/compiler/defaultNamedExportWithType4.ts ===
2+
interface Foo {}
3+
>Foo : Symbol(Foo, Decl(defaultNamedExportWithType4.ts, 0, 0), Decl(defaultNamedExportWithType4.ts, 1, 5))
4+
5+
const Foo = {};
6+
>Foo : Symbol(Foo, Decl(defaultNamedExportWithType4.ts, 0, 0), Decl(defaultNamedExportWithType4.ts, 1, 5))
7+
8+
export default Foo;
9+
>Foo : Symbol(Foo, Decl(defaultNamedExportWithType4.ts, 0, 0), Decl(defaultNamedExportWithType4.ts, 1, 5))
10+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
=== tests/cases/compiler/defaultNamedExportWithType4.ts ===
2+
interface Foo {}
3+
const Foo = {};
4+
>Foo : {}
5+
>{} : {}
6+
7+
export default Foo;
8+
>Foo : Foo
9+

tests/baselines/reference/duplicateVarsAcrossFileBoundaries.js

+1
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ var x = 0;
4343
var y = "";
4444
var z = 0;
4545
//// [duplicateVarsAcrossFileBoundaries_4.js]
46+
var p = P;
4647
var q;
4748
//// [duplicateVarsAcrossFileBoundaries_5.js]
4849
var p;

tests/baselines/reference/importDeclWithExportModifierAndExportAssignment.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@ export = x;
88

99
//// [importDeclWithExportModifierAndExportAssignment.js]
1010
"use strict";
11-
exports.__esModule = true;
1211
exports.a = void 0;
1312
exports.a = x.c;
13+
module.exports = x;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// @target: esnext
2+
3+
type Foo = number;
4+
export const Foo = 1;
5+
export default Foo;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// @target: esnext
2+
3+
type Foo = number;
4+
const Foo = 1;
5+
export default Foo;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// @target: esnext
2+
3+
interface Foo {}
4+
export const Foo = {};
5+
export default Foo;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// @target: esnext
2+
3+
interface Foo {}
4+
const Foo = {};
5+
export default Foo;

0 commit comments

Comments
 (0)