mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-06-11 20:37:46 -05:00
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:
@@ -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) {
|
||||
|
||||
8
tests/baselines/reference/typeAliasExport.js
Normal file
8
tests/baselines/reference/typeAliasExport.js
Normal file
@@ -0,0 +1,8 @@
|
||||
//// [typeAliasExport.ts]
|
||||
declare module "a" {
|
||||
export default 0
|
||||
export var a;
|
||||
export type a = typeof a;
|
||||
}
|
||||
|
||||
//// [typeAliasExport.js]
|
||||
10
tests/baselines/reference/typeAliasExport.symbols
Normal file
10
tests/baselines/reference/typeAliasExport.symbols
Normal 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))
|
||||
}
|
||||
10
tests/baselines/reference/typeAliasExport.types
Normal file
10
tests/baselines/reference/typeAliasExport.types
Normal 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
|
||||
}
|
||||
5
tests/cases/compiler/typeAliasExport.ts
Normal file
5
tests/cases/compiler/typeAliasExport.ts
Normal file
@@ -0,0 +1,5 @@
|
||||
declare module "a" {
|
||||
export default 0
|
||||
export var a;
|
||||
export type a = typeof a;
|
||||
}
|
||||
Reference in New Issue
Block a user