diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 27b0839720559..6adb488aea9d9 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -15085,8 +15085,8 @@ namespace ts { // in order to prevent collisions with declarations that were exported from the current module (they still contribute to local names). const excludedMeanings = (symbol.flags & (SymbolFlags.Value | SymbolFlags.ExportValue) ? SymbolFlags.Value : 0) | - (symbol.flags & (SymbolFlags.Type | SymbolFlags.ExportType) ? SymbolFlags.Type : 0) | - (symbol.flags & (SymbolFlags.Namespace | SymbolFlags.ExportNamespace) ? SymbolFlags.Namespace : 0); + (symbol.flags & SymbolFlags.Type ? SymbolFlags.Type : 0) | + (symbol.flags & SymbolFlags.Namespace ? SymbolFlags.Namespace : 0); if (target.flags & excludedMeanings) { const message = node.kind === SyntaxKind.ExportSpecifier ? Diagnostics.Export_declaration_conflicts_with_exported_declaration_of_0 : diff --git a/tests/baselines/reference/mergeWithImportedNamespace.js b/tests/baselines/reference/mergeWithImportedNamespace.js new file mode 100644 index 0000000000000..60f6fedd3f228 --- /dev/null +++ b/tests/baselines/reference/mergeWithImportedNamespace.js @@ -0,0 +1,20 @@ +//// [tests/cases/compiler/mergeWithImportedNamespace.ts] //// + +//// [f1.ts] +export namespace N { export var x = 1; } + +//// [f2.ts] +import {N} from "./f1"; +// partial revert of https://github.com/Microsoft/TypeScript/pull/7583 to prevent breaking changes +export namespace N { + export interface I {x: any} +} + +//// [f1.js] +"use strict"; +var N; +(function (N) { + N.x = 1; +})(N = exports.N || (exports.N = {})); +//// [f2.js] +"use strict"; diff --git a/tests/baselines/reference/mergeWithImportedNamespace.symbols b/tests/baselines/reference/mergeWithImportedNamespace.symbols new file mode 100644 index 0000000000000..58b0f0a811fd1 --- /dev/null +++ b/tests/baselines/reference/mergeWithImportedNamespace.symbols @@ -0,0 +1,17 @@ +=== tests/cases/compiler/f1.ts === +export namespace N { export var x = 1; } +>N : Symbol(N, Decl(f1.ts, 0, 0)) +>x : Symbol(x, Decl(f1.ts, 0, 31)) + +=== tests/cases/compiler/f2.ts === +import {N} from "./f1"; +>N : Symbol(N, Decl(f2.ts, 0, 8), Decl(f2.ts, 0, 23)) + +// partial revert of https://github.com/Microsoft/TypeScript/pull/7583 to prevent breaking changes +export namespace N { +>N : Symbol(N, Decl(f2.ts, 0, 23)) + + export interface I {x: any} +>I : Symbol(I, Decl(f2.ts, 2, 20)) +>x : Symbol(I.x, Decl(f2.ts, 3, 24)) +} diff --git a/tests/baselines/reference/mergeWithImportedNamespace.types b/tests/baselines/reference/mergeWithImportedNamespace.types new file mode 100644 index 0000000000000..d6c1df3b6090c --- /dev/null +++ b/tests/baselines/reference/mergeWithImportedNamespace.types @@ -0,0 +1,18 @@ +=== tests/cases/compiler/f1.ts === +export namespace N { export var x = 1; } +>N : typeof N +>x : number +>1 : number + +=== tests/cases/compiler/f2.ts === +import {N} from "./f1"; +>N : typeof N + +// partial revert of https://github.com/Microsoft/TypeScript/pull/7583 to prevent breaking changes +export namespace N { +>N : any + + export interface I {x: any} +>I : I +>x : any +} diff --git a/tests/baselines/reference/mergeWithImportedType.js b/tests/baselines/reference/mergeWithImportedType.js new file mode 100644 index 0000000000000..89fc353d395da --- /dev/null +++ b/tests/baselines/reference/mergeWithImportedType.js @@ -0,0 +1,18 @@ +//// [tests/cases/compiler/mergeWithImportedType.ts] //// + +//// [f1.ts] +export enum E {X} + +//// [f2.ts] +import {E} from "./f1"; +// partial revert of https://github.com/Microsoft/TypeScript/pull/7583 to prevent breaking changes +export type E = E; + +//// [f1.js] +"use strict"; +(function (E) { + E[E["X"] = 0] = "X"; +})(exports.E || (exports.E = {})); +var E = exports.E; +//// [f2.js] +"use strict"; diff --git a/tests/baselines/reference/mergeWithImportedType.symbols b/tests/baselines/reference/mergeWithImportedType.symbols new file mode 100644 index 0000000000000..d14d76f91e7b4 --- /dev/null +++ b/tests/baselines/reference/mergeWithImportedType.symbols @@ -0,0 +1,14 @@ +=== tests/cases/compiler/f1.ts === +export enum E {X} +>E : Symbol(E, Decl(f1.ts, 0, 0)) +>X : Symbol(E.X, Decl(f1.ts, 0, 15)) + +=== tests/cases/compiler/f2.ts === +import {E} from "./f1"; +>E : Symbol(E, Decl(f2.ts, 0, 8), Decl(f2.ts, 0, 23)) + +// partial revert of https://github.com/Microsoft/TypeScript/pull/7583 to prevent breaking changes +export type E = E; +>E : Symbol(E, Decl(f2.ts, 0, 23)) +>E : Symbol(E, Decl(f2.ts, 0, 8), Decl(f2.ts, 0, 23)) + diff --git a/tests/baselines/reference/mergeWithImportedType.types b/tests/baselines/reference/mergeWithImportedType.types new file mode 100644 index 0000000000000..583492444c596 --- /dev/null +++ b/tests/baselines/reference/mergeWithImportedType.types @@ -0,0 +1,14 @@ +=== tests/cases/compiler/f1.ts === +export enum E {X} +>E : E +>X : E + +=== tests/cases/compiler/f2.ts === +import {E} from "./f1"; +>E : typeof E + +// partial revert of https://github.com/Microsoft/TypeScript/pull/7583 to prevent breaking changes +export type E = E; +>E : E +>E : E + diff --git a/tests/cases/compiler/mergeWithImportedNamespace.ts b/tests/cases/compiler/mergeWithImportedNamespace.ts new file mode 100644 index 0000000000000..79a94fd0ba4e8 --- /dev/null +++ b/tests/cases/compiler/mergeWithImportedNamespace.ts @@ -0,0 +1,10 @@ +// @module:commonjs +// @filename: f1.ts +export namespace N { export var x = 1; } + +// @filename: f2.ts +import {N} from "./f1"; +// partial revert of https://github.com/Microsoft/TypeScript/pull/7583 to prevent breaking changes +export namespace N { + export interface I {x: any} +} \ No newline at end of file diff --git a/tests/cases/compiler/mergeWithImportedType.ts b/tests/cases/compiler/mergeWithImportedType.ts new file mode 100644 index 0000000000000..2310022012f32 --- /dev/null +++ b/tests/cases/compiler/mergeWithImportedType.ts @@ -0,0 +1,8 @@ +// @module:commonjs +// @filename: f1.ts +export enum E {X} + +// @filename: f2.ts +import {E} from "./f1"; +// partial revert of https://github.com/Microsoft/TypeScript/pull/7583 to prevent breaking changes +export type E = E; \ No newline at end of file