Merge pull request #7591 from Microsoft/allow-merge-for-types-namespaces
Allow aliases to be merged with exported types\namespaces
This commit is contained in:
commit
cc8277c4db
|
@ -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 :
|
||||
|
|
20
tests/baselines/reference/mergeWithImportedNamespace.js
Normal file
20
tests/baselines/reference/mergeWithImportedNamespace.js
Normal file
|
@ -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";
|
17
tests/baselines/reference/mergeWithImportedNamespace.symbols
Normal file
17
tests/baselines/reference/mergeWithImportedNamespace.symbols
Normal file
|
@ -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))
|
||||
}
|
18
tests/baselines/reference/mergeWithImportedNamespace.types
Normal file
18
tests/baselines/reference/mergeWithImportedNamespace.types
Normal file
|
@ -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
|
||||
}
|
18
tests/baselines/reference/mergeWithImportedType.js
Normal file
18
tests/baselines/reference/mergeWithImportedType.js
Normal file
|
@ -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";
|
14
tests/baselines/reference/mergeWithImportedType.symbols
Normal file
14
tests/baselines/reference/mergeWithImportedType.symbols
Normal file
|
@ -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))
|
||||
|
14
tests/baselines/reference/mergeWithImportedType.types
Normal file
14
tests/baselines/reference/mergeWithImportedType.types
Normal file
|
@ -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
|
||||
|
10
tests/cases/compiler/mergeWithImportedNamespace.ts
Normal file
10
tests/cases/compiler/mergeWithImportedNamespace.ts
Normal file
|
@ -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}
|
||||
}
|
8
tests/cases/compiler/mergeWithImportedType.ts
Normal file
8
tests/cases/compiler/mergeWithImportedType.ts
Normal file
|
@ -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;
|
Loading…
Reference in a new issue