Merge pull request #6044 from weswigham/redeclared-export-type

Exempt one type declaration from the redeclared export check - Fix #6043
This commit is contained in:
Wesley Wigham 2015-12-11 16:15:22 -08:00
commit 5ee0957974
5 changed files with 34 additions and 1 deletions

View file

@ -14295,7 +14295,7 @@ namespace ts {
}
const { declarations, flags } = exports[id];
// 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)
if (!(flags & (SymbolFlags.Namespace | SymbolFlags.Interface | SymbolFlags.Enum)) && declarations.length > 1) {
if (!(flags & (SymbolFlags.Namespace | SymbolFlags.Interface | SymbolFlags.Enum)) && (flags & SymbolFlags.TypeAlias ? declarations.length - 1 : declarations.length) > 1) {
const exportedDeclarations: Declaration[] = filter(declarations, isNotOverload);
if (exportedDeclarations.length > 1) {
for (const declaration of exportedDeclarations) {

View file

@ -0,0 +1,8 @@
//// [typeAliasExport.ts]
declare module "a" {
export default 0
export var a;
export type a = typeof a;
}
//// [typeAliasExport.js]

View file

@ -0,0 +1,10 @@
=== tests/cases/compiler/typeAliasExport.ts ===
declare module "a" {
export default 0
export var a;
>a : Symbol(a, Decl(typeAliasExport.ts, 2, 12), Decl(typeAliasExport.ts, 2, 15))
export type a = typeof a;
>a : Symbol(a, Decl(typeAliasExport.ts, 2, 12), Decl(typeAliasExport.ts, 2, 15))
>a : Symbol(a, Decl(typeAliasExport.ts, 2, 12), Decl(typeAliasExport.ts, 2, 15))
}

View file

@ -0,0 +1,10 @@
=== tests/cases/compiler/typeAliasExport.ts ===
declare module "a" {
export default 0
export var a;
>a : any
export type a = typeof a;
>a : any
>a : any
}

View file

@ -0,0 +1,5 @@
declare module "a" {
export default 0
export var a;
export type a = typeof a;
}