Skip to content

Commit

Permalink
fix(43359): emit default exports with named exports that have the sam…
Browse files Browse the repository at this point in the history
…e names with types (#44718)
  • Loading branch information
a-tarasyuk committed Nov 12, 2021
1 parent fe3e117 commit 719ab0b
Show file tree
Hide file tree
Showing 19 changed files with 139 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/compiler/checker.ts
Expand Up @@ -41589,7 +41589,7 @@ namespace ts {
if (!symbol) {
return false;
}
const target = resolveAlias(symbol);
const target = getExportSymbolOfValueSymbolIfExported(resolveAlias(symbol));
if (target === unknownSymbol) {
return true;
}
Expand Down
9 changes: 9 additions & 0 deletions tests/baselines/reference/defaultNamedExportWithType1.js
@@ -0,0 +1,9 @@
//// [defaultNamedExportWithType1.ts]
type Foo = number;
export const Foo = 1;
export default Foo;


//// [defaultNamedExportWithType1.js]
export const Foo = 1;
export default Foo;
10 changes: 10 additions & 0 deletions tests/baselines/reference/defaultNamedExportWithType1.symbols
@@ -0,0 +1,10 @@
=== tests/cases/compiler/defaultNamedExportWithType1.ts ===
type Foo = number;
>Foo : Symbol(Foo, Decl(defaultNamedExportWithType1.ts, 0, 0), Decl(defaultNamedExportWithType1.ts, 1, 12))

export const Foo = 1;
>Foo : Symbol(Foo, Decl(defaultNamedExportWithType1.ts, 1, 12))

export default Foo;
>Foo : Symbol(Foo, Decl(defaultNamedExportWithType1.ts, 0, 0), Decl(defaultNamedExportWithType1.ts, 1, 12))

11 changes: 11 additions & 0 deletions tests/baselines/reference/defaultNamedExportWithType1.types
@@ -0,0 +1,11 @@
=== tests/cases/compiler/defaultNamedExportWithType1.ts ===
type Foo = number;
>Foo : number

export const Foo = 1;
>Foo : 1
>1 : 1

export default Foo;
>Foo : number

9 changes: 9 additions & 0 deletions tests/baselines/reference/defaultNamedExportWithType2.js
@@ -0,0 +1,9 @@
//// [defaultNamedExportWithType2.ts]
type Foo = number;
const Foo = 1;
export default Foo;


//// [defaultNamedExportWithType2.js]
const Foo = 1;
export default Foo;
10 changes: 10 additions & 0 deletions tests/baselines/reference/defaultNamedExportWithType2.symbols
@@ -0,0 +1,10 @@
=== tests/cases/compiler/defaultNamedExportWithType2.ts ===
type Foo = number;
>Foo : Symbol(Foo, Decl(defaultNamedExportWithType2.ts, 0, 0), Decl(defaultNamedExportWithType2.ts, 1, 5))

const Foo = 1;
>Foo : Symbol(Foo, Decl(defaultNamedExportWithType2.ts, 0, 0), Decl(defaultNamedExportWithType2.ts, 1, 5))

export default Foo;
>Foo : Symbol(Foo, Decl(defaultNamedExportWithType2.ts, 0, 0), Decl(defaultNamedExportWithType2.ts, 1, 5))

11 changes: 11 additions & 0 deletions tests/baselines/reference/defaultNamedExportWithType2.types
@@ -0,0 +1,11 @@
=== tests/cases/compiler/defaultNamedExportWithType2.ts ===
type Foo = number;
>Foo : number

const Foo = 1;
>Foo : 1
>1 : 1

export default Foo;
>Foo : number

9 changes: 9 additions & 0 deletions tests/baselines/reference/defaultNamedExportWithType3.js
@@ -0,0 +1,9 @@
//// [defaultNamedExportWithType3.ts]
interface Foo {}
export const Foo = {};
export default Foo;


//// [defaultNamedExportWithType3.js]
export const Foo = {};
export default Foo;
10 changes: 10 additions & 0 deletions tests/baselines/reference/defaultNamedExportWithType3.symbols
@@ -0,0 +1,10 @@
=== tests/cases/compiler/defaultNamedExportWithType3.ts ===
interface Foo {}
>Foo : Symbol(Foo, Decl(defaultNamedExportWithType3.ts, 0, 0), Decl(defaultNamedExportWithType3.ts, 1, 12))

export const Foo = {};
>Foo : Symbol(Foo, Decl(defaultNamedExportWithType3.ts, 1, 12))

export default Foo;
>Foo : Symbol(Foo, Decl(defaultNamedExportWithType3.ts, 0, 0), Decl(defaultNamedExportWithType3.ts, 1, 12))

9 changes: 9 additions & 0 deletions tests/baselines/reference/defaultNamedExportWithType3.types
@@ -0,0 +1,9 @@
=== tests/cases/compiler/defaultNamedExportWithType3.ts ===
interface Foo {}
export const Foo = {};
>Foo : {}
>{} : {}

export default Foo;
>Foo : Foo

9 changes: 9 additions & 0 deletions tests/baselines/reference/defaultNamedExportWithType4.js
@@ -0,0 +1,9 @@
//// [defaultNamedExportWithType4.ts]
interface Foo {}
const Foo = {};
export default Foo;


//// [defaultNamedExportWithType4.js]
const Foo = {};
export default Foo;
10 changes: 10 additions & 0 deletions tests/baselines/reference/defaultNamedExportWithType4.symbols
@@ -0,0 +1,10 @@
=== tests/cases/compiler/defaultNamedExportWithType4.ts ===
interface Foo {}
>Foo : Symbol(Foo, Decl(defaultNamedExportWithType4.ts, 0, 0), Decl(defaultNamedExportWithType4.ts, 1, 5))

const Foo = {};
>Foo : Symbol(Foo, Decl(defaultNamedExportWithType4.ts, 0, 0), Decl(defaultNamedExportWithType4.ts, 1, 5))

export default Foo;
>Foo : Symbol(Foo, Decl(defaultNamedExportWithType4.ts, 0, 0), Decl(defaultNamedExportWithType4.ts, 1, 5))

9 changes: 9 additions & 0 deletions tests/baselines/reference/defaultNamedExportWithType4.types
@@ -0,0 +1,9 @@
=== tests/cases/compiler/defaultNamedExportWithType4.ts ===
interface Foo {}
const Foo = {};
>Foo : {}
>{} : {}

export default Foo;
>Foo : Foo

Expand Up @@ -43,6 +43,7 @@ var x = 0;
var y = "";
var z = 0;
//// [duplicateVarsAcrossFileBoundaries_4.js]
var p = P;
var q;
//// [duplicateVarsAcrossFileBoundaries_5.js]
var p;
Expand Up @@ -8,6 +8,6 @@ export = x;

//// [importDeclWithExportModifierAndExportAssignment.js]
"use strict";
exports.__esModule = true;
exports.a = void 0;
exports.a = x.c;
module.exports = x;
5 changes: 5 additions & 0 deletions tests/cases/compiler/defaultNamedExportWithType1.ts
@@ -0,0 +1,5 @@
// @target: esnext

type Foo = number;
export const Foo = 1;
export default Foo;
5 changes: 5 additions & 0 deletions tests/cases/compiler/defaultNamedExportWithType2.ts
@@ -0,0 +1,5 @@
// @target: esnext

type Foo = number;
const Foo = 1;
export default Foo;
5 changes: 5 additions & 0 deletions tests/cases/compiler/defaultNamedExportWithType3.ts
@@ -0,0 +1,5 @@
// @target: esnext

interface Foo {}
export const Foo = {};
export default Foo;
5 changes: 5 additions & 0 deletions tests/cases/compiler/defaultNamedExportWithType4.ts
@@ -0,0 +1,5 @@
// @target: esnext

interface Foo {}
const Foo = {};
export default Foo;

0 comments on commit 719ab0b

Please sign in to comment.