Skip to content

Commit 139f10f

Browse files
committed
test for and fix microsoft#6043
1 parent 58400ed commit 139f10f

File tree

5 files changed

+35
-1
lines changed

5 files changed

+35
-1
lines changed

src/compiler/checker.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14310,8 +14310,9 @@ namespace ts {
1431014310
continue;
1431114311
}
1431214312
const { declarations, flags } = exports[id];
14313+
let declarationLength = declarations.length;
1431314314
// 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)
14314-
if (!(flags & (SymbolFlags.Namespace | SymbolFlags.Interface | SymbolFlags.Enum)) && declarations.length > 1) {
14315+
if (!(flags & (SymbolFlags.Namespace | SymbolFlags.Interface | SymbolFlags.Enum)) && (flags & SymbolFlags.TypeAlias ? declarationLength-- : true) && declarationLength > 1) {
1431514316
const exportedDeclarations: Declaration[] = filter(declarations, isNotOverload);
1431614317
if (exportedDeclarations.length > 1) {
1431714318
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)