Skip to content

Commit 5ee0957

Browse files
committed
Merge pull request microsoft#6044 from weswigham/redeclared-export-type
Exempt one type declaration from the redeclared export check - Fix microsoft#6043
2 parents f51de5b + ef6c137 commit 5ee0957

File tree

5 files changed

+34
-1
lines changed

5 files changed

+34
-1
lines changed

src/compiler/checker.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14295,7 +14295,7 @@ namespace ts {
1429514295
}
1429614296
const { declarations, flags } = exports[id];
1429714297
// ECMA262: 15.2.1.1 It is a Syntax Error if the ExportedNames of ModuleItemList contains any duplicate entries. (TS Exceptions: namespaces, function overloads, enums, and interfaces)
14298-
if (!(flags & (SymbolFlags.Namespace | SymbolFlags.Interface | SymbolFlags.Enum)) && declarations.length > 1) {
14298+
if (!(flags & (SymbolFlags.Namespace | SymbolFlags.Interface | SymbolFlags.Enum)) && (flags & SymbolFlags.TypeAlias ? declarations.length - 1 : declarations.length) > 1) {
1429914299
const exportedDeclarations: Declaration[] = filter(declarations, isNotOverload);
1430014300
if (exportedDeclarations.length > 1) {
1430114301
for (const declaration of exportedDeclarations) {
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
//// [typeAliasExport.ts]
2+
declare module "a" {
3+
export default 0
4+
export var a;
5+
export type a = typeof a;
6+
}
7+
8+
//// [typeAliasExport.js]
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
=== tests/cases/compiler/typeAliasExport.ts ===
2+
declare module "a" {
3+
export default 0
4+
export var a;
5+
>a : Symbol(a, Decl(typeAliasExport.ts, 2, 12), Decl(typeAliasExport.ts, 2, 15))
6+
7+
export type a = typeof a;
8+
>a : Symbol(a, Decl(typeAliasExport.ts, 2, 12), Decl(typeAliasExport.ts, 2, 15))
9+
>a : Symbol(a, Decl(typeAliasExport.ts, 2, 12), Decl(typeAliasExport.ts, 2, 15))
10+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
=== tests/cases/compiler/typeAliasExport.ts ===
2+
declare module "a" {
3+
export default 0
4+
export var a;
5+
>a : any
6+
7+
export type a = typeof a;
8+
>a : any
9+
>a : any
10+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
declare module "a" {
2+
export default 0
3+
export var a;
4+
export type a = typeof a;
5+
}

0 commit comments

Comments
 (0)