diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index c83e11fc2a4a0..558c47b82e509 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -830,7 +830,7 @@ function createBinder(): (file: SourceFile, options: CompilerOptions) => void { let messageNeedsName = true; if (symbol.flags & SymbolFlags.Enum || includes & SymbolFlags.Enum) { - message = Diagnostics.Enum_declarations_can_only_merge_with_namespace_or_other_enum_declarations; + message = Diagnostics.Enum_declarations_can_only_merge_with_namespace_declarations; messageNeedsName = false; } diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index cbdb92933023e..5cbf45c6caa36 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -2724,7 +2724,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { function reportMergeSymbolError(target: Symbol, source: Symbol) { const isEitherEnum = !!(target.flags & SymbolFlags.Enum || source.flags & SymbolFlags.Enum); const isEitherBlockScoped = !!(target.flags & SymbolFlags.BlockScopedVariable || source.flags & SymbolFlags.BlockScopedVariable); - const message = isEitherEnum ? Diagnostics.Enum_declarations_can_only_merge_with_namespace_or_other_enum_declarations + const message = isEitherEnum ? Diagnostics.Enum_declarations_can_only_merge_with_namespace_declarations : isEitherBlockScoped ? Diagnostics.Cannot_redeclare_block_scoped_variable_0 : Diagnostics.Duplicate_identifier_0; const sourceSymbolFile = source.declarations && getSourceFileOfNode(source.declarations[0]); diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index be2fe3957b20a..9295db02aec48 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -2864,7 +2864,7 @@ "category": "Error", "code": 2566 }, - "Enum declarations can only merge with namespace or other enum declarations.": { + "Enum declarations can only merge with namespace declarations.": { "category": "Error", "code": 2567 }, diff --git a/src/compiler/types.ts b/src/compiler/types.ts index f6ca75a68e17d..414fdac5160b9 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -5938,7 +5938,7 @@ export const enum SymbolFlags { FunctionExcludes = Value & ~(Function | ValueModule | Class), ClassExcludes = (Value | Type) & ~(ValueModule | Interface | Function), // class-interface mergability done in checker.ts InterfaceExcludes = Type & ~(Interface | Class), - RegularEnumExcludes = (Value | Type) & ~(RegularEnum | ValueModule), // regular enums merge only with regular enums and modules + RegularEnumExcludes = (Value | Type) & ~ValueModule, // regular enums merge only modules ConstEnumExcludes = (Value | Type) & ~ConstEnum, // const enums merge only with const enums ValueModuleExcludes = Value & ~(Function | Class | RegularEnum | ValueModule), NamespaceModuleExcludes = 0, diff --git a/tests/baselines/reference/api/typescript.d.ts b/tests/baselines/reference/api/typescript.d.ts index 2531c9ea0413d..49824e925f87e 100644 --- a/tests/baselines/reference/api/typescript.d.ts +++ b/tests/baselines/reference/api/typescript.d.ts @@ -6489,7 +6489,7 @@ declare namespace ts { FunctionExcludes = 110991, ClassExcludes = 899503, InterfaceExcludes = 788872, - RegularEnumExcludes = 899327, + RegularEnumExcludes = 899583, ConstEnumExcludes = 899967, ValueModuleExcludes = 110735, NamespaceModuleExcludes = 0, diff --git a/tests/baselines/reference/augmentedTypesClass.errors.txt b/tests/baselines/reference/augmentedTypesClass.errors.txt index 370128c528ff0..ee9a31ae9ea20 100644 --- a/tests/baselines/reference/augmentedTypesClass.errors.txt +++ b/tests/baselines/reference/augmentedTypesClass.errors.txt @@ -1,7 +1,7 @@ augmentedTypesClass.ts(2,7): error TS2300: Duplicate identifier 'c1'. augmentedTypesClass.ts(3,5): error TS2300: Duplicate identifier 'c1'. -augmentedTypesClass.ts(6,7): error TS2567: Enum declarations can only merge with namespace or other enum declarations. -augmentedTypesClass.ts(7,6): error TS2567: Enum declarations can only merge with namespace or other enum declarations. +augmentedTypesClass.ts(6,7): error TS2567: Enum declarations can only merge with namespace declarations. +augmentedTypesClass.ts(7,6): error TS2567: Enum declarations can only merge with namespace declarations. ==== augmentedTypesClass.ts (4 errors) ==== @@ -16,7 +16,7 @@ augmentedTypesClass.ts(7,6): error TS2567: Enum declarations can only merge with //// class then enum class c4 { public foo() { } } ~~ -!!! error TS2567: Enum declarations can only merge with namespace or other enum declarations. +!!! error TS2567: Enum declarations can only merge with namespace declarations. enum c4 { One } // error ~~ -!!! error TS2567: Enum declarations can only merge with namespace or other enum declarations. \ No newline at end of file +!!! error TS2567: Enum declarations can only merge with namespace declarations. \ No newline at end of file diff --git a/tests/baselines/reference/augmentedTypesClass2.errors.txt b/tests/baselines/reference/augmentedTypesClass2.errors.txt index a3469041868e4..cfd14a36804f4 100644 --- a/tests/baselines/reference/augmentedTypesClass2.errors.txt +++ b/tests/baselines/reference/augmentedTypesClass2.errors.txt @@ -1,5 +1,5 @@ -augmentedTypesClass2.ts(16,7): error TS2567: Enum declarations can only merge with namespace or other enum declarations. -augmentedTypesClass2.ts(21,6): error TS2567: Enum declarations can only merge with namespace or other enum declarations. +augmentedTypesClass2.ts(16,7): error TS2567: Enum declarations can only merge with namespace declarations. +augmentedTypesClass2.ts(21,6): error TS2567: Enum declarations can only merge with namespace declarations. ==== augmentedTypesClass2.ts (2 errors) ==== @@ -20,14 +20,14 @@ augmentedTypesClass2.ts(21,6): error TS2567: Enum declarations can only merge wi // class then enum class c33 { ~~~ -!!! error TS2567: Enum declarations can only merge with namespace or other enum declarations. +!!! error TS2567: Enum declarations can only merge with namespace declarations. foo() { return 1; } } enum c33 { One }; ~~~ -!!! error TS2567: Enum declarations can only merge with namespace or other enum declarations. +!!! error TS2567: Enum declarations can only merge with namespace declarations. // class then import class c44 { diff --git a/tests/baselines/reference/augmentedTypesEnum.errors.txt b/tests/baselines/reference/augmentedTypesEnum.errors.txt index a8e9752429881..f5491875f72e5 100644 --- a/tests/baselines/reference/augmentedTypesEnum.errors.txt +++ b/tests/baselines/reference/augmentedTypesEnum.errors.txt @@ -1,63 +1,63 @@ -augmentedTypesEnum.ts(2,6): error TS2567: Enum declarations can only merge with namespace or other enum declarations. -augmentedTypesEnum.ts(3,5): error TS2567: Enum declarations can only merge with namespace or other enum declarations. -augmentedTypesEnum.ts(6,6): error TS2567: Enum declarations can only merge with namespace or other enum declarations. -augmentedTypesEnum.ts(7,10): error TS2567: Enum declarations can only merge with namespace or other enum declarations. -augmentedTypesEnum.ts(9,6): error TS2567: Enum declarations can only merge with namespace or other enum declarations. -augmentedTypesEnum.ts(10,5): error TS2567: Enum declarations can only merge with namespace or other enum declarations. -augmentedTypesEnum.ts(13,6): error TS2567: Enum declarations can only merge with namespace or other enum declarations. -augmentedTypesEnum.ts(14,7): error TS2567: Enum declarations can only merge with namespace or other enum declarations. -augmentedTypesEnum.ts(18,11): error TS2432: In an enum with multiple declarations, only one declaration can omit an initializer for its first enum element. -augmentedTypesEnum.ts(20,12): error TS2300: Duplicate identifier 'One'. -augmentedTypesEnum.ts(21,12): error TS2300: Duplicate identifier 'One'. -augmentedTypesEnum.ts(21,12): error TS2432: In an enum with multiple declarations, only one declaration can omit an initializer for its first enum element. +augmentedTypesEnum.ts(2,6): error TS2567: Enum declarations can only merge with namespace declarations. +augmentedTypesEnum.ts(3,5): error TS2567: Enum declarations can only merge with namespace declarations. +augmentedTypesEnum.ts(6,6): error TS2567: Enum declarations can only merge with namespace declarations. +augmentedTypesEnum.ts(7,10): error TS2567: Enum declarations can only merge with namespace declarations. +augmentedTypesEnum.ts(9,6): error TS2567: Enum declarations can only merge with namespace declarations. +augmentedTypesEnum.ts(10,5): error TS2567: Enum declarations can only merge with namespace declarations. +augmentedTypesEnum.ts(13,6): error TS2567: Enum declarations can only merge with namespace declarations. +augmentedTypesEnum.ts(14,7): error TS2567: Enum declarations can only merge with namespace declarations. +augmentedTypesEnum.ts(17,6): error TS2567: Enum declarations can only merge with namespace declarations. +augmentedTypesEnum.ts(18,6): error TS2567: Enum declarations can only merge with namespace declarations. +augmentedTypesEnum.ts(20,6): error TS2567: Enum declarations can only merge with namespace declarations. +augmentedTypesEnum.ts(21,6): error TS2567: Enum declarations can only merge with namespace declarations. ==== augmentedTypesEnum.ts (12 errors) ==== // enum then var enum e1111 { One } // error ~~~~~ -!!! error TS2567: Enum declarations can only merge with namespace or other enum declarations. +!!! error TS2567: Enum declarations can only merge with namespace declarations. var e1111 = 1; // error ~~~~~ -!!! error TS2567: Enum declarations can only merge with namespace or other enum declarations. +!!! error TS2567: Enum declarations can only merge with namespace declarations. // enum then function enum e2 { One } // error ~~ -!!! error TS2567: Enum declarations can only merge with namespace or other enum declarations. +!!! error TS2567: Enum declarations can only merge with namespace declarations. function e2() { } // error ~~ -!!! error TS2567: Enum declarations can only merge with namespace or other enum declarations. +!!! error TS2567: Enum declarations can only merge with namespace declarations. enum e3 { One } // error ~~ -!!! error TS2567: Enum declarations can only merge with namespace or other enum declarations. +!!! error TS2567: Enum declarations can only merge with namespace declarations. var e3 = () => { } // error ~~ -!!! error TS2567: Enum declarations can only merge with namespace or other enum declarations. +!!! error TS2567: Enum declarations can only merge with namespace declarations. // enum then class enum e4 { One } // error ~~ -!!! error TS2567: Enum declarations can only merge with namespace or other enum declarations. +!!! error TS2567: Enum declarations can only merge with namespace declarations. class e4 { public foo() { } } // error ~~ -!!! error TS2567: Enum declarations can only merge with namespace or other enum declarations. +!!! error TS2567: Enum declarations can only merge with namespace declarations. // enum then enum enum e5 { One } + ~~ +!!! error TS2567: Enum declarations can only merge with namespace declarations. enum e5 { Two } // error - ~~~ -!!! error TS2432: In an enum with multiple declarations, only one declaration can omit an initializer for its first enum element. + ~~ +!!! error TS2567: Enum declarations can only merge with namespace declarations. enum e5a { One } // error - ~~~ -!!! error TS2300: Duplicate identifier 'One'. + ~~~ +!!! error TS2567: Enum declarations can only merge with namespace declarations. enum e5a { One } // error - ~~~ -!!! error TS2300: Duplicate identifier 'One'. - ~~~ -!!! error TS2432: In an enum with multiple declarations, only one declaration can omit an initializer for its first enum element. + ~~~ +!!! error TS2567: Enum declarations can only merge with namespace declarations. // enum then internal module enum e6 { One } diff --git a/tests/baselines/reference/augmentedTypesEnum.symbols b/tests/baselines/reference/augmentedTypesEnum.symbols index 1dd7fe3f24ff5..6030fa2e51692 100644 --- a/tests/baselines/reference/augmentedTypesEnum.symbols +++ b/tests/baselines/reference/augmentedTypesEnum.symbols @@ -35,19 +35,19 @@ class e4 { public foo() { } } // error // enum then enum enum e5 { One } ->e5 : Symbol(e5, Decl(augmentedTypesEnum.ts, 13, 29), Decl(augmentedTypesEnum.ts, 16, 15)) +>e5 : Symbol(e5, Decl(augmentedTypesEnum.ts, 13, 29)) >One : Symbol(e5.One, Decl(augmentedTypesEnum.ts, 16, 9)) enum e5 { Two } // error ->e5 : Symbol(e5, Decl(augmentedTypesEnum.ts, 13, 29), Decl(augmentedTypesEnum.ts, 16, 15)) +>e5 : Symbol(e5, Decl(augmentedTypesEnum.ts, 16, 15)) >Two : Symbol(e5.Two, Decl(augmentedTypesEnum.ts, 17, 9)) enum e5a { One } // error ->e5a : Symbol(e5a, Decl(augmentedTypesEnum.ts, 17, 15), Decl(augmentedTypesEnum.ts, 19, 16)) +>e5a : Symbol(e5a, Decl(augmentedTypesEnum.ts, 17, 15)) >One : Symbol(e5a.One, Decl(augmentedTypesEnum.ts, 19, 10)) enum e5a { One } // error ->e5a : Symbol(e5a, Decl(augmentedTypesEnum.ts, 17, 15), Decl(augmentedTypesEnum.ts, 19, 16)) +>e5a : Symbol(e5a, Decl(augmentedTypesEnum.ts, 19, 16)) >One : Symbol(e5a.One, Decl(augmentedTypesEnum.ts, 20, 10)) // enum then internal module diff --git a/tests/baselines/reference/augmentedTypesEnum.types b/tests/baselines/reference/augmentedTypesEnum.types index 733022e95d24d..a1ab0b54d740b 100644 --- a/tests/baselines/reference/augmentedTypesEnum.types +++ b/tests/baselines/reference/augmentedTypesEnum.types @@ -60,7 +60,7 @@ enum e5 { One } enum e5 { Two } // error >e5 : e5 > : ^^ ->Two : e5.One +>Two : e5.Two > : ^^^^^^ enum e5a { One } // error diff --git a/tests/baselines/reference/augmentedTypesEnum2.errors.txt b/tests/baselines/reference/augmentedTypesEnum2.errors.txt index 296bf37fb29b8..70be0beaa508d 100644 --- a/tests/baselines/reference/augmentedTypesEnum2.errors.txt +++ b/tests/baselines/reference/augmentedTypesEnum2.errors.txt @@ -1,18 +1,18 @@ -augmentedTypesEnum2.ts(2,6): error TS2567: Enum declarations can only merge with namespace or other enum declarations. -augmentedTypesEnum2.ts(4,11): error TS2567: Enum declarations can only merge with namespace or other enum declarations. -augmentedTypesEnum2.ts(11,6): error TS2567: Enum declarations can only merge with namespace or other enum declarations. -augmentedTypesEnum2.ts(12,7): error TS2567: Enum declarations can only merge with namespace or other enum declarations. +augmentedTypesEnum2.ts(2,6): error TS2567: Enum declarations can only merge with namespace declarations. +augmentedTypesEnum2.ts(4,11): error TS2567: Enum declarations can only merge with namespace declarations. +augmentedTypesEnum2.ts(11,6): error TS2567: Enum declarations can only merge with namespace declarations. +augmentedTypesEnum2.ts(12,7): error TS2567: Enum declarations can only merge with namespace declarations. ==== augmentedTypesEnum2.ts (4 errors) ==== // enum then interface enum e1 { One } // error ~~ -!!! error TS2567: Enum declarations can only merge with namespace or other enum declarations. +!!! error TS2567: Enum declarations can only merge with namespace declarations. interface e1 { // error ~~ -!!! error TS2567: Enum declarations can only merge with namespace or other enum declarations. +!!! error TS2567: Enum declarations can only merge with namespace declarations. foo(): void; } @@ -21,10 +21,10 @@ augmentedTypesEnum2.ts(12,7): error TS2567: Enum declarations can only merge wit // enum then class enum e2 { One }; // error ~~ -!!! error TS2567: Enum declarations can only merge with namespace or other enum declarations. +!!! error TS2567: Enum declarations can only merge with namespace declarations. class e2 { // error ~~ -!!! error TS2567: Enum declarations can only merge with namespace or other enum declarations. +!!! error TS2567: Enum declarations can only merge with namespace declarations. foo() { return 1; } diff --git a/tests/baselines/reference/augmentedTypesEnum3.errors.txt b/tests/baselines/reference/augmentedTypesEnum3.errors.txt index a50b45318012d..9e8622b139049 100644 --- a/tests/baselines/reference/augmentedTypesEnum3.errors.txt +++ b/tests/baselines/reference/augmentedTypesEnum3.errors.txt @@ -1,7 +1,9 @@ -augmentedTypesEnum3.ts(16,5): error TS2432: In an enum with multiple declarations, only one declaration can omit an initializer for its first enum element. +augmentedTypesEnum3.ts(9,8): error TS2567: Enum declarations can only merge with namespace declarations. +augmentedTypesEnum3.ts(12,6): error TS2567: Enum declarations can only merge with namespace declarations. +augmentedTypesEnum3.ts(15,6): error TS2567: Enum declarations can only merge with namespace declarations. -==== augmentedTypesEnum3.ts (1 errors) ==== +==== augmentedTypesEnum3.ts (3 errors) ==== module E { var t; } @@ -11,15 +13,19 @@ augmentedTypesEnum3.ts(16,5): error TS2432: In an enum with multiple declaration module F { var t; } module A { + ~ +!!! error TS2567: Enum declarations can only merge with namespace declarations. var o; } enum A { + ~ +!!! error TS2567: Enum declarations can only merge with namespace declarations. b } enum A { + ~ +!!! error TS2567: Enum declarations can only merge with namespace declarations. c - ~ -!!! error TS2432: In an enum with multiple declarations, only one declaration can omit an initializer for its first enum element. } module A { var p; diff --git a/tests/baselines/reference/augmentedTypesEnum3.symbols b/tests/baselines/reference/augmentedTypesEnum3.symbols index 5b852406f2222..aac5e26e8b8fa 100644 --- a/tests/baselines/reference/augmentedTypesEnum3.symbols +++ b/tests/baselines/reference/augmentedTypesEnum3.symbols @@ -18,25 +18,25 @@ module F { var t; } >t : Symbol(t, Decl(augmentedTypesEnum3.ts, 6, 14)) module A { ->A : Symbol(A, Decl(augmentedTypesEnum3.ts, 6, 19), Decl(augmentedTypesEnum3.ts, 10, 1), Decl(augmentedTypesEnum3.ts, 13, 1), Decl(augmentedTypesEnum3.ts, 16, 1)) +>A : Symbol(A, Decl(augmentedTypesEnum3.ts, 6, 19), Decl(augmentedTypesEnum3.ts, 10, 1), Decl(augmentedTypesEnum3.ts, 16, 1)) var o; >o : Symbol(o, Decl(augmentedTypesEnum3.ts, 9, 7)) } enum A { ->A : Symbol(A, Decl(augmentedTypesEnum3.ts, 6, 19), Decl(augmentedTypesEnum3.ts, 10, 1), Decl(augmentedTypesEnum3.ts, 13, 1), Decl(augmentedTypesEnum3.ts, 16, 1)) +>A : Symbol(A, Decl(augmentedTypesEnum3.ts, 6, 19), Decl(augmentedTypesEnum3.ts, 10, 1), Decl(augmentedTypesEnum3.ts, 16, 1)) b >b : Symbol(A.b, Decl(augmentedTypesEnum3.ts, 11, 8)) } enum A { ->A : Symbol(A, Decl(augmentedTypesEnum3.ts, 6, 19), Decl(augmentedTypesEnum3.ts, 10, 1), Decl(augmentedTypesEnum3.ts, 13, 1), Decl(augmentedTypesEnum3.ts, 16, 1)) +>A : Symbol(A, Decl(augmentedTypesEnum3.ts, 13, 1)) c >c : Symbol(A.c, Decl(augmentedTypesEnum3.ts, 14, 8)) } module A { ->A : Symbol(A, Decl(augmentedTypesEnum3.ts, 6, 19), Decl(augmentedTypesEnum3.ts, 10, 1), Decl(augmentedTypesEnum3.ts, 13, 1), Decl(augmentedTypesEnum3.ts, 16, 1)) +>A : Symbol(A, Decl(augmentedTypesEnum3.ts, 6, 19), Decl(augmentedTypesEnum3.ts, 10, 1), Decl(augmentedTypesEnum3.ts, 16, 1)) var p; >p : Symbol(p, Decl(augmentedTypesEnum3.ts, 18, 7)) diff --git a/tests/baselines/reference/augmentedTypesEnum3.types b/tests/baselines/reference/augmentedTypesEnum3.types index f8336837df8b8..51f8e6c544214 100644 --- a/tests/baselines/reference/augmentedTypesEnum3.types +++ b/tests/baselines/reference/augmentedTypesEnum3.types @@ -44,7 +44,7 @@ enum A { > : ^ c ->c : A.b +>c : A.c > : ^^^ } module A { diff --git a/tests/baselines/reference/augmentedTypesFunction.errors.txt b/tests/baselines/reference/augmentedTypesFunction.errors.txt index 241e746460938..d153f86fd3bb6 100644 --- a/tests/baselines/reference/augmentedTypesFunction.errors.txt +++ b/tests/baselines/reference/augmentedTypesFunction.errors.txt @@ -8,8 +8,8 @@ augmentedTypesFunction.ts(13,10): error TS2814: Function with bodies can only me augmentedTypesFunction.ts(14,7): error TS2813: Class declaration cannot implement overload list for 'y3'. augmentedTypesFunction.ts(16,10): error TS2814: Function with bodies can only merge with classes that are ambient. augmentedTypesFunction.ts(17,7): error TS2813: Class declaration cannot implement overload list for 'y3a'. -augmentedTypesFunction.ts(20,10): error TS2567: Enum declarations can only merge with namespace or other enum declarations. -augmentedTypesFunction.ts(21,6): error TS2567: Enum declarations can only merge with namespace or other enum declarations. +augmentedTypesFunction.ts(20,10): error TS2567: Enum declarations can only merge with namespace declarations. +augmentedTypesFunction.ts(21,6): error TS2567: Enum declarations can only merge with namespace declarations. ==== augmentedTypesFunction.ts (12 errors) ==== @@ -58,10 +58,10 @@ augmentedTypesFunction.ts(21,6): error TS2567: Enum declarations can only merge // function then enum function y4() { } // error ~~ -!!! error TS2567: Enum declarations can only merge with namespace or other enum declarations. +!!! error TS2567: Enum declarations can only merge with namespace declarations. enum y4 { One } // error ~~ -!!! error TS2567: Enum declarations can only merge with namespace or other enum declarations. +!!! error TS2567: Enum declarations can only merge with namespace declarations. // function then internal module function y5() { } diff --git a/tests/baselines/reference/augmentedTypesInterface.errors.txt b/tests/baselines/reference/augmentedTypesInterface.errors.txt index 10fe6678663c7..a5d7f57f3cc21 100644 --- a/tests/baselines/reference/augmentedTypesInterface.errors.txt +++ b/tests/baselines/reference/augmentedTypesInterface.errors.txt @@ -1,5 +1,5 @@ -augmentedTypesInterface.ts(23,11): error TS2567: Enum declarations can only merge with namespace or other enum declarations. -augmentedTypesInterface.ts(26,6): error TS2567: Enum declarations can only merge with namespace or other enum declarations. +augmentedTypesInterface.ts(23,11): error TS2567: Enum declarations can only merge with namespace declarations. +augmentedTypesInterface.ts(26,6): error TS2567: Enum declarations can only merge with namespace declarations. ==== augmentedTypesInterface.ts (2 errors) ==== @@ -27,12 +27,12 @@ augmentedTypesInterface.ts(26,6): error TS2567: Enum declarations can only merge // interface then enum interface i3 { // error ~~ -!!! error TS2567: Enum declarations can only merge with namespace or other enum declarations. +!!! error TS2567: Enum declarations can only merge with namespace declarations. foo(): void; } enum i3 { One }; // error ~~ -!!! error TS2567: Enum declarations can only merge with namespace or other enum declarations. +!!! error TS2567: Enum declarations can only merge with namespace declarations. // interface then import interface i4 { diff --git a/tests/baselines/reference/augmentedTypesVar.errors.txt b/tests/baselines/reference/augmentedTypesVar.errors.txt index 724b5660fd68f..1a348ec703cea 100644 --- a/tests/baselines/reference/augmentedTypesVar.errors.txt +++ b/tests/baselines/reference/augmentedTypesVar.errors.txt @@ -5,8 +5,8 @@ augmentedTypesVar.ts(13,5): error TS2300: Duplicate identifier 'x4'. augmentedTypesVar.ts(14,7): error TS2300: Duplicate identifier 'x4'. augmentedTypesVar.ts(16,5): error TS2300: Duplicate identifier 'x4a'. augmentedTypesVar.ts(17,7): error TS2300: Duplicate identifier 'x4a'. -augmentedTypesVar.ts(20,5): error TS2567: Enum declarations can only merge with namespace or other enum declarations. -augmentedTypesVar.ts(21,6): error TS2567: Enum declarations can only merge with namespace or other enum declarations. +augmentedTypesVar.ts(20,5): error TS2567: Enum declarations can only merge with namespace declarations. +augmentedTypesVar.ts(21,6): error TS2567: Enum declarations can only merge with namespace declarations. augmentedTypesVar.ts(27,5): error TS2300: Duplicate identifier 'x6a'. augmentedTypesVar.ts(28,8): error TS2300: Duplicate identifier 'x6a'. augmentedTypesVar.ts(30,5): error TS2300: Duplicate identifier 'x6b'. @@ -50,10 +50,10 @@ augmentedTypesVar.ts(31,8): error TS2300: Duplicate identifier 'x6b'. // var then enum var x5 = 1; ~~ -!!! error TS2567: Enum declarations can only merge with namespace or other enum declarations. +!!! error TS2567: Enum declarations can only merge with namespace declarations. enum x5 { One } // error ~~ -!!! error TS2567: Enum declarations can only merge with namespace or other enum declarations. +!!! error TS2567: Enum declarations can only merge with namespace declarations. // var then module var x6 = 1; diff --git a/tests/baselines/reference/autonumberingInEnums.errors.txt b/tests/baselines/reference/autonumberingInEnums.errors.txt new file mode 100644 index 0000000000000..04d74d2fdd172 --- /dev/null +++ b/tests/baselines/reference/autonumberingInEnums.errors.txt @@ -0,0 +1,16 @@ +autonumberingInEnums.ts(1,6): error TS2567: Enum declarations can only merge with namespace declarations. +autonumberingInEnums.ts(5,6): error TS2567: Enum declarations can only merge with namespace declarations. + + +==== autonumberingInEnums.ts (2 errors) ==== + enum Foo { + ~~~ +!!! error TS2567: Enum declarations can only merge with namespace declarations. + a = 1 + } + + enum Foo { + ~~~ +!!! error TS2567: Enum declarations can only merge with namespace declarations. + b + } \ No newline at end of file diff --git a/tests/baselines/reference/autonumberingInEnums.js b/tests/baselines/reference/autonumberingInEnums.js index 244e77a96a8c9..f969492635995 100644 --- a/tests/baselines/reference/autonumberingInEnums.js +++ b/tests/baselines/reference/autonumberingInEnums.js @@ -6,7 +6,7 @@ enum Foo { } enum Foo { - b // should work fine + b } //// [autonumberingInEnums.js] @@ -15,5 +15,5 @@ var Foo; Foo[Foo["a"] = 1] = "a"; })(Foo || (Foo = {})); (function (Foo) { - Foo[Foo["b"] = 0] = "b"; // should work fine + Foo[Foo["b"] = 0] = "b"; })(Foo || (Foo = {})); diff --git a/tests/baselines/reference/autonumberingInEnums.symbols b/tests/baselines/reference/autonumberingInEnums.symbols index 62bd3c92ca019..a9030368e2790 100644 --- a/tests/baselines/reference/autonumberingInEnums.symbols +++ b/tests/baselines/reference/autonumberingInEnums.symbols @@ -2,15 +2,15 @@ === autonumberingInEnums.ts === enum Foo { ->Foo : Symbol(Foo, Decl(autonumberingInEnums.ts, 0, 0), Decl(autonumberingInEnums.ts, 2, 1)) +>Foo : Symbol(Foo, Decl(autonumberingInEnums.ts, 0, 0)) a = 1 >a : Symbol(Foo.a, Decl(autonumberingInEnums.ts, 0, 10)) } enum Foo { ->Foo : Symbol(Foo, Decl(autonumberingInEnums.ts, 0, 0), Decl(autonumberingInEnums.ts, 2, 1)) +>Foo : Symbol(Foo, Decl(autonumberingInEnums.ts, 2, 1)) - b // should work fine + b >b : Symbol(Foo.b, Decl(autonumberingInEnums.ts, 4, 10)) } diff --git a/tests/baselines/reference/autonumberingInEnums.types b/tests/baselines/reference/autonumberingInEnums.types index a6ed2b020a1ce..90db164e3a0ed 100644 --- a/tests/baselines/reference/autonumberingInEnums.types +++ b/tests/baselines/reference/autonumberingInEnums.types @@ -16,7 +16,7 @@ enum Foo { >Foo : Foo > : ^^^ - b // should work fine + b >b : Foo.b > : ^^^^^ } diff --git a/tests/baselines/reference/constEnumErrors.errors.txt b/tests/baselines/reference/constEnumErrors.errors.txt index 9c5eb5e7fa219..551cad6239875 100644 --- a/tests/baselines/reference/constEnumErrors.errors.txt +++ b/tests/baselines/reference/constEnumErrors.errors.txt @@ -1,5 +1,5 @@ -constEnumErrors.ts(1,12): error TS2567: Enum declarations can only merge with namespace or other enum declarations. -constEnumErrors.ts(5,8): error TS2567: Enum declarations can only merge with namespace or other enum declarations. +constEnumErrors.ts(1,12): error TS2567: Enum declarations can only merge with namespace declarations. +constEnumErrors.ts(5,8): error TS2567: Enum declarations can only merge with namespace declarations. constEnumErrors.ts(12,9): error TS2651: A member initializer in a enum declaration cannot reference members declared after it, including members defined in other enums. constEnumErrors.ts(14,9): error TS2474: const enum member initializers must be constant expressions. constEnumErrors.ts(14,12): error TS2339: Property 'Z' does not exist on type 'typeof E1'. @@ -19,13 +19,13 @@ constEnumErrors.ts(43,9): error TS2478: 'const' enum member initializer was eval ==== constEnumErrors.ts (16 errors) ==== const enum E { ~ -!!! error TS2567: Enum declarations can only merge with namespace or other enum declarations. +!!! error TS2567: Enum declarations can only merge with namespace declarations. A } module E { ~ -!!! error TS2567: Enum declarations can only merge with namespace or other enum declarations. +!!! error TS2567: Enum declarations can only merge with namespace declarations. var x = 1; } diff --git a/tests/baselines/reference/duplicateIdentifierEnum.errors.txt b/tests/baselines/reference/duplicateIdentifierEnum.errors.txt index 6faa8fb65f1db..7b841aee2fa19 100644 --- a/tests/baselines/reference/duplicateIdentifierEnum.errors.txt +++ b/tests/baselines/reference/duplicateIdentifierEnum.errors.txt @@ -1,58 +1,58 @@ -duplicateIdentifierEnum_A.ts(1,6): error TS2567: Enum declarations can only merge with namespace or other enum declarations. -duplicateIdentifierEnum_A.ts(4,7): error TS2567: Enum declarations can only merge with namespace or other enum declarations. -duplicateIdentifierEnum_A.ts(8,11): error TS2567: Enum declarations can only merge with namespace or other enum declarations. -duplicateIdentifierEnum_A.ts(11,12): error TS2567: Enum declarations can only merge with namespace or other enum declarations. -duplicateIdentifierEnum_A.ts(15,12): error TS2567: Enum declarations can only merge with namespace or other enum declarations. -duplicateIdentifierEnum_A.ts(18,10): error TS2567: Enum declarations can only merge with namespace or other enum declarations. -duplicateIdentifierEnum_A.ts(22,6): error TS2567: Enum declarations can only merge with namespace or other enum declarations. -duplicateIdentifierEnum_A.ts(25,7): error TS2567: Enum declarations can only merge with namespace or other enum declarations. -duplicateIdentifierEnum_B.ts(1,10): error TS2567: Enum declarations can only merge with namespace or other enum declarations. -duplicateIdentifierEnum_B.ts(4,6): error TS2567: Enum declarations can only merge with namespace or other enum declarations. +duplicateIdentifierEnum_A.ts(1,6): error TS2567: Enum declarations can only merge with namespace declarations. +duplicateIdentifierEnum_A.ts(4,7): error TS2567: Enum declarations can only merge with namespace declarations. +duplicateIdentifierEnum_A.ts(8,11): error TS2567: Enum declarations can only merge with namespace declarations. +duplicateIdentifierEnum_A.ts(11,12): error TS2567: Enum declarations can only merge with namespace declarations. +duplicateIdentifierEnum_A.ts(15,12): error TS2567: Enum declarations can only merge with namespace declarations. +duplicateIdentifierEnum_A.ts(18,10): error TS2567: Enum declarations can only merge with namespace declarations. +duplicateIdentifierEnum_A.ts(22,6): error TS2567: Enum declarations can only merge with namespace declarations. +duplicateIdentifierEnum_A.ts(25,7): error TS2567: Enum declarations can only merge with namespace declarations. +duplicateIdentifierEnum_B.ts(1,10): error TS2567: Enum declarations can only merge with namespace declarations. +duplicateIdentifierEnum_B.ts(4,6): error TS2567: Enum declarations can only merge with namespace declarations. ==== duplicateIdentifierEnum_A.ts (8 errors) ==== enum A { ~ -!!! error TS2567: Enum declarations can only merge with namespace or other enum declarations. +!!! error TS2567: Enum declarations can only merge with namespace declarations. bar } class A { ~ -!!! error TS2567: Enum declarations can only merge with namespace or other enum declarations. +!!! error TS2567: Enum declarations can only merge with namespace declarations. foo: number; } interface B { ~ -!!! error TS2567: Enum declarations can only merge with namespace or other enum declarations. +!!! error TS2567: Enum declarations can only merge with namespace declarations. foo: number; } const enum B { ~ -!!! error TS2567: Enum declarations can only merge with namespace or other enum declarations. +!!! error TS2567: Enum declarations can only merge with namespace declarations. bar } const enum C { ~ -!!! error TS2567: Enum declarations can only merge with namespace or other enum declarations. +!!! error TS2567: Enum declarations can only merge with namespace declarations. } function C() { ~ -!!! error TS2567: Enum declarations can only merge with namespace or other enum declarations. +!!! error TS2567: Enum declarations can only merge with namespace declarations. return 0; } enum D { ~ -!!! error TS2567: Enum declarations can only merge with namespace or other enum declarations. +!!! error TS2567: Enum declarations can only merge with namespace declarations. !!! related TS6203 duplicateIdentifierEnum_B.ts:1:10: 'D' was also declared here. bar } class E { ~ -!!! error TS2567: Enum declarations can only merge with namespace or other enum declarations. +!!! error TS2567: Enum declarations can only merge with namespace declarations. !!! related TS6203 duplicateIdentifierEnum_B.ts:4:6: 'E' was also declared here. foo: number; } @@ -60,13 +60,13 @@ duplicateIdentifierEnum_B.ts(4,6): error TS2567: Enum declarations can only merg ==== duplicateIdentifierEnum_B.ts (2 errors) ==== function D() { ~ -!!! error TS2567: Enum declarations can only merge with namespace or other enum declarations. +!!! error TS2567: Enum declarations can only merge with namespace declarations. !!! related TS6203 duplicateIdentifierEnum_A.ts:22:6: 'D' was also declared here. return 0; } enum E { ~ -!!! error TS2567: Enum declarations can only merge with namespace or other enum declarations. +!!! error TS2567: Enum declarations can only merge with namespace declarations. !!! related TS6203 duplicateIdentifierEnum_A.ts:25:7: 'E' was also declared here. bar } \ No newline at end of file diff --git a/tests/baselines/reference/enumAssignmentCompat3.errors.txt b/tests/baselines/reference/enumAssignmentCompat3.errors.txt index 9c10fd6b13d95..734adb274f13b 100644 --- a/tests/baselines/reference/enumAssignmentCompat3.errors.txt +++ b/tests/baselines/reference/enumAssignmentCompat3.errors.txt @@ -1,3 +1,5 @@ +enumAssignmentCompat3.ts(40,17): error TS2567: Enum declarations can only merge with namespace declarations. +enumAssignmentCompat3.ts(43,17): error TS2567: Enum declarations can only merge with namespace declarations. enumAssignmentCompat3.ts(68,1): error TS2322: Type 'Abcd.E' is not assignable to type 'First.E'. Property 'd' is missing in type 'First.E'. enumAssignmentCompat3.ts(70,1): error TS2322: Type 'Cd.E' is not assignable to type 'First.E'. @@ -14,13 +16,11 @@ enumAssignmentCompat3.ts(78,1): error TS2322: Type 'First.E' is not assignable t Each declaration of 'E.c' differs in its value, where '3' was expected but '2' was given. enumAssignmentCompat3.ts(82,1): error TS2322: Type 'Const.E' is not assignable to type 'First.E'. enumAssignmentCompat3.ts(83,1): error TS2322: Type 'First.E' is not assignable to type 'Const.E'. -enumAssignmentCompat3.ts(86,1): error TS2322: Type 'Merged.E' is not assignable to type 'First.E'. - Each declaration of 'E.c' differs in its value, where '2' was expected but '3' was given. -enumAssignmentCompat3.ts(87,1): error TS2322: Type 'First.E' is not assignable to type 'Merged.E'. - Each declaration of 'E.c' differs in its value, where '3' was expected but '2' was given. +enumAssignmentCompat3.ts(87,1): error TS2322: Type 'E.a | E.b' is not assignable to type 'E'. + Type 'E.a' is not assignable to type 'E'. -==== enumAssignmentCompat3.ts (12 errors) ==== +==== enumAssignmentCompat3.ts (13 errors) ==== namespace First { export enum E { a, b, c, @@ -61,9 +61,13 @@ enumAssignmentCompat3.ts(87,1): error TS2322: Type 'First.E' is not assignable t } namespace Merged { export enum E { + ~ +!!! error TS2567: Enum declarations can only merge with namespace declarations. a, b, } export enum E { + ~ +!!! error TS2567: Enum declarations can only merge with namespace declarations. c = 3, d, } } @@ -133,12 +137,9 @@ enumAssignmentCompat3.ts(87,1): error TS2322: Type 'First.E' is not assignable t // merged enums compare all their members abc = merged; // missing 'd' - ~~~ -!!! error TS2322: Type 'Merged.E' is not assignable to type 'First.E'. -!!! error TS2322: Each declaration of 'E.c' differs in its value, where '2' was expected but '3' was given. merged = abc; // bad - value of 'c' differs between these enums ~~~~~~ -!!! error TS2322: Type 'First.E' is not assignable to type 'Merged.E'. -!!! error TS2322: Each declaration of 'E.c' differs in its value, where '3' was expected but '2' was given. +!!! error TS2322: Type 'E.a | E.b' is not assignable to type 'E'. +!!! error TS2322: Type 'E.a' is not assignable to type 'E'. abc = merged2; // ok merged2 = abc; // ok \ No newline at end of file diff --git a/tests/baselines/reference/enumAssignmentCompat3.symbols b/tests/baselines/reference/enumAssignmentCompat3.symbols index 00ee430fc60b3..822be6ffced23 100644 --- a/tests/baselines/reference/enumAssignmentCompat3.symbols +++ b/tests/baselines/reference/enumAssignmentCompat3.symbols @@ -96,18 +96,18 @@ namespace Merged { >Merged : Symbol(Merged, Decl(enumAssignmentCompat3.ts, 37, 1)) export enum E { ->E : Symbol(E, Decl(enumAssignmentCompat3.ts, 38, 18), Decl(enumAssignmentCompat3.ts, 41, 5)) +>E : Symbol(E, Decl(enumAssignmentCompat3.ts, 38, 18)) a, b, >a : Symbol(E.a, Decl(enumAssignmentCompat3.ts, 39, 19)) >b : Symbol(E.b, Decl(enumAssignmentCompat3.ts, 40, 10)) } export enum E { ->E : Symbol(E, Decl(enumAssignmentCompat3.ts, 38, 18), Decl(enumAssignmentCompat3.ts, 41, 5)) +>E : Symbol(E, Decl(enumAssignmentCompat3.ts, 41, 5)) c = 3, d, ->c : Symbol(E.c, Decl(enumAssignmentCompat3.ts, 42, 19)) ->d : Symbol(E.d, Decl(enumAssignmentCompat3.ts, 43, 14)) +>c : Symbol(Merged.E.c, Decl(enumAssignmentCompat3.ts, 42, 19)) +>d : Symbol(Merged.E.d, Decl(enumAssignmentCompat3.ts, 43, 14)) } } @@ -173,7 +173,7 @@ var decl: Decl.E; var merged: Merged.E; >merged : Symbol(merged, Decl(enumAssignmentCompat3.ts, 64, 3)) >Merged : Symbol(Merged, Decl(enumAssignmentCompat3.ts, 37, 1)) ->E : Symbol(Merged.E, Decl(enumAssignmentCompat3.ts, 38, 18), Decl(enumAssignmentCompat3.ts, 41, 5)) +>E : Symbol(Merged.E, Decl(enumAssignmentCompat3.ts, 38, 18)) var merged2: Merged2.E; >merged2 : Symbol(merged2, Decl(enumAssignmentCompat3.ts, 65, 3)) diff --git a/tests/baselines/reference/enumAssignmentCompat3.types b/tests/baselines/reference/enumAssignmentCompat3.types index 2415b1f676907..8b3ed7e0ce5d4 100644 --- a/tests/baselines/reference/enumAssignmentCompat3.types +++ b/tests/baselines/reference/enumAssignmentCompat3.types @@ -144,16 +144,16 @@ namespace Merged { > : ^^^ } export enum E { ->E : E -> : ^ +>E : Merged.E +> : ^^^^^^^^ c = 3, d, ->c : E.c -> : ^^^ +>c : Merged.E.c +> : ^^^^^^^^^^ >3 : 3 > : ^ ->d : E.d -> : ^^^ +>d : Merged.E.d +> : ^^^^^^^^^^ } } @@ -376,12 +376,12 @@ abc = merged; // missing 'd' > : ^^^^^^^^ merged = abc; // bad - value of 'c' differs between these enums ->merged = abc : First.E -> : ^^^^^^^ +>merged = abc : First.E.a | First.E.b +> : ^^^^^^^^^^^^^^^^^^^^^ >merged : Merged.E > : ^^^^^^^^ ->abc : First.E -> : ^^^^^^^ +>abc : First.E.a | First.E.b +> : ^^^^^^^^^^^^^^^^^^^^^ abc = merged2; // ok >abc = merged2 : Merged2.E diff --git a/tests/baselines/reference/enumBasics1.errors.txt b/tests/baselines/reference/enumBasics1.errors.txt index 9e8458afe07e3..b71e15e77f69e 100644 --- a/tests/baselines/reference/enumBasics1.errors.txt +++ b/tests/baselines/reference/enumBasics1.errors.txt @@ -1,8 +1,9 @@ enumBasics1.ts(26,5): error TS2339: Property 'A' does not exist on type 'E.A'. -enumBasics1.ts(35,2): error TS2432: In an enum with multiple declarations, only one declaration can omit an initializer for its first enum element. +enumBasics1.ts(29,6): error TS2567: Enum declarations can only merge with namespace declarations. +enumBasics1.ts(34,6): error TS2567: Enum declarations can only merge with namespace declarations. -==== enumBasics1.ts (2 errors) ==== +==== enumBasics1.ts (3 errors) ==== enum E { A = 1, B, @@ -34,13 +35,15 @@ enumBasics1.ts(35,2): error TS2432: In an enum with multiple declarations, only enum E2 { + ~~ +!!! error TS2567: Enum declarations can only merge with namespace declarations. A, B, } enum E2 { // should error for continued autonumbering + ~~ +!!! error TS2567: Enum declarations can only merge with namespace declarations. C, - ~ -!!! error TS2432: In an enum with multiple declarations, only one declaration can omit an initializer for its first enum element. D, } \ No newline at end of file diff --git a/tests/baselines/reference/enumBasics1.symbols b/tests/baselines/reference/enumBasics1.symbols index 8dc1af393ad24..20f206571be9b 100644 --- a/tests/baselines/reference/enumBasics1.symbols +++ b/tests/baselines/reference/enumBasics1.symbols @@ -40,7 +40,7 @@ E.A.A; // should error enum E2 { ->E2 : Symbol(E2, Decl(enumBasics1.ts, 25, 6), Decl(enumBasics1.ts, 31, 1)) +>E2 : Symbol(E2, Decl(enumBasics1.ts, 25, 6)) A, >A : Symbol(E2.A, Decl(enumBasics1.ts, 28, 9)) @@ -50,7 +50,7 @@ enum E2 { } enum E2 { // should error for continued autonumbering ->E2 : Symbol(E2, Decl(enumBasics1.ts, 25, 6), Decl(enumBasics1.ts, 31, 1)) +>E2 : Symbol(E2, Decl(enumBasics1.ts, 31, 1)) C, >C : Symbol(E2.C, Decl(enumBasics1.ts, 33, 9)) diff --git a/tests/baselines/reference/enumBasics1.types b/tests/baselines/reference/enumBasics1.types index 36545a4b7ab99..cb29da0583f6d 100644 --- a/tests/baselines/reference/enumBasics1.types +++ b/tests/baselines/reference/enumBasics1.types @@ -70,10 +70,10 @@ enum E2 { // should error for continued autonumbering > : ^^ C, ->C : E2.A +>C : E2.C > : ^^^^ D, ->D : E2.B +>D : E2.D > : ^^^^ } diff --git a/tests/baselines/reference/enumExportMergingES6.errors.txt b/tests/baselines/reference/enumExportMergingES6.errors.txt new file mode 100644 index 0000000000000..d3c872ffbfac5 --- /dev/null +++ b/tests/baselines/reference/enumExportMergingES6.errors.txt @@ -0,0 +1,28 @@ +enumExportMergingES6.ts(1,13): error TS2567: Enum declarations can only merge with namespace declarations. +enumExportMergingES6.ts(4,13): error TS2567: Enum declarations can only merge with namespace declarations. +enumExportMergingES6.ts(7,13): error TS2567: Enum declarations can only merge with namespace declarations. +enumExportMergingES6.ts(8,11): error TS2304: Cannot find name 'Cat'. +enumExportMergingES6.ts(8,17): error TS2304: Cannot find name 'Dog'. + + +==== enumExportMergingES6.ts (5 errors) ==== + export enum Animals { + ~~~~~~~ +!!! error TS2567: Enum declarations can only merge with namespace declarations. + Cat = 1 + } + export enum Animals { + ~~~~~~~ +!!! error TS2567: Enum declarations can only merge with namespace declarations. + Dog = 2 + } + export enum Animals { + ~~~~~~~ +!!! error TS2567: Enum declarations can only merge with namespace declarations. + CatDog = Cat | Dog + ~~~ +!!! error TS2304: Cannot find name 'Cat'. + ~~~ +!!! error TS2304: Cannot find name 'Dog'. + } + \ No newline at end of file diff --git a/tests/baselines/reference/enumExportMergingES6.js b/tests/baselines/reference/enumExportMergingES6.js index 5da0278e573e5..f8ac99c794ea3 100644 --- a/tests/baselines/reference/enumExportMergingES6.js +++ b/tests/baselines/reference/enumExportMergingES6.js @@ -21,5 +21,5 @@ export var Animals; Animals[Animals["Dog"] = 2] = "Dog"; })(Animals || (Animals = {})); (function (Animals) { - Animals[Animals["CatDog"] = 3] = "CatDog"; + Animals[Animals["CatDog"] = Cat | Dog] = "CatDog"; })(Animals || (Animals = {})); diff --git a/tests/baselines/reference/enumExportMergingES6.symbols b/tests/baselines/reference/enumExportMergingES6.symbols index 40c9720a3b1eb..808b1ff3b96d7 100644 --- a/tests/baselines/reference/enumExportMergingES6.symbols +++ b/tests/baselines/reference/enumExportMergingES6.symbols @@ -2,23 +2,21 @@ === enumExportMergingES6.ts === export enum Animals { ->Animals : Symbol(Animals, Decl(enumExportMergingES6.ts, 0, 0), Decl(enumExportMergingES6.ts, 2, 1), Decl(enumExportMergingES6.ts, 5, 1)) +>Animals : Symbol(Animals, Decl(enumExportMergingES6.ts, 0, 0)) Cat = 1 >Cat : Symbol(Animals.Cat, Decl(enumExportMergingES6.ts, 0, 21)) } export enum Animals { ->Animals : Symbol(Animals, Decl(enumExportMergingES6.ts, 0, 0), Decl(enumExportMergingES6.ts, 2, 1), Decl(enumExportMergingES6.ts, 5, 1)) +>Animals : Symbol(Animals, Decl(enumExportMergingES6.ts, 2, 1)) Dog = 2 >Dog : Symbol(Animals.Dog, Decl(enumExportMergingES6.ts, 3, 21)) } export enum Animals { ->Animals : Symbol(Animals, Decl(enumExportMergingES6.ts, 0, 0), Decl(enumExportMergingES6.ts, 2, 1), Decl(enumExportMergingES6.ts, 5, 1)) +>Animals : Symbol(Animals, Decl(enumExportMergingES6.ts, 5, 1)) CatDog = Cat | Dog >CatDog : Symbol(Animals.CatDog, Decl(enumExportMergingES6.ts, 6, 21)) ->Cat : Symbol(Animals.Cat, Decl(enumExportMergingES6.ts, 0, 21)) ->Dog : Symbol(Animals.Dog, Decl(enumExportMergingES6.ts, 3, 21)) } diff --git a/tests/baselines/reference/enumExportMergingES6.types b/tests/baselines/reference/enumExportMergingES6.types index a198eae58696d..6e692692b7164 100644 --- a/tests/baselines/reference/enumExportMergingES6.types +++ b/tests/baselines/reference/enumExportMergingES6.types @@ -12,27 +12,27 @@ export enum Animals { > : ^ } export enum Animals { ->Animals : Animals -> : ^^^^^^^ +>Animals : import("enumExportMergingES6").Animals +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Dog = 2 ->Dog : Animals.Dog -> : ^^^^^^^^^^^ +>Dog : import("enumExportMergingES6").Animals.Dog +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ >2 : 2 > : ^ } export enum Animals { ->Animals : Animals -> : ^^^^^^^ +>Animals : import("enumExportMergingES6").Animals +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ CatDog = Cat | Dog ->CatDog : Animals.CatDog -> : ^^^^^^^^^^^^^^ +>CatDog : import("enumExportMergingES6").Animals.CatDog +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ >Cat | Dog : number > : ^^^^^^ ->Cat : Animals.Cat -> : ^^^^^^^^^^^ ->Dog : Animals.Dog -> : ^^^^^^^^^^^ +>Cat : any +> : ^^^ +>Dog : any +> : ^^^ } diff --git a/tests/baselines/reference/enumGenericTypeClash.errors.txt b/tests/baselines/reference/enumGenericTypeClash.errors.txt index 3a47cb0fa8001..30b3afb1ab68f 100644 --- a/tests/baselines/reference/enumGenericTypeClash.errors.txt +++ b/tests/baselines/reference/enumGenericTypeClash.errors.txt @@ -1,12 +1,12 @@ -enumGenericTypeClash.ts(1,7): error TS2567: Enum declarations can only merge with namespace or other enum declarations. -enumGenericTypeClash.ts(2,6): error TS2567: Enum declarations can only merge with namespace or other enum declarations. +enumGenericTypeClash.ts(1,7): error TS2567: Enum declarations can only merge with namespace declarations. +enumGenericTypeClash.ts(2,6): error TS2567: Enum declarations can only merge with namespace declarations. ==== enumGenericTypeClash.ts (2 errors) ==== class X { } ~ -!!! error TS2567: Enum declarations can only merge with namespace or other enum declarations. +!!! error TS2567: Enum declarations can only merge with namespace declarations. enum X { MyVal } ~ -!!! error TS2567: Enum declarations can only merge with namespace or other enum declarations. +!!! error TS2567: Enum declarations can only merge with namespace declarations. \ No newline at end of file diff --git a/tests/baselines/reference/enumMerging.errors.txt b/tests/baselines/reference/enumMerging.errors.txt new file mode 100644 index 0000000000000..6b4cb368656e5 --- /dev/null +++ b/tests/baselines/reference/enumMerging.errors.txt @@ -0,0 +1,120 @@ +enumMerging.ts(4,10): error TS2567: Enum declarations can only merge with namespace declarations. +enumMerging.ts(8,10): error TS2567: Enum declarations can only merge with namespace declarations. +enumMerging.ts(12,17): error TS2567: Enum declarations can only merge with namespace declarations. +enumMerging.ts(16,17): error TS2567: Enum declarations can only merge with namespace declarations. +enumMerging.ts(20,22): error TS2339: Property 'A' does not exist on type 'typeof EConst1'. +enumMerging.ts(20,33): error TS2339: Property 'B' does not exist on type 'typeof EConst1'. +enumMerging.ts(20,44): error TS2339: Property 'C' does not exist on type 'typeof EConst1'. +enumMerging.ts(25,17): error TS2567: Enum declarations can only merge with namespace declarations. +enumMerging.ts(29,17): error TS2567: Enum declarations can only merge with namespace declarations. +enumMerging.ts(33,21): error TS2339: Property 'A' does not exist on type 'typeof EComp2'. +enumMerging.ts(33,31): error TS2339: Property 'B' does not exist on type 'typeof EComp2'. +enumMerging.ts(33,41): error TS2339: Property 'C' does not exist on type 'typeof EComp2'. +enumMerging.ts(38,10): error TS2567: Enum declarations can only merge with namespace declarations. +enumMerging.ts(43,10): error TS2567: Enum declarations can only merge with namespace declarations. +enumMerging.ts(57,17): error TS2567: Enum declarations can only merge with namespace declarations. +enumMerging.ts(61,21): error TS2567: Enum declarations can only merge with namespace declarations. +enumMerging.ts(63,21): error TS2339: Property 'Yellow' does not exist on type 'typeof Color'. + + +==== enumMerging.ts (17 errors) ==== + // Enum with only constant members across 2 declarations with the same root module + // Enum with initializer in all declarations with constant members with the same root module + module M1 { + enum EImpl1 { + ~~~~~~ +!!! error TS2567: Enum declarations can only merge with namespace declarations. + A, B, C + } + + enum EImpl1 { + ~~~~~~ +!!! error TS2567: Enum declarations can only merge with namespace declarations. + D = 1, E, F + } + + export enum EConst1 { + ~~~~~~~ +!!! error TS2567: Enum declarations can only merge with namespace declarations. + A = 3, B = 2, C = 1 + } + + export enum EConst1 { + ~~~~~~~ +!!! error TS2567: Enum declarations can only merge with namespace declarations. + D = 7, E = 9, F = 8 + } + + var x = [EConst1.A, EConst1.B, EConst1.C, EConst1.D, EConst1.E, EConst1.F]; + ~ +!!! error TS2339: Property 'A' does not exist on type 'typeof EConst1'. + ~ +!!! error TS2339: Property 'B' does not exist on type 'typeof EConst1'. + ~ +!!! error TS2339: Property 'C' does not exist on type 'typeof EConst1'. + } + + // Enum with only computed members across 2 declarations with the same root module + module M2 { + export enum EComp2 { + ~~~~~~ +!!! error TS2567: Enum declarations can only merge with namespace declarations. + A = 'foo'.length, B = 'foo'.length, C = 'foo'.length + } + + export enum EComp2 { + ~~~~~~ +!!! error TS2567: Enum declarations can only merge with namespace declarations. + D = 'foo'.length, E = 'foo'.length, F = 'foo'.length + } + + var x = [EComp2.A, EComp2.B, EComp2.C, EComp2.D, EComp2.E, EComp2.F]; + ~ +!!! error TS2339: Property 'A' does not exist on type 'typeof EComp2'. + ~ +!!! error TS2339: Property 'B' does not exist on type 'typeof EComp2'. + ~ +!!! error TS2339: Property 'C' does not exist on type 'typeof EComp2'. + } + + // Enum with initializer in only one of two declarations with constant members with the same root module + module M3 { + enum EInit { + ~~~~~ +!!! error TS2567: Enum declarations can only merge with namespace declarations. + A, + B + } + + enum EInit { + ~~~~~ +!!! error TS2567: Enum declarations can only merge with namespace declarations. + C = 1, D, E + } + } + + // Enums with same name but different root module + module M4 { + export enum Color { Red, Green, Blue } + } + module M5 { + export enum Color { Red, Green, Blue } + } + + module M6.A { + export enum Color { Red, Green, Blue } + ~~~~~ +!!! error TS2567: Enum declarations can only merge with namespace declarations. + } + module M6 { + export module A { + export enum Color { Yellow = 1 } + ~~~~~ +!!! error TS2567: Enum declarations can only merge with namespace declarations. + } + var t = A.Color.Yellow; + ~~~~~~ +!!! error TS2339: Property 'Yellow' does not exist on type 'typeof Color'. + t = A.Color.Red; + } + \ No newline at end of file diff --git a/tests/baselines/reference/enumMerging.symbols b/tests/baselines/reference/enumMerging.symbols index d74457db3eb16..66965a7aa4e81 100644 --- a/tests/baselines/reference/enumMerging.symbols +++ b/tests/baselines/reference/enumMerging.symbols @@ -7,7 +7,7 @@ module M1 { >M1 : Symbol(M1, Decl(enumMerging.ts, 0, 0)) enum EImpl1 { ->EImpl1 : Symbol(EImpl1, Decl(enumMerging.ts, 2, 11), Decl(enumMerging.ts, 5, 5)) +>EImpl1 : Symbol(EImpl1, Decl(enumMerging.ts, 2, 11)) A, B, C >A : Symbol(EImpl1.A, Decl(enumMerging.ts, 3, 17)) @@ -16,7 +16,7 @@ module M1 { } enum EImpl1 { ->EImpl1 : Symbol(EImpl1, Decl(enumMerging.ts, 2, 11), Decl(enumMerging.ts, 5, 5)) +>EImpl1 : Symbol(EImpl1, Decl(enumMerging.ts, 5, 5)) D = 1, E, F >D : Symbol(EImpl1.D, Decl(enumMerging.ts, 7, 17)) @@ -25,7 +25,7 @@ module M1 { } export enum EConst1 { ->EConst1 : Symbol(EConst1, Decl(enumMerging.ts, 9, 5), Decl(enumMerging.ts, 13, 5)) +>EConst1 : Symbol(EConst1, Decl(enumMerging.ts, 9, 5)) A = 3, B = 2, C = 1 >A : Symbol(EConst1.A, Decl(enumMerging.ts, 11, 25)) @@ -34,34 +34,28 @@ module M1 { } export enum EConst1 { ->EConst1 : Symbol(EConst1, Decl(enumMerging.ts, 9, 5), Decl(enumMerging.ts, 13, 5)) +>EConst1 : Symbol(EConst1, Decl(enumMerging.ts, 13, 5)) D = 7, E = 9, F = 8 ->D : Symbol(EConst1.D, Decl(enumMerging.ts, 15, 25)) ->E : Symbol(EConst1.E, Decl(enumMerging.ts, 16, 14)) ->F : Symbol(EConst1.F, Decl(enumMerging.ts, 16, 21)) +>D : Symbol(M1.EConst1.D, Decl(enumMerging.ts, 15, 25)) +>E : Symbol(M1.EConst1.E, Decl(enumMerging.ts, 16, 14)) +>F : Symbol(M1.EConst1.F, Decl(enumMerging.ts, 16, 21)) } var x = [EConst1.A, EConst1.B, EConst1.C, EConst1.D, EConst1.E, EConst1.F]; >x : Symbol(x, Decl(enumMerging.ts, 19, 7)) ->EConst1.A : Symbol(EConst1.A, Decl(enumMerging.ts, 11, 25)) ->EConst1 : Symbol(EConst1, Decl(enumMerging.ts, 9, 5), Decl(enumMerging.ts, 13, 5)) ->A : Symbol(EConst1.A, Decl(enumMerging.ts, 11, 25)) ->EConst1.B : Symbol(EConst1.B, Decl(enumMerging.ts, 12, 14)) ->EConst1 : Symbol(EConst1, Decl(enumMerging.ts, 9, 5), Decl(enumMerging.ts, 13, 5)) ->B : Symbol(EConst1.B, Decl(enumMerging.ts, 12, 14)) ->EConst1.C : Symbol(EConst1.C, Decl(enumMerging.ts, 12, 21)) ->EConst1 : Symbol(EConst1, Decl(enumMerging.ts, 9, 5), Decl(enumMerging.ts, 13, 5)) ->C : Symbol(EConst1.C, Decl(enumMerging.ts, 12, 21)) ->EConst1.D : Symbol(EConst1.D, Decl(enumMerging.ts, 15, 25)) ->EConst1 : Symbol(EConst1, Decl(enumMerging.ts, 9, 5), Decl(enumMerging.ts, 13, 5)) ->D : Symbol(EConst1.D, Decl(enumMerging.ts, 15, 25)) ->EConst1.E : Symbol(EConst1.E, Decl(enumMerging.ts, 16, 14)) ->EConst1 : Symbol(EConst1, Decl(enumMerging.ts, 9, 5), Decl(enumMerging.ts, 13, 5)) ->E : Symbol(EConst1.E, Decl(enumMerging.ts, 16, 14)) ->EConst1.F : Symbol(EConst1.F, Decl(enumMerging.ts, 16, 21)) ->EConst1 : Symbol(EConst1, Decl(enumMerging.ts, 9, 5), Decl(enumMerging.ts, 13, 5)) ->F : Symbol(EConst1.F, Decl(enumMerging.ts, 16, 21)) +>EConst1 : Symbol(EConst1, Decl(enumMerging.ts, 9, 5)) +>EConst1 : Symbol(EConst1, Decl(enumMerging.ts, 9, 5)) +>EConst1 : Symbol(EConst1, Decl(enumMerging.ts, 9, 5)) +>EConst1.D : Symbol(M1.EConst1.D, Decl(enumMerging.ts, 15, 25)) +>EConst1 : Symbol(EConst1, Decl(enumMerging.ts, 9, 5)) +>D : Symbol(M1.EConst1.D, Decl(enumMerging.ts, 15, 25)) +>EConst1.E : Symbol(M1.EConst1.E, Decl(enumMerging.ts, 16, 14)) +>EConst1 : Symbol(EConst1, Decl(enumMerging.ts, 9, 5)) +>E : Symbol(M1.EConst1.E, Decl(enumMerging.ts, 16, 14)) +>EConst1.F : Symbol(M1.EConst1.F, Decl(enumMerging.ts, 16, 21)) +>EConst1 : Symbol(EConst1, Decl(enumMerging.ts, 9, 5)) +>F : Symbol(M1.EConst1.F, Decl(enumMerging.ts, 16, 21)) } // Enum with only computed members across 2 declarations with the same root module @@ -69,7 +63,7 @@ module M2 { >M2 : Symbol(M2, Decl(enumMerging.ts, 20, 1)) export enum EComp2 { ->EComp2 : Symbol(EComp2, Decl(enumMerging.ts, 23, 11), Decl(enumMerging.ts, 26, 5)) +>EComp2 : Symbol(EComp2, Decl(enumMerging.ts, 23, 11)) A = 'foo'.length, B = 'foo'.length, C = 'foo'.length >A : Symbol(EComp2.A, Decl(enumMerging.ts, 24, 24)) @@ -84,40 +78,34 @@ module M2 { } export enum EComp2 { ->EComp2 : Symbol(EComp2, Decl(enumMerging.ts, 23, 11), Decl(enumMerging.ts, 26, 5)) +>EComp2 : Symbol(EComp2, Decl(enumMerging.ts, 26, 5)) D = 'foo'.length, E = 'foo'.length, F = 'foo'.length ->D : Symbol(EComp2.D, Decl(enumMerging.ts, 28, 24)) +>D : Symbol(M2.EComp2.D, Decl(enumMerging.ts, 28, 24)) >'foo'.length : Symbol(String.length, Decl(lib.es5.d.ts, --, --)) >length : Symbol(String.length, Decl(lib.es5.d.ts, --, --)) ->E : Symbol(EComp2.E, Decl(enumMerging.ts, 29, 25)) +>E : Symbol(M2.EComp2.E, Decl(enumMerging.ts, 29, 25)) >'foo'.length : Symbol(String.length, Decl(lib.es5.d.ts, --, --)) >length : Symbol(String.length, Decl(lib.es5.d.ts, --, --)) ->F : Symbol(EComp2.F, Decl(enumMerging.ts, 29, 43)) +>F : Symbol(M2.EComp2.F, Decl(enumMerging.ts, 29, 43)) >'foo'.length : Symbol(String.length, Decl(lib.es5.d.ts, --, --)) >length : Symbol(String.length, Decl(lib.es5.d.ts, --, --)) } var x = [EComp2.A, EComp2.B, EComp2.C, EComp2.D, EComp2.E, EComp2.F]; >x : Symbol(x, Decl(enumMerging.ts, 32, 7)) ->EComp2.A : Symbol(EComp2.A, Decl(enumMerging.ts, 24, 24)) ->EComp2 : Symbol(EComp2, Decl(enumMerging.ts, 23, 11), Decl(enumMerging.ts, 26, 5)) ->A : Symbol(EComp2.A, Decl(enumMerging.ts, 24, 24)) ->EComp2.B : Symbol(EComp2.B, Decl(enumMerging.ts, 25, 25)) ->EComp2 : Symbol(EComp2, Decl(enumMerging.ts, 23, 11), Decl(enumMerging.ts, 26, 5)) ->B : Symbol(EComp2.B, Decl(enumMerging.ts, 25, 25)) ->EComp2.C : Symbol(EComp2.C, Decl(enumMerging.ts, 25, 43)) ->EComp2 : Symbol(EComp2, Decl(enumMerging.ts, 23, 11), Decl(enumMerging.ts, 26, 5)) ->C : Symbol(EComp2.C, Decl(enumMerging.ts, 25, 43)) ->EComp2.D : Symbol(EComp2.D, Decl(enumMerging.ts, 28, 24)) ->EComp2 : Symbol(EComp2, Decl(enumMerging.ts, 23, 11), Decl(enumMerging.ts, 26, 5)) ->D : Symbol(EComp2.D, Decl(enumMerging.ts, 28, 24)) ->EComp2.E : Symbol(EComp2.E, Decl(enumMerging.ts, 29, 25)) ->EComp2 : Symbol(EComp2, Decl(enumMerging.ts, 23, 11), Decl(enumMerging.ts, 26, 5)) ->E : Symbol(EComp2.E, Decl(enumMerging.ts, 29, 25)) ->EComp2.F : Symbol(EComp2.F, Decl(enumMerging.ts, 29, 43)) ->EComp2 : Symbol(EComp2, Decl(enumMerging.ts, 23, 11), Decl(enumMerging.ts, 26, 5)) ->F : Symbol(EComp2.F, Decl(enumMerging.ts, 29, 43)) +>EComp2 : Symbol(EComp2, Decl(enumMerging.ts, 23, 11)) +>EComp2 : Symbol(EComp2, Decl(enumMerging.ts, 23, 11)) +>EComp2 : Symbol(EComp2, Decl(enumMerging.ts, 23, 11)) +>EComp2.D : Symbol(M2.EComp2.D, Decl(enumMerging.ts, 28, 24)) +>EComp2 : Symbol(EComp2, Decl(enumMerging.ts, 23, 11)) +>D : Symbol(M2.EComp2.D, Decl(enumMerging.ts, 28, 24)) +>EComp2.E : Symbol(M2.EComp2.E, Decl(enumMerging.ts, 29, 25)) +>EComp2 : Symbol(EComp2, Decl(enumMerging.ts, 23, 11)) +>E : Symbol(M2.EComp2.E, Decl(enumMerging.ts, 29, 25)) +>EComp2.F : Symbol(M2.EComp2.F, Decl(enumMerging.ts, 29, 43)) +>EComp2 : Symbol(EComp2, Decl(enumMerging.ts, 23, 11)) +>F : Symbol(M2.EComp2.F, Decl(enumMerging.ts, 29, 43)) } // Enum with initializer in only one of two declarations with constant members with the same root module @@ -125,7 +113,7 @@ module M3 { >M3 : Symbol(M3, Decl(enumMerging.ts, 33, 1)) enum EInit { ->EInit : Symbol(EInit, Decl(enumMerging.ts, 36, 11), Decl(enumMerging.ts, 40, 5)) +>EInit : Symbol(EInit, Decl(enumMerging.ts, 36, 11)) A, >A : Symbol(EInit.A, Decl(enumMerging.ts, 37, 16)) @@ -135,7 +123,7 @@ module M3 { } enum EInit { ->EInit : Symbol(EInit, Decl(enumMerging.ts, 36, 11), Decl(enumMerging.ts, 40, 5)) +>EInit : Symbol(EInit, Decl(enumMerging.ts, 40, 5)) C = 1, D, E >C : Symbol(EInit.C, Decl(enumMerging.ts, 42, 16)) @@ -169,7 +157,7 @@ module M6.A { >A : Symbol(A, Decl(enumMerging.ts, 55, 10), Decl(enumMerging.ts, 58, 11)) export enum Color { Red, Green, Blue } ->Color : Symbol(Color, Decl(enumMerging.ts, 55, 13), Decl(enumMerging.ts, 59, 21)) +>Color : Symbol(Color, Decl(enumMerging.ts, 55, 13)) >Red : Symbol(Color.Red, Decl(enumMerging.ts, 56, 23)) >Green : Symbol(Color.Green, Decl(enumMerging.ts, 56, 28)) >Blue : Symbol(Color.Blue, Decl(enumMerging.ts, 56, 35)) @@ -181,23 +169,21 @@ module M6 { >A : Symbol(A, Decl(enumMerging.ts, 55, 10), Decl(enumMerging.ts, 58, 11)) export enum Color { Yellow = 1 } ->Color : Symbol(Color, Decl(enumMerging.ts, 55, 13), Decl(enumMerging.ts, 59, 21)) ->Yellow : Symbol(Color.Yellow, Decl(enumMerging.ts, 60, 27)) +>Color : Symbol(Color, Decl(enumMerging.ts, 59, 21)) +>Yellow : Symbol(A.Color.Yellow, Decl(enumMerging.ts, 60, 27)) } var t = A.Color.Yellow; >t : Symbol(t, Decl(enumMerging.ts, 62, 7)) ->A.Color.Yellow : Symbol(A.Color.Yellow, Decl(enumMerging.ts, 60, 27)) ->A.Color : Symbol(A.Color, Decl(enumMerging.ts, 55, 13), Decl(enumMerging.ts, 59, 21)) +>A.Color : Symbol(A.Color, Decl(enumMerging.ts, 55, 13)) >A : Symbol(A, Decl(enumMerging.ts, 55, 10), Decl(enumMerging.ts, 58, 11)) ->Color : Symbol(A.Color, Decl(enumMerging.ts, 55, 13), Decl(enumMerging.ts, 59, 21)) ->Yellow : Symbol(A.Color.Yellow, Decl(enumMerging.ts, 60, 27)) +>Color : Symbol(A.Color, Decl(enumMerging.ts, 55, 13)) t = A.Color.Red; >t : Symbol(t, Decl(enumMerging.ts, 62, 7)) >A.Color.Red : Symbol(A.Color.Red, Decl(enumMerging.ts, 56, 23)) ->A.Color : Symbol(A.Color, Decl(enumMerging.ts, 55, 13), Decl(enumMerging.ts, 59, 21)) +>A.Color : Symbol(A.Color, Decl(enumMerging.ts, 55, 13)) >A : Symbol(A, Decl(enumMerging.ts, 55, 10), Decl(enumMerging.ts, 58, 11)) ->Color : Symbol(A.Color, Decl(enumMerging.ts, 55, 13), Decl(enumMerging.ts, 59, 21)) +>Color : Symbol(A.Color, Decl(enumMerging.ts, 55, 13)) >Red : Symbol(A.Color.Red, Decl(enumMerging.ts, 56, 23)) } diff --git a/tests/baselines/reference/enumMerging.types b/tests/baselines/reference/enumMerging.types index 5586a56222de3..581fc124290c6 100644 --- a/tests/baselines/reference/enumMerging.types +++ b/tests/baselines/reference/enumMerging.types @@ -25,11 +25,11 @@ module M1 { > : ^^^^^^ D = 1, E, F ->D : EImpl1.B +>D : EImpl1.D > : ^^^^^^^^ >1 : 1 > : ^ ->E : EImpl1.C +>E : EImpl1.E > : ^^^^^^^^ >F : EImpl1.F > : ^^^^^^^^ @@ -55,65 +55,65 @@ module M1 { } export enum EConst1 { ->EConst1 : EConst1 -> : ^^^^^^^ +>EConst1 : M1.EConst1 +> : ^^^^^^^^^^ D = 7, E = 9, F = 8 ->D : EConst1.D -> : ^^^^^^^^^ +>D : M1.EConst1.D +> : ^^^^^^^^^^^^ >7 : 7 > : ^ ->E : EConst1.E -> : ^^^^^^^^^ +>E : M1.EConst1.E +> : ^^^^^^^^^^^^ >9 : 9 > : ^ ->F : EConst1.F -> : ^^^^^^^^^ +>F : M1.EConst1.F +> : ^^^^^^^^^^^^ >8 : 8 > : ^ } var x = [EConst1.A, EConst1.B, EConst1.C, EConst1.D, EConst1.E, EConst1.F]; ->x : EConst1[] -> : ^^^^^^^^^ ->[EConst1.A, EConst1.B, EConst1.C, EConst1.D, EConst1.E, EConst1.F] : EConst1[] -> : ^^^^^^^^^ ->EConst1.A : EConst1.A -> : ^^^^^^^^^ ->EConst1 : typeof EConst1 -> : ^^^^^^^^^^^^^^ ->A : EConst1.A -> : ^^^^^^^^^ ->EConst1.B : EConst1.B -> : ^^^^^^^^^ ->EConst1 : typeof EConst1 -> : ^^^^^^^^^^^^^^ ->B : EConst1.B -> : ^^^^^^^^^ ->EConst1.C : EConst1.C -> : ^^^^^^^^^ ->EConst1 : typeof EConst1 -> : ^^^^^^^^^^^^^^ ->C : EConst1.C -> : ^^^^^^^^^ ->EConst1.D : EConst1.D -> : ^^^^^^^^^ ->EConst1 : typeof EConst1 -> : ^^^^^^^^^^^^^^ ->D : EConst1.D -> : ^^^^^^^^^ ->EConst1.E : EConst1.E -> : ^^^^^^^^^ ->EConst1 : typeof EConst1 -> : ^^^^^^^^^^^^^^ ->E : EConst1.E -> : ^^^^^^^^^ ->EConst1.F : EConst1.F -> : ^^^^^^^^^ ->EConst1 : typeof EConst1 -> : ^^^^^^^^^^^^^^ ->F : EConst1.F -> : ^^^^^^^^^ +>x : any[] +> : ^^^^^ +>[EConst1.A, EConst1.B, EConst1.C, EConst1.D, EConst1.E, EConst1.F] : any[] +> : ^^^^^ +>EConst1.A : any +> : ^^^ +>EConst1 : typeof M1.EConst1 +> : ^^^^^^^^^^^^^^^^^ +>A : any +> : ^^^ +>EConst1.B : any +> : ^^^ +>EConst1 : typeof M1.EConst1 +> : ^^^^^^^^^^^^^^^^^ +>B : any +> : ^^^ +>EConst1.C : any +> : ^^^ +>EConst1 : typeof M1.EConst1 +> : ^^^^^^^^^^^^^^^^^ +>C : any +> : ^^^ +>EConst1.D : M1.EConst1.D +> : ^^^^^^^^^^^^ +>EConst1 : typeof M1.EConst1 +> : ^^^^^^^^^^^^^^^^^ +>D : M1.EConst1.D +> : ^^^^^^^^^^^^ +>EConst1.E : M1.EConst1.E +> : ^^^^^^^^^^^^ +>EConst1 : typeof M1.EConst1 +> : ^^^^^^^^^^^^^^^^^ +>E : M1.EConst1.E +> : ^^^^^^^^^^^^ +>EConst1.F : M1.EConst1.F +> : ^^^^^^^^^^^^ +>EConst1 : typeof M1.EConst1 +> : ^^^^^^^^^^^^^^^^^ +>F : M1.EConst1.F +> : ^^^^^^^^^^^^ } // Enum with only computed members across 2 declarations with the same root module @@ -153,28 +153,28 @@ module M2 { } export enum EComp2 { ->EComp2 : EComp2 -> : ^^^^^^ +>EComp2 : M2.EComp2 +> : ^^^^^^^^^ D = 'foo'.length, E = 'foo'.length, F = 'foo'.length ->D : EComp2.D -> : ^^^^^^^^ +>D : M2.EComp2.D +> : ^^^^^^^^^^^ >'foo'.length : number > : ^^^^^^ >'foo' : "foo" > : ^^^^^ >length : number > : ^^^^^^ ->E : EComp2.E -> : ^^^^^^^^ +>E : M2.EComp2.E +> : ^^^^^^^^^^^ >'foo'.length : number > : ^^^^^^ >'foo' : "foo" > : ^^^^^ >length : number > : ^^^^^^ ->F : EComp2.F -> : ^^^^^^^^ +>F : M2.EComp2.F +> : ^^^^^^^^^^^ >'foo'.length : number > : ^^^^^^ >'foo' : "foo" @@ -184,46 +184,46 @@ module M2 { } var x = [EComp2.A, EComp2.B, EComp2.C, EComp2.D, EComp2.E, EComp2.F]; ->x : EComp2[] -> : ^^^^^^^^ ->[EComp2.A, EComp2.B, EComp2.C, EComp2.D, EComp2.E, EComp2.F] : EComp2[] -> : ^^^^^^^^ ->EComp2.A : EComp2.A -> : ^^^^^^^^ ->EComp2 : typeof EComp2 -> : ^^^^^^^^^^^^^ ->A : EComp2.A -> : ^^^^^^^^ ->EComp2.B : EComp2.B -> : ^^^^^^^^ ->EComp2 : typeof EComp2 -> : ^^^^^^^^^^^^^ ->B : EComp2.B -> : ^^^^^^^^ ->EComp2.C : EComp2.C -> : ^^^^^^^^ ->EComp2 : typeof EComp2 -> : ^^^^^^^^^^^^^ ->C : EComp2.C -> : ^^^^^^^^ ->EComp2.D : EComp2.D -> : ^^^^^^^^ ->EComp2 : typeof EComp2 -> : ^^^^^^^^^^^^^ ->D : EComp2.D -> : ^^^^^^^^ ->EComp2.E : EComp2.E -> : ^^^^^^^^ ->EComp2 : typeof EComp2 -> : ^^^^^^^^^^^^^ ->E : EComp2.E -> : ^^^^^^^^ ->EComp2.F : EComp2.F -> : ^^^^^^^^ ->EComp2 : typeof EComp2 -> : ^^^^^^^^^^^^^ ->F : EComp2.F -> : ^^^^^^^^ +>x : any[] +> : ^^^^^ +>[EComp2.A, EComp2.B, EComp2.C, EComp2.D, EComp2.E, EComp2.F] : any[] +> : ^^^^^ +>EComp2.A : any +> : ^^^ +>EComp2 : typeof M2.EComp2 +> : ^^^^^^^^^^^^^^^^ +>A : any +> : ^^^ +>EComp2.B : any +> : ^^^ +>EComp2 : typeof M2.EComp2 +> : ^^^^^^^^^^^^^^^^ +>B : any +> : ^^^ +>EComp2.C : any +> : ^^^ +>EComp2 : typeof M2.EComp2 +> : ^^^^^^^^^^^^^^^^ +>C : any +> : ^^^ +>EComp2.D : M2.EComp2.D +> : ^^^^^^^^^^^ +>EComp2 : typeof M2.EComp2 +> : ^^^^^^^^^^^^^^^^ +>D : M2.EComp2.D +> : ^^^^^^^^^^^ +>EComp2.E : M2.EComp2.E +> : ^^^^^^^^^^^ +>EComp2 : typeof M2.EComp2 +> : ^^^^^^^^^^^^^^^^ +>E : M2.EComp2.E +> : ^^^^^^^^^^^ +>EComp2.F : M2.EComp2.F +> : ^^^^^^^^^^^ +>EComp2 : typeof M2.EComp2 +> : ^^^^^^^^^^^^^^^^ +>F : M2.EComp2.F +> : ^^^^^^^^^^^ } // Enum with initializer in only one of two declarations with constant members with the same root module @@ -249,7 +249,7 @@ module M3 { > : ^^^^^ C = 1, D, E ->C : EInit.B +>C : EInit.C > : ^^^^^^^ >1 : 1 > : ^ @@ -315,32 +315,32 @@ module M6 { > : ^^^^^^^^ export enum Color { Yellow = 1 } ->Color : Color -> : ^^^^^ ->Yellow : Color.Green -> : ^^^^^^^^^^^ +>Color : A.Color +> : ^^^^^^^ +>Yellow : A.Color.Yellow +> : ^^^^^^^^^^^^^^ >1 : 1 > : ^ } var t = A.Color.Yellow; ->t : A.Color -> : ^^^^^^^ ->A.Color.Yellow : A.Color.Green -> : ^^^^^^^^^^^^^ +>t : any +> : ^^^ +>A.Color.Yellow : any +> : ^^^ >A.Color : typeof A.Color > : ^^^^^^^^^^^^^^ >A : typeof A > : ^^^^^^^^ >Color : typeof A.Color > : ^^^^^^^^^^^^^^ ->Yellow : A.Color.Green -> : ^^^^^^^^^^^^^ +>Yellow : any +> : ^^^ t = A.Color.Red; >t = A.Color.Red : A.Color.Red > : ^^^^^^^^^^^ ->t : A.Color -> : ^^^^^^^ +>t : any +> : ^^^ >A.Color.Red : A.Color.Red > : ^^^^^^^^^^^ >A.Color : typeof A.Color diff --git a/tests/baselines/reference/enumMergingErrors.errors.txt b/tests/baselines/reference/enumMergingErrors.errors.txt index e0d3ba2e8233a..35f1ba8fa70d5 100644 --- a/tests/baselines/reference/enumMergingErrors.errors.txt +++ b/tests/baselines/reference/enumMergingErrors.errors.txt @@ -1,50 +1,89 @@ -enumMergingErrors.ts(26,22): error TS2432: In an enum with multiple declarations, only one declaration can omit an initializer for its first enum element. -enumMergingErrors.ts(38,22): error TS2432: In an enum with multiple declarations, only one declaration can omit an initializer for its first enum element. +enumMergingErrors.ts(3,17): error TS2567: Enum declarations can only merge with namespace declarations. +enumMergingErrors.ts(4,17): error TS2567: Enum declarations can only merge with namespace declarations. +enumMergingErrors.ts(5,17): error TS2567: Enum declarations can only merge with namespace declarations. +enumMergingErrors.ts(8,17): error TS2567: Enum declarations can only merge with namespace declarations. +enumMergingErrors.ts(9,17): error TS2567: Enum declarations can only merge with namespace declarations. +enumMergingErrors.ts(10,17): error TS2567: Enum declarations can only merge with namespace declarations. +enumMergingErrors.ts(13,17): error TS2567: Enum declarations can only merge with namespace declarations. +enumMergingErrors.ts(14,17): error TS2567: Enum declarations can only merge with namespace declarations. +enumMergingErrors.ts(15,17): error TS2567: Enum declarations can only merge with namespace declarations. +enumMergingErrors.ts(20,17): error TS2567: Enum declarations can only merge with namespace declarations. +enumMergingErrors.ts(23,17): error TS2567: Enum declarations can only merge with namespace declarations. +enumMergingErrors.ts(26,17): error TS2567: Enum declarations can only merge with namespace declarations. +enumMergingErrors.ts(32,17): error TS2567: Enum declarations can only merge with namespace declarations. +enumMergingErrors.ts(35,17): error TS2567: Enum declarations can only merge with namespace declarations. +enumMergingErrors.ts(38,17): error TS2567: Enum declarations can only merge with namespace declarations. -==== enumMergingErrors.ts (2 errors) ==== +==== enumMergingErrors.ts (15 errors) ==== // Enum with constant, computed, constant members split across 3 declarations with the same root module module M { export enum E1 { A = 0 } + ~~ +!!! error TS2567: Enum declarations can only merge with namespace declarations. export enum E2 { C } + ~~ +!!! error TS2567: Enum declarations can only merge with namespace declarations. export enum E3 { A = 0 } + ~~ +!!! error TS2567: Enum declarations can only merge with namespace declarations. } module M { export enum E1 { B = 'foo'.length } + ~~ +!!! error TS2567: Enum declarations can only merge with namespace declarations. export enum E2 { B = 'foo'.length } + ~~ +!!! error TS2567: Enum declarations can only merge with namespace declarations. export enum E3 { C } + ~~ +!!! error TS2567: Enum declarations can only merge with namespace declarations. } module M { export enum E1 { C } + ~~ +!!! error TS2567: Enum declarations can only merge with namespace declarations. export enum E2 { A = 0 } + ~~ +!!! error TS2567: Enum declarations can only merge with namespace declarations. export enum E3 { B = 'foo'.length } + ~~ +!!! error TS2567: Enum declarations can only merge with namespace declarations. } // Enum with no initializer in either declaration with constant members with the same root module module M1 { export enum E1 { A = 0 } + ~~ +!!! error TS2567: Enum declarations can only merge with namespace declarations. } module M1 { export enum E1 { B } + ~~ +!!! error TS2567: Enum declarations can only merge with namespace declarations. } module M1 { export enum E1 { C } - ~ -!!! error TS2432: In an enum with multiple declarations, only one declaration can omit an initializer for its first enum element. + ~~ +!!! error TS2567: Enum declarations can only merge with namespace declarations. } // Enum with initializer in only one of three declarations with constant members with the same root module module M2 { export enum E1 { A } + ~~ +!!! error TS2567: Enum declarations can only merge with namespace declarations. } module M2 { export enum E1 { B = 0 } + ~~ +!!! error TS2567: Enum declarations can only merge with namespace declarations. } module M2 { export enum E1 { C } - ~ -!!! error TS2432: In an enum with multiple declarations, only one declaration can omit an initializer for its first enum element. + ~~ +!!! error TS2567: Enum declarations can only merge with namespace declarations. } diff --git a/tests/baselines/reference/enumMergingErrors.symbols b/tests/baselines/reference/enumMergingErrors.symbols index 2b51b9b36d0cd..0843e14da66b3 100644 --- a/tests/baselines/reference/enumMergingErrors.symbols +++ b/tests/baselines/reference/enumMergingErrors.symbols @@ -6,50 +6,50 @@ module M { >M : Symbol(M, Decl(enumMergingErrors.ts, 0, 0), Decl(enumMergingErrors.ts, 5, 1), Decl(enumMergingErrors.ts, 10, 1)) export enum E1 { A = 0 } ->E1 : Symbol(E1, Decl(enumMergingErrors.ts, 1, 10), Decl(enumMergingErrors.ts, 6, 10), Decl(enumMergingErrors.ts, 11, 10)) +>E1 : Symbol(E1, Decl(enumMergingErrors.ts, 1, 10)) >A : Symbol(E1.A, Decl(enumMergingErrors.ts, 2, 20)) export enum E2 { C } ->E2 : Symbol(E2, Decl(enumMergingErrors.ts, 2, 28), Decl(enumMergingErrors.ts, 7, 39), Decl(enumMergingErrors.ts, 12, 24)) +>E2 : Symbol(E2, Decl(enumMergingErrors.ts, 2, 28)) >C : Symbol(E2.C, Decl(enumMergingErrors.ts, 3, 20)) export enum E3 { A = 0 } ->E3 : Symbol(E3, Decl(enumMergingErrors.ts, 3, 24), Decl(enumMergingErrors.ts, 8, 39), Decl(enumMergingErrors.ts, 13, 28)) +>E3 : Symbol(E3, Decl(enumMergingErrors.ts, 3, 24)) >A : Symbol(E3.A, Decl(enumMergingErrors.ts, 4, 20)) } module M { >M : Symbol(M, Decl(enumMergingErrors.ts, 0, 0), Decl(enumMergingErrors.ts, 5, 1), Decl(enumMergingErrors.ts, 10, 1)) export enum E1 { B = 'foo'.length } ->E1 : Symbol(E1, Decl(enumMergingErrors.ts, 1, 10), Decl(enumMergingErrors.ts, 6, 10), Decl(enumMergingErrors.ts, 11, 10)) ->B : Symbol(E1.B, Decl(enumMergingErrors.ts, 7, 20)) +>E1 : Symbol(E1, Decl(enumMergingErrors.ts, 6, 10)) +>B : Symbol(M.E1.B, Decl(enumMergingErrors.ts, 7, 20)) >'foo'.length : Symbol(String.length, Decl(lib.es5.d.ts, --, --)) >length : Symbol(String.length, Decl(lib.es5.d.ts, --, --)) export enum E2 { B = 'foo'.length } ->E2 : Symbol(E2, Decl(enumMergingErrors.ts, 2, 28), Decl(enumMergingErrors.ts, 7, 39), Decl(enumMergingErrors.ts, 12, 24)) ->B : Symbol(E2.B, Decl(enumMergingErrors.ts, 8, 20)) +>E2 : Symbol(E2, Decl(enumMergingErrors.ts, 7, 39)) +>B : Symbol(M.E2.B, Decl(enumMergingErrors.ts, 8, 20)) >'foo'.length : Symbol(String.length, Decl(lib.es5.d.ts, --, --)) >length : Symbol(String.length, Decl(lib.es5.d.ts, --, --)) export enum E3 { C } ->E3 : Symbol(E3, Decl(enumMergingErrors.ts, 3, 24), Decl(enumMergingErrors.ts, 8, 39), Decl(enumMergingErrors.ts, 13, 28)) ->C : Symbol(E3.C, Decl(enumMergingErrors.ts, 9, 20)) +>E3 : Symbol(E3, Decl(enumMergingErrors.ts, 8, 39)) +>C : Symbol(M.E3.C, Decl(enumMergingErrors.ts, 9, 20)) } module M { >M : Symbol(M, Decl(enumMergingErrors.ts, 0, 0), Decl(enumMergingErrors.ts, 5, 1), Decl(enumMergingErrors.ts, 10, 1)) export enum E1 { C } ->E1 : Symbol(E1, Decl(enumMergingErrors.ts, 1, 10), Decl(enumMergingErrors.ts, 6, 10), Decl(enumMergingErrors.ts, 11, 10)) ->C : Symbol(E1.C, Decl(enumMergingErrors.ts, 12, 20)) +>E1 : Symbol(E1, Decl(enumMergingErrors.ts, 11, 10)) +>C : Symbol(M.E1.C, Decl(enumMergingErrors.ts, 12, 20)) export enum E2 { A = 0 } ->E2 : Symbol(E2, Decl(enumMergingErrors.ts, 2, 28), Decl(enumMergingErrors.ts, 7, 39), Decl(enumMergingErrors.ts, 12, 24)) ->A : Symbol(E2.A, Decl(enumMergingErrors.ts, 13, 20)) +>E2 : Symbol(E2, Decl(enumMergingErrors.ts, 12, 24)) +>A : Symbol(M.E2.A, Decl(enumMergingErrors.ts, 13, 20)) export enum E3 { B = 'foo'.length } ->E3 : Symbol(E3, Decl(enumMergingErrors.ts, 3, 24), Decl(enumMergingErrors.ts, 8, 39), Decl(enumMergingErrors.ts, 13, 28)) ->B : Symbol(E3.B, Decl(enumMergingErrors.ts, 14, 20)) +>E3 : Symbol(E3, Decl(enumMergingErrors.ts, 13, 28)) +>B : Symbol(M.E3.B, Decl(enumMergingErrors.ts, 14, 20)) >'foo'.length : Symbol(String.length, Decl(lib.es5.d.ts, --, --)) >length : Symbol(String.length, Decl(lib.es5.d.ts, --, --)) } @@ -59,22 +59,22 @@ module M1 { >M1 : Symbol(M1, Decl(enumMergingErrors.ts, 15, 1), Decl(enumMergingErrors.ts, 20, 1), Decl(enumMergingErrors.ts, 23, 1)) export enum E1 { A = 0 } ->E1 : Symbol(E1, Decl(enumMergingErrors.ts, 18, 11), Decl(enumMergingErrors.ts, 21, 11), Decl(enumMergingErrors.ts, 24, 11)) +>E1 : Symbol(E1, Decl(enumMergingErrors.ts, 18, 11)) >A : Symbol(E1.A, Decl(enumMergingErrors.ts, 19, 20)) } module M1 { >M1 : Symbol(M1, Decl(enumMergingErrors.ts, 15, 1), Decl(enumMergingErrors.ts, 20, 1), Decl(enumMergingErrors.ts, 23, 1)) export enum E1 { B } ->E1 : Symbol(E1, Decl(enumMergingErrors.ts, 18, 11), Decl(enumMergingErrors.ts, 21, 11), Decl(enumMergingErrors.ts, 24, 11)) ->B : Symbol(E1.B, Decl(enumMergingErrors.ts, 22, 20)) +>E1 : Symbol(E1, Decl(enumMergingErrors.ts, 21, 11)) +>B : Symbol(M1.E1.B, Decl(enumMergingErrors.ts, 22, 20)) } module M1 { >M1 : Symbol(M1, Decl(enumMergingErrors.ts, 15, 1), Decl(enumMergingErrors.ts, 20, 1), Decl(enumMergingErrors.ts, 23, 1)) export enum E1 { C } ->E1 : Symbol(E1, Decl(enumMergingErrors.ts, 18, 11), Decl(enumMergingErrors.ts, 21, 11), Decl(enumMergingErrors.ts, 24, 11)) ->C : Symbol(E1.C, Decl(enumMergingErrors.ts, 25, 20)) +>E1 : Symbol(E1, Decl(enumMergingErrors.ts, 24, 11)) +>C : Symbol(M1.E1.C, Decl(enumMergingErrors.ts, 25, 20)) } @@ -83,22 +83,22 @@ module M2 { >M2 : Symbol(M2, Decl(enumMergingErrors.ts, 26, 1), Decl(enumMergingErrors.ts, 32, 1), Decl(enumMergingErrors.ts, 35, 1)) export enum E1 { A } ->E1 : Symbol(E1, Decl(enumMergingErrors.ts, 30, 11), Decl(enumMergingErrors.ts, 33, 11), Decl(enumMergingErrors.ts, 36, 11)) +>E1 : Symbol(E1, Decl(enumMergingErrors.ts, 30, 11)) >A : Symbol(E1.A, Decl(enumMergingErrors.ts, 31, 20)) } module M2 { >M2 : Symbol(M2, Decl(enumMergingErrors.ts, 26, 1), Decl(enumMergingErrors.ts, 32, 1), Decl(enumMergingErrors.ts, 35, 1)) export enum E1 { B = 0 } ->E1 : Symbol(E1, Decl(enumMergingErrors.ts, 30, 11), Decl(enumMergingErrors.ts, 33, 11), Decl(enumMergingErrors.ts, 36, 11)) ->B : Symbol(E1.B, Decl(enumMergingErrors.ts, 34, 20)) +>E1 : Symbol(E1, Decl(enumMergingErrors.ts, 33, 11)) +>B : Symbol(M2.E1.B, Decl(enumMergingErrors.ts, 34, 20)) } module M2 { >M2 : Symbol(M2, Decl(enumMergingErrors.ts, 26, 1), Decl(enumMergingErrors.ts, 32, 1), Decl(enumMergingErrors.ts, 35, 1)) export enum E1 { C } ->E1 : Symbol(E1, Decl(enumMergingErrors.ts, 30, 11), Decl(enumMergingErrors.ts, 33, 11), Decl(enumMergingErrors.ts, 36, 11)) ->C : Symbol(E1.C, Decl(enumMergingErrors.ts, 37, 20)) +>E1 : Symbol(E1, Decl(enumMergingErrors.ts, 36, 11)) +>C : Symbol(M2.E1.C, Decl(enumMergingErrors.ts, 37, 20)) } diff --git a/tests/baselines/reference/enumMergingErrors.types b/tests/baselines/reference/enumMergingErrors.types index 963a299bf36bf..a45ccf249c931 100644 --- a/tests/baselines/reference/enumMergingErrors.types +++ b/tests/baselines/reference/enumMergingErrors.types @@ -33,10 +33,10 @@ module M { > : ^^^^^^^^ export enum E1 { B = 'foo'.length } ->E1 : E1 -> : ^^ ->B : E1.B -> : ^^^^ +>E1 : M.E1 +> : ^^^^ +>B : M.E1.B +> : ^^^^^^ >'foo'.length : number > : ^^^^^^ >'foo' : "foo" @@ -45,10 +45,10 @@ module M { > : ^^^^^^ export enum E2 { B = 'foo'.length } ->E2 : E2 -> : ^^ ->B : E2.B -> : ^^^^ +>E2 : M.E2 +> : ^^^^ +>B : M.E2.B +> : ^^^^^^ >'foo'.length : number > : ^^^^^^ >'foo' : "foo" @@ -57,34 +57,34 @@ module M { > : ^^^^^^ export enum E3 { C } ->E3 : E3 -> : ^^ ->C : E3.A -> : ^^^^ +>E3 : M.E3 +> : ^^^^ +>C : M.E3.C +> : ^^^^^^ } module M { >M : typeof M > : ^^^^^^^^ export enum E1 { C } ->E1 : E1 -> : ^^ ->C : E1.A -> : ^^^^ +>E1 : M.E1 +> : ^^^^ +>C : M.E1.C +> : ^^^^^^ export enum E2 { A = 0 } ->E2 : E2 -> : ^^ ->A : E2.C -> : ^^^^ +>E2 : M.E2 +> : ^^^^ +>A : M.E2.A +> : ^^^^^^ >0 : 0 > : ^ export enum E3 { B = 'foo'.length } ->E3 : E3 -> : ^^ ->B : E3.B -> : ^^^^ +>E3 : M.E3 +> : ^^^^ +>B : M.E3.B +> : ^^^^^^ >'foo'.length : number > : ^^^^^^ >'foo' : "foo" @@ -111,20 +111,20 @@ module M1 { > : ^^^^^^^^^ export enum E1 { B } ->E1 : E1 -> : ^^ ->B : E1.A -> : ^^^^ +>E1 : M1.E1 +> : ^^^^^ +>B : M1.E1.B +> : ^^^^^^^ } module M1 { >M1 : typeof M1 > : ^^^^^^^^^ export enum E1 { C } ->E1 : E1 -> : ^^ ->C : E1.A -> : ^^^^ +>E1 : M1.E1 +> : ^^^^^ +>C : M1.E1.C +> : ^^^^^^^ } @@ -144,10 +144,10 @@ module M2 { > : ^^^^^^^^^ export enum E1 { B = 0 } ->E1 : E1 -> : ^^ ->B : E1.A -> : ^^^^ +>E1 : M2.E1 +> : ^^^^^ +>B : M2.E1.B +> : ^^^^^^^ >0 : 0 > : ^ } @@ -156,10 +156,10 @@ module M2 { > : ^^^^^^^^^ export enum E1 { C } ->E1 : E1 -> : ^^ ->C : E1.A -> : ^^^^ +>E1 : M2.E1 +> : ^^^^^ +>C : M2.E1.C +> : ^^^^^^^ } diff --git a/tests/baselines/reference/enumsWithMultipleDeclarations1.errors.txt b/tests/baselines/reference/enumsWithMultipleDeclarations1.errors.txt index 1ff4e0b0fb7d1..c25d6ee541fc2 100644 --- a/tests/baselines/reference/enumsWithMultipleDeclarations1.errors.txt +++ b/tests/baselines/reference/enumsWithMultipleDeclarations1.errors.txt @@ -1,20 +1,23 @@ -enumsWithMultipleDeclarations1.ts(6,3): error TS2432: In an enum with multiple declarations, only one declaration can omit an initializer for its first enum element. -enumsWithMultipleDeclarations1.ts(10,3): error TS2432: In an enum with multiple declarations, only one declaration can omit an initializer for its first enum element. +enumsWithMultipleDeclarations1.ts(1,6): error TS2567: Enum declarations can only merge with namespace declarations. +enumsWithMultipleDeclarations1.ts(5,6): error TS2567: Enum declarations can only merge with namespace declarations. +enumsWithMultipleDeclarations1.ts(9,6): error TS2567: Enum declarations can only merge with namespace declarations. -==== enumsWithMultipleDeclarations1.ts (2 errors) ==== +==== enumsWithMultipleDeclarations1.ts (3 errors) ==== enum E { + ~ +!!! error TS2567: Enum declarations can only merge with namespace declarations. A } enum E { + ~ +!!! error TS2567: Enum declarations can only merge with namespace declarations. B - ~ -!!! error TS2432: In an enum with multiple declarations, only one declaration can omit an initializer for its first enum element. } enum E { + ~ +!!! error TS2567: Enum declarations can only merge with namespace declarations. C - ~ -!!! error TS2432: In an enum with multiple declarations, only one declaration can omit an initializer for its first enum element. } \ No newline at end of file diff --git a/tests/baselines/reference/enumsWithMultipleDeclarations1.symbols b/tests/baselines/reference/enumsWithMultipleDeclarations1.symbols index 1ecc969e61456..84b2f9243b16f 100644 --- a/tests/baselines/reference/enumsWithMultipleDeclarations1.symbols +++ b/tests/baselines/reference/enumsWithMultipleDeclarations1.symbols @@ -2,21 +2,21 @@ === enumsWithMultipleDeclarations1.ts === enum E { ->E : Symbol(E, Decl(enumsWithMultipleDeclarations1.ts, 0, 0), Decl(enumsWithMultipleDeclarations1.ts, 2, 1), Decl(enumsWithMultipleDeclarations1.ts, 6, 1)) +>E : Symbol(E, Decl(enumsWithMultipleDeclarations1.ts, 0, 0)) A >A : Symbol(E.A, Decl(enumsWithMultipleDeclarations1.ts, 0, 8)) } enum E { ->E : Symbol(E, Decl(enumsWithMultipleDeclarations1.ts, 0, 0), Decl(enumsWithMultipleDeclarations1.ts, 2, 1), Decl(enumsWithMultipleDeclarations1.ts, 6, 1)) +>E : Symbol(E, Decl(enumsWithMultipleDeclarations1.ts, 2, 1)) B >B : Symbol(E.B, Decl(enumsWithMultipleDeclarations1.ts, 4, 8)) } enum E { ->E : Symbol(E, Decl(enumsWithMultipleDeclarations1.ts, 0, 0), Decl(enumsWithMultipleDeclarations1.ts, 2, 1), Decl(enumsWithMultipleDeclarations1.ts, 6, 1)) +>E : Symbol(E, Decl(enumsWithMultipleDeclarations1.ts, 6, 1)) C >C : Symbol(E.C, Decl(enumsWithMultipleDeclarations1.ts, 8, 8)) diff --git a/tests/baselines/reference/enumsWithMultipleDeclarations1.types b/tests/baselines/reference/enumsWithMultipleDeclarations1.types index 577ebeb8336b1..120292c4bf813 100644 --- a/tests/baselines/reference/enumsWithMultipleDeclarations1.types +++ b/tests/baselines/reference/enumsWithMultipleDeclarations1.types @@ -15,7 +15,7 @@ enum E { > : ^ B ->B : E.A +>B : E.B > : ^^^ } @@ -24,6 +24,6 @@ enum E { > : ^ C ->C : E.A +>C : E.C > : ^^^ } diff --git a/tests/baselines/reference/enumsWithMultipleDeclarations2.errors.txt b/tests/baselines/reference/enumsWithMultipleDeclarations2.errors.txt index 30993d0a3bb9e..938e90d3fe742 100644 --- a/tests/baselines/reference/enumsWithMultipleDeclarations2.errors.txt +++ b/tests/baselines/reference/enumsWithMultipleDeclarations2.errors.txt @@ -1,17 +1,23 @@ -enumsWithMultipleDeclarations2.ts(10,3): error TS2432: In an enum with multiple declarations, only one declaration can omit an initializer for its first enum element. +enumsWithMultipleDeclarations2.ts(1,6): error TS2567: Enum declarations can only merge with namespace declarations. +enumsWithMultipleDeclarations2.ts(5,6): error TS2567: Enum declarations can only merge with namespace declarations. +enumsWithMultipleDeclarations2.ts(9,6): error TS2567: Enum declarations can only merge with namespace declarations. -==== enumsWithMultipleDeclarations2.ts (1 errors) ==== +==== enumsWithMultipleDeclarations2.ts (3 errors) ==== enum E { + ~ +!!! error TS2567: Enum declarations can only merge with namespace declarations. A } enum E { + ~ +!!! error TS2567: Enum declarations can only merge with namespace declarations. B = 1 } enum E { + ~ +!!! error TS2567: Enum declarations can only merge with namespace declarations. C - ~ -!!! error TS2432: In an enum with multiple declarations, only one declaration can omit an initializer for its first enum element. } \ No newline at end of file diff --git a/tests/baselines/reference/enumsWithMultipleDeclarations2.symbols b/tests/baselines/reference/enumsWithMultipleDeclarations2.symbols index 31eaaee68bb60..2e132dae8d923 100644 --- a/tests/baselines/reference/enumsWithMultipleDeclarations2.symbols +++ b/tests/baselines/reference/enumsWithMultipleDeclarations2.symbols @@ -2,21 +2,21 @@ === enumsWithMultipleDeclarations2.ts === enum E { ->E : Symbol(E, Decl(enumsWithMultipleDeclarations2.ts, 0, 0), Decl(enumsWithMultipleDeclarations2.ts, 2, 1), Decl(enumsWithMultipleDeclarations2.ts, 6, 1)) +>E : Symbol(E, Decl(enumsWithMultipleDeclarations2.ts, 0, 0)) A >A : Symbol(E.A, Decl(enumsWithMultipleDeclarations2.ts, 0, 8)) } enum E { ->E : Symbol(E, Decl(enumsWithMultipleDeclarations2.ts, 0, 0), Decl(enumsWithMultipleDeclarations2.ts, 2, 1), Decl(enumsWithMultipleDeclarations2.ts, 6, 1)) +>E : Symbol(E, Decl(enumsWithMultipleDeclarations2.ts, 2, 1)) B = 1 >B : Symbol(E.B, Decl(enumsWithMultipleDeclarations2.ts, 4, 8)) } enum E { ->E : Symbol(E, Decl(enumsWithMultipleDeclarations2.ts, 0, 0), Decl(enumsWithMultipleDeclarations2.ts, 2, 1), Decl(enumsWithMultipleDeclarations2.ts, 6, 1)) +>E : Symbol(E, Decl(enumsWithMultipleDeclarations2.ts, 6, 1)) C >C : Symbol(E.C, Decl(enumsWithMultipleDeclarations2.ts, 8, 8)) diff --git a/tests/baselines/reference/enumsWithMultipleDeclarations2.types b/tests/baselines/reference/enumsWithMultipleDeclarations2.types index 3fae14b47b4f7..0bbf5260df085 100644 --- a/tests/baselines/reference/enumsWithMultipleDeclarations2.types +++ b/tests/baselines/reference/enumsWithMultipleDeclarations2.types @@ -26,6 +26,6 @@ enum E { > : ^ C ->C : E.A +>C : E.C > : ^^^ } diff --git a/tests/baselines/reference/es6modulekindWithES5Target12.errors.txt b/tests/baselines/reference/es6modulekindWithES5Target12.errors.txt new file mode 100644 index 0000000000000..dd6b546a49dc6 --- /dev/null +++ b/tests/baselines/reference/es6modulekindWithES5Target12.errors.txt @@ -0,0 +1,45 @@ +es6modulekindWithES5Target12.ts(8,13): error TS2567: Enum declarations can only merge with namespace declarations. +es6modulekindWithES5Target12.ts(12,13): error TS2567: Enum declarations can only merge with namespace declarations. + + +==== es6modulekindWithES5Target12.ts (2 errors) ==== + export class C { + } + + export namespace C { + export const x = 1; + } + + export enum E { + ~ +!!! error TS2567: Enum declarations can only merge with namespace declarations. + w = 1 + } + + export enum E { + ~ +!!! error TS2567: Enum declarations can only merge with namespace declarations. + x = 2 + } + + export namespace E { + export const y = 1; + } + + export namespace E { + export const z = 1; + } + + export namespace N { + } + + export namespace N { + export const x = 1; + } + + export function F() { + } + + export namespace F { + export const x = 1; + } \ No newline at end of file diff --git a/tests/baselines/reference/es6modulekindWithES5Target12.symbols b/tests/baselines/reference/es6modulekindWithES5Target12.symbols index b7bb970bf0b96..baf0ace1eed18 100644 --- a/tests/baselines/reference/es6modulekindWithES5Target12.symbols +++ b/tests/baselines/reference/es6modulekindWithES5Target12.symbols @@ -13,28 +13,28 @@ export namespace C { } export enum E { ->E : Symbol(E, Decl(es6modulekindWithES5Target12.ts, 5, 1), Decl(es6modulekindWithES5Target12.ts, 9, 1), Decl(es6modulekindWithES5Target12.ts, 13, 1), Decl(es6modulekindWithES5Target12.ts, 17, 1)) +>E : Symbol(E, Decl(es6modulekindWithES5Target12.ts, 5, 1), Decl(es6modulekindWithES5Target12.ts, 13, 1), Decl(es6modulekindWithES5Target12.ts, 17, 1)) w = 1 >w : Symbol(E.w, Decl(es6modulekindWithES5Target12.ts, 7, 15)) } export enum E { ->E : Symbol(E, Decl(es6modulekindWithES5Target12.ts, 5, 1), Decl(es6modulekindWithES5Target12.ts, 9, 1), Decl(es6modulekindWithES5Target12.ts, 13, 1), Decl(es6modulekindWithES5Target12.ts, 17, 1)) +>E : Symbol(E, Decl(es6modulekindWithES5Target12.ts, 9, 1)) x = 2 >x : Symbol(E.x, Decl(es6modulekindWithES5Target12.ts, 11, 15)) } export namespace E { ->E : Symbol(E, Decl(es6modulekindWithES5Target12.ts, 5, 1), Decl(es6modulekindWithES5Target12.ts, 9, 1), Decl(es6modulekindWithES5Target12.ts, 13, 1), Decl(es6modulekindWithES5Target12.ts, 17, 1)) +>E : Symbol(E, Decl(es6modulekindWithES5Target12.ts, 5, 1), Decl(es6modulekindWithES5Target12.ts, 13, 1), Decl(es6modulekindWithES5Target12.ts, 17, 1)) export const y = 1; >y : Symbol(y, Decl(es6modulekindWithES5Target12.ts, 16, 16)) } export namespace E { ->E : Symbol(E, Decl(es6modulekindWithES5Target12.ts, 5, 1), Decl(es6modulekindWithES5Target12.ts, 9, 1), Decl(es6modulekindWithES5Target12.ts, 13, 1), Decl(es6modulekindWithES5Target12.ts, 17, 1)) +>E : Symbol(E, Decl(es6modulekindWithES5Target12.ts, 5, 1), Decl(es6modulekindWithES5Target12.ts, 13, 1), Decl(es6modulekindWithES5Target12.ts, 17, 1)) export const z = 1; >z : Symbol(z, Decl(es6modulekindWithES5Target12.ts, 20, 16)) diff --git a/tests/baselines/reference/es6modulekindWithES5Target12.types b/tests/baselines/reference/es6modulekindWithES5Target12.types index 0ae2a847f5f97..50579007ac7d2 100644 --- a/tests/baselines/reference/es6modulekindWithES5Target12.types +++ b/tests/baselines/reference/es6modulekindWithES5Target12.types @@ -29,12 +29,12 @@ export enum E { } export enum E { ->E : E -> : ^ +>E : import("es6modulekindWithES5Target12").E +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ x = 2 ->x : E.x -> : ^^^ +>x : import("es6modulekindWithES5Target12").E.x +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ >2 : 2 > : ^ } diff --git a/tests/baselines/reference/esnextmodulekindWithES5Target12.errors.txt b/tests/baselines/reference/esnextmodulekindWithES5Target12.errors.txt new file mode 100644 index 0000000000000..a8bf44b3c1219 --- /dev/null +++ b/tests/baselines/reference/esnextmodulekindWithES5Target12.errors.txt @@ -0,0 +1,45 @@ +esnextmodulekindWithES5Target12.ts(8,13): error TS2567: Enum declarations can only merge with namespace declarations. +esnextmodulekindWithES5Target12.ts(12,13): error TS2567: Enum declarations can only merge with namespace declarations. + + +==== esnextmodulekindWithES5Target12.ts (2 errors) ==== + export class C { + } + + export namespace C { + export const x = 1; + } + + export enum E { + ~ +!!! error TS2567: Enum declarations can only merge with namespace declarations. + w = 1 + } + + export enum E { + ~ +!!! error TS2567: Enum declarations can only merge with namespace declarations. + x = 2 + } + + export namespace E { + export const y = 1; + } + + export namespace E { + export const z = 1; + } + + export namespace N { + } + + export namespace N { + export const x = 1; + } + + export function F() { + } + + export namespace F { + export const x = 1; + } \ No newline at end of file diff --git a/tests/baselines/reference/esnextmodulekindWithES5Target12.symbols b/tests/baselines/reference/esnextmodulekindWithES5Target12.symbols index 312784c377e67..5f84d3edbde25 100644 --- a/tests/baselines/reference/esnextmodulekindWithES5Target12.symbols +++ b/tests/baselines/reference/esnextmodulekindWithES5Target12.symbols @@ -13,28 +13,28 @@ export namespace C { } export enum E { ->E : Symbol(E, Decl(esnextmodulekindWithES5Target12.ts, 5, 1), Decl(esnextmodulekindWithES5Target12.ts, 9, 1), Decl(esnextmodulekindWithES5Target12.ts, 13, 1), Decl(esnextmodulekindWithES5Target12.ts, 17, 1)) +>E : Symbol(E, Decl(esnextmodulekindWithES5Target12.ts, 5, 1), Decl(esnextmodulekindWithES5Target12.ts, 13, 1), Decl(esnextmodulekindWithES5Target12.ts, 17, 1)) w = 1 >w : Symbol(E.w, Decl(esnextmodulekindWithES5Target12.ts, 7, 15)) } export enum E { ->E : Symbol(E, Decl(esnextmodulekindWithES5Target12.ts, 5, 1), Decl(esnextmodulekindWithES5Target12.ts, 9, 1), Decl(esnextmodulekindWithES5Target12.ts, 13, 1), Decl(esnextmodulekindWithES5Target12.ts, 17, 1)) +>E : Symbol(E, Decl(esnextmodulekindWithES5Target12.ts, 9, 1)) x = 2 >x : Symbol(E.x, Decl(esnextmodulekindWithES5Target12.ts, 11, 15)) } export namespace E { ->E : Symbol(E, Decl(esnextmodulekindWithES5Target12.ts, 5, 1), Decl(esnextmodulekindWithES5Target12.ts, 9, 1), Decl(esnextmodulekindWithES5Target12.ts, 13, 1), Decl(esnextmodulekindWithES5Target12.ts, 17, 1)) +>E : Symbol(E, Decl(esnextmodulekindWithES5Target12.ts, 5, 1), Decl(esnextmodulekindWithES5Target12.ts, 13, 1), Decl(esnextmodulekindWithES5Target12.ts, 17, 1)) export const y = 1; >y : Symbol(y, Decl(esnextmodulekindWithES5Target12.ts, 16, 16)) } export namespace E { ->E : Symbol(E, Decl(esnextmodulekindWithES5Target12.ts, 5, 1), Decl(esnextmodulekindWithES5Target12.ts, 9, 1), Decl(esnextmodulekindWithES5Target12.ts, 13, 1), Decl(esnextmodulekindWithES5Target12.ts, 17, 1)) +>E : Symbol(E, Decl(esnextmodulekindWithES5Target12.ts, 5, 1), Decl(esnextmodulekindWithES5Target12.ts, 13, 1), Decl(esnextmodulekindWithES5Target12.ts, 17, 1)) export const z = 1; >z : Symbol(z, Decl(esnextmodulekindWithES5Target12.ts, 20, 16)) diff --git a/tests/baselines/reference/esnextmodulekindWithES5Target12.types b/tests/baselines/reference/esnextmodulekindWithES5Target12.types index 12485b963a8af..352f8c275f1d5 100644 --- a/tests/baselines/reference/esnextmodulekindWithES5Target12.types +++ b/tests/baselines/reference/esnextmodulekindWithES5Target12.types @@ -29,12 +29,12 @@ export enum E { } export enum E { ->E : E -> : ^ +>E : import("esnextmodulekindWithES5Target12").E +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ x = 2 ->x : E.x -> : ^^^ +>x : import("esnextmodulekindWithES5Target12").E.x +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ >2 : 2 > : ^ } diff --git a/tests/baselines/reference/exportDeclaration_missingBraces.errors.txt b/tests/baselines/reference/exportDeclaration_missingBraces.errors.txt index 6c372d837b135..dacc96f68074f 100644 --- a/tests/baselines/reference/exportDeclaration_missingBraces.errors.txt +++ b/tests/baselines/reference/exportDeclaration_missingBraces.errors.txt @@ -1,8 +1,8 @@ -exportDeclaration_missingBraces.ts(1,6): error TS2567: Enum declarations can only merge with namespace or other enum declarations. +exportDeclaration_missingBraces.ts(1,6): error TS2567: Enum declarations can only merge with namespace declarations. exportDeclaration_missingBraces.ts(6,7): error TS2300: Duplicate identifier 'Box'. exportDeclaration_missingBraces.ts(8,11): error TS2300: Duplicate identifier 'Circle'. exportDeclaration_missingBraces.ts(11,16): error TS1005: '=' expected. -exportDeclaration_missingBraces.ts(14,13): error TS2567: Enum declarations can only merge with namespace or other enum declarations. +exportDeclaration_missingBraces.ts(14,13): error TS2567: Enum declarations can only merge with namespace declarations. exportDeclaration_missingBraces.ts(14,20): error TS1005: '=' expected. exportDeclaration_missingBraces.ts(15,13): error TS2300: Duplicate identifier 'Box'. exportDeclaration_missingBraces.ts(15,16): error TS1005: '=' expected. @@ -14,7 +14,7 @@ exportDeclaration_missingBraces.ts(17,15): error TS1005: '=' expected. ==== exportDeclaration_missingBraces.ts (11 errors) ==== enum Numbers { ~~~~~~~ -!!! error TS2567: Enum declarations can only merge with namespace or other enum declarations. +!!! error TS2567: Enum declarations can only merge with namespace declarations. One, Two } @@ -35,7 +35,7 @@ exportDeclaration_missingBraces.ts(17,15): error TS1005: '=' expected. export type Numbers; ~~~~~~~ -!!! error TS2567: Enum declarations can only merge with namespace or other enum declarations. +!!! error TS2567: Enum declarations can only merge with namespace declarations. !!! related TS1369 exportDeclaration_missingBraces.ts:14:13: Did you mean 'export type { Numbers }'? ~ !!! error TS1005: '=' expected. diff --git a/tests/baselines/reference/forwardRefInEnum.errors.txt b/tests/baselines/reference/forwardRefInEnum.errors.txt index f56417a643d9e..d43afe858cbf0 100644 --- a/tests/baselines/reference/forwardRefInEnum.errors.txt +++ b/tests/baselines/reference/forwardRefInEnum.errors.txt @@ -1,11 +1,14 @@ +forwardRefInEnum.ts(1,6): error TS2567: Enum declarations can only merge with namespace declarations. forwardRefInEnum.ts(4,9): error TS2651: A member initializer in a enum declaration cannot reference members declared after it, including members defined in other enums. forwardRefInEnum.ts(5,10): error TS2651: A member initializer in a enum declaration cannot reference members declared after it, including members defined in other enums. -forwardRefInEnum.ts(7,9): error TS2651: A member initializer in a enum declaration cannot reference members declared after it, including members defined in other enums. -forwardRefInEnum.ts(8,10): error TS2651: A member initializer in a enum declaration cannot reference members declared after it, including members defined in other enums. +forwardRefInEnum.ts(7,12): error TS2339: Property 'Z' does not exist on type 'typeof E1'. +forwardRefInEnum.ts(11,6): error TS2567: Enum declarations can only merge with namespace declarations. -==== forwardRefInEnum.ts (4 errors) ==== +==== forwardRefInEnum.ts (5 errors) ==== enum E1 { + ~~ +!!! error TS2567: Enum declarations can only merge with namespace declarations. // illegal case // forward reference to the element of the same enum X = Y, @@ -16,14 +19,14 @@ forwardRefInEnum.ts(8,10): error TS2651: A member initializer in a enum declarat !!! error TS2651: A member initializer in a enum declaration cannot reference members declared after it, including members defined in other enums. // forward reference to the element of the same enum Y = E1.Z, - ~~~~ -!!! error TS2651: A member initializer in a enum declaration cannot reference members declared after it, including members defined in other enums. + ~ +!!! error TS2339: Property 'Z' does not exist on type 'typeof E1'. Y1 = E1["Z"] - ~~~~~~~ -!!! error TS2651: A member initializer in a enum declaration cannot reference members declared after it, including members defined in other enums. } enum E1 { + ~~ +!!! error TS2567: Enum declarations can only merge with namespace declarations. Z = 4 } \ No newline at end of file diff --git a/tests/baselines/reference/forwardRefInEnum.js b/tests/baselines/reference/forwardRefInEnum.js index ac5e142d2dccd..d7d8b10306740 100644 --- a/tests/baselines/reference/forwardRefInEnum.js +++ b/tests/baselines/reference/forwardRefInEnum.js @@ -24,8 +24,8 @@ var E1; E1[E1["X"] = 0] = "X"; E1[E1["X1"] = 0] = "X1"; // forward reference to the element of the same enum - E1[E1["Y"] = 0] = "Y"; - E1[E1["Y1"] = 0] = "Y1"; + E1[E1["Y"] = E1.Z] = "Y"; + E1[E1["Y1"] = E1["Z"]] = "Y1"; })(E1 || (E1 = {})); (function (E1) { E1[E1["Z"] = 4] = "Z"; diff --git a/tests/baselines/reference/forwardRefInEnum.symbols b/tests/baselines/reference/forwardRefInEnum.symbols index 388b18dd880a9..4bc05740173f7 100644 --- a/tests/baselines/reference/forwardRefInEnum.symbols +++ b/tests/baselines/reference/forwardRefInEnum.symbols @@ -2,7 +2,7 @@ === forwardRefInEnum.ts === enum E1 { ->E1 : Symbol(E1, Decl(forwardRefInEnum.ts, 0, 0), Decl(forwardRefInEnum.ts, 8, 1)) +>E1 : Symbol(E1, Decl(forwardRefInEnum.ts, 0, 0)) // illegal case // forward reference to the element of the same enum @@ -12,24 +12,21 @@ enum E1 { X1 = E1["Y"], >X1 : Symbol(E1.X1, Decl(forwardRefInEnum.ts, 3, 10)) ->E1 : Symbol(E1, Decl(forwardRefInEnum.ts, 0, 0), Decl(forwardRefInEnum.ts, 8, 1)) +>E1 : Symbol(E1, Decl(forwardRefInEnum.ts, 0, 0)) >"Y" : Symbol(E1.Y, Decl(forwardRefInEnum.ts, 4, 17)) // forward reference to the element of the same enum Y = E1.Z, >Y : Symbol(E1.Y, Decl(forwardRefInEnum.ts, 4, 17)) ->E1.Z : Symbol(E1.Z, Decl(forwardRefInEnum.ts, 10, 9)) ->E1 : Symbol(E1, Decl(forwardRefInEnum.ts, 0, 0), Decl(forwardRefInEnum.ts, 8, 1)) ->Z : Symbol(E1.Z, Decl(forwardRefInEnum.ts, 10, 9)) +>E1 : Symbol(E1, Decl(forwardRefInEnum.ts, 0, 0)) Y1 = E1["Z"] >Y1 : Symbol(E1.Y1, Decl(forwardRefInEnum.ts, 6, 13)) ->E1 : Symbol(E1, Decl(forwardRefInEnum.ts, 0, 0), Decl(forwardRefInEnum.ts, 8, 1)) ->"Z" : Symbol(E1.Z, Decl(forwardRefInEnum.ts, 10, 9)) +>E1 : Symbol(E1, Decl(forwardRefInEnum.ts, 0, 0)) } enum E1 { ->E1 : Symbol(E1, Decl(forwardRefInEnum.ts, 0, 0), Decl(forwardRefInEnum.ts, 8, 1)) +>E1 : Symbol(E1, Decl(forwardRefInEnum.ts, 8, 1)) Z = 4 >Z : Symbol(E1.Z, Decl(forwardRefInEnum.ts, 10, 9)) diff --git a/tests/baselines/reference/forwardRefInEnum.types b/tests/baselines/reference/forwardRefInEnum.types index 6ea5b7cdad6ef..fdedcd8cb65f2 100644 --- a/tests/baselines/reference/forwardRefInEnum.types +++ b/tests/baselines/reference/forwardRefInEnum.types @@ -10,13 +10,13 @@ enum E1 { X = Y, >X : E1.X > : ^^^^ ->Y : E1.X +>Y : E1.Y > : ^^^^ X1 = E1["Y"], >X1 : E1.X > : ^^^^ ->E1["Y"] : E1.X +>E1["Y"] : E1.Y > : ^^^^ >E1 : typeof E1 > : ^^^^^^^^^ @@ -25,20 +25,20 @@ enum E1 { // forward reference to the element of the same enum Y = E1.Z, ->Y : E1.X +>Y : E1.Y > : ^^^^ ->E1.Z : E1.Z -> : ^^^^ +>E1.Z : any +> : ^^^ >E1 : typeof E1 > : ^^^^^^^^^ ->Z : E1.Z -> : ^^^^ +>Z : any +> : ^^^ Y1 = E1["Z"] ->Y1 : E1.X -> : ^^^^ ->E1["Z"] : E1.Z -> : ^^^^ +>Y1 : E1.Y1 +> : ^^^^^ +>E1["Z"] : any +> : ^^^ >E1 : typeof E1 > : ^^^^^^^^^ >"Z" : "Z" diff --git a/tests/baselines/reference/isolatedModulesGlobalNamespacesAndEnums.errors.txt b/tests/baselines/reference/isolatedModulesGlobalNamespacesAndEnums.errors.txt index d5e4778259d40..74f729d0043cc 100644 --- a/tests/baselines/reference/isolatedModulesGlobalNamespacesAndEnums.errors.txt +++ b/tests/baselines/reference/isolatedModulesGlobalNamespacesAndEnums.errors.txt @@ -1,6 +1,12 @@ +enum1.ts(1,6): error TS2567: Enum declarations can only merge with namespace declarations. +enum1.ts(2,14): error TS2567: Enum declarations can only merge with namespace declarations. +enum2.ts(1,6): error TS2567: Enum declarations can only merge with namespace declarations. enum2.ts(2,9): error TS18055: 'Enum.D' has a string type, but must have syntactically recognizable string syntax when 'isolatedModules' is enabled. -enum2.ts(3,9): error TS1281: Cannot access 'A' from another file without qualification when 'isolatedModules' is enabled. Use 'Enum.A' instead. -enum2.ts(4,9): error TS1281: Cannot access 'X' from another file without qualification when 'isolatedModules' is enabled. Use 'Enum.X' instead. +enum2.ts(3,9): error TS2304: Cannot find name 'A'. +enum2.ts(4,9): error TS2304: Cannot find name 'X'. +enum2.ts(8,14): error TS2567: Enum declarations can only merge with namespace declarations. +enum2.ts(9,9): error TS1066: In ambient enum declarations member initializer must be constant expression. +enum2.ts(9,9): error TS2304: Cannot find name 'A'. script-namespaces.ts(1,11): error TS1280: Namespaces are not allowed in global script files when 'isolatedModules' is enabled. If this file is not intended to be a global script, set 'moduleDetection' to 'force' or add an empty 'export {}' statement. @@ -22,25 +28,39 @@ script-namespaces.ts(1,11): error TS1280: Namespaces are not allowed in global s export const x = 1; } -==== enum1.ts (0 errors) ==== +==== enum1.ts (2 errors) ==== enum Enum { A, B, C } + ~~~~ +!!! error TS2567: Enum declarations can only merge with namespace declarations. +!!! related TS6203 enum2.ts:1:6: 'Enum' was also declared here. declare enum Enum { X = 1_000_000 } + ~~~~ +!!! error TS2567: Enum declarations can only merge with namespace declarations. const d = 'd'; -==== enum2.ts (3 errors) ==== +==== enum2.ts (7 errors) ==== enum Enum { + ~~~~ +!!! error TS2567: Enum declarations can only merge with namespace declarations. +!!! related TS6203 enum1.ts:1:6: 'Enum' was also declared here. D = d, ~ !!! error TS18055: 'Enum.D' has a string type, but must have syntactically recognizable string syntax when 'isolatedModules' is enabled. E = A, // error ~ -!!! error TS1281: Cannot access 'A' from another file without qualification when 'isolatedModules' is enabled. Use 'Enum.A' instead. +!!! error TS2304: Cannot find name 'A'. Y = X, // error ~ -!!! error TS1281: Cannot access 'X' from another file without qualification when 'isolatedModules' is enabled. Use 'Enum.X' instead. +!!! error TS2304: Cannot find name 'X'. Z = Enum.A } declare enum Enum { + ~~~~ +!!! error TS2567: Enum declarations can only merge with namespace declarations. F = A + ~ +!!! error TS1066: In ambient enum declarations member initializer must be constant expression. + ~ +!!! error TS2304: Cannot find name 'A'. } \ No newline at end of file diff --git a/tests/baselines/reference/isolatedModulesGlobalNamespacesAndEnums.js b/tests/baselines/reference/isolatedModulesGlobalNamespacesAndEnums.js index c8c9a8f0aaaff..8b3e780709e1b 100644 --- a/tests/baselines/reference/isolatedModulesGlobalNamespacesAndEnums.js +++ b/tests/baselines/reference/isolatedModulesGlobalNamespacesAndEnums.js @@ -58,7 +58,7 @@ var d = 'd'; var Enum; (function (Enum) { Enum["D"] = "d"; - Enum[Enum["E"] = 0] = "E"; - Enum[Enum["Y"] = 1000000] = "Y"; + Enum[Enum["E"] = A] = "E"; + Enum[Enum["Y"] = X] = "Y"; Enum[Enum["Z"] = 0] = "Z"; })(Enum || (Enum = {})); diff --git a/tests/baselines/reference/isolatedModulesGlobalNamespacesAndEnums.symbols b/tests/baselines/reference/isolatedModulesGlobalNamespacesAndEnums.symbols index 525e5b4634762..db00024522d06 100644 --- a/tests/baselines/reference/isolatedModulesGlobalNamespacesAndEnums.symbols +++ b/tests/baselines/reference/isolatedModulesGlobalNamespacesAndEnums.symbols @@ -30,13 +30,13 @@ export namespace Instantiated { === enum1.ts === enum Enum { A, B, C } ->Enum : Symbol(Enum, Decl(enum1.ts, 0, 0), Decl(enum1.ts, 0, 21), Decl(enum2.ts, 0, 0), Decl(enum2.ts, 5, 1)) +>Enum : Symbol(Enum, Decl(enum1.ts, 0, 0)) >A : Symbol(Enum.A, Decl(enum1.ts, 0, 11)) >B : Symbol(Enum.B, Decl(enum1.ts, 0, 14)) >C : Symbol(Enum.C, Decl(enum1.ts, 0, 17)) declare enum Enum { X = 1_000_000 } ->Enum : Symbol(Enum, Decl(enum1.ts, 0, 0), Decl(enum1.ts, 0, 21), Decl(enum2.ts, 0, 0), Decl(enum2.ts, 5, 1)) +>Enum : Symbol(Enum, Decl(enum1.ts, 0, 21)) >X : Symbol(Enum.X, Decl(enum1.ts, 1, 19)) const d = 'd'; @@ -44,7 +44,7 @@ const d = 'd'; === enum2.ts === enum Enum { ->Enum : Symbol(Enum, Decl(enum1.ts, 0, 0), Decl(enum1.ts, 0, 21), Decl(enum2.ts, 0, 0), Decl(enum2.ts, 5, 1)) +>Enum : Symbol(Enum, Decl(enum2.ts, 0, 0)) D = d, >D : Symbol(Enum.D, Decl(enum2.ts, 0, 11)) @@ -52,23 +52,20 @@ enum Enum { E = A, // error >E : Symbol(Enum.E, Decl(enum2.ts, 1, 10)) ->A : Symbol(Enum.A, Decl(enum1.ts, 0, 11)) Y = X, // error >Y : Symbol(Enum.Y, Decl(enum2.ts, 2, 10)) ->X : Symbol(Enum.X, Decl(enum1.ts, 1, 19)) Z = Enum.A >Z : Symbol(Enum.Z, Decl(enum2.ts, 3, 10)) >Enum.A : Symbol(Enum.A, Decl(enum1.ts, 0, 11)) ->Enum : Symbol(Enum, Decl(enum1.ts, 0, 0), Decl(enum1.ts, 0, 21), Decl(enum2.ts, 0, 0), Decl(enum2.ts, 5, 1)) +>Enum : Symbol(Enum, Decl(enum1.ts, 0, 0)) >A : Symbol(Enum.A, Decl(enum1.ts, 0, 11)) } declare enum Enum { ->Enum : Symbol(Enum, Decl(enum1.ts, 0, 0), Decl(enum1.ts, 0, 21), Decl(enum2.ts, 0, 0), Decl(enum2.ts, 5, 1)) +>Enum : Symbol(Enum, Decl(enum2.ts, 5, 1)) F = A >F : Symbol(Enum.F, Decl(enum2.ts, 7, 19)) ->A : Symbol(Enum.A, Decl(enum1.ts, 0, 11)) } diff --git a/tests/baselines/reference/isolatedModulesGlobalNamespacesAndEnums.types b/tests/baselines/reference/isolatedModulesGlobalNamespacesAndEnums.types index f3bbaba6fbcbf..c5200c9d7273c 100644 --- a/tests/baselines/reference/isolatedModulesGlobalNamespacesAndEnums.types +++ b/tests/baselines/reference/isolatedModulesGlobalNamespacesAndEnums.types @@ -74,19 +74,19 @@ enum Enum { > : ^^^ E = A, // error ->E : Enum.A -> : ^^^^^^ ->A : Enum.A +>E : Enum.E > : ^^^^^^ +>A : any +> : ^^^ Y = X, // error ->Y : Enum.X -> : ^^^^^^ ->X : Enum.X +>Y : Enum.Y > : ^^^^^^ +>X : any +> : ^^^ Z = Enum.A ->Z : Enum.A +>Z : Enum.Z > : ^^^^^^ >Enum.A : Enum.A > : ^^^^^^ @@ -101,8 +101,8 @@ declare enum Enum { > : ^^^^ F = A ->F : Enum.A -> : ^^^^^^ ->A : Enum.A +>F : Enum.F > : ^^^^^^ +>A : any +> : ^^^ } diff --git a/tests/baselines/reference/mergedDeclarations2.errors.txt b/tests/baselines/reference/mergedDeclarations2.errors.txt index d7b6912c9426c..84c1058c1a31e 100644 --- a/tests/baselines/reference/mergedDeclarations2.errors.txt +++ b/tests/baselines/reference/mergedDeclarations2.errors.txt @@ -1,12 +1,21 @@ +mergedDeclarations2.ts(1,6): error TS2567: Enum declarations can only merge with namespace declarations. +mergedDeclarations2.ts(4,6): error TS2567: Enum declarations can only merge with namespace declarations. +mergedDeclarations2.ts(5,9): error TS2304: Cannot find name 'b'. mergedDeclarations2.ts(9,20): error TS2304: Cannot find name 'b'. -==== mergedDeclarations2.ts (1 errors) ==== +==== mergedDeclarations2.ts (4 errors) ==== enum Foo { + ~~~ +!!! error TS2567: Enum declarations can only merge with namespace declarations. b } enum Foo { + ~~~ +!!! error TS2567: Enum declarations can only merge with namespace declarations. a = b + ~ +!!! error TS2304: Cannot find name 'b'. } module Foo { diff --git a/tests/baselines/reference/mergedDeclarations2.js b/tests/baselines/reference/mergedDeclarations2.js index b12581beed202..0f1757f5ac73f 100644 --- a/tests/baselines/reference/mergedDeclarations2.js +++ b/tests/baselines/reference/mergedDeclarations2.js @@ -18,7 +18,7 @@ var Foo; Foo[Foo["b"] = 0] = "b"; })(Foo || (Foo = {})); (function (Foo) { - Foo[Foo["a"] = 0] = "a"; + Foo[Foo["a"] = b] = "a"; })(Foo || (Foo = {})); (function (Foo) { Foo.x = b; diff --git a/tests/baselines/reference/mergedDeclarations2.symbols b/tests/baselines/reference/mergedDeclarations2.symbols index 9c2f56838a51e..1e089ef391868 100644 --- a/tests/baselines/reference/mergedDeclarations2.symbols +++ b/tests/baselines/reference/mergedDeclarations2.symbols @@ -2,21 +2,20 @@ === mergedDeclarations2.ts === enum Foo { ->Foo : Symbol(Foo, Decl(mergedDeclarations2.ts, 0, 0), Decl(mergedDeclarations2.ts, 2, 1), Decl(mergedDeclarations2.ts, 5, 1)) +>Foo : Symbol(Foo, Decl(mergedDeclarations2.ts, 0, 0), Decl(mergedDeclarations2.ts, 5, 1)) b >b : Symbol(Foo.b, Decl(mergedDeclarations2.ts, 0, 10)) } enum Foo { ->Foo : Symbol(Foo, Decl(mergedDeclarations2.ts, 0, 0), Decl(mergedDeclarations2.ts, 2, 1), Decl(mergedDeclarations2.ts, 5, 1)) +>Foo : Symbol(Foo, Decl(mergedDeclarations2.ts, 2, 1)) a = b >a : Symbol(Foo.a, Decl(mergedDeclarations2.ts, 3, 10)) ->b : Symbol(Foo.b, Decl(mergedDeclarations2.ts, 0, 10)) } module Foo { ->Foo : Symbol(Foo, Decl(mergedDeclarations2.ts, 0, 0), Decl(mergedDeclarations2.ts, 2, 1), Decl(mergedDeclarations2.ts, 5, 1)) +>Foo : Symbol(Foo, Decl(mergedDeclarations2.ts, 0, 0), Decl(mergedDeclarations2.ts, 5, 1)) export var x = b >x : Symbol(x, Decl(mergedDeclarations2.ts, 8, 14)) diff --git a/tests/baselines/reference/mergedDeclarations2.types b/tests/baselines/reference/mergedDeclarations2.types index c4feff20c96b1..e717f39f21fa6 100644 --- a/tests/baselines/reference/mergedDeclarations2.types +++ b/tests/baselines/reference/mergedDeclarations2.types @@ -14,9 +14,9 @@ enum Foo { > : ^^^ a = b ->a : Foo.b +>a : Foo.a > : ^^^^^ ->b : Foo +>b : any > : ^^^ } diff --git a/tests/baselines/reference/mergedEnumDeclarationCodeGen.errors.txt b/tests/baselines/reference/mergedEnumDeclarationCodeGen.errors.txt new file mode 100644 index 0000000000000..21ef376b332f5 --- /dev/null +++ b/tests/baselines/reference/mergedEnumDeclarationCodeGen.errors.txt @@ -0,0 +1,19 @@ +mergedEnumDeclarationCodeGen.ts(1,6): error TS2567: Enum declarations can only merge with namespace declarations. +mergedEnumDeclarationCodeGen.ts(5,6): error TS2567: Enum declarations can only merge with namespace declarations. +mergedEnumDeclarationCodeGen.ts(6,9): error TS2304: Cannot find name 'a'. + + +==== mergedEnumDeclarationCodeGen.ts (3 errors) ==== + enum E { + ~ +!!! error TS2567: Enum declarations can only merge with namespace declarations. + a, + b = a + } + enum E { + ~ +!!! error TS2567: Enum declarations can only merge with namespace declarations. + c = a + ~ +!!! error TS2304: Cannot find name 'a'. + } \ No newline at end of file diff --git a/tests/baselines/reference/mergedEnumDeclarationCodeGen.js b/tests/baselines/reference/mergedEnumDeclarationCodeGen.js index ba996221a7699..47662dfdac78a 100644 --- a/tests/baselines/reference/mergedEnumDeclarationCodeGen.js +++ b/tests/baselines/reference/mergedEnumDeclarationCodeGen.js @@ -16,5 +16,5 @@ var E; E[E["b"] = 0] = "b"; })(E || (E = {})); (function (E) { - E[E["c"] = 0] = "c"; + E[E["c"] = a] = "c"; })(E || (E = {})); diff --git a/tests/baselines/reference/mergedEnumDeclarationCodeGen.symbols b/tests/baselines/reference/mergedEnumDeclarationCodeGen.symbols index 8ae95b278fc00..dbe521f105dd9 100644 --- a/tests/baselines/reference/mergedEnumDeclarationCodeGen.symbols +++ b/tests/baselines/reference/mergedEnumDeclarationCodeGen.symbols @@ -2,7 +2,7 @@ === mergedEnumDeclarationCodeGen.ts === enum E { ->E : Symbol(E, Decl(mergedEnumDeclarationCodeGen.ts, 0, 0), Decl(mergedEnumDeclarationCodeGen.ts, 3, 1)) +>E : Symbol(E, Decl(mergedEnumDeclarationCodeGen.ts, 0, 0)) a, >a : Symbol(E.a, Decl(mergedEnumDeclarationCodeGen.ts, 0, 8)) @@ -12,9 +12,8 @@ enum E { >a : Symbol(E.a, Decl(mergedEnumDeclarationCodeGen.ts, 0, 8)) } enum E { ->E : Symbol(E, Decl(mergedEnumDeclarationCodeGen.ts, 0, 0), Decl(mergedEnumDeclarationCodeGen.ts, 3, 1)) +>E : Symbol(E, Decl(mergedEnumDeclarationCodeGen.ts, 3, 1)) c = a >c : Symbol(E.c, Decl(mergedEnumDeclarationCodeGen.ts, 4, 8)) ->a : Symbol(E.a, Decl(mergedEnumDeclarationCodeGen.ts, 0, 8)) } diff --git a/tests/baselines/reference/mergedEnumDeclarationCodeGen.types b/tests/baselines/reference/mergedEnumDeclarationCodeGen.types index 22b7eb2a1e609..edca710180808 100644 --- a/tests/baselines/reference/mergedEnumDeclarationCodeGen.types +++ b/tests/baselines/reference/mergedEnumDeclarationCodeGen.types @@ -20,8 +20,8 @@ enum E { > : ^ c = a ->c : E.a +>c : E.c +> : ^^^ +>a : any > : ^^^ ->a : E -> : ^ } diff --git a/tests/baselines/reference/moduleAugmentationEnumClassMergeOfReexportIsError.errors.txt b/tests/baselines/reference/moduleAugmentationEnumClassMergeOfReexportIsError.errors.txt index 0f4cb39d33e03..15eb263632580 100644 --- a/tests/baselines/reference/moduleAugmentationEnumClassMergeOfReexportIsError.errors.txt +++ b/tests/baselines/reference/moduleAugmentationEnumClassMergeOfReexportIsError.errors.txt @@ -1,11 +1,11 @@ -augment.ts(4,17): error TS2567: Enum declarations can only merge with namespace or other enum declarations. -file.ts(1,14): error TS2567: Enum declarations can only merge with namespace or other enum declarations. +augment.ts(4,17): error TS2567: Enum declarations can only merge with namespace declarations. +file.ts(1,14): error TS2567: Enum declarations can only merge with namespace declarations. ==== file.ts (1 errors) ==== export class Foo { ~~~ -!!! error TS2567: Enum declarations can only merge with namespace or other enum declarations. +!!! error TS2567: Enum declarations can only merge with namespace declarations. !!! related TS6203 augment.ts:4:17: 'Foo' was also declared here. member: string; } @@ -17,7 +17,7 @@ file.ts(1,14): error TS2567: Enum declarations can only merge with namespace or declare module "./reexport" { export enum Foo { ~~~ -!!! error TS2567: Enum declarations can only merge with namespace or other enum declarations. +!!! error TS2567: Enum declarations can only merge with namespace declarations. !!! related TS6203 file.ts:1:14: 'Foo' was also declared here. A, B, C } diff --git a/tests/baselines/reference/moduleDuplicateIdentifiers.errors.txt b/tests/baselines/reference/moduleDuplicateIdentifiers.errors.txt index 01ed54e736e46..9a4d64427413d 100644 --- a/tests/baselines/reference/moduleDuplicateIdentifiers.errors.txt +++ b/tests/baselines/reference/moduleDuplicateIdentifiers.errors.txt @@ -2,9 +2,11 @@ moduleDuplicateIdentifiers.ts(1,12): error TS2323: Cannot redeclare exported var moduleDuplicateIdentifiers.ts(2,12): error TS2323: Cannot redeclare exported variable 'Foo'. moduleDuplicateIdentifiers.ts(20,14): error TS2300: Duplicate identifier 'Kettle'. moduleDuplicateIdentifiers.ts(24,14): error TS2300: Duplicate identifier 'Kettle'. +moduleDuplicateIdentifiers.ts(31,13): error TS2567: Enum declarations can only merge with namespace declarations. +moduleDuplicateIdentifiers.ts(37,13): error TS2567: Enum declarations can only merge with namespace declarations. -==== moduleDuplicateIdentifiers.ts (4 errors) ==== +==== moduleDuplicateIdentifiers.ts (6 errors) ==== export var Foo = 2; ~~~ !!! error TS2323: Cannot redeclare exported variable 'Foo'. @@ -44,12 +46,16 @@ moduleDuplicateIdentifiers.ts(24,14): error TS2300: Duplicate identifier 'Kettle Pot = 42; // Shouldn't error export enum Utensils { + ~~~~~~~~ +!!! error TS2567: Enum declarations can only merge with namespace declarations. Spoon, Fork, Knife } export enum Utensils { // Shouldn't error + ~~~~~~~~ +!!! error TS2567: Enum declarations can only merge with namespace declarations. Spork = 3 } \ No newline at end of file diff --git a/tests/baselines/reference/moduleDuplicateIdentifiers.js b/tests/baselines/reference/moduleDuplicateIdentifiers.js index 334cccebd5428..bca5728079938 100644 --- a/tests/baselines/reference/moduleDuplicateIdentifiers.js +++ b/tests/baselines/reference/moduleDuplicateIdentifiers.js @@ -76,7 +76,7 @@ var Utensils; Utensils[Utensils["Spoon"] = 0] = "Spoon"; Utensils[Utensils["Fork"] = 1] = "Fork"; Utensils[Utensils["Knife"] = 2] = "Knife"; -})(Utensils || (exports.Utensils = Utensils = {})); +})(Utensils || (Utensils = {})); (function (Utensils) { Utensils[Utensils["Spork"] = 3] = "Spork"; -})(Utensils || (exports.Utensils = Utensils = {})); +})(Utensils || (Utensils = {})); diff --git a/tests/baselines/reference/moduleDuplicateIdentifiers.symbols b/tests/baselines/reference/moduleDuplicateIdentifiers.symbols index c8e336c801a73..645c7d04390df 100644 --- a/tests/baselines/reference/moduleDuplicateIdentifiers.symbols +++ b/tests/baselines/reference/moduleDuplicateIdentifiers.symbols @@ -56,7 +56,7 @@ Pot = 42; // Shouldn't error >Pot : Symbol(Pot, Decl(moduleDuplicateIdentifiers.ts, 27, 10)) export enum Utensils { ->Utensils : Symbol(Utensils, Decl(moduleDuplicateIdentifiers.ts, 28, 9), Decl(moduleDuplicateIdentifiers.ts, 34, 1)) +>Utensils : Symbol(Utensils, Decl(moduleDuplicateIdentifiers.ts, 28, 9)) Spoon, >Spoon : Symbol(Utensils.Spoon, Decl(moduleDuplicateIdentifiers.ts, 30, 22)) @@ -69,7 +69,7 @@ export enum Utensils { } export enum Utensils { // Shouldn't error ->Utensils : Symbol(Utensils, Decl(moduleDuplicateIdentifiers.ts, 28, 9), Decl(moduleDuplicateIdentifiers.ts, 34, 1)) +>Utensils : Symbol(Utensils, Decl(moduleDuplicateIdentifiers.ts, 34, 1)) Spork = 3 >Spork : Symbol(Utensils.Spork, Decl(moduleDuplicateIdentifiers.ts, 36, 22)) diff --git a/tests/baselines/reference/moduleDuplicateIdentifiers.types b/tests/baselines/reference/moduleDuplicateIdentifiers.types index bf218b7140163..be19fa4c5e67d 100644 --- a/tests/baselines/reference/moduleDuplicateIdentifiers.types +++ b/tests/baselines/reference/moduleDuplicateIdentifiers.types @@ -101,12 +101,12 @@ export enum Utensils { } export enum Utensils { // Shouldn't error ->Utensils : Utensils -> : ^^^^^^^^ +>Utensils : import("moduleDuplicateIdentifiers").Utensils +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Spork = 3 ->Spork : Utensils.Spork -> : ^^^^^^^^^^^^^^ +>Spork : import("moduleDuplicateIdentifiers").Utensils.Spork +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ >3 : 3 > : ^ } diff --git a/tests/baselines/reference/reservedWords2.errors.txt b/tests/baselines/reference/reservedWords2.errors.txt index 4686d7ff69204..938e67ad0a3b2 100644 --- a/tests/baselines/reference/reservedWords2.errors.txt +++ b/tests/baselines/reference/reservedWords2.errors.txt @@ -3,7 +3,7 @@ reservedWords2.ts(1,14): error TS1005: '(' expected. reservedWords2.ts(1,16): error TS2580: Cannot find name 'require'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. reservedWords2.ts(1,31): error TS1005: ')' expected. reservedWords2.ts(2,12): error TS2300: Duplicate identifier '(Missing)'. -reservedWords2.ts(2,12): error TS2567: Enum declarations can only merge with namespace or other enum declarations. +reservedWords2.ts(2,12): error TS2567: Enum declarations can only merge with namespace declarations. reservedWords2.ts(2,14): error TS1359: Identifier expected. 'while' is a reserved word that cannot be used here. reservedWords2.ts(2,20): error TS1005: '(' expected. reservedWords2.ts(2,20): error TS2304: Cannot find name 'from'. @@ -11,7 +11,7 @@ reservedWords2.ts(2,25): error TS1005: ')' expected. reservedWords2.ts(4,5): error TS1389: 'typeof' is not allowed as a variable declaration name. reservedWords2.ts(4,12): error TS1109: Expression expected. reservedWords2.ts(5,9): error TS2300: Duplicate identifier '(Missing)'. -reservedWords2.ts(5,9): error TS2567: Enum declarations can only merge with namespace or other enum declarations. +reservedWords2.ts(5,9): error TS2567: Enum declarations can only merge with namespace declarations. reservedWords2.ts(5,10): error TS1359: Identifier expected. 'throw' is a reserved word that cannot be used here. reservedWords2.ts(5,18): error TS1005: '=>' expected. reservedWords2.ts(6,1): error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. @@ -28,7 +28,7 @@ reservedWords2.ts(9,6): error TS1181: Array element destructuring pattern expect reservedWords2.ts(9,14): error TS1005: ';' expected. reservedWords2.ts(9,18): error TS1005: '(' expected. reservedWords2.ts(9,20): error TS1128: Declaration or statement expected. -reservedWords2.ts(10,5): error TS2567: Enum declarations can only merge with namespace or other enum declarations. +reservedWords2.ts(10,5): error TS2567: Enum declarations can only merge with namespace declarations. reservedWords2.ts(10,6): error TS1359: Identifier expected. 'void' is a reserved word that cannot be used here. reservedWords2.ts(11,12): error TS1359: Identifier expected. 'default' is a reserved word that cannot be used here. reservedWords2.ts(12,13): error TS1359: Identifier expected. 'null' is a reserved word that cannot be used here. @@ -49,7 +49,7 @@ reservedWords2.ts(12,17): error TS1138: Parameter declaration expected. !!! error TS2300: Duplicate identifier '(Missing)'. -!!! error TS2567: Enum declarations can only merge with namespace or other enum declarations. +!!! error TS2567: Enum declarations can only merge with namespace declarations. ~~~~~ !!! error TS1359: Identifier expected. 'while' is a reserved word that cannot be used here. ~~~~ @@ -68,7 +68,7 @@ reservedWords2.ts(12,17): error TS1138: Parameter declaration expected. !!! error TS2300: Duplicate identifier '(Missing)'. -!!! error TS2567: Enum declarations can only merge with namespace or other enum declarations. +!!! error TS2567: Enum declarations can only merge with namespace declarations. ~~~~~ !!! error TS1359: Identifier expected. 'throw' is a reserved word that cannot be used here. ~ @@ -107,7 +107,7 @@ reservedWords2.ts(12,17): error TS1138: Parameter declaration expected. !!! error TS1128: Declaration or statement expected. enum void {} -!!! error TS2567: Enum declarations can only merge with namespace or other enum declarations. +!!! error TS2567: Enum declarations can only merge with namespace declarations. ~~~~ !!! error TS1359: Identifier expected. 'void' is a reserved word that cannot be used here. function f(default: number) {} diff --git a/tests/baselines/reference/reservedWords3.errors.txt b/tests/baselines/reference/reservedWords3.errors.txt index aeb3f0173429c..5b4fcdb494dd0 100644 --- a/tests/baselines/reference/reservedWords3.errors.txt +++ b/tests/baselines/reference/reservedWords3.errors.txt @@ -1,10 +1,10 @@ reservedWords3.ts(1,13): error TS1390: 'enum' is not allowed as a parameter name. -reservedWords3.ts(1,17): error TS2567: Enum declarations can only merge with namespace or other enum declarations. +reservedWords3.ts(1,17): error TS2567: Enum declarations can only merge with namespace declarations. reservedWords3.ts(1,17): error TS1003: Identifier expected. reservedWords3.ts(2,13): error TS1390: 'class' is not allowed as a parameter name. reservedWords3.ts(2,18): error TS1005: '{' expected. reservedWords3.ts(3,13): error TS1390: 'function' is not allowed as a parameter name. -reservedWords3.ts(3,21): error TS2567: Enum declarations can only merge with namespace or other enum declarations. +reservedWords3.ts(3,21): error TS2567: Enum declarations can only merge with namespace declarations. reservedWords3.ts(3,21): error TS1003: Identifier expected. reservedWords3.ts(4,13): error TS1390: 'while' is not allowed as a parameter name. reservedWords3.ts(4,18): error TS1005: '(' expected. @@ -17,7 +17,7 @@ reservedWords3.ts(5,16): error TS1005: '(' expected. ~~~~ !!! error TS1390: 'enum' is not allowed as a parameter name. -!!! error TS2567: Enum declarations can only merge with namespace or other enum declarations. +!!! error TS2567: Enum declarations can only merge with namespace declarations. ~ !!! error TS1003: Identifier expected. function f2(class) {} @@ -29,7 +29,7 @@ reservedWords3.ts(5,16): error TS1005: '(' expected. ~~~~~~~~ !!! error TS1390: 'function' is not allowed as a parameter name. -!!! error TS2567: Enum declarations can only merge with namespace or other enum declarations. +!!! error TS2567: Enum declarations can only merge with namespace declarations. ~ !!! error TS1003: Identifier expected. function f4(while) {} diff --git a/tests/baselines/reference/typeOfEnumAndVarRedeclarations.errors.txt b/tests/baselines/reference/typeOfEnumAndVarRedeclarations.errors.txt index 2b3a5240b3608..e60fe20637861 100644 --- a/tests/baselines/reference/typeOfEnumAndVarRedeclarations.errors.txt +++ b/tests/baselines/reference/typeOfEnumAndVarRedeclarations.errors.txt @@ -1,14 +1,20 @@ +typeOfEnumAndVarRedeclarations.ts(1,6): error TS2567: Enum declarations can only merge with namespace declarations. +typeOfEnumAndVarRedeclarations.ts(4,6): error TS2567: Enum declarations can only merge with namespace declarations. typeOfEnumAndVarRedeclarations.ts(8,5): error TS2403: Subsequent variable declarations must have the same type. Variable 'x' must be of type 'typeof E', but here has type '{ readonly [x: number]: string; readonly a: E; readonly b: E; }'. typeOfEnumAndVarRedeclarations.ts(10,5): error TS2403: Subsequent variable declarations must have the same type. Variable 'y' must be of type 'typeof E', but here has type '{ readonly [x: number]: string; readonly a: E; readonly b: E; }'. typeOfEnumAndVarRedeclarations.ts(10,40): error TS2374: Duplicate index signature for type 'number'. typeOfEnumAndVarRedeclarations.ts(10,70): error TS2374: Duplicate index signature for type 'number'. -==== typeOfEnumAndVarRedeclarations.ts (4 errors) ==== +==== typeOfEnumAndVarRedeclarations.ts (6 errors) ==== enum E { + ~ +!!! error TS2567: Enum declarations can only merge with namespace declarations. a } enum E { + ~ +!!! error TS2567: Enum declarations can only merge with namespace declarations. b = 1 } var x = E; diff --git a/tests/baselines/reference/typeOfEnumAndVarRedeclarations.symbols b/tests/baselines/reference/typeOfEnumAndVarRedeclarations.symbols index de9b49260ef93..ede60a8b32726 100644 --- a/tests/baselines/reference/typeOfEnumAndVarRedeclarations.symbols +++ b/tests/baselines/reference/typeOfEnumAndVarRedeclarations.symbols @@ -2,39 +2,39 @@ === typeOfEnumAndVarRedeclarations.ts === enum E { ->E : Symbol(E, Decl(typeOfEnumAndVarRedeclarations.ts, 0, 0), Decl(typeOfEnumAndVarRedeclarations.ts, 2, 1)) +>E : Symbol(E, Decl(typeOfEnumAndVarRedeclarations.ts, 0, 0)) a >a : Symbol(E.a, Decl(typeOfEnumAndVarRedeclarations.ts, 0, 8)) } enum E { ->E : Symbol(E, Decl(typeOfEnumAndVarRedeclarations.ts, 0, 0), Decl(typeOfEnumAndVarRedeclarations.ts, 2, 1)) +>E : Symbol(E, Decl(typeOfEnumAndVarRedeclarations.ts, 2, 1)) b = 1 >b : Symbol(E.b, Decl(typeOfEnumAndVarRedeclarations.ts, 3, 8)) } var x = E; >x : Symbol(x, Decl(typeOfEnumAndVarRedeclarations.ts, 6, 3), Decl(typeOfEnumAndVarRedeclarations.ts, 7, 3)) ->E : Symbol(E, Decl(typeOfEnumAndVarRedeclarations.ts, 0, 0), Decl(typeOfEnumAndVarRedeclarations.ts, 2, 1)) +>E : Symbol(E, Decl(typeOfEnumAndVarRedeclarations.ts, 0, 0)) var x: { readonly a: E; readonly b: E; readonly [x: number]: string; }; // Shouldnt error >x : Symbol(x, Decl(typeOfEnumAndVarRedeclarations.ts, 6, 3), Decl(typeOfEnumAndVarRedeclarations.ts, 7, 3)) >a : Symbol(a, Decl(typeOfEnumAndVarRedeclarations.ts, 7, 8)) ->E : Symbol(E, Decl(typeOfEnumAndVarRedeclarations.ts, 0, 0), Decl(typeOfEnumAndVarRedeclarations.ts, 2, 1)) +>E : Symbol(E, Decl(typeOfEnumAndVarRedeclarations.ts, 0, 0)) >b : Symbol(b, Decl(typeOfEnumAndVarRedeclarations.ts, 7, 23)) ->E : Symbol(E, Decl(typeOfEnumAndVarRedeclarations.ts, 0, 0), Decl(typeOfEnumAndVarRedeclarations.ts, 2, 1)) +>E : Symbol(E, Decl(typeOfEnumAndVarRedeclarations.ts, 0, 0)) >x : Symbol(x, Decl(typeOfEnumAndVarRedeclarations.ts, 7, 49)) var y = E; >y : Symbol(y, Decl(typeOfEnumAndVarRedeclarations.ts, 8, 3), Decl(typeOfEnumAndVarRedeclarations.ts, 9, 3)) ->E : Symbol(E, Decl(typeOfEnumAndVarRedeclarations.ts, 0, 0), Decl(typeOfEnumAndVarRedeclarations.ts, 2, 1)) +>E : Symbol(E, Decl(typeOfEnumAndVarRedeclarations.ts, 0, 0)) var y: { readonly a: E; readonly b: E; readonly [x: number]: string; readonly [x: number]: string } // two errors: the types are not identical and duplicate signatures >y : Symbol(y, Decl(typeOfEnumAndVarRedeclarations.ts, 8, 3), Decl(typeOfEnumAndVarRedeclarations.ts, 9, 3)) >a : Symbol(a, Decl(typeOfEnumAndVarRedeclarations.ts, 9, 8)) ->E : Symbol(E, Decl(typeOfEnumAndVarRedeclarations.ts, 0, 0), Decl(typeOfEnumAndVarRedeclarations.ts, 2, 1)) +>E : Symbol(E, Decl(typeOfEnumAndVarRedeclarations.ts, 0, 0)) >b : Symbol(b, Decl(typeOfEnumAndVarRedeclarations.ts, 9, 23)) ->E : Symbol(E, Decl(typeOfEnumAndVarRedeclarations.ts, 0, 0), Decl(typeOfEnumAndVarRedeclarations.ts, 2, 1)) +>E : Symbol(E, Decl(typeOfEnumAndVarRedeclarations.ts, 0, 0)) >x : Symbol(x, Decl(typeOfEnumAndVarRedeclarations.ts, 9, 49)) >x : Symbol(x, Decl(typeOfEnumAndVarRedeclarations.ts, 9, 79)) diff --git a/tests/cases/compiler/autonumberingInEnums.ts b/tests/cases/compiler/autonumberingInEnums.ts index 728980d43bba2..6cb18e6cdd206 100644 --- a/tests/cases/compiler/autonumberingInEnums.ts +++ b/tests/cases/compiler/autonumberingInEnums.ts @@ -3,5 +3,5 @@ enum Foo { } enum Foo { - b // should work fine + b } \ No newline at end of file diff --git a/tests/cases/fourslash/memberListInReopenedEnum.ts b/tests/cases/fourslash/memberListInReopenedEnum.ts index 70dae89b7820d..bbddf45181c6d 100644 --- a/tests/cases/fourslash/memberListInReopenedEnum.ts +++ b/tests/cases/fourslash/memberListInReopenedEnum.ts @@ -15,7 +15,5 @@ verify.completions({ exact: [ { name: "A", text: "(enum member) E.A = 0" }, { name: "B", text: "(enum member) E.B = 1" }, - { name: "C", text: "(enum member) E.C = 0" }, - { name: "D", text: "(enum member) E.D = 1" }, ], });