From 813d227e370c280f276a3e218402c2f760f896e1 Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Wed, 27 May 2015 16:31:29 -0700 Subject: [PATCH 01/31] classInterface: changed excludes flags --- src/compiler/types.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/compiler/types.ts b/src/compiler/types.ts index c8d22b2672863..87a887da5da8b 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -1339,8 +1339,8 @@ module ts { PropertyExcludes = Value, EnumMemberExcludes = Value, FunctionExcludes = Value & ~(Function | ValueModule), - ClassExcludes = (Value | Type) & ~ValueModule, - InterfaceExcludes = Type & ~Interface, + ClassExcludes = (Value | Type) & ~(ValueModule | Interface), + InterfaceExcludes = Type & ~(Class | Interface), RegularEnumExcludes = (Value | Type) & ~(RegularEnum | ValueModule), // regular enums merge only with regular enums and modules ConstEnumExcludes = (Value | Type) & ~ConstEnum, // const enums merge only with const enums ValueModuleExcludes = Value & ~(Function | Class | RegularEnum | ValueModule), From 18abf470c25cb839829c97fc2c3e5e98ef4a2b18 Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Mon, 1 Jun 2015 09:17:09 -0700 Subject: [PATCH 02/31] Revert "classInterface: changed excludes flags" This reverts commit 813d227e370c280f276a3e218402c2f760f896e1. --- src/compiler/types.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 87a887da5da8b..c8d22b2672863 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -1339,8 +1339,8 @@ module ts { PropertyExcludes = Value, EnumMemberExcludes = Value, FunctionExcludes = Value & ~(Function | ValueModule), - ClassExcludes = (Value | Type) & ~(ValueModule | Interface), - InterfaceExcludes = Type & ~(Class | Interface), + ClassExcludes = (Value | Type) & ~ValueModule, + InterfaceExcludes = Type & ~Interface, RegularEnumExcludes = (Value | Type) & ~(RegularEnum | ValueModule), // regular enums merge only with regular enums and modules ConstEnumExcludes = (Value | Type) & ~ConstEnum, // const enums merge only with const enums ValueModuleExcludes = Value & ~(Function | Class | RegularEnum | ValueModule), From 05500f4577aa7761e46dc5ddcbd3a2e644c4c079 Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Mon, 1 Jun 2015 14:49:11 -0700 Subject: [PATCH 03/31] Added merged declarations for ambient class/interfaces --- src/compiler/binder.ts | 42 +++++++++++++++++++++++++++++++----------- src/compiler/types.ts | 3 ++- 2 files changed, 33 insertions(+), 12 deletions(-) diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index b66497fc40d59..15370d5e9db32 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -6,8 +6,8 @@ module ts { export const enum ModuleInstanceState { NonInstantiated = 0, - Instantiated = 1, - ConstEnumOnly = 2 + Instantiated = 1, + ConstEnumOnly = 2 } export function getModuleInstanceState(node: Node): ModuleInstanceState { @@ -135,6 +135,26 @@ module ts { return node.name ? declarationNameToString(node.name) : getDeclarationName(node); } + /* internal */ + /** + * Checks if the symbol contains a class declaration declaration that is non-ambient. + */ + function hasNonAmbientClass(symbol: Symbol): boolean { + if (symbol) { + return !! forEach(symbol.declarations, (element: Declaration, index: number) => { + return (element.kind === SyntaxKind.ClassDeclaration && !(element.flags & NodeFlags.Ambient)) + }); + } + } + + /** + * Declares a Symbol for the Node and add it to symbols. Reports errors for conflicting identifier names, + * @param symbols - The symbolTable which node will be added to. + * @param parent - If node is in a class, parent denotes the parent declaration. + * @param node - The declaration to be added to the symbol table + * @param includes - The SymbolFlags that node has in addition to its declaration type (eg: export, ambient, etc.) + * @param excludes - The flags which node cannot be declared alongside in a symbol table. Used to report forbidden declarations. + */ function declareSymbol(symbols: SymbolTable, parent: Symbol, node: Declaration, includes: SymbolFlags, excludes: SymbolFlags): Symbol { Debug.assert(!hasDynamicName(node)); @@ -144,15 +164,15 @@ module ts { let symbol: Symbol; if (name !== undefined) { symbol = hasProperty(symbols, name) ? symbols[name] : (symbols[name] = createSymbol(0, name)); - if (symbol.flags & excludes) { - if (node.name) { - node.name.parent = node; - } + if (symbol.flags & excludes || (node.kind === SyntaxKind.InterfaceDeclaration && hasNonAmbientClass(symbol)) ) { + if (node.name) { + node.name.parent = node; + } // Report errors every position with duplicate declaration // Report errors on previous encountered declarations let message = symbol.flags & SymbolFlags.BlockScopedVariable - ? Diagnostics.Cannot_redeclare_block_scoped_variable_0 + ? Diagnostics.Cannot_redeclare_block_scoped_variable_0 : Diagnostics.Duplicate_identifier_0; forEach(symbol.declarations, declaration => { @@ -249,7 +269,7 @@ module ts { // these cases are: // - node has locals (symbolKind & HasLocals) !== 0 // - node is a source file - setBlockScopeContainer(node, /*cleanLocals*/ (symbolKind & SymbolFlags.HasLocals) === 0 && node.kind !== SyntaxKind.SourceFile); + setBlockScopeContainer(node, /*cleanLocals*/(symbolKind & SymbolFlags.HasLocals) === 0 && node.kind !== SyntaxKind.SourceFile); } forEachChild(node, bind); @@ -403,7 +423,7 @@ module ts { declareModuleMember(node, symbolKind, symbolExcludes); break; } - // fall through. + // fall through. default: if (!blockScopeContainer.locals) { blockScopeContainer.locals = {}; @@ -424,7 +444,7 @@ module ts { function bind(node: Node) { node.parent = parent; - + switch (node.kind) { case SyntaxKind.TypeParameter: bindDeclaration(node, SymbolFlags.TypeParameter, SymbolFlags.TypeParameterExcludes, /*isBlockScopeContainer*/ false); @@ -516,7 +536,7 @@ module ts { bindCatchVariableDeclaration(node); break; case SyntaxKind.ClassDeclaration: - bindBlockScopedDeclaration(node, SymbolFlags.Class, SymbolFlags.ClassExcludes); + bindBlockScopedDeclaration(node, SymbolFlags.Class, isAmbientContext(node) ? SymbolFlags.AmbientClassExcludes : SymbolFlags.ClassExcludes); break; case SyntaxKind.InterfaceDeclaration: bindDeclaration(node, SymbolFlags.Interface, SymbolFlags.InterfaceExcludes, /*isBlockScopeContainer*/ false); diff --git a/src/compiler/types.ts b/src/compiler/types.ts index c8d22b2672863..807d8ce756464 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -1340,7 +1340,8 @@ module ts { EnumMemberExcludes = Value, FunctionExcludes = Value & ~(Function | ValueModule), ClassExcludes = (Value | Type) & ~ValueModule, - InterfaceExcludes = Type & ~Interface, + AmbientClassExcludes = (Value | Type) & ~(ValueModule | Interface), + InterfaceExcludes = Type & ~(Interface | Class), RegularEnumExcludes = (Value | Type) & ~(RegularEnum | ValueModule), // regular enums merge only with regular enums and modules ConstEnumExcludes = (Value | Type) & ~ConstEnum, // const enums merge only with const enums ValueModuleExcludes = Value & ~(Function | Class | RegularEnum | ValueModule), From 6c98c677146ec32b9c41122daffc6946ef1c599c Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Mon, 1 Jun 2015 16:26:41 -0700 Subject: [PATCH 04/31] added conformance tests --- ...lassAndInterfaceMergeConflictingMembers.ts | 23 +++++++++++++++++++ .../declaredClassMergedwithSelf.ts | 9 ++++++++ .../classDeclarations/mergedClassInterface.ts | 11 +++++++++ 3 files changed, 43 insertions(+) create mode 100644 tests/cases/conformance/classes/classDeclarations/classAndInterfaceMergeConflictingMembers.ts create mode 100644 tests/cases/conformance/classes/classDeclarations/declaredClassMergedwithSelf.ts create mode 100644 tests/cases/conformance/classes/classDeclarations/mergedClassInterface.ts diff --git a/tests/cases/conformance/classes/classDeclarations/classAndInterfaceMergeConflictingMembers.ts b/tests/cases/conformance/classes/classDeclarations/classAndInterfaceMergeConflictingMembers.ts new file mode 100644 index 0000000000000..d11d67c3feabb --- /dev/null +++ b/tests/cases/conformance/classes/classDeclarations/classAndInterfaceMergeConflictingMembers.ts @@ -0,0 +1,23 @@ +declare class C1 { + public x : number; +} + +interface C1 { + x : number; +} + +declare class C2 { + protected x : number; +} + +interface C2 { + x : number; +} + +declare class C3 { + private x : number; +} + +interface C3 { + x : number; +} \ No newline at end of file diff --git a/tests/cases/conformance/classes/classDeclarations/declaredClassMergedwithSelf.ts b/tests/cases/conformance/classes/classDeclarations/declaredClassMergedwithSelf.ts new file mode 100644 index 0000000000000..4688fec9e2679 --- /dev/null +++ b/tests/cases/conformance/classes/classDeclarations/declaredClassMergedwithSelf.ts @@ -0,0 +1,9 @@ +declare class C1 {} + +declare class C1 {} + +declare class C2 {} + +interface C2 {} + +declare class C2 {} \ No newline at end of file diff --git a/tests/cases/conformance/classes/classDeclarations/mergedClassInterface.ts b/tests/cases/conformance/classes/classDeclarations/mergedClassInterface.ts new file mode 100644 index 0000000000000..4fac95b516ab8 --- /dev/null +++ b/tests/cases/conformance/classes/classDeclarations/mergedClassInterface.ts @@ -0,0 +1,11 @@ +declare class C1 {} + +interface C1 {} + +interface C2 {} + +declare class C2 {} + +interface C2 {} + +interface C2 {} \ No newline at end of file From b864df2fd4715ad291ca834583f43bcca385d927 Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Mon, 1 Jun 2015 16:39:41 -0700 Subject: [PATCH 05/31] New Baselines for class-interface merging --- ...nterfaceMergeConflictingMembers.errors.txt | 44 +++++++++++++++++++ ...lassAndInterfaceMergeConflictingMembers.js | 26 +++++++++++ .../declaredClassMergedwithSelf.errors.txt | 27 ++++++++++++ .../reference/declaredClassMergedwithSelf.js | 12 +++++ .../reference/mergedClassInterface.js | 14 ++++++ .../reference/mergedClassInterface.symbols | 19 ++++++++ .../reference/mergedClassInterface.types | 19 ++++++++ 7 files changed, 161 insertions(+) create mode 100644 tests/baselines/reference/classAndInterfaceMergeConflictingMembers.errors.txt create mode 100644 tests/baselines/reference/classAndInterfaceMergeConflictingMembers.js create mode 100644 tests/baselines/reference/declaredClassMergedwithSelf.errors.txt create mode 100644 tests/baselines/reference/declaredClassMergedwithSelf.js create mode 100644 tests/baselines/reference/mergedClassInterface.js create mode 100644 tests/baselines/reference/mergedClassInterface.symbols create mode 100644 tests/baselines/reference/mergedClassInterface.types diff --git a/tests/baselines/reference/classAndInterfaceMergeConflictingMembers.errors.txt b/tests/baselines/reference/classAndInterfaceMergeConflictingMembers.errors.txt new file mode 100644 index 0000000000000..48e52faae1e78 --- /dev/null +++ b/tests/baselines/reference/classAndInterfaceMergeConflictingMembers.errors.txt @@ -0,0 +1,44 @@ +tests/cases/conformance/classes/classDeclarations/classAndInterfaceMergeConflictingMembers.ts(2,12): error TS2300: Duplicate identifier 'x'. +tests/cases/conformance/classes/classDeclarations/classAndInterfaceMergeConflictingMembers.ts(6,5): error TS2300: Duplicate identifier 'x'. +tests/cases/conformance/classes/classDeclarations/classAndInterfaceMergeConflictingMembers.ts(10,15): error TS2300: Duplicate identifier 'x'. +tests/cases/conformance/classes/classDeclarations/classAndInterfaceMergeConflictingMembers.ts(14,5): error TS2300: Duplicate identifier 'x'. +tests/cases/conformance/classes/classDeclarations/classAndInterfaceMergeConflictingMembers.ts(18,13): error TS2300: Duplicate identifier 'x'. +tests/cases/conformance/classes/classDeclarations/classAndInterfaceMergeConflictingMembers.ts(22,5): error TS2300: Duplicate identifier 'x'. + + +==== tests/cases/conformance/classes/classDeclarations/classAndInterfaceMergeConflictingMembers.ts (6 errors) ==== + declare class C1 { + public x : number; + ~ +!!! error TS2300: Duplicate identifier 'x'. + } + + interface C1 { + x : number; + ~ +!!! error TS2300: Duplicate identifier 'x'. + } + + declare class C2 { + protected x : number; + ~ +!!! error TS2300: Duplicate identifier 'x'. + } + + interface C2 { + x : number; + ~ +!!! error TS2300: Duplicate identifier 'x'. + } + + declare class C3 { + private x : number; + ~ +!!! error TS2300: Duplicate identifier 'x'. + } + + interface C3 { + x : number; + ~ +!!! error TS2300: Duplicate identifier 'x'. + } \ No newline at end of file diff --git a/tests/baselines/reference/classAndInterfaceMergeConflictingMembers.js b/tests/baselines/reference/classAndInterfaceMergeConflictingMembers.js new file mode 100644 index 0000000000000..07b425383f439 --- /dev/null +++ b/tests/baselines/reference/classAndInterfaceMergeConflictingMembers.js @@ -0,0 +1,26 @@ +//// [classAndInterfaceMergeConflictingMembers.ts] +declare class C1 { + public x : number; +} + +interface C1 { + x : number; +} + +declare class C2 { + protected x : number; +} + +interface C2 { + x : number; +} + +declare class C3 { + private x : number; +} + +interface C3 { + x : number; +} + +//// [classAndInterfaceMergeConflictingMembers.js] diff --git a/tests/baselines/reference/declaredClassMergedwithSelf.errors.txt b/tests/baselines/reference/declaredClassMergedwithSelf.errors.txt new file mode 100644 index 0000000000000..8a783639c1c9a --- /dev/null +++ b/tests/baselines/reference/declaredClassMergedwithSelf.errors.txt @@ -0,0 +1,27 @@ +tests/cases/conformance/classes/classDeclarations/declaredClassMergedwithSelf.ts(1,15): error TS2300: Duplicate identifier 'C1'. +tests/cases/conformance/classes/classDeclarations/declaredClassMergedwithSelf.ts(3,15): error TS2300: Duplicate identifier 'C1'. +tests/cases/conformance/classes/classDeclarations/declaredClassMergedwithSelf.ts(5,15): error TS2300: Duplicate identifier 'C2'. +tests/cases/conformance/classes/classDeclarations/declaredClassMergedwithSelf.ts(7,11): error TS2300: Duplicate identifier 'C2'. +tests/cases/conformance/classes/classDeclarations/declaredClassMergedwithSelf.ts(9,15): error TS2300: Duplicate identifier 'C2'. + + +==== tests/cases/conformance/classes/classDeclarations/declaredClassMergedwithSelf.ts (5 errors) ==== + declare class C1 {} + ~~ +!!! error TS2300: Duplicate identifier 'C1'. + + declare class C1 {} + ~~ +!!! error TS2300: Duplicate identifier 'C1'. + + declare class C2 {} + ~~ +!!! error TS2300: Duplicate identifier 'C2'. + + interface C2 {} + ~~ +!!! error TS2300: Duplicate identifier 'C2'. + + declare class C2 {} + ~~ +!!! error TS2300: Duplicate identifier 'C2'. \ No newline at end of file diff --git a/tests/baselines/reference/declaredClassMergedwithSelf.js b/tests/baselines/reference/declaredClassMergedwithSelf.js new file mode 100644 index 0000000000000..85213668adc48 --- /dev/null +++ b/tests/baselines/reference/declaredClassMergedwithSelf.js @@ -0,0 +1,12 @@ +//// [declaredClassMergedwithSelf.ts] +declare class C1 {} + +declare class C1 {} + +declare class C2 {} + +interface C2 {} + +declare class C2 {} + +//// [declaredClassMergedwithSelf.js] diff --git a/tests/baselines/reference/mergedClassInterface.js b/tests/baselines/reference/mergedClassInterface.js new file mode 100644 index 0000000000000..70c8b7d2b2f69 --- /dev/null +++ b/tests/baselines/reference/mergedClassInterface.js @@ -0,0 +1,14 @@ +//// [mergedClassInterface.ts] +declare class C1 {} + +interface C1 {} + +interface C2 {} + +declare class C2 {} + +interface C2 {} + +interface C2 {} + +//// [mergedClassInterface.js] diff --git a/tests/baselines/reference/mergedClassInterface.symbols b/tests/baselines/reference/mergedClassInterface.symbols new file mode 100644 index 0000000000000..dc7ba89155109 --- /dev/null +++ b/tests/baselines/reference/mergedClassInterface.symbols @@ -0,0 +1,19 @@ +=== tests/cases/conformance/classes/classDeclarations/mergedClassInterface.ts === +declare class C1 {} +>C1 : Symbol(C1, Decl(mergedClassInterface.ts, 0, 0), Decl(mergedClassInterface.ts, 0, 19)) + +interface C1 {} +>C1 : Symbol(C1, Decl(mergedClassInterface.ts, 0, 0), Decl(mergedClassInterface.ts, 0, 19)) + +interface C2 {} +>C2 : Symbol(C2, Decl(mergedClassInterface.ts, 2, 15), Decl(mergedClassInterface.ts, 4, 15), Decl(mergedClassInterface.ts, 6, 19), Decl(mergedClassInterface.ts, 8, 15)) + +declare class C2 {} +>C2 : Symbol(C2, Decl(mergedClassInterface.ts, 2, 15), Decl(mergedClassInterface.ts, 4, 15), Decl(mergedClassInterface.ts, 6, 19), Decl(mergedClassInterface.ts, 8, 15)) + +interface C2 {} +>C2 : Symbol(C2, Decl(mergedClassInterface.ts, 2, 15), Decl(mergedClassInterface.ts, 4, 15), Decl(mergedClassInterface.ts, 6, 19), Decl(mergedClassInterface.ts, 8, 15)) + +interface C2 {} +>C2 : Symbol(C2, Decl(mergedClassInterface.ts, 2, 15), Decl(mergedClassInterface.ts, 4, 15), Decl(mergedClassInterface.ts, 6, 19), Decl(mergedClassInterface.ts, 8, 15)) + diff --git a/tests/baselines/reference/mergedClassInterface.types b/tests/baselines/reference/mergedClassInterface.types new file mode 100644 index 0000000000000..a31f147b7344f --- /dev/null +++ b/tests/baselines/reference/mergedClassInterface.types @@ -0,0 +1,19 @@ +=== tests/cases/conformance/classes/classDeclarations/mergedClassInterface.ts === +declare class C1 {} +>C1 : C1 + +interface C1 {} +>C1 : C1 + +interface C2 {} +>C2 : C2 + +declare class C2 {} +>C2 : C2 + +interface C2 {} +>C2 : C2 + +interface C2 {} +>C2 : C2 + From ed46bc3b588de7bb53209a9678d60ba64c076c30 Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Mon, 1 Jun 2015 16:43:43 -0700 Subject: [PATCH 06/31] Fixed intendation typo --- src/compiler/binder.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index 32fc5872ef671..6d91d11990c5b 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -164,10 +164,10 @@ module ts { let symbol: Symbol; if (name !== undefined) { symbol = hasProperty(symbols, name) ? symbols[name] : (symbols[name] = createSymbol(0, name)); - if (symbol.flags & excludes || (node.kind === SyntaxKind.InterfaceDeclaration && hasNonAmbientClass(symbol)) ) { - if (node.name) { - node.name.parent = node; - } + if (symbol.flags & excludes || (node.kind === SyntaxKind.InterfaceDeclaration && hasNonAmbientClass(symbol))) { + if (node.name) { + node.name.parent = node; + } // Report errors every position with duplicate declaration // Report errors on previous encountered declarations @@ -269,7 +269,7 @@ module ts { // these cases are: // - node has locals (symbolKind & HasLocals) !== 0 // - node is a source file - setBlockScopeContainer(node, /*cleanLocals*/(symbolKind & SymbolFlags.HasLocals) === 0 && node.kind !== SyntaxKind.SourceFile); + setBlockScopeContainer(node, /*cleanLocals*/ (symbolKind & SymbolFlags.HasLocals) === 0 && node.kind !== SyntaxKind.SourceFile); } forEachChild(node, bind); From d25b91032f96ba5a0a4d92f6a7bcca84b2c598b7 Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Mon, 1 Jun 2015 16:45:11 -0700 Subject: [PATCH 07/31] fixed indentation --- src/compiler/binder.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index 6d91d11990c5b..7c38b2ecb908a 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -6,8 +6,8 @@ module ts { export const enum ModuleInstanceState { NonInstantiated = 0, - Instantiated = 1, - ConstEnumOnly = 2 + Instantiated = 1, + ConstEnumOnly = 2 } export function getModuleInstanceState(node: Node): ModuleInstanceState { From 1f74b134f1ece1276a00f03836853ac3e3fe67c4 Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Tue, 2 Jun 2015 09:30:28 -0700 Subject: [PATCH 08/31] fixed style, added comment --- src/compiler/binder.ts | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index 7c38b2ecb908a..975f890927e00 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -135,14 +135,13 @@ module ts { return node.name ? declarationNameToString(node.name) : getDeclarationName(node); } - /* internal */ /** - * Checks if the symbol contains a class declaration declaration that is non-ambient. + * Checks if the symbol contains a class declaration that is non-ambient. */ function hasNonAmbientClass(symbol: Symbol): boolean { if (symbol) { - return !! forEach(symbol.declarations, (element: Declaration, index: number) => { - return (element.kind === SyntaxKind.ClassDeclaration && !(element.flags & NodeFlags.Ambient)) + return forEach(symbol.declarations, (element: Declaration) => { + return element.kind === SyntaxKind.ClassDeclaration && !(element.flags & NodeFlags.Ambient); }); } } @@ -164,6 +163,9 @@ module ts { let symbol: Symbol; if (name !== undefined) { symbol = hasProperty(symbols, name) ? symbols[name] : (symbols[name] = createSymbol(0, name)); + + // Check for declarations node cannot be merged with. + // Interfaces declarations cannot be merged with non-ambient class declarations, which isn't encoded in SymbolFlags. if (symbol.flags & excludes || (node.kind === SyntaxKind.InterfaceDeclaration && hasNonAmbientClass(symbol))) { if (node.name) { node.name.parent = node; @@ -423,7 +425,7 @@ module ts { declareModuleMember(node, symbolKind, symbolExcludes); break; } - // fall through. + // fall through. default: if (!blockScopeContainer.locals) { blockScopeContainer.locals = {}; From 2d77cbdc06d7b0ef9a3e653ce0bae86a6b38a79e Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Tue, 2 Jun 2015 10:49:22 -0700 Subject: [PATCH 09/31] cleaner hasNonAmbientClass --- src/compiler/binder.ts | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index 975f890927e00..30514c84e4004 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -139,11 +139,9 @@ module ts { * Checks if the symbol contains a class declaration that is non-ambient. */ function hasNonAmbientClass(symbol: Symbol): boolean { - if (symbol) { - return forEach(symbol.declarations, (element: Declaration) => { - return element.kind === SyntaxKind.ClassDeclaration && !(element.flags & NodeFlags.Ambient); - }); - } + return symbol && forEach(symbol.declarations, (element: Declaration) => { + return element.kind === SyntaxKind.ClassDeclaration && !(element.flags & NodeFlags.Ambient); + }); } /** From edc4611341680ea6cb7a446c73defccc83e87132 Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Tue, 2 Jun 2015 11:27:40 -0700 Subject: [PATCH 10/31] removed comma --- src/compiler/binder.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index 30514c84e4004..b417892d3543f 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -145,7 +145,7 @@ module ts { } /** - * Declares a Symbol for the Node and add it to symbols. Reports errors for conflicting identifier names, + * Declares a Symbol for the Node and add it to symbols. Reports errors for conflicting identifier names. * @param symbols - The symbolTable which node will be added to. * @param parent - If node is in a class, parent denotes the parent declaration. * @param node - The declaration to be added to the symbol table @@ -162,7 +162,7 @@ module ts { if (name !== undefined) { symbol = hasProperty(symbols, name) ? symbols[name] : (symbols[name] = createSymbol(0, name)); - // Check for declarations node cannot be merged with. + // Check for declarations 'node' cannot be merged with. // Interfaces declarations cannot be merged with non-ambient class declarations, which isn't encoded in SymbolFlags. if (symbol.flags & excludes || (node.kind === SyntaxKind.InterfaceDeclaration && hasNonAmbientClass(symbol))) { if (node.name) { From a50ab3ebb00d381974ad0308aaff2c4c9091be4c Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Tue, 2 Jun 2015 12:20:36 -0700 Subject: [PATCH 11/31] Remove checking in declareSymbol --- src/compiler/binder.ts | 20 ++++++++++---------- src/compiler/types.ts | 3 +-- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index b417892d3543f..60b5a622ac65a 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -135,14 +135,14 @@ module ts { return node.name ? declarationNameToString(node.name) : getDeclarationName(node); } - /** - * Checks if the symbol contains a class declaration that is non-ambient. - */ - function hasNonAmbientClass(symbol: Symbol): boolean { - return symbol && forEach(symbol.declarations, (element: Declaration) => { - return element.kind === SyntaxKind.ClassDeclaration && !(element.flags & NodeFlags.Ambient); - }); - } + // /** + // * Checks if the symbol contains a class declaration that is non-ambient. + // */ + // function hasNonAmbientClass(symbol: Symbol): boolean { + // return symbol && forEach(symbol.declarations, (element: Declaration) => { + // return element.kind === SyntaxKind.ClassDeclaration && !(element.flags & NodeFlags.Ambient); + // }); + // } /** * Declares a Symbol for the Node and add it to symbols. Reports errors for conflicting identifier names. @@ -164,7 +164,7 @@ module ts { // Check for declarations 'node' cannot be merged with. // Interfaces declarations cannot be merged with non-ambient class declarations, which isn't encoded in SymbolFlags. - if (symbol.flags & excludes || (node.kind === SyntaxKind.InterfaceDeclaration && hasNonAmbientClass(symbol))) { + if (symbol.flags & excludes) { if (node.name) { node.name.parent = node; } @@ -536,7 +536,7 @@ module ts { bindCatchVariableDeclaration(node); break; case SyntaxKind.ClassDeclaration: - bindBlockScopedDeclaration(node, SymbolFlags.Class, isAmbientContext(node) ? SymbolFlags.AmbientClassExcludes : SymbolFlags.ClassExcludes); + bindBlockScopedDeclaration(node, SymbolFlags.Class, SymbolFlags.ClassExcludes); break; case SyntaxKind.InterfaceDeclaration: bindBlockScopedDeclaration(node, SymbolFlags.Interface, SymbolFlags.InterfaceExcludes); diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 890c6968de9fe..ec5a8de00513d 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -1472,8 +1472,7 @@ module ts { PropertyExcludes = Value, EnumMemberExcludes = Value, FunctionExcludes = Value & ~(Function | ValueModule), - ClassExcludes = (Value | Type) & ~ValueModule, - AmbientClassExcludes = (Value | Type) & ~(ValueModule | Interface), + ClassExcludes = (Value | Type) & ~(ValueModule | Interface), // 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 ConstEnumExcludes = (Value | Type) & ~ConstEnum, // const enums merge only with const enums From 90e19551bc71f25473eaf559f27611ccb89b8474 Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Tue, 2 Jun 2015 15:03:01 -0700 Subject: [PATCH 12/31] merge compatiblity now performed in checker.ts --- src/compiler/binder.ts | 12 +------- src/compiler/checker.ts | 28 +++++++++++++++++++ .../diagnosticInformationMap.generated.ts | 2 ++ src/compiler/diagnosticMessages.json | 17 +++++++---- 4 files changed, 43 insertions(+), 16 deletions(-) diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index 60b5a622ac65a..42c22eda571d7 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -135,15 +135,6 @@ module ts { return node.name ? declarationNameToString(node.name) : getDeclarationName(node); } - // /** - // * Checks if the symbol contains a class declaration that is non-ambient. - // */ - // function hasNonAmbientClass(symbol: Symbol): boolean { - // return symbol && forEach(symbol.declarations, (element: Declaration) => { - // return element.kind === SyntaxKind.ClassDeclaration && !(element.flags & NodeFlags.Ambient); - // }); - // } - /** * Declares a Symbol for the Node and add it to symbols. Reports errors for conflicting identifier names. * @param symbols - The symbolTable which node will be added to. @@ -162,8 +153,7 @@ module ts { if (name !== undefined) { symbol = hasProperty(symbols, name) ? symbols[name] : (symbols[name] = createSymbol(0, name)); - // Check for declarations 'node' cannot be merged with. - // Interfaces declarations cannot be merged with non-ambient class declarations, which isn't encoded in SymbolFlags. + // Check for declarations 'node' cannot be merged with. if (symbol.flags & excludes) { if (node.name) { node.name.parent = node; diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 759b235ad0a9b..20b0fc6d68e98 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -10393,6 +10393,15 @@ module ts { }); } + // Non-ambient classes cannot merge with interfaces. + if (!(node.flags & NodeFlags.Ambient)) { + if (forEach(symbol.declarations, (element: Declaration) => { + return element.kind === SyntaxKind.InterfaceDeclaration; + })) { + error(node, Diagnostics.A_non_ambient_class_cannot_be_merged_with_an_interface) + } + } + forEach(node.members, checkSourceElement); if (produceDiagnostics) { checkIndexConstraints(type); @@ -10544,6 +10553,15 @@ module ts { return ok; } + /** + * Checks if the symbol contains a class declaration that is non-ambient. + */ + function hasNonAmbientClass(symbol: Symbol): boolean { + return symbol && forEach(symbol.declarations, (element: Declaration) => { + return element.kind === SyntaxKind.ClassDeclaration && !(element.flags & NodeFlags.Ambient); + }); + } + function checkInterfaceDeclaration(node: InterfaceDeclaration) { // Grammar checking checkGrammarDeclarationNameInStrictMode(node) || checkGrammarDecorators(node) || checkGrammarModifiers(node) || checkGrammarInterfaceDeclaration(node); @@ -10572,6 +10590,13 @@ module ts { checkIndexConstraints(type); } } + + // Interfaces cannot merge with non-ambient classes. + if (!(node.flags & NodeFlags.Ambient)) { + if (hasNonAmbientClass(symbol)) { + error(node, Diagnostics.An_interface_cannot_merge_with_a_non_ambient_class); + } + } } forEach(getInterfaceBaseTypeNodes(node), heritageElement => { if (!isSupportedExpressionWithTypeArguments(heritageElement)) { @@ -10580,6 +10605,9 @@ module ts { checkExpressionWithTypeArguments(heritageElement); }); + + + forEach(node.members, checkSourceElement); if (produceDiagnostics) { diff --git a/src/compiler/diagnosticInformationMap.generated.ts b/src/compiler/diagnosticInformationMap.generated.ts index 6e73d28bdddd1..2d7fd358f7088 100644 --- a/src/compiler/diagnosticInformationMap.generated.ts +++ b/src/compiler/diagnosticInformationMap.generated.ts @@ -371,6 +371,8 @@ module ts { Cannot_find_namespace_0: { code: 2503, category: DiagnosticCategory.Error, key: "Cannot find namespace '{0}'." }, No_best_common_type_exists_among_yield_expressions: { code: 2504, category: DiagnosticCategory.Error, key: "No best common type exists among yield expressions." }, A_generator_cannot_have_a_void_type_annotation: { code: 2505, category: DiagnosticCategory.Error, key: "A generator cannot have a 'void' type annotation." }, + A_non_ambient_class_cannot_be_merged_with_an_interface: { code: 2506, category: DiagnosticCategory.Error, key: "A non-ambient class cannot be merged with an interface." }, + An_interface_cannot_merge_with_a_non_ambient_class: { code: 2507, category: DiagnosticCategory.Error, key: "An interface cannot merge with a non-ambient class." }, Import_declaration_0_is_using_private_name_1: { code: 4000, category: DiagnosticCategory.Error, key: "Import declaration '{0}' is using private name '{1}'." }, Type_parameter_0_of_exported_class_has_or_is_using_private_name_1: { code: 4002, category: DiagnosticCategory.Error, key: "Type parameter '{0}' of exported class has or is using private name '{1}'." }, Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1: { code: 4004, category: DiagnosticCategory.Error, key: "Type parameter '{0}' of exported interface has or is using private name '{1}'." }, diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index d5764605d51bb..fdf3598518961 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -1456,15 +1456,15 @@ "A rest element cannot contain a binding pattern.": { "category": "Error", "code": 2501 - }, + }, "'{0}' is referenced directly or indirectly in its own type annotation.": { "category": "Error", "code": 2502 - }, + }, "Cannot find namespace '{0}'.": { "category": "Error", "code": 2503 - }, + }, "No best common type exists among yield expressions.": { "category": "Error", "code": 2504 @@ -1472,8 +1472,15 @@ "A generator cannot have a 'void' type annotation.": { "category": "Error", "code": 2505 - }, - + }, + "A non-ambient class cannot be merged with an interface.": { + "category": "Error", + "code": 2506 + }, + "An interface cannot merge with a non-ambient class.": { + "category": "Error", + "code": 2507 + }, "Import declaration '{0}' is using private name '{1}'.": { "category": "Error", "code": 4000 From c629c3fbee82ab3057b43076134574a94f30edaf Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Tue, 2 Jun 2015 15:15:23 -0700 Subject: [PATCH 13/31] deleted redundant tests --- tests/cases/compiler/class1.ts | 2 -- tests/cases/compiler/classAndInterface1.ts | 2 -- 2 files changed, 4 deletions(-) delete mode 100644 tests/cases/compiler/class1.ts delete mode 100644 tests/cases/compiler/classAndInterface1.ts diff --git a/tests/cases/compiler/class1.ts b/tests/cases/compiler/class1.ts deleted file mode 100644 index c7b2115b88b28..0000000000000 --- a/tests/cases/compiler/class1.ts +++ /dev/null @@ -1,2 +0,0 @@ -interface foo{ } // error -class foo{ } // error \ No newline at end of file diff --git a/tests/cases/compiler/classAndInterface1.ts b/tests/cases/compiler/classAndInterface1.ts deleted file mode 100644 index 79b029158572e..0000000000000 --- a/tests/cases/compiler/classAndInterface1.ts +++ /dev/null @@ -1,2 +0,0 @@ - class cli { } // error -interface cli { } // error \ No newline at end of file From e4bc29e9a036f7b82a30cfb5dd06b72510571f0e Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Tue, 2 Jun 2015 15:22:52 -0700 Subject: [PATCH 14/31] Updated tests --- ...uplicateIdentifiersAcrossFileBoundaries.ts | 33 +++++++++++ .../classAndInterfaceMerge.d.ts | 25 +++++++++ .../declaredClassMergedwithSelf.ts | 13 ++++- .../classDeclarations/mergedClassInterface.ts | 55 +++++++++++++++++-- 4 files changed, 119 insertions(+), 7 deletions(-) create mode 100644 tests/cases/compiler/duplicateIdentifiersAcrossFileBoundaries.ts create mode 100644 tests/cases/conformance/classes/classDeclarations/classAndInterfaceMerge.d.ts diff --git a/tests/cases/compiler/duplicateIdentifiersAcrossFileBoundaries.ts b/tests/cases/compiler/duplicateIdentifiersAcrossFileBoundaries.ts new file mode 100644 index 0000000000000..94e5cd94ab188 --- /dev/null +++ b/tests/cases/compiler/duplicateIdentifiersAcrossFileBoundaries.ts @@ -0,0 +1,33 @@ +// @declaration: true + +// @Filename: file1.ts +interface I { } +class C1 { } +class C2 { } +function f() { } +var v = 3; + +class Foo { + static x: number; +} + +module N { + export module F { + var t; + } +} + +// @Filename: file2.ts +class I { } // error -- cannot merge interface with non-ambient class +interface C1 { } // error -- cannot merge interface with non-ambient class +function C2() { } // error -- cannot merge function with non-ambient class +class f { } // error -- cannot merge function with non-ambient class +var v = 3; + +module Foo { + export var x: number; // error for redeclaring var in a different parent +} + +declare module N { + export function F(); // no error because function is ambient +} diff --git a/tests/cases/conformance/classes/classDeclarations/classAndInterfaceMerge.d.ts b/tests/cases/conformance/classes/classDeclarations/classAndInterfaceMerge.d.ts new file mode 100644 index 0000000000000..1ef7724f81d30 --- /dev/null +++ b/tests/cases/conformance/classes/classDeclarations/classAndInterfaceMerge.d.ts @@ -0,0 +1,25 @@ + +interface C { } + +declare class C { } + +interface C { } + +interface C { } + +declare module M { + + interface C1 { } + + class C1 { } + + interface C1 { } + + interface C1 { } + + export class C2 { } +} + +declare module M { + export interface C2 { } +} \ No newline at end of file diff --git a/tests/cases/conformance/classes/classDeclarations/declaredClassMergedwithSelf.ts b/tests/cases/conformance/classes/classDeclarations/declaredClassMergedwithSelf.ts index 4688fec9e2679..7445104e22833 100644 --- a/tests/cases/conformance/classes/classDeclarations/declaredClassMergedwithSelf.ts +++ b/tests/cases/conformance/classes/classDeclarations/declaredClassMergedwithSelf.ts @@ -1,3 +1,6 @@ + +// @Filename: file1.ts + declare class C1 {} declare class C1 {} @@ -6,4 +9,12 @@ declare class C2 {} interface C2 {} -declare class C2 {} \ No newline at end of file +declare class C2 {} + +// @Filename: file2.ts + +declare class C3 { } + +// @Filename: file3.ts + +declare class C3 { } \ No newline at end of file diff --git a/tests/cases/conformance/classes/classDeclarations/mergedClassInterface.ts b/tests/cases/conformance/classes/classDeclarations/mergedClassInterface.ts index 4fac95b516ab8..29400c63808b8 100644 --- a/tests/cases/conformance/classes/classDeclarations/mergedClassInterface.ts +++ b/tests/cases/conformance/classes/classDeclarations/mergedClassInterface.ts @@ -1,11 +1,54 @@ -declare class C1 {} +// @declaration: true -interface C1 {} +// @Filename: file1.ts -interface C2 {} +declare class C1 { } -declare class C2 {} +interface C1 { } -interface C2 {} +interface C2 { } -interface C2 {} \ No newline at end of file +declare class C2 { } + +class C3 { } // error -- cannot merge non-ambient class and interface + +interface C3 { } // error -- cannot merge non-ambient class and interface + +interface C4 { } // error -- cannot merge non-ambient class and interface + +class C4 { } // error -- cannot merge non-ambient class and interface + +interface C5 { + x1: number; +} + +declare class C5 { + x2: number; +} + +interface C5 { + x3: number; +} + +interface C5 { + x4: number; +} + +// checks if properties actually were merged +var c5 : C5; +c5.x1; +c5.x2; +c5.x3; +c5.x4; + +// @Filename: file2.ts + +declare class C6 { } + +interface C7 { } + +// @Filename: file3.ts + +interface C6 { } + +declare class C7 { } \ No newline at end of file From b293da4f9bec122ef3b7761b4d3606661f2f0e03 Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Tue, 2 Jun 2015 15:26:43 -0700 Subject: [PATCH 15/31] updated baselines --- .../reference/augmentedTypesClass2.errors.txt | 8 +- .../augmentedTypesInterface.errors.txt | 8 +- tests/baselines/reference/class1.errors.txt | 11 -- tests/baselines/reference/class1.js | 10 -- .../reference/classAndInterface1.errors.txt | 11 -- .../baselines/reference/classAndInterface1.js | 10 -- .../classAndInterfaceMerge.d.errors.txt | 46 +++++++ .../classAndInterfaceWithSameName.errors.txt | 30 +++-- .../reference/clinterfaces.errors.txt | 32 ++--- tests/baselines/reference/clinterfaces.js | 1 + .../baselines/reference/declInput.errors.txt | 8 +- .../declaredClassMergedwithSelf.errors.txt | 30 +++-- .../reference/declaredClassMergedwithSelf.js | 20 ++- ...ifiersAcrossContainerBoundaries.errors.txt | 8 +- ...IdentifiersAcrossFileBoundaries.errors.txt | 67 ++++++++++ ...uplicateIdentifiersAcrossFileBoundaries.js | 76 +++++++++++ .../interfaceDeclaration2.errors.txt | 8 +- .../reference/mergedClassInterface.errors.txt | 67 ++++++++++ .../reference/mergedClassInterface.js | 119 ++++++++++++++++-- .../reference/mergedClassInterface.symbols | 19 --- .../reference/mergedClassInterface.types | 19 --- .../reference/nameCollisions.errors.txt | 16 +-- ...tringsArrayTypeDefinedInES5Mode.errors.txt | 14 +-- ...ingsArrayTypeRedefinedInES6Mode.errors.txt | 14 +-- 24 files changed, 487 insertions(+), 165 deletions(-) delete mode 100644 tests/baselines/reference/class1.errors.txt delete mode 100644 tests/baselines/reference/class1.js delete mode 100644 tests/baselines/reference/classAndInterface1.errors.txt delete mode 100644 tests/baselines/reference/classAndInterface1.js create mode 100644 tests/baselines/reference/classAndInterfaceMerge.d.errors.txt create mode 100644 tests/baselines/reference/duplicateIdentifiersAcrossFileBoundaries.errors.txt create mode 100644 tests/baselines/reference/duplicateIdentifiersAcrossFileBoundaries.js create mode 100644 tests/baselines/reference/mergedClassInterface.errors.txt delete mode 100644 tests/baselines/reference/mergedClassInterface.symbols delete mode 100644 tests/baselines/reference/mergedClassInterface.types diff --git a/tests/baselines/reference/augmentedTypesClass2.errors.txt b/tests/baselines/reference/augmentedTypesClass2.errors.txt index 5881e49dae92d..2622429d74395 100644 --- a/tests/baselines/reference/augmentedTypesClass2.errors.txt +++ b/tests/baselines/reference/augmentedTypesClass2.errors.txt @@ -1,5 +1,5 @@ -tests/cases/compiler/augmentedTypesClass2.ts(4,7): error TS2300: Duplicate identifier 'c11'. -tests/cases/compiler/augmentedTypesClass2.ts(10,11): error TS2300: Duplicate identifier 'c11'. +tests/cases/compiler/augmentedTypesClass2.ts(4,7): error TS2506: A non-ambient class cannot be merged with an interface. +tests/cases/compiler/augmentedTypesClass2.ts(10,11): error TS2507: An interface cannot merge with a non-ambient class. tests/cases/compiler/augmentedTypesClass2.ts(16,7): error TS2300: Duplicate identifier 'c33'. tests/cases/compiler/augmentedTypesClass2.ts(21,6): error TS2300: Duplicate identifier 'c33'. @@ -10,7 +10,7 @@ tests/cases/compiler/augmentedTypesClass2.ts(21,6): error TS2300: Duplicate iden // class then interface class c11 { // error ~~~ -!!! error TS2300: Duplicate identifier 'c11'. +!!! error TS2506: A non-ambient class cannot be merged with an interface. foo() { return 1; } @@ -18,7 +18,7 @@ tests/cases/compiler/augmentedTypesClass2.ts(21,6): error TS2300: Duplicate iden interface c11 { // error ~~~ -!!! error TS2300: Duplicate identifier 'c11'. +!!! error TS2507: An interface cannot merge with a non-ambient class. bar(): void; } diff --git a/tests/baselines/reference/augmentedTypesInterface.errors.txt b/tests/baselines/reference/augmentedTypesInterface.errors.txt index a9fc28dd5ae57..9719539b344ed 100644 --- a/tests/baselines/reference/augmentedTypesInterface.errors.txt +++ b/tests/baselines/reference/augmentedTypesInterface.errors.txt @@ -1,5 +1,5 @@ -tests/cases/compiler/augmentedTypesInterface.ts(12,11): error TS2300: Duplicate identifier 'i2'. -tests/cases/compiler/augmentedTypesInterface.ts(16,7): error TS2300: Duplicate identifier 'i2'. +tests/cases/compiler/augmentedTypesInterface.ts(12,11): error TS2507: An interface cannot merge with a non-ambient class. +tests/cases/compiler/augmentedTypesInterface.ts(16,7): error TS2506: A non-ambient class cannot be merged with an interface. tests/cases/compiler/augmentedTypesInterface.ts(23,11): error TS2300: Duplicate identifier 'i3'. tests/cases/compiler/augmentedTypesInterface.ts(26,6): error TS2300: Duplicate identifier 'i3'. @@ -18,13 +18,13 @@ tests/cases/compiler/augmentedTypesInterface.ts(26,6): error TS2300: Duplicate i // interface then class interface i2 { // error ~~ -!!! error TS2300: Duplicate identifier 'i2'. +!!! error TS2507: An interface cannot merge with a non-ambient class. foo(): void; } class i2 { // error ~~ -!!! error TS2300: Duplicate identifier 'i2'. +!!! error TS2506: A non-ambient class cannot be merged with an interface. bar() { return 1; } diff --git a/tests/baselines/reference/class1.errors.txt b/tests/baselines/reference/class1.errors.txt deleted file mode 100644 index b90fae9cb402e..0000000000000 --- a/tests/baselines/reference/class1.errors.txt +++ /dev/null @@ -1,11 +0,0 @@ -tests/cases/compiler/class1.ts(1,11): error TS2300: Duplicate identifier 'foo'. -tests/cases/compiler/class1.ts(2,7): error TS2300: Duplicate identifier 'foo'. - - -==== tests/cases/compiler/class1.ts (2 errors) ==== - interface foo{ } // error - ~~~ -!!! error TS2300: Duplicate identifier 'foo'. - class foo{ } // error - ~~~ -!!! error TS2300: Duplicate identifier 'foo'. \ No newline at end of file diff --git a/tests/baselines/reference/class1.js b/tests/baselines/reference/class1.js deleted file mode 100644 index 7a104e237b6c0..0000000000000 --- a/tests/baselines/reference/class1.js +++ /dev/null @@ -1,10 +0,0 @@ -//// [class1.ts] -interface foo{ } // error -class foo{ } // error - -//// [class1.js] -var foo = (function () { - function foo() { - } - return foo; -})(); // error diff --git a/tests/baselines/reference/classAndInterface1.errors.txt b/tests/baselines/reference/classAndInterface1.errors.txt deleted file mode 100644 index 8d31e847d71e7..0000000000000 --- a/tests/baselines/reference/classAndInterface1.errors.txt +++ /dev/null @@ -1,11 +0,0 @@ -tests/cases/compiler/classAndInterface1.ts(1,8): error TS2300: Duplicate identifier 'cli'. -tests/cases/compiler/classAndInterface1.ts(2,11): error TS2300: Duplicate identifier 'cli'. - - -==== tests/cases/compiler/classAndInterface1.ts (2 errors) ==== - class cli { } // error - ~~~ -!!! error TS2300: Duplicate identifier 'cli'. - interface cli { } // error - ~~~ -!!! error TS2300: Duplicate identifier 'cli'. \ No newline at end of file diff --git a/tests/baselines/reference/classAndInterface1.js b/tests/baselines/reference/classAndInterface1.js deleted file mode 100644 index 5efabded83813..0000000000000 --- a/tests/baselines/reference/classAndInterface1.js +++ /dev/null @@ -1,10 +0,0 @@ -//// [classAndInterface1.ts] - class cli { } // error -interface cli { } // error - -//// [classAndInterface1.js] -var cli = (function () { - function cli() { - } - return cli; -})(); // error diff --git a/tests/baselines/reference/classAndInterfaceMerge.d.errors.txt b/tests/baselines/reference/classAndInterfaceMerge.d.errors.txt new file mode 100644 index 0000000000000..d4afe3bc7c9de --- /dev/null +++ b/tests/baselines/reference/classAndInterfaceMerge.d.errors.txt @@ -0,0 +1,46 @@ +tests/cases/conformance/classes/classDeclarations/classAndInterfaceMerge.d.ts(12,15): error TS2507: An interface cannot merge with a non-ambient class. +tests/cases/conformance/classes/classDeclarations/classAndInterfaceMerge.d.ts(14,11): error TS2506: A non-ambient class cannot be merged with an interface. +tests/cases/conformance/classes/classDeclarations/classAndInterfaceMerge.d.ts(16,15): error TS2507: An interface cannot merge with a non-ambient class. +tests/cases/conformance/classes/classDeclarations/classAndInterfaceMerge.d.ts(18,15): error TS2507: An interface cannot merge with a non-ambient class. +tests/cases/conformance/classes/classDeclarations/classAndInterfaceMerge.d.ts(20,18): error TS2506: A non-ambient class cannot be merged with an interface. +tests/cases/conformance/classes/classDeclarations/classAndInterfaceMerge.d.ts(24,22): error TS2507: An interface cannot merge with a non-ambient class. + + +==== tests/cases/conformance/classes/classDeclarations/classAndInterfaceMerge.d.ts (6 errors) ==== + + interface C { } + + declare class C { } + + interface C { } + + interface C { } + + declare module M { + + interface C1 { } + ~~ +!!! error TS2507: An interface cannot merge with a non-ambient class. + + class C1 { } + ~~ +!!! error TS2506: A non-ambient class cannot be merged with an interface. + + interface C1 { } + ~~ +!!! error TS2507: An interface cannot merge with a non-ambient class. + + interface C1 { } + ~~ +!!! error TS2507: An interface cannot merge with a non-ambient class. + + export class C2 { } + ~~ +!!! error TS2506: A non-ambient class cannot be merged with an interface. + } + + declare module M { + export interface C2 { } + ~~ +!!! error TS2507: An interface cannot merge with a non-ambient class. + } \ No newline at end of file diff --git a/tests/baselines/reference/classAndInterfaceWithSameName.errors.txt b/tests/baselines/reference/classAndInterfaceWithSameName.errors.txt index aa3e687cf4d3f..6bf95880ceb4d 100644 --- a/tests/baselines/reference/classAndInterfaceWithSameName.errors.txt +++ b/tests/baselines/reference/classAndInterfaceWithSameName.errors.txt @@ -1,27 +1,39 @@ -tests/cases/conformance/classes/classDeclarations/classAndInterfaceWithSameName.ts(1,7): error TS2300: Duplicate identifier 'C'. -tests/cases/conformance/classes/classDeclarations/classAndInterfaceWithSameName.ts(2,11): error TS2300: Duplicate identifier 'C'. -tests/cases/conformance/classes/classDeclarations/classAndInterfaceWithSameName.ts(5,11): error TS2300: Duplicate identifier 'D'. -tests/cases/conformance/classes/classDeclarations/classAndInterfaceWithSameName.ts(9,15): error TS2300: Duplicate identifier 'D'. +tests/cases/conformance/classes/classDeclarations/classAndInterfaceWithSameName.ts(1,7): error TS2506: A non-ambient class cannot be merged with an interface. +tests/cases/conformance/classes/classDeclarations/classAndInterfaceWithSameName.ts(1,11): error TS2300: Duplicate identifier 'foo'. +tests/cases/conformance/classes/classDeclarations/classAndInterfaceWithSameName.ts(2,11): error TS2507: An interface cannot merge with a non-ambient class. +tests/cases/conformance/classes/classDeclarations/classAndInterfaceWithSameName.ts(2,15): error TS2300: Duplicate identifier 'foo'. +tests/cases/conformance/classes/classDeclarations/classAndInterfaceWithSameName.ts(5,11): error TS2506: A non-ambient class cannot be merged with an interface. +tests/cases/conformance/classes/classDeclarations/classAndInterfaceWithSameName.ts(6,9): error TS2300: Duplicate identifier 'bar'. +tests/cases/conformance/classes/classDeclarations/classAndInterfaceWithSameName.ts(9,15): error TS2507: An interface cannot merge with a non-ambient class. +tests/cases/conformance/classes/classDeclarations/classAndInterfaceWithSameName.ts(10,9): error TS2300: Duplicate identifier 'bar'. -==== tests/cases/conformance/classes/classDeclarations/classAndInterfaceWithSameName.ts (4 errors) ==== +==== tests/cases/conformance/classes/classDeclarations/classAndInterfaceWithSameName.ts (8 errors) ==== class C { foo: string; } ~ -!!! error TS2300: Duplicate identifier 'C'. +!!! error TS2506: A non-ambient class cannot be merged with an interface. + ~~~ +!!! error TS2300: Duplicate identifier 'foo'. interface C { foo: string; } // error ~ -!!! error TS2300: Duplicate identifier 'C'. +!!! error TS2507: An interface cannot merge with a non-ambient class. + ~~~ +!!! error TS2300: Duplicate identifier 'foo'. module M { class D { ~ -!!! error TS2300: Duplicate identifier 'D'. +!!! error TS2506: A non-ambient class cannot be merged with an interface. bar: string; + ~~~ +!!! error TS2300: Duplicate identifier 'bar'. } interface D { // error ~ -!!! error TS2300: Duplicate identifier 'D'. +!!! error TS2507: An interface cannot merge with a non-ambient class. bar: string; + ~~~ +!!! error TS2300: Duplicate identifier 'bar'. } } \ No newline at end of file diff --git a/tests/baselines/reference/clinterfaces.errors.txt b/tests/baselines/reference/clinterfaces.errors.txt index d5eab2c7994df..6e172fa0d9684 100644 --- a/tests/baselines/reference/clinterfaces.errors.txt +++ b/tests/baselines/reference/clinterfaces.errors.txt @@ -1,50 +1,50 @@ -tests/cases/compiler/clinterfaces.ts(2,11): error TS2300: Duplicate identifier 'C'. -tests/cases/compiler/clinterfaces.ts(3,15): error TS2300: Duplicate identifier 'C'. -tests/cases/compiler/clinterfaces.ts(4,15): error TS2300: Duplicate identifier 'D'. -tests/cases/compiler/clinterfaces.ts(5,11): error TS2300: Duplicate identifier 'D'. -tests/cases/compiler/clinterfaces.ts(8,11): error TS2300: Duplicate identifier 'Foo'. -tests/cases/compiler/clinterfaces.ts(12,7): error TS2300: Duplicate identifier 'Foo'. -tests/cases/compiler/clinterfaces.ts(16,7): error TS2300: Duplicate identifier 'Bar'. -tests/cases/compiler/clinterfaces.ts(20,11): error TS2300: Duplicate identifier 'Bar'. +tests/cases/compiler/clinterfaces.ts(2,11): error TS2506: A non-ambient class cannot be merged with an interface. +tests/cases/compiler/clinterfaces.ts(3,15): error TS2507: An interface cannot merge with a non-ambient class. +tests/cases/compiler/clinterfaces.ts(4,15): error TS2507: An interface cannot merge with a non-ambient class. +tests/cases/compiler/clinterfaces.ts(5,11): error TS2506: A non-ambient class cannot be merged with an interface. +tests/cases/compiler/clinterfaces.ts(8,11): error TS2507: An interface cannot merge with a non-ambient class. +tests/cases/compiler/clinterfaces.ts(12,7): error TS2506: A non-ambient class cannot be merged with an interface. +tests/cases/compiler/clinterfaces.ts(16,7): error TS2506: A non-ambient class cannot be merged with an interface. +tests/cases/compiler/clinterfaces.ts(20,11): error TS2507: An interface cannot merge with a non-ambient class. ==== tests/cases/compiler/clinterfaces.ts (8 errors) ==== module M { class C { } ~ -!!! error TS2300: Duplicate identifier 'C'. +!!! error TS2506: A non-ambient class cannot be merged with an interface. interface C { } ~ -!!! error TS2300: Duplicate identifier 'C'. +!!! error TS2507: An interface cannot merge with a non-ambient class. interface D { } ~ -!!! error TS2300: Duplicate identifier 'D'. +!!! error TS2507: An interface cannot merge with a non-ambient class. class D { } ~ -!!! error TS2300: Duplicate identifier 'D'. +!!! error TS2506: A non-ambient class cannot be merged with an interface. } interface Foo { ~~~ -!!! error TS2300: Duplicate identifier 'Foo'. +!!! error TS2507: An interface cannot merge with a non-ambient class. a: string; } class Foo{ ~~~ -!!! error TS2300: Duplicate identifier 'Foo'. +!!! error TS2506: A non-ambient class cannot be merged with an interface. b: number; } class Bar{ ~~~ -!!! error TS2300: Duplicate identifier 'Bar'. +!!! error TS2506: A non-ambient class cannot be merged with an interface. b: number; } interface Bar { ~~~ -!!! error TS2300: Duplicate identifier 'Bar'. +!!! error TS2507: An interface cannot merge with a non-ambient class. a: string; } diff --git a/tests/baselines/reference/clinterfaces.js b/tests/baselines/reference/clinterfaces.js index 02ae73498697a..a55924227c9ef 100644 --- a/tests/baselines/reference/clinterfaces.js +++ b/tests/baselines/reference/clinterfaces.js @@ -49,3 +49,4 @@ var Bar = (function () { } return Bar; })(); +module.exports = Foo; diff --git a/tests/baselines/reference/declInput.errors.txt b/tests/baselines/reference/declInput.errors.txt index 8ec341ce15bb9..313866cf93d5f 100644 --- a/tests/baselines/reference/declInput.errors.txt +++ b/tests/baselines/reference/declInput.errors.txt @@ -1,17 +1,17 @@ -tests/cases/compiler/declInput.ts(1,11): error TS2300: Duplicate identifier 'bar'. -tests/cases/compiler/declInput.ts(5,7): error TS2300: Duplicate identifier 'bar'. +tests/cases/compiler/declInput.ts(1,11): error TS2507: An interface cannot merge with a non-ambient class. +tests/cases/compiler/declInput.ts(5,7): error TS2506: A non-ambient class cannot be merged with an interface. ==== tests/cases/compiler/declInput.ts (2 errors) ==== interface bar { ~~~ -!!! error TS2300: Duplicate identifier 'bar'. +!!! error TS2507: An interface cannot merge with a non-ambient class. } class bar { ~~~ -!!! error TS2300: Duplicate identifier 'bar'. +!!! error TS2506: A non-ambient class cannot be merged with an interface. public f() { return ''; } public g() { return {a: null, b: undefined, c: void 4 }; } public h(x = 4, y = null, z = '') { x++; } diff --git a/tests/baselines/reference/declaredClassMergedwithSelf.errors.txt b/tests/baselines/reference/declaredClassMergedwithSelf.errors.txt index 8a783639c1c9a..a46dfb0d3394a 100644 --- a/tests/baselines/reference/declaredClassMergedwithSelf.errors.txt +++ b/tests/baselines/reference/declaredClassMergedwithSelf.errors.txt @@ -1,11 +1,15 @@ -tests/cases/conformance/classes/classDeclarations/declaredClassMergedwithSelf.ts(1,15): error TS2300: Duplicate identifier 'C1'. -tests/cases/conformance/classes/classDeclarations/declaredClassMergedwithSelf.ts(3,15): error TS2300: Duplicate identifier 'C1'. -tests/cases/conformance/classes/classDeclarations/declaredClassMergedwithSelf.ts(5,15): error TS2300: Duplicate identifier 'C2'. -tests/cases/conformance/classes/classDeclarations/declaredClassMergedwithSelf.ts(7,11): error TS2300: Duplicate identifier 'C2'. -tests/cases/conformance/classes/classDeclarations/declaredClassMergedwithSelf.ts(9,15): error TS2300: Duplicate identifier 'C2'. +tests/cases/conformance/classes/classDeclarations/file1.ts(3,15): error TS2300: Duplicate identifier 'C1'. +tests/cases/conformance/classes/classDeclarations/file1.ts(5,15): error TS2300: Duplicate identifier 'C1'. +tests/cases/conformance/classes/classDeclarations/file1.ts(7,15): error TS2300: Duplicate identifier 'C2'. +tests/cases/conformance/classes/classDeclarations/file1.ts(9,11): error TS2300: Duplicate identifier 'C2'. +tests/cases/conformance/classes/classDeclarations/file1.ts(11,15): error TS2300: Duplicate identifier 'C2'. +tests/cases/conformance/classes/classDeclarations/file2.ts(2,15): error TS2300: Duplicate identifier 'C3'. +tests/cases/conformance/classes/classDeclarations/file3.ts(2,15): error TS2300: Duplicate identifier 'C3'. -==== tests/cases/conformance/classes/classDeclarations/declaredClassMergedwithSelf.ts (5 errors) ==== +==== tests/cases/conformance/classes/classDeclarations/file1.ts (5 errors) ==== + + declare class C1 {} ~~ !!! error TS2300: Duplicate identifier 'C1'. @@ -24,4 +28,16 @@ tests/cases/conformance/classes/classDeclarations/declaredClassMergedwithSelf.ts declare class C2 {} ~~ -!!! error TS2300: Duplicate identifier 'C2'. \ No newline at end of file +!!! error TS2300: Duplicate identifier 'C2'. + +==== tests/cases/conformance/classes/classDeclarations/file2.ts (1 errors) ==== + + declare class C3 { } + ~~ +!!! error TS2300: Duplicate identifier 'C3'. + +==== tests/cases/conformance/classes/classDeclarations/file3.ts (1 errors) ==== + + declare class C3 { } + ~~ +!!! error TS2300: Duplicate identifier 'C3'. \ No newline at end of file diff --git a/tests/baselines/reference/declaredClassMergedwithSelf.js b/tests/baselines/reference/declaredClassMergedwithSelf.js index 85213668adc48..a38391d90dbc8 100644 --- a/tests/baselines/reference/declaredClassMergedwithSelf.js +++ b/tests/baselines/reference/declaredClassMergedwithSelf.js @@ -1,4 +1,8 @@ -//// [declaredClassMergedwithSelf.ts] +//// [tests/cases/conformance/classes/classDeclarations/declaredClassMergedwithSelf.ts] //// + +//// [file1.ts] + + declare class C1 {} declare class C1 {} @@ -7,6 +11,16 @@ declare class C2 {} interface C2 {} -declare class C2 {} +declare class C2 {} + +//// [file2.ts] + +declare class C3 { } + +//// [file3.ts] + +declare class C3 { } -//// [declaredClassMergedwithSelf.js] +//// [file1.js] +//// [file2.js] +//// [file3.js] diff --git a/tests/baselines/reference/duplicateIdentifiersAcrossContainerBoundaries.errors.txt b/tests/baselines/reference/duplicateIdentifiersAcrossContainerBoundaries.errors.txt index 6c80d13b2f44a..77a7f4ffb3553 100644 --- a/tests/baselines/reference/duplicateIdentifiersAcrossContainerBoundaries.errors.txt +++ b/tests/baselines/reference/duplicateIdentifiersAcrossContainerBoundaries.errors.txt @@ -1,5 +1,5 @@ -tests/cases/compiler/duplicateIdentifiersAcrossContainerBoundaries.ts(2,22): error TS2300: Duplicate identifier 'I'. -tests/cases/compiler/duplicateIdentifiersAcrossContainerBoundaries.ts(5,18): error TS2300: Duplicate identifier 'I'. +tests/cases/compiler/duplicateIdentifiersAcrossContainerBoundaries.ts(2,22): error TS2507: An interface cannot merge with a non-ambient class. +tests/cases/compiler/duplicateIdentifiersAcrossContainerBoundaries.ts(5,18): error TS2506: A non-ambient class cannot be merged with an interface. tests/cases/compiler/duplicateIdentifiersAcrossContainerBoundaries.ts(9,21): error TS2300: Duplicate identifier 'f'. tests/cases/compiler/duplicateIdentifiersAcrossContainerBoundaries.ts(12,18): error TS2300: Duplicate identifier 'f'. tests/cases/compiler/duplicateIdentifiersAcrossContainerBoundaries.ts(37,12): error TS2300: Duplicate identifier 'x'. @@ -10,12 +10,12 @@ tests/cases/compiler/duplicateIdentifiersAcrossContainerBoundaries.ts(41,16): er module M { export interface I { } ~ -!!! error TS2300: Duplicate identifier 'I'. +!!! error TS2507: An interface cannot merge with a non-ambient class. } module M { export class I { } // error ~ -!!! error TS2300: Duplicate identifier 'I'. +!!! error TS2506: A non-ambient class cannot be merged with an interface. } module M { diff --git a/tests/baselines/reference/duplicateIdentifiersAcrossFileBoundaries.errors.txt b/tests/baselines/reference/duplicateIdentifiersAcrossFileBoundaries.errors.txt new file mode 100644 index 0000000000000..0febfd77ec5ba --- /dev/null +++ b/tests/baselines/reference/duplicateIdentifiersAcrossFileBoundaries.errors.txt @@ -0,0 +1,67 @@ +tests/cases/compiler/file1.ts(1,11): error TS2507: An interface cannot merge with a non-ambient class. +tests/cases/compiler/file1.ts(2,7): error TS2506: A non-ambient class cannot be merged with an interface. +tests/cases/compiler/file1.ts(3,7): error TS2300: Duplicate identifier 'C2'. +tests/cases/compiler/file1.ts(4,10): error TS2300: Duplicate identifier 'f'. +tests/cases/compiler/file1.ts(8,12): error TS2300: Duplicate identifier 'x'. +tests/cases/compiler/file2.ts(1,7): error TS2506: A non-ambient class cannot be merged with an interface. +tests/cases/compiler/file2.ts(2,11): error TS2507: An interface cannot merge with a non-ambient class. +tests/cases/compiler/file2.ts(3,10): error TS2300: Duplicate identifier 'C2'. +tests/cases/compiler/file2.ts(4,7): error TS2300: Duplicate identifier 'f'. +tests/cases/compiler/file2.ts(7,8): error TS2433: A namespace declaration cannot be in a different file from a class or function with which it is merged +tests/cases/compiler/file2.ts(8,16): error TS2300: Duplicate identifier 'x'. + + +==== tests/cases/compiler/file1.ts (5 errors) ==== + interface I { } + ~ +!!! error TS2507: An interface cannot merge with a non-ambient class. + class C1 { } + ~~ +!!! error TS2506: A non-ambient class cannot be merged with an interface. + class C2 { } + ~~ +!!! error TS2300: Duplicate identifier 'C2'. + function f() { } + ~ +!!! error TS2300: Duplicate identifier 'f'. + var v = 3; + + class Foo { + static x: number; + ~ +!!! error TS2300: Duplicate identifier 'x'. + } + + module N { + export module F { + var t; + } + } + +==== tests/cases/compiler/file2.ts (6 errors) ==== + class I { } // error -- cannot merge interface with non-ambient class + ~ +!!! error TS2506: A non-ambient class cannot be merged with an interface. + interface C1 { } // error -- cannot merge interface with non-ambient class + ~~ +!!! error TS2507: An interface cannot merge with a non-ambient class. + function C2() { } // error -- cannot merge function with non-ambient class + ~~ +!!! error TS2300: Duplicate identifier 'C2'. + class f { } // error -- cannot merge function with non-ambient class + ~ +!!! error TS2300: Duplicate identifier 'f'. + var v = 3; + + module Foo { + ~~~ +!!! error TS2433: A namespace declaration cannot be in a different file from a class or function with which it is merged + export var x: number; // error for redeclaring var in a different parent + ~ +!!! error TS2300: Duplicate identifier 'x'. + } + + declare module N { + export function F(); // no error because function is ambient + } + \ No newline at end of file diff --git a/tests/baselines/reference/duplicateIdentifiersAcrossFileBoundaries.js b/tests/baselines/reference/duplicateIdentifiersAcrossFileBoundaries.js new file mode 100644 index 0000000000000..f6e3a5652e5d0 --- /dev/null +++ b/tests/baselines/reference/duplicateIdentifiersAcrossFileBoundaries.js @@ -0,0 +1,76 @@ +//// [tests/cases/compiler/duplicateIdentifiersAcrossFileBoundaries.ts] //// + +//// [file1.ts] +interface I { } +class C1 { } +class C2 { } +function f() { } +var v = 3; + +class Foo { + static x: number; +} + +module N { + export module F { + var t; + } +} + +//// [file2.ts] +class I { } // error -- cannot merge interface with non-ambient class +interface C1 { } // error -- cannot merge interface with non-ambient class +function C2() { } // error -- cannot merge function with non-ambient class +class f { } // error -- cannot merge function with non-ambient class +var v = 3; + +module Foo { + export var x: number; // error for redeclaring var in a different parent +} + +declare module N { + export function F(); // no error because function is ambient +} + + +//// [file1.js] +var C1 = (function () { + function C1() { + } + return C1; +})(); +var C2 = (function () { + function C2() { + } + return C2; +})(); +function f() { } +var v = 3; +var Foo = (function () { + function Foo() { + } + return Foo; +})(); +var N; +(function (N) { + var F; + (function (F) { + var t; + })(F = N.F || (N.F = {})); +})(N || (N = {})); +//// [file2.js] +var I = (function () { + function I() { + } + return I; +})(); // error -- cannot merge interface with non-ambient class +function C2() { } // error -- cannot merge function with non-ambient class +var f = (function () { + function f() { + } + return f; +})(); // error -- cannot merge function with non-ambient class +var v = 3; +var Foo; +(function (Foo) { +})(Foo || (Foo = {})); diff --git a/tests/baselines/reference/interfaceDeclaration2.errors.txt b/tests/baselines/reference/interfaceDeclaration2.errors.txt index 9739d946bc52b..06a0e24730188 100644 --- a/tests/baselines/reference/interfaceDeclaration2.errors.txt +++ b/tests/baselines/reference/interfaceDeclaration2.errors.txt @@ -1,5 +1,5 @@ -tests/cases/compiler/interfaceDeclaration2.ts(4,11): error TS2300: Duplicate identifier 'I2'. -tests/cases/compiler/interfaceDeclaration2.ts(5,7): error TS2300: Duplicate identifier 'I2'. +tests/cases/compiler/interfaceDeclaration2.ts(4,11): error TS2507: An interface cannot merge with a non-ambient class. +tests/cases/compiler/interfaceDeclaration2.ts(5,7): error TS2506: A non-ambient class cannot be merged with an interface. ==== tests/cases/compiler/interfaceDeclaration2.ts (2 errors) ==== @@ -8,10 +8,10 @@ tests/cases/compiler/interfaceDeclaration2.ts(5,7): error TS2300: Duplicate iden interface I2 { } ~~ -!!! error TS2300: Duplicate identifier 'I2'. +!!! error TS2507: An interface cannot merge with a non-ambient class. class I2 { } ~~ -!!! error TS2300: Duplicate identifier 'I2'. +!!! error TS2506: A non-ambient class cannot be merged with an interface. interface I3 { } function I3() { } diff --git a/tests/baselines/reference/mergedClassInterface.errors.txt b/tests/baselines/reference/mergedClassInterface.errors.txt new file mode 100644 index 0000000000000..42f0a14b8ef76 --- /dev/null +++ b/tests/baselines/reference/mergedClassInterface.errors.txt @@ -0,0 +1,67 @@ +tests/cases/conformance/classes/classDeclarations/file1.ts(11,7): error TS2506: A non-ambient class cannot be merged with an interface. +tests/cases/conformance/classes/classDeclarations/file1.ts(13,11): error TS2507: An interface cannot merge with a non-ambient class. +tests/cases/conformance/classes/classDeclarations/file1.ts(15,11): error TS2507: An interface cannot merge with a non-ambient class. +tests/cases/conformance/classes/classDeclarations/file1.ts(17,7): error TS2506: A non-ambient class cannot be merged with an interface. + + +==== tests/cases/conformance/classes/classDeclarations/file1.ts (4 errors) ==== + + + declare class C1 { } + + interface C1 { } + + interface C2 { } + + declare class C2 { } + + class C3 { } // error -- cannot merge non-ambient class and interface + ~~ +!!! error TS2506: A non-ambient class cannot be merged with an interface. + + interface C3 { } // error -- cannot merge non-ambient class and interface + ~~ +!!! error TS2507: An interface cannot merge with a non-ambient class. + + interface C4 { } // error -- cannot merge non-ambient class and interface + ~~ +!!! error TS2507: An interface cannot merge with a non-ambient class. + + class C4 { } // error -- cannot merge non-ambient class and interface + ~~ +!!! error TS2506: A non-ambient class cannot be merged with an interface. + + interface C5 { + x1: number; + } + + declare class C5 { + x2: number; + } + + interface C5 { + x3: number; + } + + interface C5 { + x4: number; + } + + // checks if properties actually were merged + var c5 : C5; + c5.x1; + c5.x2; + c5.x3; + c5.x4; + +==== tests/cases/conformance/classes/classDeclarations/file2.ts (0 errors) ==== + + declare class C6 { } + + interface C7 { } + +==== tests/cases/conformance/classes/classDeclarations/file3.ts (0 errors) ==== + + interface C6 { } + + declare class C7 { } \ No newline at end of file diff --git a/tests/baselines/reference/mergedClassInterface.js b/tests/baselines/reference/mergedClassInterface.js index 70c8b7d2b2f69..7176255655dbf 100644 --- a/tests/baselines/reference/mergedClassInterface.js +++ b/tests/baselines/reference/mergedClassInterface.js @@ -1,14 +1,117 @@ -//// [mergedClassInterface.ts] -declare class C1 {} +//// [tests/cases/conformance/classes/classDeclarations/mergedClassInterface.ts] //// + +//// [file1.ts] + + +declare class C1 { } + +interface C1 { } + +interface C2 { } + +declare class C2 { } + +class C3 { } // error -- cannot merge non-ambient class and interface + +interface C3 { } // error -- cannot merge non-ambient class and interface + +interface C4 { } // error -- cannot merge non-ambient class and interface -interface C1 {} +class C4 { } // error -- cannot merge non-ambient class and interface -interface C2 {} +interface C5 { + x1: number; +} -declare class C2 {} +declare class C5 { + x2: number; +} -interface C2 {} +interface C5 { + x3: number; +} -interface C2 {} +interface C5 { + x4: number; +} + +// checks if properties actually were merged +var c5 : C5; +c5.x1; +c5.x2; +c5.x3; +c5.x4; + +//// [file2.ts] + +declare class C6 { } + +interface C7 { } + +//// [file3.ts] + +interface C6 { } + +declare class C7 { } + +//// [file1.js] +var C3 = (function () { + function C3() { + } + return C3; +})(); // error -- cannot merge non-ambient class and interface +var C4 = (function () { + function C4() { + } + return C4; +})(); // error -- cannot merge non-ambient class and interface +// checks if properties actually were merged +var c5; +c5.x1; +c5.x2; +c5.x3; +c5.x4; +//// [file2.js] +//// [file3.js] + -//// [mergedClassInterface.js] +//// [file1.d.ts] +declare class C1 { +} +interface C1 { +} +interface C2 { +} +declare class C2 { +} +declare class C3 { +} +interface C3 { +} +interface C4 { +} +declare class C4 { +} +interface C5 { + x1: number; +} +declare class C5 { + x2: number; +} +interface C5 { + x3: number; +} +interface C5 { + x4: number; +} +declare var c5: C5; +//// [file2.d.ts] +declare class C6 { +} +interface C7 { +} +//// [file3.d.ts] +interface C6 { +} +declare class C7 { +} diff --git a/tests/baselines/reference/mergedClassInterface.symbols b/tests/baselines/reference/mergedClassInterface.symbols deleted file mode 100644 index dc7ba89155109..0000000000000 --- a/tests/baselines/reference/mergedClassInterface.symbols +++ /dev/null @@ -1,19 +0,0 @@ -=== tests/cases/conformance/classes/classDeclarations/mergedClassInterface.ts === -declare class C1 {} ->C1 : Symbol(C1, Decl(mergedClassInterface.ts, 0, 0), Decl(mergedClassInterface.ts, 0, 19)) - -interface C1 {} ->C1 : Symbol(C1, Decl(mergedClassInterface.ts, 0, 0), Decl(mergedClassInterface.ts, 0, 19)) - -interface C2 {} ->C2 : Symbol(C2, Decl(mergedClassInterface.ts, 2, 15), Decl(mergedClassInterface.ts, 4, 15), Decl(mergedClassInterface.ts, 6, 19), Decl(mergedClassInterface.ts, 8, 15)) - -declare class C2 {} ->C2 : Symbol(C2, Decl(mergedClassInterface.ts, 2, 15), Decl(mergedClassInterface.ts, 4, 15), Decl(mergedClassInterface.ts, 6, 19), Decl(mergedClassInterface.ts, 8, 15)) - -interface C2 {} ->C2 : Symbol(C2, Decl(mergedClassInterface.ts, 2, 15), Decl(mergedClassInterface.ts, 4, 15), Decl(mergedClassInterface.ts, 6, 19), Decl(mergedClassInterface.ts, 8, 15)) - -interface C2 {} ->C2 : Symbol(C2, Decl(mergedClassInterface.ts, 2, 15), Decl(mergedClassInterface.ts, 4, 15), Decl(mergedClassInterface.ts, 6, 19), Decl(mergedClassInterface.ts, 8, 15)) - diff --git a/tests/baselines/reference/mergedClassInterface.types b/tests/baselines/reference/mergedClassInterface.types deleted file mode 100644 index a31f147b7344f..0000000000000 --- a/tests/baselines/reference/mergedClassInterface.types +++ /dev/null @@ -1,19 +0,0 @@ -=== tests/cases/conformance/classes/classDeclarations/mergedClassInterface.ts === -declare class C1 {} ->C1 : C1 - -interface C1 {} ->C1 : C1 - -interface C2 {} ->C2 : C2 - -declare class C2 {} ->C2 : C2 - -interface C2 {} ->C2 : C2 - -interface C2 {} ->C2 : C2 - diff --git a/tests/baselines/reference/nameCollisions.errors.txt b/tests/baselines/reference/nameCollisions.errors.txt index 5eb7ea2cf8023..d570d9e127841 100644 --- a/tests/baselines/reference/nameCollisions.errors.txt +++ b/tests/baselines/reference/nameCollisions.errors.txt @@ -11,10 +11,10 @@ tests/cases/compiler/nameCollisions.ts(33,11): error TS2300: Duplicate identifie tests/cases/compiler/nameCollisions.ts(34,14): error TS2300: Duplicate identifier 'C'. tests/cases/compiler/nameCollisions.ts(36,14): error TS2300: Duplicate identifier 'C2'. tests/cases/compiler/nameCollisions.ts(37,11): error TS2300: Duplicate identifier 'C2'. -tests/cases/compiler/nameCollisions.ts(42,11): error TS2300: Duplicate identifier 'cli'. -tests/cases/compiler/nameCollisions.ts(43,15): error TS2300: Duplicate identifier 'cli'. -tests/cases/compiler/nameCollisions.ts(45,15): error TS2300: Duplicate identifier 'cli2'. -tests/cases/compiler/nameCollisions.ts(46,11): error TS2300: Duplicate identifier 'cli2'. +tests/cases/compiler/nameCollisions.ts(42,11): error TS2506: A non-ambient class cannot be merged with an interface. +tests/cases/compiler/nameCollisions.ts(43,15): error TS2507: An interface cannot merge with a non-ambient class. +tests/cases/compiler/nameCollisions.ts(45,15): error TS2507: An interface cannot merge with a non-ambient class. +tests/cases/compiler/nameCollisions.ts(46,11): error TS2506: A non-ambient class cannot be merged with an interface. ==== tests/cases/compiler/nameCollisions.ts (17 errors) ==== @@ -87,15 +87,15 @@ tests/cases/compiler/nameCollisions.ts(46,11): error TS2300: Duplicate identifie class cli { } ~~~ -!!! error TS2300: Duplicate identifier 'cli'. +!!! error TS2506: A non-ambient class cannot be merged with an interface. interface cli { } // error ~~~ -!!! error TS2300: Duplicate identifier 'cli'. +!!! error TS2507: An interface cannot merge with a non-ambient class. interface cli2 { } ~~~~ -!!! error TS2300: Duplicate identifier 'cli2'. +!!! error TS2507: An interface cannot merge with a non-ambient class. class cli2 { } // error ~~~~ -!!! error TS2300: Duplicate identifier 'cli2'. +!!! error TS2506: A non-ambient class cannot be merged with an interface. } \ No newline at end of file diff --git a/tests/baselines/reference/templateStringsArrayTypeDefinedInES5Mode.errors.txt b/tests/baselines/reference/templateStringsArrayTypeDefinedInES5Mode.errors.txt index 7c796d4739869..9d6da3ec4b473 100644 --- a/tests/baselines/reference/templateStringsArrayTypeDefinedInES5Mode.errors.txt +++ b/tests/baselines/reference/templateStringsArrayTypeDefinedInES5Mode.errors.txt @@ -1,14 +1,14 @@ -lib.d.ts(521,11): error TS2300: Duplicate identifier 'TemplateStringsArray'. -tests/cases/compiler/templateStringsArrayTypeDefinedInES5Mode.ts(2,7): error TS2300: Duplicate identifier 'TemplateStringsArray'. -tests/cases/compiler/templateStringsArrayTypeDefinedInES5Mode.ts(8,3): error TS2345: Argument of type '{ [x: number]: undefined; }' is not assignable to parameter of type 'TemplateStringsArray'. - Property 'raw' is missing in type '{ [x: number]: undefined; }'. +lib.d.ts(521,11): error TS2507: An interface cannot merge with a non-ambient class. +tests/cases/compiler/templateStringsArrayTypeDefinedInES5Mode.ts(2,7): error TS2506: A non-ambient class cannot be merged with an interface. +tests/cases/compiler/templateStringsArrayTypeDefinedInES5Mode.ts(8,3): error TS2345: Argument of type '{}' is not assignable to parameter of type 'TemplateStringsArray'. + Property 'raw' is missing in type '{}'. ==== tests/cases/compiler/templateStringsArrayTypeDefinedInES5Mode.ts (2 errors) ==== class TemplateStringsArray { ~~~~~~~~~~~~~~~~~~~~ -!!! error TS2300: Duplicate identifier 'TemplateStringsArray'. +!!! error TS2506: A non-ambient class cannot be merged with an interface. } function f(x: TemplateStringsArray, y: number, z: number) { @@ -16,7 +16,7 @@ tests/cases/compiler/templateStringsArrayTypeDefinedInES5Mode.ts(8,3): error TS2 f({}, 10, 10); ~~ -!!! error TS2345: Argument of type '{ [x: number]: undefined; }' is not assignable to parameter of type 'TemplateStringsArray'. -!!! error TS2345: Property 'raw' is missing in type '{ [x: number]: undefined; }'. +!!! error TS2345: Argument of type '{}' is not assignable to parameter of type 'TemplateStringsArray'. +!!! error TS2345: Property 'raw' is missing in type '{}'. f `abcdef${ 1234 }${ 5678 }ghijkl`; \ No newline at end of file diff --git a/tests/baselines/reference/templateStringsArrayTypeRedefinedInES6Mode.errors.txt b/tests/baselines/reference/templateStringsArrayTypeRedefinedInES6Mode.errors.txt index 4b9cb63d9aaeb..ffb619cedc76a 100644 --- a/tests/baselines/reference/templateStringsArrayTypeRedefinedInES6Mode.errors.txt +++ b/tests/baselines/reference/templateStringsArrayTypeRedefinedInES6Mode.errors.txt @@ -1,14 +1,14 @@ -lib.d.ts(521,11): error TS2300: Duplicate identifier 'TemplateStringsArray'. -tests/cases/compiler/templateStringsArrayTypeRedefinedInES6Mode.ts(2,7): error TS2300: Duplicate identifier 'TemplateStringsArray'. -tests/cases/compiler/templateStringsArrayTypeRedefinedInES6Mode.ts(8,3): error TS2345: Argument of type '{ [x: number]: undefined; }' is not assignable to parameter of type 'TemplateStringsArray'. - Property 'raw' is missing in type '{ [x: number]: undefined; }'. +lib.d.ts(521,11): error TS2507: An interface cannot merge with a non-ambient class. +tests/cases/compiler/templateStringsArrayTypeRedefinedInES6Mode.ts(2,7): error TS2506: A non-ambient class cannot be merged with an interface. +tests/cases/compiler/templateStringsArrayTypeRedefinedInES6Mode.ts(8,3): error TS2345: Argument of type '{}' is not assignable to parameter of type 'TemplateStringsArray'. + Property 'raw' is missing in type '{}'. ==== tests/cases/compiler/templateStringsArrayTypeRedefinedInES6Mode.ts (2 errors) ==== class TemplateStringsArray { ~~~~~~~~~~~~~~~~~~~~ -!!! error TS2300: Duplicate identifier 'TemplateStringsArray'. +!!! error TS2506: A non-ambient class cannot be merged with an interface. } function f(x: TemplateStringsArray, y: number, z: number) { @@ -16,7 +16,7 @@ tests/cases/compiler/templateStringsArrayTypeRedefinedInES6Mode.ts(8,3): error T f({}, 10, 10); ~~ -!!! error TS2345: Argument of type '{ [x: number]: undefined; }' is not assignable to parameter of type 'TemplateStringsArray'. -!!! error TS2345: Property 'raw' is missing in type '{ [x: number]: undefined; }'. +!!! error TS2345: Argument of type '{}' is not assignable to parameter of type 'TemplateStringsArray'. +!!! error TS2345: Property 'raw' is missing in type '{}'. f `abcdef${ 1234 }${ 5678 }ghijkl`; \ No newline at end of file From 0917582a014cf3973d9d7f5f2d21d0ecb094b5e7 Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Tue, 2 Jun 2015 15:39:48 -0700 Subject: [PATCH 16/31] removed extra newlines --- src/compiler/checker.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index cce77cdd7de03..4a65b3503d92c 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -10614,9 +10614,7 @@ module ts { checkExpressionWithTypeArguments(heritageElement); }); - - forEach(node.members, checkSourceElement); if (produceDiagnostics) { From fa06f3e4e658bda108b6fbd4c8e0c8ab39284ba4 Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Tue, 2 Jun 2015 15:58:15 -0700 Subject: [PATCH 17/31] fixed merge conflict. --- src/compiler/diagnosticMessages.json | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index d4595d4cd28d8..8f3973fbdb871 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -1476,7 +1476,6 @@ "category": "Error", "code": 2505 }, -<<<<<<< HEAD "A non-ambient class cannot be merged with an interface.": { "category": "Error", "code": 2506 @@ -1485,9 +1484,6 @@ "category": "Error", "code": 2507 }, -======= - ->>>>>>> master "Import declaration '{0}' is using private name '{1}'.": { "category": "Error", "code": 4000 From fa9b6fcb0708d9a90f3d537198107abbe235627b Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Tue, 2 Jun 2015 17:34:34 -0700 Subject: [PATCH 18/31] fixed loops, merged baseline --- src/compiler/checker.ts | 27 +++++---------- .../classAndInterfaceMerge.d.errors.txt | 4 +-- ...IdentifiersAcrossFileBoundaries.errors.txt | 11 +++--- ...uplicateIdentifiersAcrossFileBoundaries.js | 34 +++++++++++++++++++ 4 files changed, 50 insertions(+), 26 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 4a65b3503d92c..36012af42a5d4 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -10403,12 +10403,8 @@ module ts { } // Non-ambient classes cannot merge with interfaces. - if (!(node.flags & NodeFlags.Ambient)) { - if (forEach(symbol.declarations, (element: Declaration) => { - return element.kind === SyntaxKind.InterfaceDeclaration; - })) { - error(node, Diagnostics.A_non_ambient_class_cannot_be_merged_with_an_interface) - } + if (!(node.flags & NodeFlags.Ambient) && getDeclarationOfKind(symbol, SyntaxKind.InterfaceDeclaration)) { + error(node, Diagnostics.A_non_ambient_class_cannot_be_merged_with_an_interface) } forEach(node.members, checkSourceElement); @@ -10562,15 +10558,6 @@ module ts { return ok; } - /** - * Checks if the symbol contains a class declaration that is non-ambient. - */ - function hasNonAmbientClass(symbol: Symbol): boolean { - return symbol && forEach(symbol.declarations, (element: Declaration) => { - return element.kind === SyntaxKind.ClassDeclaration && !(element.flags & NodeFlags.Ambient); - }); - } - function checkInterfaceDeclaration(node: InterfaceDeclaration) { // Grammar checking checkGrammarDeclarationNameInStrictMode(node) || checkGrammarDecorators(node) || checkGrammarModifiers(node) || checkGrammarInterfaceDeclaration(node); @@ -10600,10 +10587,12 @@ module ts { } } - // Interfaces cannot merge with non-ambient classes. - if (!(node.flags & NodeFlags.Ambient)) { - if (hasNonAmbientClass(symbol)) { - error(node, Diagnostics.An_interface_cannot_merge_with_a_non_ambient_class); + if (symbol && symbol.declarations) { + for (let declaration of symbol.declarations) { + if (declaration.kind === SyntaxKind.ClassDeclaration && !(declaration.flags & NodeFlags.Ambient)) { + error(node, Diagnostics.An_interface_cannot_merge_with_a_non_ambient_class); + break; + } } } } diff --git a/tests/baselines/reference/classAndInterfaceMerge.d.errors.txt b/tests/baselines/reference/classAndInterfaceMerge.d.errors.txt index d4afe3bc7c9de..d73e5fcb2f030 100644 --- a/tests/baselines/reference/classAndInterfaceMerge.d.errors.txt +++ b/tests/baselines/reference/classAndInterfaceMerge.d.errors.txt @@ -17,7 +17,7 @@ tests/cases/conformance/classes/classDeclarations/classAndInterfaceMerge.d.ts(24 interface C { } declare module M { - + interface C1 { } ~~ !!! error TS2507: An interface cannot merge with a non-ambient class. @@ -33,7 +33,7 @@ tests/cases/conformance/classes/classDeclarations/classAndInterfaceMerge.d.ts(24 interface C1 { } ~~ !!! error TS2507: An interface cannot merge with a non-ambient class. - + export class C2 { } ~~ !!! error TS2506: A non-ambient class cannot be merged with an interface. diff --git a/tests/baselines/reference/duplicateIdentifiersAcrossFileBoundaries.errors.txt b/tests/baselines/reference/duplicateIdentifiersAcrossFileBoundaries.errors.txt index 0febfd77ec5ba..bd2233306690a 100644 --- a/tests/baselines/reference/duplicateIdentifiersAcrossFileBoundaries.errors.txt +++ b/tests/baselines/reference/duplicateIdentifiersAcrossFileBoundaries.errors.txt @@ -1,8 +1,8 @@ -tests/cases/compiler/file1.ts(1,11): error TS2507: An interface cannot merge with a non-ambient class. -tests/cases/compiler/file1.ts(2,7): error TS2506: A non-ambient class cannot be merged with an interface. -tests/cases/compiler/file1.ts(3,7): error TS2300: Duplicate identifier 'C2'. -tests/cases/compiler/file1.ts(4,10): error TS2300: Duplicate identifier 'f'. -tests/cases/compiler/file1.ts(8,12): error TS2300: Duplicate identifier 'x'. +tests/cases/compiler/file1.ts(2,11): error TS2507: An interface cannot merge with a non-ambient class. +tests/cases/compiler/file1.ts(3,7): error TS2506: A non-ambient class cannot be merged with an interface. +tests/cases/compiler/file1.ts(4,7): error TS2300: Duplicate identifier 'C2'. +tests/cases/compiler/file1.ts(5,10): error TS2300: Duplicate identifier 'f'. +tests/cases/compiler/file1.ts(9,12): error TS2300: Duplicate identifier 'x'. tests/cases/compiler/file2.ts(1,7): error TS2506: A non-ambient class cannot be merged with an interface. tests/cases/compiler/file2.ts(2,11): error TS2507: An interface cannot merge with a non-ambient class. tests/cases/compiler/file2.ts(3,10): error TS2300: Duplicate identifier 'C2'. @@ -12,6 +12,7 @@ tests/cases/compiler/file2.ts(8,16): error TS2300: Duplicate identifier 'x'. ==== tests/cases/compiler/file1.ts (5 errors) ==== + interface I { } ~ !!! error TS2507: An interface cannot merge with a non-ambient class. diff --git a/tests/baselines/reference/duplicateIdentifiersAcrossFileBoundaries.js b/tests/baselines/reference/duplicateIdentifiersAcrossFileBoundaries.js index f6e3a5652e5d0..a2509ea97f462 100644 --- a/tests/baselines/reference/duplicateIdentifiersAcrossFileBoundaries.js +++ b/tests/baselines/reference/duplicateIdentifiersAcrossFileBoundaries.js @@ -1,6 +1,7 @@ //// [tests/cases/compiler/duplicateIdentifiersAcrossFileBoundaries.ts] //// //// [file1.ts] + interface I { } class C1 { } class C2 { } @@ -74,3 +75,36 @@ var v = 3; var Foo; (function (Foo) { })(Foo || (Foo = {})); + + +//// [file1.d.ts] +interface I { +} +declare class C1 { +} +declare class C2 { +} +declare function f(): void; +declare var v: number; +declare class Foo { + static x: number; +} +declare module N { + module F { + } +} +//// [file2.d.ts] +declare class I { +} +interface C1 { +} +declare function C2(): void; +declare class f { +} +declare var v: number; +declare module Foo { + var x: number; +} +declare module N { + function F(): any; +} From f3278e2f0f034c592a0bb2ab931811955a1590c4 Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Wed, 3 Jun 2015 10:32:59 -0700 Subject: [PATCH 19/31] fixed a grammatical issue --- src/compiler/binder.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index 96950ce7b427b..b8b63c3aa4560 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -166,7 +166,7 @@ module ts { } /** - * Declares a Symbol for the Node and add it to symbols. Reports errors for conflicting identifier names. + * Declares a Symbol for the node and adds it to symbols. Reports errors for conflicting identifier names. * @param symbolTable - The symbol table which node will be added to. * @param parent - If node is in a class, parent denotes the parent declaration. * @param node - The declaration to be added to the symbol table @@ -185,7 +185,7 @@ module ts { // Check and see if the symbol table already has a symbol with this name. If not, // create a new symbol with this name and add it to the table. Note that we don't // give the new symbol any flags *yet*. This ensures that it will not conflict - // witht he 'excludes' flags we pass in. + // with the 'excludes' flags we pass in. // // If we do get an existing symbol, see if it conflicts with the new symbol we're // creating. For example, a 'var' symbol and a 'class' symbol will conflict within From 2b899f129a27e9bbd97de703f09315463f5cadbb Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Wed, 3 Jun 2015 14:05:18 -0700 Subject: [PATCH 20/31] simplified check --- src/compiler/checker.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index ecf22938201cb..6a45dacb32a21 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -10416,7 +10416,7 @@ module ts { } // Non-ambient classes cannot merge with interfaces. - if (!(node.flags & NodeFlags.Ambient) && getDeclarationOfKind(symbol, SyntaxKind.InterfaceDeclaration)) { + if (!(node.flags & NodeFlags.Ambient) && symbol.flags & SymbolFlags.Interface) { error(node, Diagnostics.A_non_ambient_class_cannot_be_merged_with_an_interface) } From 29c9286cbc35d0a0a46e8cb149e8a141032d0b96 Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Wed, 3 Jun 2015 14:11:13 -0700 Subject: [PATCH 21/31] Updated error message --- src/compiler/checker.ts | 5 +++-- src/compiler/diagnosticInformationMap.generated.ts | 3 +-- src/compiler/diagnosticMessages.json | 6 +----- 3 files changed, 5 insertions(+), 9 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 6a45dacb32a21..b0b6521e23087 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -10417,7 +10417,7 @@ module ts { // Non-ambient classes cannot merge with interfaces. if (!(node.flags & NodeFlags.Ambient) && symbol.flags & SymbolFlags.Interface) { - error(node, Diagnostics.A_non_ambient_class_cannot_be_merged_with_an_interface) + error(node, Diagnostics.Only_an_ambient_class_can_be_merged_with_an_interface) } forEach(node.members, checkSourceElement); @@ -10600,10 +10600,11 @@ module ts { } } + // Interfaces cannot merge with non-ambient classes. if (symbol && symbol.declarations) { for (let declaration of symbol.declarations) { if (declaration.kind === SyntaxKind.ClassDeclaration && !(declaration.flags & NodeFlags.Ambient)) { - error(node, Diagnostics.An_interface_cannot_merge_with_a_non_ambient_class); + error(node, Diagnostics.Only_an_ambient_class_can_be_merged_with_an_interface); break; } } diff --git a/src/compiler/diagnosticInformationMap.generated.ts b/src/compiler/diagnosticInformationMap.generated.ts index 358dea6e9884e..e327a51631113 100644 --- a/src/compiler/diagnosticInformationMap.generated.ts +++ b/src/compiler/diagnosticInformationMap.generated.ts @@ -372,8 +372,7 @@ module ts { Cannot_find_namespace_0: { code: 2503, category: DiagnosticCategory.Error, key: "Cannot find namespace '{0}'." }, No_best_common_type_exists_among_yield_expressions: { code: 2504, category: DiagnosticCategory.Error, key: "No best common type exists among yield expressions." }, A_generator_cannot_have_a_void_type_annotation: { code: 2505, category: DiagnosticCategory.Error, key: "A generator cannot have a 'void' type annotation." }, - A_non_ambient_class_cannot_be_merged_with_an_interface: { code: 2506, category: DiagnosticCategory.Error, key: "A non-ambient class cannot be merged with an interface." }, - An_interface_cannot_merge_with_a_non_ambient_class: { code: 2507, category: DiagnosticCategory.Error, key: "An interface cannot merge with a non-ambient class." }, + Only_an_ambient_class_can_be_merged_with_an_interface: { code: 2506, category: DiagnosticCategory.Error, key: "Only an ambient class can be merged with an interface." }, Import_declaration_0_is_using_private_name_1: { code: 4000, category: DiagnosticCategory.Error, key: "Import declaration '{0}' is using private name '{1}'." }, Type_parameter_0_of_exported_class_has_or_is_using_private_name_1: { code: 4002, category: DiagnosticCategory.Error, key: "Type parameter '{0}' of exported class has or is using private name '{1}'." }, Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1: { code: 4004, category: DiagnosticCategory.Error, key: "Type parameter '{0}' of exported interface has or is using private name '{1}'." }, diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 8f3973fbdb871..871fb2d9ea83d 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -1476,14 +1476,10 @@ "category": "Error", "code": 2505 }, - "A non-ambient class cannot be merged with an interface.": { + "Only an ambient class can be merged with an interface.": { "category": "Error", "code": 2506 }, - "An interface cannot merge with a non-ambient class.": { - "category": "Error", - "code": 2507 - }, "Import declaration '{0}' is using private name '{1}'.": { "category": "Error", "code": 4000 From d000e0164b8b3bb548d1a1451057c0e83d6a1622 Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Wed, 3 Jun 2015 14:17:29 -0700 Subject: [PATCH 22/31] updated baselines to reflect new error message --- .../reference/augmentedTypesClass2.errors.txt | 8 ++--- .../augmentedTypesInterface.errors.txt | 8 ++--- .../classAndInterfaceMerge.d.errors.txt | 24 +++++++------- .../classAndInterfaceWithSameName.errors.txt | 16 +++++----- .../reference/clinterfaces.errors.txt | 32 +++++++++---------- .../baselines/reference/declInput.errors.txt | 8 ++--- ...ifiersAcrossContainerBoundaries.errors.txt | 8 ++--- ...IdentifiersAcrossFileBoundaries.errors.txt | 16 +++++----- .../interfaceDeclaration2.errors.txt | 8 ++--- .../reference/mergedClassInterface.errors.txt | 16 +++++----- .../reference/nameCollisions.errors.txt | 16 +++++----- ...tringsArrayTypeDefinedInES5Mode.errors.txt | 6 ++-- ...ingsArrayTypeRedefinedInES6Mode.errors.txt | 6 ++-- 13 files changed, 86 insertions(+), 86 deletions(-) diff --git a/tests/baselines/reference/augmentedTypesClass2.errors.txt b/tests/baselines/reference/augmentedTypesClass2.errors.txt index 2622429d74395..9d0b7b25c3414 100644 --- a/tests/baselines/reference/augmentedTypesClass2.errors.txt +++ b/tests/baselines/reference/augmentedTypesClass2.errors.txt @@ -1,5 +1,5 @@ -tests/cases/compiler/augmentedTypesClass2.ts(4,7): error TS2506: A non-ambient class cannot be merged with an interface. -tests/cases/compiler/augmentedTypesClass2.ts(10,11): error TS2507: An interface cannot merge with a non-ambient class. +tests/cases/compiler/augmentedTypesClass2.ts(4,7): error TS2506: Only an ambient class can be merged with an interface. +tests/cases/compiler/augmentedTypesClass2.ts(10,11): error TS2506: Only an ambient class can be merged with an interface. tests/cases/compiler/augmentedTypesClass2.ts(16,7): error TS2300: Duplicate identifier 'c33'. tests/cases/compiler/augmentedTypesClass2.ts(21,6): error TS2300: Duplicate identifier 'c33'. @@ -10,7 +10,7 @@ tests/cases/compiler/augmentedTypesClass2.ts(21,6): error TS2300: Duplicate iden // class then interface class c11 { // error ~~~ -!!! error TS2506: A non-ambient class cannot be merged with an interface. +!!! error TS2506: Only an ambient class can be merged with an interface. foo() { return 1; } @@ -18,7 +18,7 @@ tests/cases/compiler/augmentedTypesClass2.ts(21,6): error TS2300: Duplicate iden interface c11 { // error ~~~ -!!! error TS2507: An interface cannot merge with a non-ambient class. +!!! error TS2506: Only an ambient class can be merged with an interface. bar(): void; } diff --git a/tests/baselines/reference/augmentedTypesInterface.errors.txt b/tests/baselines/reference/augmentedTypesInterface.errors.txt index 9719539b344ed..8ee7dc4e1e80b 100644 --- a/tests/baselines/reference/augmentedTypesInterface.errors.txt +++ b/tests/baselines/reference/augmentedTypesInterface.errors.txt @@ -1,5 +1,5 @@ -tests/cases/compiler/augmentedTypesInterface.ts(12,11): error TS2507: An interface cannot merge with a non-ambient class. -tests/cases/compiler/augmentedTypesInterface.ts(16,7): error TS2506: A non-ambient class cannot be merged with an interface. +tests/cases/compiler/augmentedTypesInterface.ts(12,11): error TS2506: Only an ambient class can be merged with an interface. +tests/cases/compiler/augmentedTypesInterface.ts(16,7): error TS2506: Only an ambient class can be merged with an interface. tests/cases/compiler/augmentedTypesInterface.ts(23,11): error TS2300: Duplicate identifier 'i3'. tests/cases/compiler/augmentedTypesInterface.ts(26,6): error TS2300: Duplicate identifier 'i3'. @@ -18,13 +18,13 @@ tests/cases/compiler/augmentedTypesInterface.ts(26,6): error TS2300: Duplicate i // interface then class interface i2 { // error ~~ -!!! error TS2507: An interface cannot merge with a non-ambient class. +!!! error TS2506: Only an ambient class can be merged with an interface. foo(): void; } class i2 { // error ~~ -!!! error TS2506: A non-ambient class cannot be merged with an interface. +!!! error TS2506: Only an ambient class can be merged with an interface. bar() { return 1; } diff --git a/tests/baselines/reference/classAndInterfaceMerge.d.errors.txt b/tests/baselines/reference/classAndInterfaceMerge.d.errors.txt index d73e5fcb2f030..fa0d239cdc770 100644 --- a/tests/baselines/reference/classAndInterfaceMerge.d.errors.txt +++ b/tests/baselines/reference/classAndInterfaceMerge.d.errors.txt @@ -1,9 +1,9 @@ -tests/cases/conformance/classes/classDeclarations/classAndInterfaceMerge.d.ts(12,15): error TS2507: An interface cannot merge with a non-ambient class. -tests/cases/conformance/classes/classDeclarations/classAndInterfaceMerge.d.ts(14,11): error TS2506: A non-ambient class cannot be merged with an interface. -tests/cases/conformance/classes/classDeclarations/classAndInterfaceMerge.d.ts(16,15): error TS2507: An interface cannot merge with a non-ambient class. -tests/cases/conformance/classes/classDeclarations/classAndInterfaceMerge.d.ts(18,15): error TS2507: An interface cannot merge with a non-ambient class. -tests/cases/conformance/classes/classDeclarations/classAndInterfaceMerge.d.ts(20,18): error TS2506: A non-ambient class cannot be merged with an interface. -tests/cases/conformance/classes/classDeclarations/classAndInterfaceMerge.d.ts(24,22): error TS2507: An interface cannot merge with a non-ambient class. +tests/cases/conformance/classes/classDeclarations/classAndInterfaceMerge.d.ts(12,15): error TS2506: Only an ambient class can be merged with an interface. +tests/cases/conformance/classes/classDeclarations/classAndInterfaceMerge.d.ts(14,11): error TS2506: Only an ambient class can be merged with an interface. +tests/cases/conformance/classes/classDeclarations/classAndInterfaceMerge.d.ts(16,15): error TS2506: Only an ambient class can be merged with an interface. +tests/cases/conformance/classes/classDeclarations/classAndInterfaceMerge.d.ts(18,15): error TS2506: Only an ambient class can be merged with an interface. +tests/cases/conformance/classes/classDeclarations/classAndInterfaceMerge.d.ts(20,18): error TS2506: Only an ambient class can be merged with an interface. +tests/cases/conformance/classes/classDeclarations/classAndInterfaceMerge.d.ts(24,22): error TS2506: Only an ambient class can be merged with an interface. ==== tests/cases/conformance/classes/classDeclarations/classAndInterfaceMerge.d.ts (6 errors) ==== @@ -20,27 +20,27 @@ tests/cases/conformance/classes/classDeclarations/classAndInterfaceMerge.d.ts(24 interface C1 { } ~~ -!!! error TS2507: An interface cannot merge with a non-ambient class. +!!! error TS2506: Only an ambient class can be merged with an interface. class C1 { } ~~ -!!! error TS2506: A non-ambient class cannot be merged with an interface. +!!! error TS2506: Only an ambient class can be merged with an interface. interface C1 { } ~~ -!!! error TS2507: An interface cannot merge with a non-ambient class. +!!! error TS2506: Only an ambient class can be merged with an interface. interface C1 { } ~~ -!!! error TS2507: An interface cannot merge with a non-ambient class. +!!! error TS2506: Only an ambient class can be merged with an interface. export class C2 { } ~~ -!!! error TS2506: A non-ambient class cannot be merged with an interface. +!!! error TS2506: Only an ambient class can be merged with an interface. } declare module M { export interface C2 { } ~~ -!!! error TS2507: An interface cannot merge with a non-ambient class. +!!! error TS2506: Only an ambient class can be merged with an interface. } \ No newline at end of file diff --git a/tests/baselines/reference/classAndInterfaceWithSameName.errors.txt b/tests/baselines/reference/classAndInterfaceWithSameName.errors.txt index 6bf95880ceb4d..170ff29226b2d 100644 --- a/tests/baselines/reference/classAndInterfaceWithSameName.errors.txt +++ b/tests/baselines/reference/classAndInterfaceWithSameName.errors.txt @@ -1,29 +1,29 @@ -tests/cases/conformance/classes/classDeclarations/classAndInterfaceWithSameName.ts(1,7): error TS2506: A non-ambient class cannot be merged with an interface. +tests/cases/conformance/classes/classDeclarations/classAndInterfaceWithSameName.ts(1,7): error TS2506: Only an ambient class can be merged with an interface. tests/cases/conformance/classes/classDeclarations/classAndInterfaceWithSameName.ts(1,11): error TS2300: Duplicate identifier 'foo'. -tests/cases/conformance/classes/classDeclarations/classAndInterfaceWithSameName.ts(2,11): error TS2507: An interface cannot merge with a non-ambient class. +tests/cases/conformance/classes/classDeclarations/classAndInterfaceWithSameName.ts(2,11): error TS2506: Only an ambient class can be merged with an interface. tests/cases/conformance/classes/classDeclarations/classAndInterfaceWithSameName.ts(2,15): error TS2300: Duplicate identifier 'foo'. -tests/cases/conformance/classes/classDeclarations/classAndInterfaceWithSameName.ts(5,11): error TS2506: A non-ambient class cannot be merged with an interface. +tests/cases/conformance/classes/classDeclarations/classAndInterfaceWithSameName.ts(5,11): error TS2506: Only an ambient class can be merged with an interface. tests/cases/conformance/classes/classDeclarations/classAndInterfaceWithSameName.ts(6,9): error TS2300: Duplicate identifier 'bar'. -tests/cases/conformance/classes/classDeclarations/classAndInterfaceWithSameName.ts(9,15): error TS2507: An interface cannot merge with a non-ambient class. +tests/cases/conformance/classes/classDeclarations/classAndInterfaceWithSameName.ts(9,15): error TS2506: Only an ambient class can be merged with an interface. tests/cases/conformance/classes/classDeclarations/classAndInterfaceWithSameName.ts(10,9): error TS2300: Duplicate identifier 'bar'. ==== tests/cases/conformance/classes/classDeclarations/classAndInterfaceWithSameName.ts (8 errors) ==== class C { foo: string; } ~ -!!! error TS2506: A non-ambient class cannot be merged with an interface. +!!! error TS2506: Only an ambient class can be merged with an interface. ~~~ !!! error TS2300: Duplicate identifier 'foo'. interface C { foo: string; } // error ~ -!!! error TS2507: An interface cannot merge with a non-ambient class. +!!! error TS2506: Only an ambient class can be merged with an interface. ~~~ !!! error TS2300: Duplicate identifier 'foo'. module M { class D { ~ -!!! error TS2506: A non-ambient class cannot be merged with an interface. +!!! error TS2506: Only an ambient class can be merged with an interface. bar: string; ~~~ !!! error TS2300: Duplicate identifier 'bar'. @@ -31,7 +31,7 @@ tests/cases/conformance/classes/classDeclarations/classAndInterfaceWithSameName. interface D { // error ~ -!!! error TS2507: An interface cannot merge with a non-ambient class. +!!! error TS2506: Only an ambient class can be merged with an interface. bar: string; ~~~ !!! error TS2300: Duplicate identifier 'bar'. diff --git a/tests/baselines/reference/clinterfaces.errors.txt b/tests/baselines/reference/clinterfaces.errors.txt index 6e172fa0d9684..1d5ecd136f066 100644 --- a/tests/baselines/reference/clinterfaces.errors.txt +++ b/tests/baselines/reference/clinterfaces.errors.txt @@ -1,50 +1,50 @@ -tests/cases/compiler/clinterfaces.ts(2,11): error TS2506: A non-ambient class cannot be merged with an interface. -tests/cases/compiler/clinterfaces.ts(3,15): error TS2507: An interface cannot merge with a non-ambient class. -tests/cases/compiler/clinterfaces.ts(4,15): error TS2507: An interface cannot merge with a non-ambient class. -tests/cases/compiler/clinterfaces.ts(5,11): error TS2506: A non-ambient class cannot be merged with an interface. -tests/cases/compiler/clinterfaces.ts(8,11): error TS2507: An interface cannot merge with a non-ambient class. -tests/cases/compiler/clinterfaces.ts(12,7): error TS2506: A non-ambient class cannot be merged with an interface. -tests/cases/compiler/clinterfaces.ts(16,7): error TS2506: A non-ambient class cannot be merged with an interface. -tests/cases/compiler/clinterfaces.ts(20,11): error TS2507: An interface cannot merge with a non-ambient class. +tests/cases/compiler/clinterfaces.ts(2,11): error TS2506: Only an ambient class can be merged with an interface. +tests/cases/compiler/clinterfaces.ts(3,15): error TS2506: Only an ambient class can be merged with an interface. +tests/cases/compiler/clinterfaces.ts(4,15): error TS2506: Only an ambient class can be merged with an interface. +tests/cases/compiler/clinterfaces.ts(5,11): error TS2506: Only an ambient class can be merged with an interface. +tests/cases/compiler/clinterfaces.ts(8,11): error TS2506: Only an ambient class can be merged with an interface. +tests/cases/compiler/clinterfaces.ts(12,7): error TS2506: Only an ambient class can be merged with an interface. +tests/cases/compiler/clinterfaces.ts(16,7): error TS2506: Only an ambient class can be merged with an interface. +tests/cases/compiler/clinterfaces.ts(20,11): error TS2506: Only an ambient class can be merged with an interface. ==== tests/cases/compiler/clinterfaces.ts (8 errors) ==== module M { class C { } ~ -!!! error TS2506: A non-ambient class cannot be merged with an interface. +!!! error TS2506: Only an ambient class can be merged with an interface. interface C { } ~ -!!! error TS2507: An interface cannot merge with a non-ambient class. +!!! error TS2506: Only an ambient class can be merged with an interface. interface D { } ~ -!!! error TS2507: An interface cannot merge with a non-ambient class. +!!! error TS2506: Only an ambient class can be merged with an interface. class D { } ~ -!!! error TS2506: A non-ambient class cannot be merged with an interface. +!!! error TS2506: Only an ambient class can be merged with an interface. } interface Foo { ~~~ -!!! error TS2507: An interface cannot merge with a non-ambient class. +!!! error TS2506: Only an ambient class can be merged with an interface. a: string; } class Foo{ ~~~ -!!! error TS2506: A non-ambient class cannot be merged with an interface. +!!! error TS2506: Only an ambient class can be merged with an interface. b: number; } class Bar{ ~~~ -!!! error TS2506: A non-ambient class cannot be merged with an interface. +!!! error TS2506: Only an ambient class can be merged with an interface. b: number; } interface Bar { ~~~ -!!! error TS2507: An interface cannot merge with a non-ambient class. +!!! error TS2506: Only an ambient class can be merged with an interface. a: string; } diff --git a/tests/baselines/reference/declInput.errors.txt b/tests/baselines/reference/declInput.errors.txt index 313866cf93d5f..4e12c802bee61 100644 --- a/tests/baselines/reference/declInput.errors.txt +++ b/tests/baselines/reference/declInput.errors.txt @@ -1,17 +1,17 @@ -tests/cases/compiler/declInput.ts(1,11): error TS2507: An interface cannot merge with a non-ambient class. -tests/cases/compiler/declInput.ts(5,7): error TS2506: A non-ambient class cannot be merged with an interface. +tests/cases/compiler/declInput.ts(1,11): error TS2506: Only an ambient class can be merged with an interface. +tests/cases/compiler/declInput.ts(5,7): error TS2506: Only an ambient class can be merged with an interface. ==== tests/cases/compiler/declInput.ts (2 errors) ==== interface bar { ~~~ -!!! error TS2507: An interface cannot merge with a non-ambient class. +!!! error TS2506: Only an ambient class can be merged with an interface. } class bar { ~~~ -!!! error TS2506: A non-ambient class cannot be merged with an interface. +!!! error TS2506: Only an ambient class can be merged with an interface. public f() { return ''; } public g() { return {a: null, b: undefined, c: void 4 }; } public h(x = 4, y = null, z = '') { x++; } diff --git a/tests/baselines/reference/duplicateIdentifiersAcrossContainerBoundaries.errors.txt b/tests/baselines/reference/duplicateIdentifiersAcrossContainerBoundaries.errors.txt index 77a7f4ffb3553..f8b5c5595154a 100644 --- a/tests/baselines/reference/duplicateIdentifiersAcrossContainerBoundaries.errors.txt +++ b/tests/baselines/reference/duplicateIdentifiersAcrossContainerBoundaries.errors.txt @@ -1,5 +1,5 @@ -tests/cases/compiler/duplicateIdentifiersAcrossContainerBoundaries.ts(2,22): error TS2507: An interface cannot merge with a non-ambient class. -tests/cases/compiler/duplicateIdentifiersAcrossContainerBoundaries.ts(5,18): error TS2506: A non-ambient class cannot be merged with an interface. +tests/cases/compiler/duplicateIdentifiersAcrossContainerBoundaries.ts(2,22): error TS2506: Only an ambient class can be merged with an interface. +tests/cases/compiler/duplicateIdentifiersAcrossContainerBoundaries.ts(5,18): error TS2506: Only an ambient class can be merged with an interface. tests/cases/compiler/duplicateIdentifiersAcrossContainerBoundaries.ts(9,21): error TS2300: Duplicate identifier 'f'. tests/cases/compiler/duplicateIdentifiersAcrossContainerBoundaries.ts(12,18): error TS2300: Duplicate identifier 'f'. tests/cases/compiler/duplicateIdentifiersAcrossContainerBoundaries.ts(37,12): error TS2300: Duplicate identifier 'x'. @@ -10,12 +10,12 @@ tests/cases/compiler/duplicateIdentifiersAcrossContainerBoundaries.ts(41,16): er module M { export interface I { } ~ -!!! error TS2507: An interface cannot merge with a non-ambient class. +!!! error TS2506: Only an ambient class can be merged with an interface. } module M { export class I { } // error ~ -!!! error TS2506: A non-ambient class cannot be merged with an interface. +!!! error TS2506: Only an ambient class can be merged with an interface. } module M { diff --git a/tests/baselines/reference/duplicateIdentifiersAcrossFileBoundaries.errors.txt b/tests/baselines/reference/duplicateIdentifiersAcrossFileBoundaries.errors.txt index bd2233306690a..dcb2440aa2680 100644 --- a/tests/baselines/reference/duplicateIdentifiersAcrossFileBoundaries.errors.txt +++ b/tests/baselines/reference/duplicateIdentifiersAcrossFileBoundaries.errors.txt @@ -1,10 +1,10 @@ -tests/cases/compiler/file1.ts(2,11): error TS2507: An interface cannot merge with a non-ambient class. -tests/cases/compiler/file1.ts(3,7): error TS2506: A non-ambient class cannot be merged with an interface. +tests/cases/compiler/file1.ts(2,11): error TS2506: Only an ambient class can be merged with an interface. +tests/cases/compiler/file1.ts(3,7): error TS2506: Only an ambient class can be merged with an interface. tests/cases/compiler/file1.ts(4,7): error TS2300: Duplicate identifier 'C2'. tests/cases/compiler/file1.ts(5,10): error TS2300: Duplicate identifier 'f'. tests/cases/compiler/file1.ts(9,12): error TS2300: Duplicate identifier 'x'. -tests/cases/compiler/file2.ts(1,7): error TS2506: A non-ambient class cannot be merged with an interface. -tests/cases/compiler/file2.ts(2,11): error TS2507: An interface cannot merge with a non-ambient class. +tests/cases/compiler/file2.ts(1,7): error TS2506: Only an ambient class can be merged with an interface. +tests/cases/compiler/file2.ts(2,11): error TS2506: Only an ambient class can be merged with an interface. tests/cases/compiler/file2.ts(3,10): error TS2300: Duplicate identifier 'C2'. tests/cases/compiler/file2.ts(4,7): error TS2300: Duplicate identifier 'f'. tests/cases/compiler/file2.ts(7,8): error TS2433: A namespace declaration cannot be in a different file from a class or function with which it is merged @@ -15,10 +15,10 @@ tests/cases/compiler/file2.ts(8,16): error TS2300: Duplicate identifier 'x'. interface I { } ~ -!!! error TS2507: An interface cannot merge with a non-ambient class. +!!! error TS2506: Only an ambient class can be merged with an interface. class C1 { } ~~ -!!! error TS2506: A non-ambient class cannot be merged with an interface. +!!! error TS2506: Only an ambient class can be merged with an interface. class C2 { } ~~ !!! error TS2300: Duplicate identifier 'C2'. @@ -42,10 +42,10 @@ tests/cases/compiler/file2.ts(8,16): error TS2300: Duplicate identifier 'x'. ==== tests/cases/compiler/file2.ts (6 errors) ==== class I { } // error -- cannot merge interface with non-ambient class ~ -!!! error TS2506: A non-ambient class cannot be merged with an interface. +!!! error TS2506: Only an ambient class can be merged with an interface. interface C1 { } // error -- cannot merge interface with non-ambient class ~~ -!!! error TS2507: An interface cannot merge with a non-ambient class. +!!! error TS2506: Only an ambient class can be merged with an interface. function C2() { } // error -- cannot merge function with non-ambient class ~~ !!! error TS2300: Duplicate identifier 'C2'. diff --git a/tests/baselines/reference/interfaceDeclaration2.errors.txt b/tests/baselines/reference/interfaceDeclaration2.errors.txt index 06a0e24730188..2789657a20208 100644 --- a/tests/baselines/reference/interfaceDeclaration2.errors.txt +++ b/tests/baselines/reference/interfaceDeclaration2.errors.txt @@ -1,5 +1,5 @@ -tests/cases/compiler/interfaceDeclaration2.ts(4,11): error TS2507: An interface cannot merge with a non-ambient class. -tests/cases/compiler/interfaceDeclaration2.ts(5,7): error TS2506: A non-ambient class cannot be merged with an interface. +tests/cases/compiler/interfaceDeclaration2.ts(4,11): error TS2506: Only an ambient class can be merged with an interface. +tests/cases/compiler/interfaceDeclaration2.ts(5,7): error TS2506: Only an ambient class can be merged with an interface. ==== tests/cases/compiler/interfaceDeclaration2.ts (2 errors) ==== @@ -8,10 +8,10 @@ tests/cases/compiler/interfaceDeclaration2.ts(5,7): error TS2506: A non-ambient interface I2 { } ~~ -!!! error TS2507: An interface cannot merge with a non-ambient class. +!!! error TS2506: Only an ambient class can be merged with an interface. class I2 { } ~~ -!!! error TS2506: A non-ambient class cannot be merged with an interface. +!!! error TS2506: Only an ambient class can be merged with an interface. interface I3 { } function I3() { } diff --git a/tests/baselines/reference/mergedClassInterface.errors.txt b/tests/baselines/reference/mergedClassInterface.errors.txt index 42f0a14b8ef76..6177b5fa8713b 100644 --- a/tests/baselines/reference/mergedClassInterface.errors.txt +++ b/tests/baselines/reference/mergedClassInterface.errors.txt @@ -1,7 +1,7 @@ -tests/cases/conformance/classes/classDeclarations/file1.ts(11,7): error TS2506: A non-ambient class cannot be merged with an interface. -tests/cases/conformance/classes/classDeclarations/file1.ts(13,11): error TS2507: An interface cannot merge with a non-ambient class. -tests/cases/conformance/classes/classDeclarations/file1.ts(15,11): error TS2507: An interface cannot merge with a non-ambient class. -tests/cases/conformance/classes/classDeclarations/file1.ts(17,7): error TS2506: A non-ambient class cannot be merged with an interface. +tests/cases/conformance/classes/classDeclarations/file1.ts(11,7): error TS2506: Only an ambient class can be merged with an interface. +tests/cases/conformance/classes/classDeclarations/file1.ts(13,11): error TS2506: Only an ambient class can be merged with an interface. +tests/cases/conformance/classes/classDeclarations/file1.ts(15,11): error TS2506: Only an ambient class can be merged with an interface. +tests/cases/conformance/classes/classDeclarations/file1.ts(17,7): error TS2506: Only an ambient class can be merged with an interface. ==== tests/cases/conformance/classes/classDeclarations/file1.ts (4 errors) ==== @@ -17,19 +17,19 @@ tests/cases/conformance/classes/classDeclarations/file1.ts(17,7): error TS2506: class C3 { } // error -- cannot merge non-ambient class and interface ~~ -!!! error TS2506: A non-ambient class cannot be merged with an interface. +!!! error TS2506: Only an ambient class can be merged with an interface. interface C3 { } // error -- cannot merge non-ambient class and interface ~~ -!!! error TS2507: An interface cannot merge with a non-ambient class. +!!! error TS2506: Only an ambient class can be merged with an interface. interface C4 { } // error -- cannot merge non-ambient class and interface ~~ -!!! error TS2507: An interface cannot merge with a non-ambient class. +!!! error TS2506: Only an ambient class can be merged with an interface. class C4 { } // error -- cannot merge non-ambient class and interface ~~ -!!! error TS2506: A non-ambient class cannot be merged with an interface. +!!! error TS2506: Only an ambient class can be merged with an interface. interface C5 { x1: number; diff --git a/tests/baselines/reference/nameCollisions.errors.txt b/tests/baselines/reference/nameCollisions.errors.txt index d570d9e127841..bc7ec75257310 100644 --- a/tests/baselines/reference/nameCollisions.errors.txt +++ b/tests/baselines/reference/nameCollisions.errors.txt @@ -11,10 +11,10 @@ tests/cases/compiler/nameCollisions.ts(33,11): error TS2300: Duplicate identifie tests/cases/compiler/nameCollisions.ts(34,14): error TS2300: Duplicate identifier 'C'. tests/cases/compiler/nameCollisions.ts(36,14): error TS2300: Duplicate identifier 'C2'. tests/cases/compiler/nameCollisions.ts(37,11): error TS2300: Duplicate identifier 'C2'. -tests/cases/compiler/nameCollisions.ts(42,11): error TS2506: A non-ambient class cannot be merged with an interface. -tests/cases/compiler/nameCollisions.ts(43,15): error TS2507: An interface cannot merge with a non-ambient class. -tests/cases/compiler/nameCollisions.ts(45,15): error TS2507: An interface cannot merge with a non-ambient class. -tests/cases/compiler/nameCollisions.ts(46,11): error TS2506: A non-ambient class cannot be merged with an interface. +tests/cases/compiler/nameCollisions.ts(42,11): error TS2506: Only an ambient class can be merged with an interface. +tests/cases/compiler/nameCollisions.ts(43,15): error TS2506: Only an ambient class can be merged with an interface. +tests/cases/compiler/nameCollisions.ts(45,15): error TS2506: Only an ambient class can be merged with an interface. +tests/cases/compiler/nameCollisions.ts(46,11): error TS2506: Only an ambient class can be merged with an interface. ==== tests/cases/compiler/nameCollisions.ts (17 errors) ==== @@ -87,15 +87,15 @@ tests/cases/compiler/nameCollisions.ts(46,11): error TS2506: A non-ambient class class cli { } ~~~ -!!! error TS2506: A non-ambient class cannot be merged with an interface. +!!! error TS2506: Only an ambient class can be merged with an interface. interface cli { } // error ~~~ -!!! error TS2507: An interface cannot merge with a non-ambient class. +!!! error TS2506: Only an ambient class can be merged with an interface. interface cli2 { } ~~~~ -!!! error TS2507: An interface cannot merge with a non-ambient class. +!!! error TS2506: Only an ambient class can be merged with an interface. class cli2 { } // error ~~~~ -!!! error TS2506: A non-ambient class cannot be merged with an interface. +!!! error TS2506: Only an ambient class can be merged with an interface. } \ No newline at end of file diff --git a/tests/baselines/reference/templateStringsArrayTypeDefinedInES5Mode.errors.txt b/tests/baselines/reference/templateStringsArrayTypeDefinedInES5Mode.errors.txt index 9d6da3ec4b473..aabebad055226 100644 --- a/tests/baselines/reference/templateStringsArrayTypeDefinedInES5Mode.errors.txt +++ b/tests/baselines/reference/templateStringsArrayTypeDefinedInES5Mode.errors.txt @@ -1,5 +1,5 @@ -lib.d.ts(521,11): error TS2507: An interface cannot merge with a non-ambient class. -tests/cases/compiler/templateStringsArrayTypeDefinedInES5Mode.ts(2,7): error TS2506: A non-ambient class cannot be merged with an interface. +lib.d.ts(521,11): error TS2506: Only an ambient class can be merged with an interface. +tests/cases/compiler/templateStringsArrayTypeDefinedInES5Mode.ts(2,7): error TS2506: Only an ambient class can be merged with an interface. tests/cases/compiler/templateStringsArrayTypeDefinedInES5Mode.ts(8,3): error TS2345: Argument of type '{}' is not assignable to parameter of type 'TemplateStringsArray'. Property 'raw' is missing in type '{}'. @@ -8,7 +8,7 @@ tests/cases/compiler/templateStringsArrayTypeDefinedInES5Mode.ts(8,3): error TS2 class TemplateStringsArray { ~~~~~~~~~~~~~~~~~~~~ -!!! error TS2506: A non-ambient class cannot be merged with an interface. +!!! error TS2506: Only an ambient class can be merged with an interface. } function f(x: TemplateStringsArray, y: number, z: number) { diff --git a/tests/baselines/reference/templateStringsArrayTypeRedefinedInES6Mode.errors.txt b/tests/baselines/reference/templateStringsArrayTypeRedefinedInES6Mode.errors.txt index ffb619cedc76a..8b1c5fbe0e2a7 100644 --- a/tests/baselines/reference/templateStringsArrayTypeRedefinedInES6Mode.errors.txt +++ b/tests/baselines/reference/templateStringsArrayTypeRedefinedInES6Mode.errors.txt @@ -1,5 +1,5 @@ -lib.d.ts(521,11): error TS2507: An interface cannot merge with a non-ambient class. -tests/cases/compiler/templateStringsArrayTypeRedefinedInES6Mode.ts(2,7): error TS2506: A non-ambient class cannot be merged with an interface. +lib.d.ts(521,11): error TS2506: Only an ambient class can be merged with an interface. +tests/cases/compiler/templateStringsArrayTypeRedefinedInES6Mode.ts(2,7): error TS2506: Only an ambient class can be merged with an interface. tests/cases/compiler/templateStringsArrayTypeRedefinedInES6Mode.ts(8,3): error TS2345: Argument of type '{}' is not assignable to parameter of type 'TemplateStringsArray'. Property 'raw' is missing in type '{}'. @@ -8,7 +8,7 @@ tests/cases/compiler/templateStringsArrayTypeRedefinedInES6Mode.ts(8,3): error T class TemplateStringsArray { ~~~~~~~~~~~~~~~~~~~~ -!!! error TS2506: A non-ambient class cannot be merged with an interface. +!!! error TS2506: Only an ambient class can be merged with an interface. } function f(x: TemplateStringsArray, y: number, z: number) { From 143890b1174058bee05f54e22303ef8b19da77d8 Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Wed, 3 Jun 2015 14:22:39 -0700 Subject: [PATCH 23/31] New test --- .../mergeClassInterfaceAndModule.ts | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 tests/cases/conformance/classes/classDeclarations/mergeClassInterfaceAndModule.ts diff --git a/tests/cases/conformance/classes/classDeclarations/mergeClassInterfaceAndModule.ts b/tests/cases/conformance/classes/classDeclarations/mergeClassInterfaceAndModule.ts new file mode 100644 index 0000000000000..4dc733d28c05f --- /dev/null +++ b/tests/cases/conformance/classes/classDeclarations/mergeClassInterfaceAndModule.ts @@ -0,0 +1,16 @@ + +interface C1 {} +declare class C1 {} +module C1 {} + +declare class C2 {} +interface C2 {} +module C2 {} + +declare class C3 {} +module C3 {} +interface C3 {} + +module C4 {} +declare class C4 {} // error -- class declaration must preceed module declaration +interface C4 {} \ No newline at end of file From 323ce242877219127a6b388d18dcc9b003791cbb Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Wed, 3 Jun 2015 14:28:18 -0700 Subject: [PATCH 24/31] new baselines got mergeClassInterfaceAndModule --- .../reference/mergeClassInterfaceAndModule.js | 19 ++++++++++ .../mergeClassInterfaceAndModule.symbols | 38 +++++++++++++++++++ .../mergeClassInterfaceAndModule.types | 38 +++++++++++++++++++ 3 files changed, 95 insertions(+) create mode 100644 tests/baselines/reference/mergeClassInterfaceAndModule.js create mode 100644 tests/baselines/reference/mergeClassInterfaceAndModule.symbols create mode 100644 tests/baselines/reference/mergeClassInterfaceAndModule.types diff --git a/tests/baselines/reference/mergeClassInterfaceAndModule.js b/tests/baselines/reference/mergeClassInterfaceAndModule.js new file mode 100644 index 0000000000000..5b7315031cd21 --- /dev/null +++ b/tests/baselines/reference/mergeClassInterfaceAndModule.js @@ -0,0 +1,19 @@ +//// [mergeClassInterfaceAndModule.ts] + +interface C1 {} +declare class C1 {} +module C1 {} + +declare class C2 {} +interface C2 {} +module C2 {} + +declare class C3 {} +module C3 {} +interface C3 {} + +module C4 {} +declare class C4 {} // error -- class declaration must preceed module declaration +interface C4 {} + +//// [mergeClassInterfaceAndModule.js] diff --git a/tests/baselines/reference/mergeClassInterfaceAndModule.symbols b/tests/baselines/reference/mergeClassInterfaceAndModule.symbols new file mode 100644 index 0000000000000..a10227ed4618b --- /dev/null +++ b/tests/baselines/reference/mergeClassInterfaceAndModule.symbols @@ -0,0 +1,38 @@ +=== tests/cases/conformance/classes/classDeclarations/mergeClassInterfaceAndModule.ts === + +interface C1 {} +>C1 : Symbol(C1, Decl(mergeClassInterfaceAndModule.ts, 0, 0), Decl(mergeClassInterfaceAndModule.ts, 1, 15), Decl(mergeClassInterfaceAndModule.ts, 2, 19)) + +declare class C1 {} +>C1 : Symbol(C1, Decl(mergeClassInterfaceAndModule.ts, 0, 0), Decl(mergeClassInterfaceAndModule.ts, 1, 15), Decl(mergeClassInterfaceAndModule.ts, 2, 19)) + +module C1 {} +>C1 : Symbol(C1, Decl(mergeClassInterfaceAndModule.ts, 0, 0), Decl(mergeClassInterfaceAndModule.ts, 1, 15), Decl(mergeClassInterfaceAndModule.ts, 2, 19)) + +declare class C2 {} +>C2 : Symbol(C2, Decl(mergeClassInterfaceAndModule.ts, 3, 12), Decl(mergeClassInterfaceAndModule.ts, 5, 19), Decl(mergeClassInterfaceAndModule.ts, 6, 15)) + +interface C2 {} +>C2 : Symbol(C2, Decl(mergeClassInterfaceAndModule.ts, 3, 12), Decl(mergeClassInterfaceAndModule.ts, 5, 19), Decl(mergeClassInterfaceAndModule.ts, 6, 15)) + +module C2 {} +>C2 : Symbol(C2, Decl(mergeClassInterfaceAndModule.ts, 3, 12), Decl(mergeClassInterfaceAndModule.ts, 5, 19), Decl(mergeClassInterfaceAndModule.ts, 6, 15)) + +declare class C3 {} +>C3 : Symbol(C3, Decl(mergeClassInterfaceAndModule.ts, 7, 12), Decl(mergeClassInterfaceAndModule.ts, 9, 19), Decl(mergeClassInterfaceAndModule.ts, 10, 12)) + +module C3 {} +>C3 : Symbol(C3, Decl(mergeClassInterfaceAndModule.ts, 7, 12), Decl(mergeClassInterfaceAndModule.ts, 9, 19), Decl(mergeClassInterfaceAndModule.ts, 10, 12)) + +interface C3 {} +>C3 : Symbol(C3, Decl(mergeClassInterfaceAndModule.ts, 7, 12), Decl(mergeClassInterfaceAndModule.ts, 9, 19), Decl(mergeClassInterfaceAndModule.ts, 10, 12)) + +module C4 {} +>C4 : Symbol(C4, Decl(mergeClassInterfaceAndModule.ts, 11, 15), Decl(mergeClassInterfaceAndModule.ts, 13, 12), Decl(mergeClassInterfaceAndModule.ts, 14, 19)) + +declare class C4 {} // error -- class declaration must preceed module declaration +>C4 : Symbol(C4, Decl(mergeClassInterfaceAndModule.ts, 11, 15), Decl(mergeClassInterfaceAndModule.ts, 13, 12), Decl(mergeClassInterfaceAndModule.ts, 14, 19)) + +interface C4 {} +>C4 : Symbol(C4, Decl(mergeClassInterfaceAndModule.ts, 11, 15), Decl(mergeClassInterfaceAndModule.ts, 13, 12), Decl(mergeClassInterfaceAndModule.ts, 14, 19)) + diff --git a/tests/baselines/reference/mergeClassInterfaceAndModule.types b/tests/baselines/reference/mergeClassInterfaceAndModule.types new file mode 100644 index 0000000000000..a91691e5bacda --- /dev/null +++ b/tests/baselines/reference/mergeClassInterfaceAndModule.types @@ -0,0 +1,38 @@ +=== tests/cases/conformance/classes/classDeclarations/mergeClassInterfaceAndModule.ts === + +interface C1 {} +>C1 : C1 + +declare class C1 {} +>C1 : C1 + +module C1 {} +>C1 : typeof C1 + +declare class C2 {} +>C2 : C2 + +interface C2 {} +>C2 : C2 + +module C2 {} +>C2 : typeof C2 + +declare class C3 {} +>C3 : C3 + +module C3 {} +>C3 : typeof C3 + +interface C3 {} +>C3 : C3 + +module C4 {} +>C4 : typeof C4 + +declare class C4 {} // error -- class declaration must preceed module declaration +>C4 : C4 + +interface C4 {} +>C4 : C4 + From 365ea3d9099cdfe953d95b8ee75e68cdf3e53e1b Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Wed, 3 Jun 2015 15:51:59 -0700 Subject: [PATCH 25/31] Check for ambient context instead of ambient flag --- src/compiler/checker.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index b0b6521e23087..d904c670195b5 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -10415,8 +10415,8 @@ module ts { }); } - // Non-ambient classes cannot merge with interfaces. - if (!(node.flags & NodeFlags.Ambient) && symbol.flags & SymbolFlags.Interface) { + // Interfaces cannot be merged with non-ambient classes. + if (symbol.flags & SymbolFlags.Interface && !isInAmbientContext(node)) { error(node, Diagnostics.Only_an_ambient_class_can_be_merged_with_an_interface) } @@ -10603,7 +10603,7 @@ module ts { // Interfaces cannot merge with non-ambient classes. if (symbol && symbol.declarations) { for (let declaration of symbol.declarations) { - if (declaration.kind === SyntaxKind.ClassDeclaration && !(declaration.flags & NodeFlags.Ambient)) { + if (declaration.kind === SyntaxKind.ClassDeclaration && !isInAmbientContext(declaration)) { error(node, Diagnostics.Only_an_ambient_class_can_be_merged_with_an_interface); break; } From 5ef426ca02eb15605caa1aff6c4eccf70ffe06ad Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Wed, 3 Jun 2015 16:11:19 -0700 Subject: [PATCH 26/31] new baselines --- .../classAndInterfaceMerge.d.errors.txt | 46 ------------------- .../classAndInterfaceMerge.d.symbols | 39 ++++++++++++++++ .../reference/classAndInterfaceMerge.d.types | 39 ++++++++++++++++ 3 files changed, 78 insertions(+), 46 deletions(-) delete mode 100644 tests/baselines/reference/classAndInterfaceMerge.d.errors.txt create mode 100644 tests/baselines/reference/classAndInterfaceMerge.d.symbols create mode 100644 tests/baselines/reference/classAndInterfaceMerge.d.types diff --git a/tests/baselines/reference/classAndInterfaceMerge.d.errors.txt b/tests/baselines/reference/classAndInterfaceMerge.d.errors.txt deleted file mode 100644 index fa0d239cdc770..0000000000000 --- a/tests/baselines/reference/classAndInterfaceMerge.d.errors.txt +++ /dev/null @@ -1,46 +0,0 @@ -tests/cases/conformance/classes/classDeclarations/classAndInterfaceMerge.d.ts(12,15): error TS2506: Only an ambient class can be merged with an interface. -tests/cases/conformance/classes/classDeclarations/classAndInterfaceMerge.d.ts(14,11): error TS2506: Only an ambient class can be merged with an interface. -tests/cases/conformance/classes/classDeclarations/classAndInterfaceMerge.d.ts(16,15): error TS2506: Only an ambient class can be merged with an interface. -tests/cases/conformance/classes/classDeclarations/classAndInterfaceMerge.d.ts(18,15): error TS2506: Only an ambient class can be merged with an interface. -tests/cases/conformance/classes/classDeclarations/classAndInterfaceMerge.d.ts(20,18): error TS2506: Only an ambient class can be merged with an interface. -tests/cases/conformance/classes/classDeclarations/classAndInterfaceMerge.d.ts(24,22): error TS2506: Only an ambient class can be merged with an interface. - - -==== tests/cases/conformance/classes/classDeclarations/classAndInterfaceMerge.d.ts (6 errors) ==== - - interface C { } - - declare class C { } - - interface C { } - - interface C { } - - declare module M { - - interface C1 { } - ~~ -!!! error TS2506: Only an ambient class can be merged with an interface. - - class C1 { } - ~~ -!!! error TS2506: Only an ambient class can be merged with an interface. - - interface C1 { } - ~~ -!!! error TS2506: Only an ambient class can be merged with an interface. - - interface C1 { } - ~~ -!!! error TS2506: Only an ambient class can be merged with an interface. - - export class C2 { } - ~~ -!!! error TS2506: Only an ambient class can be merged with an interface. - } - - declare module M { - export interface C2 { } - ~~ -!!! error TS2506: Only an ambient class can be merged with an interface. - } \ No newline at end of file diff --git a/tests/baselines/reference/classAndInterfaceMerge.d.symbols b/tests/baselines/reference/classAndInterfaceMerge.d.symbols new file mode 100644 index 0000000000000..84fc2b129c145 --- /dev/null +++ b/tests/baselines/reference/classAndInterfaceMerge.d.symbols @@ -0,0 +1,39 @@ +=== tests/cases/conformance/classes/classDeclarations/classAndInterfaceMerge.d.ts === + +interface C { } +>C : Symbol(C, Decl(classAndInterfaceMerge.d.ts, 0, 0), Decl(classAndInterfaceMerge.d.ts, 1, 15), Decl(classAndInterfaceMerge.d.ts, 3, 19), Decl(classAndInterfaceMerge.d.ts, 5, 15)) + +declare class C { } +>C : Symbol(C, Decl(classAndInterfaceMerge.d.ts, 0, 0), Decl(classAndInterfaceMerge.d.ts, 1, 15), Decl(classAndInterfaceMerge.d.ts, 3, 19), Decl(classAndInterfaceMerge.d.ts, 5, 15)) + +interface C { } +>C : Symbol(C, Decl(classAndInterfaceMerge.d.ts, 0, 0), Decl(classAndInterfaceMerge.d.ts, 1, 15), Decl(classAndInterfaceMerge.d.ts, 3, 19), Decl(classAndInterfaceMerge.d.ts, 5, 15)) + +interface C { } +>C : Symbol(C, Decl(classAndInterfaceMerge.d.ts, 0, 0), Decl(classAndInterfaceMerge.d.ts, 1, 15), Decl(classAndInterfaceMerge.d.ts, 3, 19), Decl(classAndInterfaceMerge.d.ts, 5, 15)) + +declare module M { +>M : Symbol(M, Decl(classAndInterfaceMerge.d.ts, 7, 15), Decl(classAndInterfaceMerge.d.ts, 20, 1)) + + interface C1 { } +>C1 : Symbol(C1, Decl(classAndInterfaceMerge.d.ts, 9, 18), Decl(classAndInterfaceMerge.d.ts, 11, 20), Decl(classAndInterfaceMerge.d.ts, 13, 16), Decl(classAndInterfaceMerge.d.ts, 15, 20)) + + class C1 { } +>C1 : Symbol(C1, Decl(classAndInterfaceMerge.d.ts, 9, 18), Decl(classAndInterfaceMerge.d.ts, 11, 20), Decl(classAndInterfaceMerge.d.ts, 13, 16), Decl(classAndInterfaceMerge.d.ts, 15, 20)) + + interface C1 { } +>C1 : Symbol(C1, Decl(classAndInterfaceMerge.d.ts, 9, 18), Decl(classAndInterfaceMerge.d.ts, 11, 20), Decl(classAndInterfaceMerge.d.ts, 13, 16), Decl(classAndInterfaceMerge.d.ts, 15, 20)) + + interface C1 { } +>C1 : Symbol(C1, Decl(classAndInterfaceMerge.d.ts, 9, 18), Decl(classAndInterfaceMerge.d.ts, 11, 20), Decl(classAndInterfaceMerge.d.ts, 13, 16), Decl(classAndInterfaceMerge.d.ts, 15, 20)) + + export class C2 { } +>C2 : Symbol(C2, Decl(classAndInterfaceMerge.d.ts, 17, 20), Decl(classAndInterfaceMerge.d.ts, 22, 18)) +} + +declare module M { +>M : Symbol(M, Decl(classAndInterfaceMerge.d.ts, 7, 15), Decl(classAndInterfaceMerge.d.ts, 20, 1)) + + export interface C2 { } +>C2 : Symbol(C2, Decl(classAndInterfaceMerge.d.ts, 17, 20), Decl(classAndInterfaceMerge.d.ts, 22, 18)) +} diff --git a/tests/baselines/reference/classAndInterfaceMerge.d.types b/tests/baselines/reference/classAndInterfaceMerge.d.types new file mode 100644 index 0000000000000..baab121ca6ea6 --- /dev/null +++ b/tests/baselines/reference/classAndInterfaceMerge.d.types @@ -0,0 +1,39 @@ +=== tests/cases/conformance/classes/classDeclarations/classAndInterfaceMerge.d.ts === + +interface C { } +>C : C + +declare class C { } +>C : C + +interface C { } +>C : C + +interface C { } +>C : C + +declare module M { +>M : typeof M + + interface C1 { } +>C1 : C1 + + class C1 { } +>C1 : C1 + + interface C1 { } +>C1 : C1 + + interface C1 { } +>C1 : C1 + + export class C2 { } +>C2 : C2 +} + +declare module M { +>M : typeof M + + export interface C2 { } +>C2 : C2 +} From 3a3479d7e2ed9fd17c0ea096825143678b9f186f Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Thu, 4 Jun 2015 11:08:13 -0700 Subject: [PATCH 27/31] New Test and Baseline --- ...sImplementsMergedClassInterface.errors.txt | 41 +++++++++++++++++ .../classImplementsMergedClassInterface.js | 46 +++++++++++++++++++ .../classImplementsMergedClassInterface.ts | 23 ++++++++++ 3 files changed, 110 insertions(+) create mode 100644 tests/baselines/reference/classImplementsMergedClassInterface.errors.txt create mode 100644 tests/baselines/reference/classImplementsMergedClassInterface.js create mode 100644 tests/cases/conformance/classes/classDeclarations/classImplementsMergedClassInterface.ts diff --git a/tests/baselines/reference/classImplementsMergedClassInterface.errors.txt b/tests/baselines/reference/classImplementsMergedClassInterface.errors.txt new file mode 100644 index 0000000000000..3e62e72be8422 --- /dev/null +++ b/tests/baselines/reference/classImplementsMergedClassInterface.errors.txt @@ -0,0 +1,41 @@ +tests/cases/conformance/classes/classDeclarations/classImplementsMergedClassInterface.ts(9,7): error TS2420: Class 'C2' incorrectly implements interface 'C1'. + Property 'x' is missing in type 'C2'. +tests/cases/conformance/classes/classDeclarations/classImplementsMergedClassInterface.ts(12,7): error TS2420: Class 'C3' incorrectly implements interface 'C1'. + Property 'y' is missing in type 'C3'. +tests/cases/conformance/classes/classDeclarations/classImplementsMergedClassInterface.ts(16,7): error TS2420: Class 'C4' incorrectly implements interface 'C1'. + Property 'x' is missing in type 'C4'. + + +==== tests/cases/conformance/classes/classDeclarations/classImplementsMergedClassInterface.ts (3 errors) ==== + declare class C1 { + x : number; + } + + interface C1 { + y : number; + } + + class C2 implements C1 { // error -- missing x + ~~ +!!! error TS2420: Class 'C2' incorrectly implements interface 'C1'. +!!! error TS2420: Property 'x' is missing in type 'C2'. + } + + class C3 implements C1 { // error -- missing y + ~~ +!!! error TS2420: Class 'C3' incorrectly implements interface 'C1'. +!!! error TS2420: Property 'y' is missing in type 'C3'. + x : number; + } + + class C4 implements C1 { // error -- missing x + ~~ +!!! error TS2420: Class 'C4' incorrectly implements interface 'C1'. +!!! error TS2420: Property 'x' is missing in type 'C4'. + y : number; + } + + class C5 implements C1 { // okay + x : number; + y : number; + } \ No newline at end of file diff --git a/tests/baselines/reference/classImplementsMergedClassInterface.js b/tests/baselines/reference/classImplementsMergedClassInterface.js new file mode 100644 index 0000000000000..64a0198cc1627 --- /dev/null +++ b/tests/baselines/reference/classImplementsMergedClassInterface.js @@ -0,0 +1,46 @@ +//// [classImplementsMergedClassInterface.ts] +declare class C1 { + x : number; +} + +interface C1 { + y : number; +} + +class C2 implements C1 { // error -- missing x +} + +class C3 implements C1 { // error -- missing y + x : number; +} + +class C4 implements C1 { // error -- missing x + y : number; +} + +class C5 implements C1 { // okay + x : number; + y : number; +} + +//// [classImplementsMergedClassInterface.js] +var C2 = (function () { + function C2() { + } + return C2; +})(); +var C3 = (function () { + function C3() { + } + return C3; +})(); +var C4 = (function () { + function C4() { + } + return C4; +})(); +var C5 = (function () { + function C5() { + } + return C5; +})(); diff --git a/tests/cases/conformance/classes/classDeclarations/classImplementsMergedClassInterface.ts b/tests/cases/conformance/classes/classDeclarations/classImplementsMergedClassInterface.ts new file mode 100644 index 0000000000000..d5ac1b005bfd3 --- /dev/null +++ b/tests/cases/conformance/classes/classDeclarations/classImplementsMergedClassInterface.ts @@ -0,0 +1,23 @@ +declare class C1 { + x : number; +} + +interface C1 { + y : number; +} + +class C2 implements C1 { // error -- missing x +} + +class C3 implements C1 { // error -- missing y + x : number; +} + +class C4 implements C1 { // error -- missing x + y : number; +} + +class C5 implements C1 { // okay + x : number; + y : number; +} \ No newline at end of file From 91e3a5cce2906474f6e6af2d34df145ddc0c9bb8 Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Thu, 18 Jun 2015 12:27:48 -0700 Subject: [PATCH 28/31] updated baselines --- .../reference/augmentedTypesClass2.errors.txt | 8 ++--- .../augmentedTypesInterface.errors.txt | 8 ++--- .../classAndInterfaceWithSameName.errors.txt | 16 +++++----- .../reference/clinterfaces.errors.txt | 32 +++++++++---------- .../baselines/reference/declInput.errors.txt | 8 ++--- ...ifiersAcrossContainerBoundaries.errors.txt | 8 ++--- ...IdentifiersAcrossFileBoundaries.errors.txt | 16 +++++----- .../interfaceDeclaration2.errors.txt | 8 ++--- .../reference/mergedClassInterface.errors.txt | 16 +++++----- .../reference/nameCollisions.errors.txt | 16 +++++----- ...tringsArrayTypeDefinedInES5Mode.errors.txt | 5 ++- ...ingsArrayTypeRedefinedInES6Mode.errors.txt | 5 ++- 12 files changed, 72 insertions(+), 74 deletions(-) diff --git a/tests/baselines/reference/augmentedTypesClass2.errors.txt b/tests/baselines/reference/augmentedTypesClass2.errors.txt index 9d0b7b25c3414..da963c59d94bd 100644 --- a/tests/baselines/reference/augmentedTypesClass2.errors.txt +++ b/tests/baselines/reference/augmentedTypesClass2.errors.txt @@ -1,5 +1,5 @@ -tests/cases/compiler/augmentedTypesClass2.ts(4,7): error TS2506: Only an ambient class can be merged with an interface. -tests/cases/compiler/augmentedTypesClass2.ts(10,11): error TS2506: Only an ambient class can be merged with an interface. +tests/cases/compiler/augmentedTypesClass2.ts(4,7): error TS2511: Only an ambient class can be merged with an interface. +tests/cases/compiler/augmentedTypesClass2.ts(10,11): error TS2511: Only an ambient class can be merged with an interface. tests/cases/compiler/augmentedTypesClass2.ts(16,7): error TS2300: Duplicate identifier 'c33'. tests/cases/compiler/augmentedTypesClass2.ts(21,6): error TS2300: Duplicate identifier 'c33'. @@ -10,7 +10,7 @@ tests/cases/compiler/augmentedTypesClass2.ts(21,6): error TS2300: Duplicate iden // class then interface class c11 { // error ~~~ -!!! error TS2506: Only an ambient class can be merged with an interface. +!!! error TS2511: Only an ambient class can be merged with an interface. foo() { return 1; } @@ -18,7 +18,7 @@ tests/cases/compiler/augmentedTypesClass2.ts(21,6): error TS2300: Duplicate iden interface c11 { // error ~~~ -!!! error TS2506: Only an ambient class can be merged with an interface. +!!! error TS2511: Only an ambient class can be merged with an interface. bar(): void; } diff --git a/tests/baselines/reference/augmentedTypesInterface.errors.txt b/tests/baselines/reference/augmentedTypesInterface.errors.txt index 8ee7dc4e1e80b..44c47e70ab3df 100644 --- a/tests/baselines/reference/augmentedTypesInterface.errors.txt +++ b/tests/baselines/reference/augmentedTypesInterface.errors.txt @@ -1,5 +1,5 @@ -tests/cases/compiler/augmentedTypesInterface.ts(12,11): error TS2506: Only an ambient class can be merged with an interface. -tests/cases/compiler/augmentedTypesInterface.ts(16,7): error TS2506: Only an ambient class can be merged with an interface. +tests/cases/compiler/augmentedTypesInterface.ts(12,11): error TS2511: Only an ambient class can be merged with an interface. +tests/cases/compiler/augmentedTypesInterface.ts(16,7): error TS2511: Only an ambient class can be merged with an interface. tests/cases/compiler/augmentedTypesInterface.ts(23,11): error TS2300: Duplicate identifier 'i3'. tests/cases/compiler/augmentedTypesInterface.ts(26,6): error TS2300: Duplicate identifier 'i3'. @@ -18,13 +18,13 @@ tests/cases/compiler/augmentedTypesInterface.ts(26,6): error TS2300: Duplicate i // interface then class interface i2 { // error ~~ -!!! error TS2506: Only an ambient class can be merged with an interface. +!!! error TS2511: Only an ambient class can be merged with an interface. foo(): void; } class i2 { // error ~~ -!!! error TS2506: Only an ambient class can be merged with an interface. +!!! error TS2511: Only an ambient class can be merged with an interface. bar() { return 1; } diff --git a/tests/baselines/reference/classAndInterfaceWithSameName.errors.txt b/tests/baselines/reference/classAndInterfaceWithSameName.errors.txt index 170ff29226b2d..b2b59c290093d 100644 --- a/tests/baselines/reference/classAndInterfaceWithSameName.errors.txt +++ b/tests/baselines/reference/classAndInterfaceWithSameName.errors.txt @@ -1,29 +1,29 @@ -tests/cases/conformance/classes/classDeclarations/classAndInterfaceWithSameName.ts(1,7): error TS2506: Only an ambient class can be merged with an interface. +tests/cases/conformance/classes/classDeclarations/classAndInterfaceWithSameName.ts(1,7): error TS2511: Only an ambient class can be merged with an interface. tests/cases/conformance/classes/classDeclarations/classAndInterfaceWithSameName.ts(1,11): error TS2300: Duplicate identifier 'foo'. -tests/cases/conformance/classes/classDeclarations/classAndInterfaceWithSameName.ts(2,11): error TS2506: Only an ambient class can be merged with an interface. +tests/cases/conformance/classes/classDeclarations/classAndInterfaceWithSameName.ts(2,11): error TS2511: Only an ambient class can be merged with an interface. tests/cases/conformance/classes/classDeclarations/classAndInterfaceWithSameName.ts(2,15): error TS2300: Duplicate identifier 'foo'. -tests/cases/conformance/classes/classDeclarations/classAndInterfaceWithSameName.ts(5,11): error TS2506: Only an ambient class can be merged with an interface. +tests/cases/conformance/classes/classDeclarations/classAndInterfaceWithSameName.ts(5,11): error TS2511: Only an ambient class can be merged with an interface. tests/cases/conformance/classes/classDeclarations/classAndInterfaceWithSameName.ts(6,9): error TS2300: Duplicate identifier 'bar'. -tests/cases/conformance/classes/classDeclarations/classAndInterfaceWithSameName.ts(9,15): error TS2506: Only an ambient class can be merged with an interface. +tests/cases/conformance/classes/classDeclarations/classAndInterfaceWithSameName.ts(9,15): error TS2511: Only an ambient class can be merged with an interface. tests/cases/conformance/classes/classDeclarations/classAndInterfaceWithSameName.ts(10,9): error TS2300: Duplicate identifier 'bar'. ==== tests/cases/conformance/classes/classDeclarations/classAndInterfaceWithSameName.ts (8 errors) ==== class C { foo: string; } ~ -!!! error TS2506: Only an ambient class can be merged with an interface. +!!! error TS2511: Only an ambient class can be merged with an interface. ~~~ !!! error TS2300: Duplicate identifier 'foo'. interface C { foo: string; } // error ~ -!!! error TS2506: Only an ambient class can be merged with an interface. +!!! error TS2511: Only an ambient class can be merged with an interface. ~~~ !!! error TS2300: Duplicate identifier 'foo'. module M { class D { ~ -!!! error TS2506: Only an ambient class can be merged with an interface. +!!! error TS2511: Only an ambient class can be merged with an interface. bar: string; ~~~ !!! error TS2300: Duplicate identifier 'bar'. @@ -31,7 +31,7 @@ tests/cases/conformance/classes/classDeclarations/classAndInterfaceWithSameName. interface D { // error ~ -!!! error TS2506: Only an ambient class can be merged with an interface. +!!! error TS2511: Only an ambient class can be merged with an interface. bar: string; ~~~ !!! error TS2300: Duplicate identifier 'bar'. diff --git a/tests/baselines/reference/clinterfaces.errors.txt b/tests/baselines/reference/clinterfaces.errors.txt index 1d5ecd136f066..8d48f29aed708 100644 --- a/tests/baselines/reference/clinterfaces.errors.txt +++ b/tests/baselines/reference/clinterfaces.errors.txt @@ -1,50 +1,50 @@ -tests/cases/compiler/clinterfaces.ts(2,11): error TS2506: Only an ambient class can be merged with an interface. -tests/cases/compiler/clinterfaces.ts(3,15): error TS2506: Only an ambient class can be merged with an interface. -tests/cases/compiler/clinterfaces.ts(4,15): error TS2506: Only an ambient class can be merged with an interface. -tests/cases/compiler/clinterfaces.ts(5,11): error TS2506: Only an ambient class can be merged with an interface. -tests/cases/compiler/clinterfaces.ts(8,11): error TS2506: Only an ambient class can be merged with an interface. -tests/cases/compiler/clinterfaces.ts(12,7): error TS2506: Only an ambient class can be merged with an interface. -tests/cases/compiler/clinterfaces.ts(16,7): error TS2506: Only an ambient class can be merged with an interface. -tests/cases/compiler/clinterfaces.ts(20,11): error TS2506: Only an ambient class can be merged with an interface. +tests/cases/compiler/clinterfaces.ts(2,11): error TS2511: Only an ambient class can be merged with an interface. +tests/cases/compiler/clinterfaces.ts(3,15): error TS2511: Only an ambient class can be merged with an interface. +tests/cases/compiler/clinterfaces.ts(4,15): error TS2511: Only an ambient class can be merged with an interface. +tests/cases/compiler/clinterfaces.ts(5,11): error TS2511: Only an ambient class can be merged with an interface. +tests/cases/compiler/clinterfaces.ts(8,11): error TS2511: Only an ambient class can be merged with an interface. +tests/cases/compiler/clinterfaces.ts(12,7): error TS2511: Only an ambient class can be merged with an interface. +tests/cases/compiler/clinterfaces.ts(16,7): error TS2511: Only an ambient class can be merged with an interface. +tests/cases/compiler/clinterfaces.ts(20,11): error TS2511: Only an ambient class can be merged with an interface. ==== tests/cases/compiler/clinterfaces.ts (8 errors) ==== module M { class C { } ~ -!!! error TS2506: Only an ambient class can be merged with an interface. +!!! error TS2511: Only an ambient class can be merged with an interface. interface C { } ~ -!!! error TS2506: Only an ambient class can be merged with an interface. +!!! error TS2511: Only an ambient class can be merged with an interface. interface D { } ~ -!!! error TS2506: Only an ambient class can be merged with an interface. +!!! error TS2511: Only an ambient class can be merged with an interface. class D { } ~ -!!! error TS2506: Only an ambient class can be merged with an interface. +!!! error TS2511: Only an ambient class can be merged with an interface. } interface Foo { ~~~ -!!! error TS2506: Only an ambient class can be merged with an interface. +!!! error TS2511: Only an ambient class can be merged with an interface. a: string; } class Foo{ ~~~ -!!! error TS2506: Only an ambient class can be merged with an interface. +!!! error TS2511: Only an ambient class can be merged with an interface. b: number; } class Bar{ ~~~ -!!! error TS2506: Only an ambient class can be merged with an interface. +!!! error TS2511: Only an ambient class can be merged with an interface. b: number; } interface Bar { ~~~ -!!! error TS2506: Only an ambient class can be merged with an interface. +!!! error TS2511: Only an ambient class can be merged with an interface. a: string; } diff --git a/tests/baselines/reference/declInput.errors.txt b/tests/baselines/reference/declInput.errors.txt index 4e12c802bee61..76257de6ea9ba 100644 --- a/tests/baselines/reference/declInput.errors.txt +++ b/tests/baselines/reference/declInput.errors.txt @@ -1,17 +1,17 @@ -tests/cases/compiler/declInput.ts(1,11): error TS2506: Only an ambient class can be merged with an interface. -tests/cases/compiler/declInput.ts(5,7): error TS2506: Only an ambient class can be merged with an interface. +tests/cases/compiler/declInput.ts(1,11): error TS2511: Only an ambient class can be merged with an interface. +tests/cases/compiler/declInput.ts(5,7): error TS2511: Only an ambient class can be merged with an interface. ==== tests/cases/compiler/declInput.ts (2 errors) ==== interface bar { ~~~ -!!! error TS2506: Only an ambient class can be merged with an interface. +!!! error TS2511: Only an ambient class can be merged with an interface. } class bar { ~~~ -!!! error TS2506: Only an ambient class can be merged with an interface. +!!! error TS2511: Only an ambient class can be merged with an interface. public f() { return ''; } public g() { return {a: null, b: undefined, c: void 4 }; } public h(x = 4, y = null, z = '') { x++; } diff --git a/tests/baselines/reference/duplicateIdentifiersAcrossContainerBoundaries.errors.txt b/tests/baselines/reference/duplicateIdentifiersAcrossContainerBoundaries.errors.txt index f8b5c5595154a..67ee1d9cc371e 100644 --- a/tests/baselines/reference/duplicateIdentifiersAcrossContainerBoundaries.errors.txt +++ b/tests/baselines/reference/duplicateIdentifiersAcrossContainerBoundaries.errors.txt @@ -1,5 +1,5 @@ -tests/cases/compiler/duplicateIdentifiersAcrossContainerBoundaries.ts(2,22): error TS2506: Only an ambient class can be merged with an interface. -tests/cases/compiler/duplicateIdentifiersAcrossContainerBoundaries.ts(5,18): error TS2506: Only an ambient class can be merged with an interface. +tests/cases/compiler/duplicateIdentifiersAcrossContainerBoundaries.ts(2,22): error TS2511: Only an ambient class can be merged with an interface. +tests/cases/compiler/duplicateIdentifiersAcrossContainerBoundaries.ts(5,18): error TS2511: Only an ambient class can be merged with an interface. tests/cases/compiler/duplicateIdentifiersAcrossContainerBoundaries.ts(9,21): error TS2300: Duplicate identifier 'f'. tests/cases/compiler/duplicateIdentifiersAcrossContainerBoundaries.ts(12,18): error TS2300: Duplicate identifier 'f'. tests/cases/compiler/duplicateIdentifiersAcrossContainerBoundaries.ts(37,12): error TS2300: Duplicate identifier 'x'. @@ -10,12 +10,12 @@ tests/cases/compiler/duplicateIdentifiersAcrossContainerBoundaries.ts(41,16): er module M { export interface I { } ~ -!!! error TS2506: Only an ambient class can be merged with an interface. +!!! error TS2511: Only an ambient class can be merged with an interface. } module M { export class I { } // error ~ -!!! error TS2506: Only an ambient class can be merged with an interface. +!!! error TS2511: Only an ambient class can be merged with an interface. } module M { diff --git a/tests/baselines/reference/duplicateIdentifiersAcrossFileBoundaries.errors.txt b/tests/baselines/reference/duplicateIdentifiersAcrossFileBoundaries.errors.txt index dcb2440aa2680..c98e0e9a8c63a 100644 --- a/tests/baselines/reference/duplicateIdentifiersAcrossFileBoundaries.errors.txt +++ b/tests/baselines/reference/duplicateIdentifiersAcrossFileBoundaries.errors.txt @@ -1,10 +1,10 @@ -tests/cases/compiler/file1.ts(2,11): error TS2506: Only an ambient class can be merged with an interface. -tests/cases/compiler/file1.ts(3,7): error TS2506: Only an ambient class can be merged with an interface. +tests/cases/compiler/file1.ts(2,11): error TS2511: Only an ambient class can be merged with an interface. +tests/cases/compiler/file1.ts(3,7): error TS2511: Only an ambient class can be merged with an interface. tests/cases/compiler/file1.ts(4,7): error TS2300: Duplicate identifier 'C2'. tests/cases/compiler/file1.ts(5,10): error TS2300: Duplicate identifier 'f'. tests/cases/compiler/file1.ts(9,12): error TS2300: Duplicate identifier 'x'. -tests/cases/compiler/file2.ts(1,7): error TS2506: Only an ambient class can be merged with an interface. -tests/cases/compiler/file2.ts(2,11): error TS2506: Only an ambient class can be merged with an interface. +tests/cases/compiler/file2.ts(1,7): error TS2511: Only an ambient class can be merged with an interface. +tests/cases/compiler/file2.ts(2,11): error TS2511: Only an ambient class can be merged with an interface. tests/cases/compiler/file2.ts(3,10): error TS2300: Duplicate identifier 'C2'. tests/cases/compiler/file2.ts(4,7): error TS2300: Duplicate identifier 'f'. tests/cases/compiler/file2.ts(7,8): error TS2433: A namespace declaration cannot be in a different file from a class or function with which it is merged @@ -15,10 +15,10 @@ tests/cases/compiler/file2.ts(8,16): error TS2300: Duplicate identifier 'x'. interface I { } ~ -!!! error TS2506: Only an ambient class can be merged with an interface. +!!! error TS2511: Only an ambient class can be merged with an interface. class C1 { } ~~ -!!! error TS2506: Only an ambient class can be merged with an interface. +!!! error TS2511: Only an ambient class can be merged with an interface. class C2 { } ~~ !!! error TS2300: Duplicate identifier 'C2'. @@ -42,10 +42,10 @@ tests/cases/compiler/file2.ts(8,16): error TS2300: Duplicate identifier 'x'. ==== tests/cases/compiler/file2.ts (6 errors) ==== class I { } // error -- cannot merge interface with non-ambient class ~ -!!! error TS2506: Only an ambient class can be merged with an interface. +!!! error TS2511: Only an ambient class can be merged with an interface. interface C1 { } // error -- cannot merge interface with non-ambient class ~~ -!!! error TS2506: Only an ambient class can be merged with an interface. +!!! error TS2511: Only an ambient class can be merged with an interface. function C2() { } // error -- cannot merge function with non-ambient class ~~ !!! error TS2300: Duplicate identifier 'C2'. diff --git a/tests/baselines/reference/interfaceDeclaration2.errors.txt b/tests/baselines/reference/interfaceDeclaration2.errors.txt index 2789657a20208..1d5807b9b1b8b 100644 --- a/tests/baselines/reference/interfaceDeclaration2.errors.txt +++ b/tests/baselines/reference/interfaceDeclaration2.errors.txt @@ -1,5 +1,5 @@ -tests/cases/compiler/interfaceDeclaration2.ts(4,11): error TS2506: Only an ambient class can be merged with an interface. -tests/cases/compiler/interfaceDeclaration2.ts(5,7): error TS2506: Only an ambient class can be merged with an interface. +tests/cases/compiler/interfaceDeclaration2.ts(4,11): error TS2511: Only an ambient class can be merged with an interface. +tests/cases/compiler/interfaceDeclaration2.ts(5,7): error TS2511: Only an ambient class can be merged with an interface. ==== tests/cases/compiler/interfaceDeclaration2.ts (2 errors) ==== @@ -8,10 +8,10 @@ tests/cases/compiler/interfaceDeclaration2.ts(5,7): error TS2506: Only an ambien interface I2 { } ~~ -!!! error TS2506: Only an ambient class can be merged with an interface. +!!! error TS2511: Only an ambient class can be merged with an interface. class I2 { } ~~ -!!! error TS2506: Only an ambient class can be merged with an interface. +!!! error TS2511: Only an ambient class can be merged with an interface. interface I3 { } function I3() { } diff --git a/tests/baselines/reference/mergedClassInterface.errors.txt b/tests/baselines/reference/mergedClassInterface.errors.txt index 6177b5fa8713b..37bd595c0b736 100644 --- a/tests/baselines/reference/mergedClassInterface.errors.txt +++ b/tests/baselines/reference/mergedClassInterface.errors.txt @@ -1,7 +1,7 @@ -tests/cases/conformance/classes/classDeclarations/file1.ts(11,7): error TS2506: Only an ambient class can be merged with an interface. -tests/cases/conformance/classes/classDeclarations/file1.ts(13,11): error TS2506: Only an ambient class can be merged with an interface. -tests/cases/conformance/classes/classDeclarations/file1.ts(15,11): error TS2506: Only an ambient class can be merged with an interface. -tests/cases/conformance/classes/classDeclarations/file1.ts(17,7): error TS2506: Only an ambient class can be merged with an interface. +tests/cases/conformance/classes/classDeclarations/file1.ts(11,7): error TS2511: Only an ambient class can be merged with an interface. +tests/cases/conformance/classes/classDeclarations/file1.ts(13,11): error TS2511: Only an ambient class can be merged with an interface. +tests/cases/conformance/classes/classDeclarations/file1.ts(15,11): error TS2511: Only an ambient class can be merged with an interface. +tests/cases/conformance/classes/classDeclarations/file1.ts(17,7): error TS2511: Only an ambient class can be merged with an interface. ==== tests/cases/conformance/classes/classDeclarations/file1.ts (4 errors) ==== @@ -17,19 +17,19 @@ tests/cases/conformance/classes/classDeclarations/file1.ts(17,7): error TS2506: class C3 { } // error -- cannot merge non-ambient class and interface ~~ -!!! error TS2506: Only an ambient class can be merged with an interface. +!!! error TS2511: Only an ambient class can be merged with an interface. interface C3 { } // error -- cannot merge non-ambient class and interface ~~ -!!! error TS2506: Only an ambient class can be merged with an interface. +!!! error TS2511: Only an ambient class can be merged with an interface. interface C4 { } // error -- cannot merge non-ambient class and interface ~~ -!!! error TS2506: Only an ambient class can be merged with an interface. +!!! error TS2511: Only an ambient class can be merged with an interface. class C4 { } // error -- cannot merge non-ambient class and interface ~~ -!!! error TS2506: Only an ambient class can be merged with an interface. +!!! error TS2511: Only an ambient class can be merged with an interface. interface C5 { x1: number; diff --git a/tests/baselines/reference/nameCollisions.errors.txt b/tests/baselines/reference/nameCollisions.errors.txt index bc7ec75257310..2aba1c43f86d3 100644 --- a/tests/baselines/reference/nameCollisions.errors.txt +++ b/tests/baselines/reference/nameCollisions.errors.txt @@ -11,10 +11,10 @@ tests/cases/compiler/nameCollisions.ts(33,11): error TS2300: Duplicate identifie tests/cases/compiler/nameCollisions.ts(34,14): error TS2300: Duplicate identifier 'C'. tests/cases/compiler/nameCollisions.ts(36,14): error TS2300: Duplicate identifier 'C2'. tests/cases/compiler/nameCollisions.ts(37,11): error TS2300: Duplicate identifier 'C2'. -tests/cases/compiler/nameCollisions.ts(42,11): error TS2506: Only an ambient class can be merged with an interface. -tests/cases/compiler/nameCollisions.ts(43,15): error TS2506: Only an ambient class can be merged with an interface. -tests/cases/compiler/nameCollisions.ts(45,15): error TS2506: Only an ambient class can be merged with an interface. -tests/cases/compiler/nameCollisions.ts(46,11): error TS2506: Only an ambient class can be merged with an interface. +tests/cases/compiler/nameCollisions.ts(42,11): error TS2511: Only an ambient class can be merged with an interface. +tests/cases/compiler/nameCollisions.ts(43,15): error TS2511: Only an ambient class can be merged with an interface. +tests/cases/compiler/nameCollisions.ts(45,15): error TS2511: Only an ambient class can be merged with an interface. +tests/cases/compiler/nameCollisions.ts(46,11): error TS2511: Only an ambient class can be merged with an interface. ==== tests/cases/compiler/nameCollisions.ts (17 errors) ==== @@ -87,15 +87,15 @@ tests/cases/compiler/nameCollisions.ts(46,11): error TS2506: Only an ambient cla class cli { } ~~~ -!!! error TS2506: Only an ambient class can be merged with an interface. +!!! error TS2511: Only an ambient class can be merged with an interface. interface cli { } // error ~~~ -!!! error TS2506: Only an ambient class can be merged with an interface. +!!! error TS2511: Only an ambient class can be merged with an interface. interface cli2 { } ~~~~ -!!! error TS2506: Only an ambient class can be merged with an interface. +!!! error TS2511: Only an ambient class can be merged with an interface. class cli2 { } // error ~~~~ -!!! error TS2506: Only an ambient class can be merged with an interface. +!!! error TS2511: Only an ambient class can be merged with an interface. } \ No newline at end of file diff --git a/tests/baselines/reference/templateStringsArrayTypeDefinedInES5Mode.errors.txt b/tests/baselines/reference/templateStringsArrayTypeDefinedInES5Mode.errors.txt index aabebad055226..a51eb18d98efc 100644 --- a/tests/baselines/reference/templateStringsArrayTypeDefinedInES5Mode.errors.txt +++ b/tests/baselines/reference/templateStringsArrayTypeDefinedInES5Mode.errors.txt @@ -1,5 +1,4 @@ -lib.d.ts(521,11): error TS2506: Only an ambient class can be merged with an interface. -tests/cases/compiler/templateStringsArrayTypeDefinedInES5Mode.ts(2,7): error TS2506: Only an ambient class can be merged with an interface. +tests/cases/compiler/templateStringsArrayTypeDefinedInES5Mode.ts(2,7): error TS2511: Only an ambient class can be merged with an interface. tests/cases/compiler/templateStringsArrayTypeDefinedInES5Mode.ts(8,3): error TS2345: Argument of type '{}' is not assignable to parameter of type 'TemplateStringsArray'. Property 'raw' is missing in type '{}'. @@ -8,7 +7,7 @@ tests/cases/compiler/templateStringsArrayTypeDefinedInES5Mode.ts(8,3): error TS2 class TemplateStringsArray { ~~~~~~~~~~~~~~~~~~~~ -!!! error TS2506: Only an ambient class can be merged with an interface. +!!! error TS2511: Only an ambient class can be merged with an interface. } function f(x: TemplateStringsArray, y: number, z: number) { diff --git a/tests/baselines/reference/templateStringsArrayTypeRedefinedInES6Mode.errors.txt b/tests/baselines/reference/templateStringsArrayTypeRedefinedInES6Mode.errors.txt index 8b1c5fbe0e2a7..d41c3d0cdbf03 100644 --- a/tests/baselines/reference/templateStringsArrayTypeRedefinedInES6Mode.errors.txt +++ b/tests/baselines/reference/templateStringsArrayTypeRedefinedInES6Mode.errors.txt @@ -1,5 +1,4 @@ -lib.d.ts(521,11): error TS2506: Only an ambient class can be merged with an interface. -tests/cases/compiler/templateStringsArrayTypeRedefinedInES6Mode.ts(2,7): error TS2506: Only an ambient class can be merged with an interface. +tests/cases/compiler/templateStringsArrayTypeRedefinedInES6Mode.ts(2,7): error TS2511: Only an ambient class can be merged with an interface. tests/cases/compiler/templateStringsArrayTypeRedefinedInES6Mode.ts(8,3): error TS2345: Argument of type '{}' is not assignable to parameter of type 'TemplateStringsArray'. Property 'raw' is missing in type '{}'. @@ -8,7 +7,7 @@ tests/cases/compiler/templateStringsArrayTypeRedefinedInES6Mode.ts(8,3): error T class TemplateStringsArray { ~~~~~~~~~~~~~~~~~~~~ -!!! error TS2506: Only an ambient class can be merged with an interface. +!!! error TS2511: Only an ambient class can be merged with an interface. } function f(x: TemplateStringsArray, y: number, z: number) { From 851c7e4bf9d2fb270a209a8a6defd3c5c9846932 Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Thu, 18 Jun 2015 12:35:06 -0700 Subject: [PATCH 29/31] fixed comment, spacing --- src/compiler/binder.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index f1d8b141a103b..07279e93b5513 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -176,7 +176,7 @@ namespace ts { /** * Declares a Symbol for the node and adds it to symbols. Reports errors for conflicting identifier names. * @param symbolTable - The symbol table which node will be added to. - * @param parent - If node is in a class, parent denotes the parent declaration. + * @param parent - node's parent declaration. * @param node - The declaration to be added to the symbol table * @param includes - The SymbolFlags that node has in addition to its declaration type (eg: export, ambient, etc.) * @param excludes - The flags which node cannot be declared alongside in a symbol table. Used to report forbidden declarations. @@ -211,11 +211,11 @@ namespace ts { symbol = hasProperty(symbolTable, name) ? symbolTable[name] : (symbolTable[name] = createSymbol(SymbolFlags.None, name)); - + if (name && (includes & SymbolFlags.Classifiable)) { - classifiableNames[name] = name; + classifiableNames[name] = name; } - + if (symbol.flags & excludes) { if (node.name) { node.name.parent = node; From c06e5eb8b493e377e44400aaa4307d00524ee4bf Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Thu, 2 Jul 2015 10:26:23 -0700 Subject: [PATCH 30/31] Update test --- .../classAbstractMergedDeclaration.ts | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMergedDeclaration.ts b/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMergedDeclaration.ts index 160c0de298bb3..6e5686feb2562 100644 --- a/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMergedDeclaration.ts +++ b/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMergedDeclaration.ts @@ -16,9 +16,25 @@ class CC1 {} class CC2 {} abstract class CC2 {} +declare abstract class DCI {} +interface DCI {} + +interface DIC {} +declare abstract class DIC {} + +declare abstract class DCC1 {} +declare class DCC1 {} + +declare class DCC2 {} +declare abstract class DCC2 {} + new CM; new MC; new CI; new IC; new CC1; -new CC2; \ No newline at end of file +new CC2; +new DCI; +new DIC; +new DCC1; +new DCC2; \ No newline at end of file From 3af3177fe3bae91761611fa419aedaaf5842080e Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Thu, 2 Jul 2015 10:26:36 -0700 Subject: [PATCH 31/31] update baselines --- .../reference/augmentedTypesClass2.errors.txt | 8 +-- .../augmentedTypesInterface.errors.txt | 8 +-- .../classAbstractMergedDeclaration.errors.txt | 71 ++++++++++++++----- .../classAbstractMergedDeclaration.js | 22 +++++- .../classAndInterfaceWithSameName.errors.txt | 16 ++--- .../reference/clinterfaces.errors.txt | 32 ++++----- .../baselines/reference/declInput.errors.txt | 8 +-- ...ifiersAcrossContainerBoundaries.errors.txt | 8 +-- ...IdentifiersAcrossFileBoundaries.errors.txt | 16 ++--- .../interfaceDeclaration2.errors.txt | 8 +-- .../reference/mergedClassInterface.errors.txt | 16 ++--- .../reference/nameCollisions.errors.txt | 16 ++--- ...tringsArrayTypeDefinedInES5Mode.errors.txt | 4 +- ...ingsArrayTypeRedefinedInES6Mode.errors.txt | 4 +- 14 files changed, 147 insertions(+), 90 deletions(-) diff --git a/tests/baselines/reference/augmentedTypesClass2.errors.txt b/tests/baselines/reference/augmentedTypesClass2.errors.txt index da963c59d94bd..278dca816fa30 100644 --- a/tests/baselines/reference/augmentedTypesClass2.errors.txt +++ b/tests/baselines/reference/augmentedTypesClass2.errors.txt @@ -1,5 +1,5 @@ -tests/cases/compiler/augmentedTypesClass2.ts(4,7): error TS2511: Only an ambient class can be merged with an interface. -tests/cases/compiler/augmentedTypesClass2.ts(10,11): error TS2511: Only an ambient class can be merged with an interface. +tests/cases/compiler/augmentedTypesClass2.ts(4,7): error TS2518: Only an ambient class can be merged with an interface. +tests/cases/compiler/augmentedTypesClass2.ts(10,11): error TS2518: Only an ambient class can be merged with an interface. tests/cases/compiler/augmentedTypesClass2.ts(16,7): error TS2300: Duplicate identifier 'c33'. tests/cases/compiler/augmentedTypesClass2.ts(21,6): error TS2300: Duplicate identifier 'c33'. @@ -10,7 +10,7 @@ tests/cases/compiler/augmentedTypesClass2.ts(21,6): error TS2300: Duplicate iden // class then interface class c11 { // error ~~~ -!!! error TS2511: Only an ambient class can be merged with an interface. +!!! error TS2518: Only an ambient class can be merged with an interface. foo() { return 1; } @@ -18,7 +18,7 @@ tests/cases/compiler/augmentedTypesClass2.ts(21,6): error TS2300: Duplicate iden interface c11 { // error ~~~ -!!! error TS2511: Only an ambient class can be merged with an interface. +!!! error TS2518: Only an ambient class can be merged with an interface. bar(): void; } diff --git a/tests/baselines/reference/augmentedTypesInterface.errors.txt b/tests/baselines/reference/augmentedTypesInterface.errors.txt index 44c47e70ab3df..690bf8b7a991c 100644 --- a/tests/baselines/reference/augmentedTypesInterface.errors.txt +++ b/tests/baselines/reference/augmentedTypesInterface.errors.txt @@ -1,5 +1,5 @@ -tests/cases/compiler/augmentedTypesInterface.ts(12,11): error TS2511: Only an ambient class can be merged with an interface. -tests/cases/compiler/augmentedTypesInterface.ts(16,7): error TS2511: Only an ambient class can be merged with an interface. +tests/cases/compiler/augmentedTypesInterface.ts(12,11): error TS2518: Only an ambient class can be merged with an interface. +tests/cases/compiler/augmentedTypesInterface.ts(16,7): error TS2518: Only an ambient class can be merged with an interface. tests/cases/compiler/augmentedTypesInterface.ts(23,11): error TS2300: Duplicate identifier 'i3'. tests/cases/compiler/augmentedTypesInterface.ts(26,6): error TS2300: Duplicate identifier 'i3'. @@ -18,13 +18,13 @@ tests/cases/compiler/augmentedTypesInterface.ts(26,6): error TS2300: Duplicate i // interface then class interface i2 { // error ~~ -!!! error TS2511: Only an ambient class can be merged with an interface. +!!! error TS2518: Only an ambient class can be merged with an interface. foo(): void; } class i2 { // error ~~ -!!! error TS2511: Only an ambient class can be merged with an interface. +!!! error TS2518: Only an ambient class can be merged with an interface. bar() { return 1; } diff --git a/tests/baselines/reference/classAbstractMergedDeclaration.errors.txt b/tests/baselines/reference/classAbstractMergedDeclaration.errors.txt index ca2cc3b8c2d08..b3a2dec5e9c52 100644 --- a/tests/baselines/reference/classAbstractMergedDeclaration.errors.txt +++ b/tests/baselines/reference/classAbstractMergedDeclaration.errors.txt @@ -1,19 +1,26 @@ -tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMergedDeclaration.ts(7,16): error TS2300: Duplicate identifier 'CI'. -tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMergedDeclaration.ts(8,11): error TS2300: Duplicate identifier 'CI'. -tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMergedDeclaration.ts(10,11): error TS2300: Duplicate identifier 'IC'. -tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMergedDeclaration.ts(11,16): error TS2300: Duplicate identifier 'IC'. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMergedDeclaration.ts(7,16): error TS2518: Only an ambient class can be merged with an interface. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMergedDeclaration.ts(8,11): error TS2518: Only an ambient class can be merged with an interface. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMergedDeclaration.ts(10,11): error TS2518: Only an ambient class can be merged with an interface. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMergedDeclaration.ts(11,16): error TS2518: Only an ambient class can be merged with an interface. tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMergedDeclaration.ts(13,16): error TS2300: Duplicate identifier 'CC1'. tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMergedDeclaration.ts(14,7): error TS2300: Duplicate identifier 'CC1'. tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMergedDeclaration.ts(16,7): error TS2300: Duplicate identifier 'CC2'. tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMergedDeclaration.ts(17,16): error TS2300: Duplicate identifier 'CC2'. -tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMergedDeclaration.ts(19,1): error TS2511: Cannot create an instance of the abstract class 'CM'. -tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMergedDeclaration.ts(20,1): error TS2511: Cannot create an instance of the abstract class 'MC'. -tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMergedDeclaration.ts(21,1): error TS2511: Cannot create an instance of the abstract class 'CI'. -tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMergedDeclaration.ts(22,5): error TS2304: Cannot find name 'IC'. -tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMergedDeclaration.ts(23,1): error TS2511: Cannot create an instance of the abstract class 'CC1'. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMergedDeclaration.ts(25,24): error TS2300: Duplicate identifier 'DCC1'. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMergedDeclaration.ts(26,15): error TS2300: Duplicate identifier 'DCC1'. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMergedDeclaration.ts(28,15): error TS2300: Duplicate identifier 'DCC2'. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMergedDeclaration.ts(29,24): error TS2300: Duplicate identifier 'DCC2'. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMergedDeclaration.ts(31,1): error TS2511: Cannot create an instance of the abstract class 'CM'. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMergedDeclaration.ts(32,1): error TS2511: Cannot create an instance of the abstract class 'MC'. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMergedDeclaration.ts(33,1): error TS2511: Cannot create an instance of the abstract class 'CI'. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMergedDeclaration.ts(34,1): error TS2511: Cannot create an instance of the abstract class 'IC'. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMergedDeclaration.ts(35,1): error TS2511: Cannot create an instance of the abstract class 'CC1'. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMergedDeclaration.ts(37,1): error TS2511: Cannot create an instance of the abstract class 'DCI'. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMergedDeclaration.ts(38,1): error TS2511: Cannot create an instance of the abstract class 'DIC'. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMergedDeclaration.ts(39,1): error TS2511: Cannot create an instance of the abstract class 'DCC1'. -==== tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMergedDeclaration.ts (13 errors) ==== +==== tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMergedDeclaration.ts (20 errors) ==== abstract class CM {} module CM {} @@ -22,17 +29,17 @@ tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbst abstract class CI {} ~~ -!!! error TS2300: Duplicate identifier 'CI'. +!!! error TS2518: Only an ambient class can be merged with an interface. interface CI {} ~~ -!!! error TS2300: Duplicate identifier 'CI'. +!!! error TS2518: Only an ambient class can be merged with an interface. interface IC {} ~~ -!!! error TS2300: Duplicate identifier 'IC'. +!!! error TS2518: Only an ambient class can be merged with an interface. abstract class IC {} ~~ -!!! error TS2300: Duplicate identifier 'IC'. +!!! error TS2518: Only an ambient class can be merged with an interface. abstract class CC1 {} ~~~ @@ -48,6 +55,26 @@ tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbst ~~~ !!! error TS2300: Duplicate identifier 'CC2'. + declare abstract class DCI {} + interface DCI {} + + interface DIC {} + declare abstract class DIC {} + + declare abstract class DCC1 {} + ~~~~ +!!! error TS2300: Duplicate identifier 'DCC1'. + declare class DCC1 {} + ~~~~ +!!! error TS2300: Duplicate identifier 'DCC1'. + + declare class DCC2 {} + ~~~~ +!!! error TS2300: Duplicate identifier 'DCC2'. + declare abstract class DCC2 {} + ~~~~ +!!! error TS2300: Duplicate identifier 'DCC2'. + new CM; ~~~~~~ !!! error TS2511: Cannot create an instance of the abstract class 'CM'. @@ -58,9 +85,19 @@ tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbst ~~~~~~ !!! error TS2511: Cannot create an instance of the abstract class 'CI'. new IC; - ~~ -!!! error TS2304: Cannot find name 'IC'. + ~~~~~~ +!!! error TS2511: Cannot create an instance of the abstract class 'IC'. new CC1; ~~~~~~~ !!! error TS2511: Cannot create an instance of the abstract class 'CC1'. - new CC2; \ No newline at end of file + new CC2; + new DCI; + ~~~~~~~ +!!! error TS2511: Cannot create an instance of the abstract class 'DCI'. + new DIC; + ~~~~~~~ +!!! error TS2511: Cannot create an instance of the abstract class 'DIC'. + new DCC1; + ~~~~~~~~ +!!! error TS2511: Cannot create an instance of the abstract class 'DCC1'. + new DCC2; \ No newline at end of file diff --git a/tests/baselines/reference/classAbstractMergedDeclaration.js b/tests/baselines/reference/classAbstractMergedDeclaration.js index 1b4d6fea342f0..f6a91f870d299 100644 --- a/tests/baselines/reference/classAbstractMergedDeclaration.js +++ b/tests/baselines/reference/classAbstractMergedDeclaration.js @@ -17,12 +17,28 @@ class CC1 {} class CC2 {} abstract class CC2 {} +declare abstract class DCI {} +interface DCI {} + +interface DIC {} +declare abstract class DIC {} + +declare abstract class DCC1 {} +declare class DCC1 {} + +declare class DCC2 {} +declare abstract class DCC2 {} + new CM; new MC; new CI; new IC; new CC1; -new CC2; +new CC2; +new DCI; +new DIC; +new DCC1; +new DCC2; //// [classAbstractMergedDeclaration.js] var CM = (function () { @@ -71,3 +87,7 @@ new CI; new IC; new CC1; new CC2; +new DCI; +new DIC; +new DCC1; +new DCC2; diff --git a/tests/baselines/reference/classAndInterfaceWithSameName.errors.txt b/tests/baselines/reference/classAndInterfaceWithSameName.errors.txt index b2b59c290093d..332024b74fdf0 100644 --- a/tests/baselines/reference/classAndInterfaceWithSameName.errors.txt +++ b/tests/baselines/reference/classAndInterfaceWithSameName.errors.txt @@ -1,29 +1,29 @@ -tests/cases/conformance/classes/classDeclarations/classAndInterfaceWithSameName.ts(1,7): error TS2511: Only an ambient class can be merged with an interface. +tests/cases/conformance/classes/classDeclarations/classAndInterfaceWithSameName.ts(1,7): error TS2518: Only an ambient class can be merged with an interface. tests/cases/conformance/classes/classDeclarations/classAndInterfaceWithSameName.ts(1,11): error TS2300: Duplicate identifier 'foo'. -tests/cases/conformance/classes/classDeclarations/classAndInterfaceWithSameName.ts(2,11): error TS2511: Only an ambient class can be merged with an interface. +tests/cases/conformance/classes/classDeclarations/classAndInterfaceWithSameName.ts(2,11): error TS2518: Only an ambient class can be merged with an interface. tests/cases/conformance/classes/classDeclarations/classAndInterfaceWithSameName.ts(2,15): error TS2300: Duplicate identifier 'foo'. -tests/cases/conformance/classes/classDeclarations/classAndInterfaceWithSameName.ts(5,11): error TS2511: Only an ambient class can be merged with an interface. +tests/cases/conformance/classes/classDeclarations/classAndInterfaceWithSameName.ts(5,11): error TS2518: Only an ambient class can be merged with an interface. tests/cases/conformance/classes/classDeclarations/classAndInterfaceWithSameName.ts(6,9): error TS2300: Duplicate identifier 'bar'. -tests/cases/conformance/classes/classDeclarations/classAndInterfaceWithSameName.ts(9,15): error TS2511: Only an ambient class can be merged with an interface. +tests/cases/conformance/classes/classDeclarations/classAndInterfaceWithSameName.ts(9,15): error TS2518: Only an ambient class can be merged with an interface. tests/cases/conformance/classes/classDeclarations/classAndInterfaceWithSameName.ts(10,9): error TS2300: Duplicate identifier 'bar'. ==== tests/cases/conformance/classes/classDeclarations/classAndInterfaceWithSameName.ts (8 errors) ==== class C { foo: string; } ~ -!!! error TS2511: Only an ambient class can be merged with an interface. +!!! error TS2518: Only an ambient class can be merged with an interface. ~~~ !!! error TS2300: Duplicate identifier 'foo'. interface C { foo: string; } // error ~ -!!! error TS2511: Only an ambient class can be merged with an interface. +!!! error TS2518: Only an ambient class can be merged with an interface. ~~~ !!! error TS2300: Duplicate identifier 'foo'. module M { class D { ~ -!!! error TS2511: Only an ambient class can be merged with an interface. +!!! error TS2518: Only an ambient class can be merged with an interface. bar: string; ~~~ !!! error TS2300: Duplicate identifier 'bar'. @@ -31,7 +31,7 @@ tests/cases/conformance/classes/classDeclarations/classAndInterfaceWithSameName. interface D { // error ~ -!!! error TS2511: Only an ambient class can be merged with an interface. +!!! error TS2518: Only an ambient class can be merged with an interface. bar: string; ~~~ !!! error TS2300: Duplicate identifier 'bar'. diff --git a/tests/baselines/reference/clinterfaces.errors.txt b/tests/baselines/reference/clinterfaces.errors.txt index 8d48f29aed708..5960e6ae32b2e 100644 --- a/tests/baselines/reference/clinterfaces.errors.txt +++ b/tests/baselines/reference/clinterfaces.errors.txt @@ -1,50 +1,50 @@ -tests/cases/compiler/clinterfaces.ts(2,11): error TS2511: Only an ambient class can be merged with an interface. -tests/cases/compiler/clinterfaces.ts(3,15): error TS2511: Only an ambient class can be merged with an interface. -tests/cases/compiler/clinterfaces.ts(4,15): error TS2511: Only an ambient class can be merged with an interface. -tests/cases/compiler/clinterfaces.ts(5,11): error TS2511: Only an ambient class can be merged with an interface. -tests/cases/compiler/clinterfaces.ts(8,11): error TS2511: Only an ambient class can be merged with an interface. -tests/cases/compiler/clinterfaces.ts(12,7): error TS2511: Only an ambient class can be merged with an interface. -tests/cases/compiler/clinterfaces.ts(16,7): error TS2511: Only an ambient class can be merged with an interface. -tests/cases/compiler/clinterfaces.ts(20,11): error TS2511: Only an ambient class can be merged with an interface. +tests/cases/compiler/clinterfaces.ts(2,11): error TS2518: Only an ambient class can be merged with an interface. +tests/cases/compiler/clinterfaces.ts(3,15): error TS2518: Only an ambient class can be merged with an interface. +tests/cases/compiler/clinterfaces.ts(4,15): error TS2518: Only an ambient class can be merged with an interface. +tests/cases/compiler/clinterfaces.ts(5,11): error TS2518: Only an ambient class can be merged with an interface. +tests/cases/compiler/clinterfaces.ts(8,11): error TS2518: Only an ambient class can be merged with an interface. +tests/cases/compiler/clinterfaces.ts(12,7): error TS2518: Only an ambient class can be merged with an interface. +tests/cases/compiler/clinterfaces.ts(16,7): error TS2518: Only an ambient class can be merged with an interface. +tests/cases/compiler/clinterfaces.ts(20,11): error TS2518: Only an ambient class can be merged with an interface. ==== tests/cases/compiler/clinterfaces.ts (8 errors) ==== module M { class C { } ~ -!!! error TS2511: Only an ambient class can be merged with an interface. +!!! error TS2518: Only an ambient class can be merged with an interface. interface C { } ~ -!!! error TS2511: Only an ambient class can be merged with an interface. +!!! error TS2518: Only an ambient class can be merged with an interface. interface D { } ~ -!!! error TS2511: Only an ambient class can be merged with an interface. +!!! error TS2518: Only an ambient class can be merged with an interface. class D { } ~ -!!! error TS2511: Only an ambient class can be merged with an interface. +!!! error TS2518: Only an ambient class can be merged with an interface. } interface Foo { ~~~ -!!! error TS2511: Only an ambient class can be merged with an interface. +!!! error TS2518: Only an ambient class can be merged with an interface. a: string; } class Foo{ ~~~ -!!! error TS2511: Only an ambient class can be merged with an interface. +!!! error TS2518: Only an ambient class can be merged with an interface. b: number; } class Bar{ ~~~ -!!! error TS2511: Only an ambient class can be merged with an interface. +!!! error TS2518: Only an ambient class can be merged with an interface. b: number; } interface Bar { ~~~ -!!! error TS2511: Only an ambient class can be merged with an interface. +!!! error TS2518: Only an ambient class can be merged with an interface. a: string; } diff --git a/tests/baselines/reference/declInput.errors.txt b/tests/baselines/reference/declInput.errors.txt index 76257de6ea9ba..179db3598abb3 100644 --- a/tests/baselines/reference/declInput.errors.txt +++ b/tests/baselines/reference/declInput.errors.txt @@ -1,17 +1,17 @@ -tests/cases/compiler/declInput.ts(1,11): error TS2511: Only an ambient class can be merged with an interface. -tests/cases/compiler/declInput.ts(5,7): error TS2511: Only an ambient class can be merged with an interface. +tests/cases/compiler/declInput.ts(1,11): error TS2518: Only an ambient class can be merged with an interface. +tests/cases/compiler/declInput.ts(5,7): error TS2518: Only an ambient class can be merged with an interface. ==== tests/cases/compiler/declInput.ts (2 errors) ==== interface bar { ~~~ -!!! error TS2511: Only an ambient class can be merged with an interface. +!!! error TS2518: Only an ambient class can be merged with an interface. } class bar { ~~~ -!!! error TS2511: Only an ambient class can be merged with an interface. +!!! error TS2518: Only an ambient class can be merged with an interface. public f() { return ''; } public g() { return {a: null, b: undefined, c: void 4 }; } public h(x = 4, y = null, z = '') { x++; } diff --git a/tests/baselines/reference/duplicateIdentifiersAcrossContainerBoundaries.errors.txt b/tests/baselines/reference/duplicateIdentifiersAcrossContainerBoundaries.errors.txt index 67ee1d9cc371e..731e97482035a 100644 --- a/tests/baselines/reference/duplicateIdentifiersAcrossContainerBoundaries.errors.txt +++ b/tests/baselines/reference/duplicateIdentifiersAcrossContainerBoundaries.errors.txt @@ -1,5 +1,5 @@ -tests/cases/compiler/duplicateIdentifiersAcrossContainerBoundaries.ts(2,22): error TS2511: Only an ambient class can be merged with an interface. -tests/cases/compiler/duplicateIdentifiersAcrossContainerBoundaries.ts(5,18): error TS2511: Only an ambient class can be merged with an interface. +tests/cases/compiler/duplicateIdentifiersAcrossContainerBoundaries.ts(2,22): error TS2518: Only an ambient class can be merged with an interface. +tests/cases/compiler/duplicateIdentifiersAcrossContainerBoundaries.ts(5,18): error TS2518: Only an ambient class can be merged with an interface. tests/cases/compiler/duplicateIdentifiersAcrossContainerBoundaries.ts(9,21): error TS2300: Duplicate identifier 'f'. tests/cases/compiler/duplicateIdentifiersAcrossContainerBoundaries.ts(12,18): error TS2300: Duplicate identifier 'f'. tests/cases/compiler/duplicateIdentifiersAcrossContainerBoundaries.ts(37,12): error TS2300: Duplicate identifier 'x'. @@ -10,12 +10,12 @@ tests/cases/compiler/duplicateIdentifiersAcrossContainerBoundaries.ts(41,16): er module M { export interface I { } ~ -!!! error TS2511: Only an ambient class can be merged with an interface. +!!! error TS2518: Only an ambient class can be merged with an interface. } module M { export class I { } // error ~ -!!! error TS2511: Only an ambient class can be merged with an interface. +!!! error TS2518: Only an ambient class can be merged with an interface. } module M { diff --git a/tests/baselines/reference/duplicateIdentifiersAcrossFileBoundaries.errors.txt b/tests/baselines/reference/duplicateIdentifiersAcrossFileBoundaries.errors.txt index c98e0e9a8c63a..9867441f7700f 100644 --- a/tests/baselines/reference/duplicateIdentifiersAcrossFileBoundaries.errors.txt +++ b/tests/baselines/reference/duplicateIdentifiersAcrossFileBoundaries.errors.txt @@ -1,10 +1,10 @@ -tests/cases/compiler/file1.ts(2,11): error TS2511: Only an ambient class can be merged with an interface. -tests/cases/compiler/file1.ts(3,7): error TS2511: Only an ambient class can be merged with an interface. +tests/cases/compiler/file1.ts(2,11): error TS2518: Only an ambient class can be merged with an interface. +tests/cases/compiler/file1.ts(3,7): error TS2518: Only an ambient class can be merged with an interface. tests/cases/compiler/file1.ts(4,7): error TS2300: Duplicate identifier 'C2'. tests/cases/compiler/file1.ts(5,10): error TS2300: Duplicate identifier 'f'. tests/cases/compiler/file1.ts(9,12): error TS2300: Duplicate identifier 'x'. -tests/cases/compiler/file2.ts(1,7): error TS2511: Only an ambient class can be merged with an interface. -tests/cases/compiler/file2.ts(2,11): error TS2511: Only an ambient class can be merged with an interface. +tests/cases/compiler/file2.ts(1,7): error TS2518: Only an ambient class can be merged with an interface. +tests/cases/compiler/file2.ts(2,11): error TS2518: Only an ambient class can be merged with an interface. tests/cases/compiler/file2.ts(3,10): error TS2300: Duplicate identifier 'C2'. tests/cases/compiler/file2.ts(4,7): error TS2300: Duplicate identifier 'f'. tests/cases/compiler/file2.ts(7,8): error TS2433: A namespace declaration cannot be in a different file from a class or function with which it is merged @@ -15,10 +15,10 @@ tests/cases/compiler/file2.ts(8,16): error TS2300: Duplicate identifier 'x'. interface I { } ~ -!!! error TS2511: Only an ambient class can be merged with an interface. +!!! error TS2518: Only an ambient class can be merged with an interface. class C1 { } ~~ -!!! error TS2511: Only an ambient class can be merged with an interface. +!!! error TS2518: Only an ambient class can be merged with an interface. class C2 { } ~~ !!! error TS2300: Duplicate identifier 'C2'. @@ -42,10 +42,10 @@ tests/cases/compiler/file2.ts(8,16): error TS2300: Duplicate identifier 'x'. ==== tests/cases/compiler/file2.ts (6 errors) ==== class I { } // error -- cannot merge interface with non-ambient class ~ -!!! error TS2511: Only an ambient class can be merged with an interface. +!!! error TS2518: Only an ambient class can be merged with an interface. interface C1 { } // error -- cannot merge interface with non-ambient class ~~ -!!! error TS2511: Only an ambient class can be merged with an interface. +!!! error TS2518: Only an ambient class can be merged with an interface. function C2() { } // error -- cannot merge function with non-ambient class ~~ !!! error TS2300: Duplicate identifier 'C2'. diff --git a/tests/baselines/reference/interfaceDeclaration2.errors.txt b/tests/baselines/reference/interfaceDeclaration2.errors.txt index 1d5807b9b1b8b..db525e6f21f25 100644 --- a/tests/baselines/reference/interfaceDeclaration2.errors.txt +++ b/tests/baselines/reference/interfaceDeclaration2.errors.txt @@ -1,5 +1,5 @@ -tests/cases/compiler/interfaceDeclaration2.ts(4,11): error TS2511: Only an ambient class can be merged with an interface. -tests/cases/compiler/interfaceDeclaration2.ts(5,7): error TS2511: Only an ambient class can be merged with an interface. +tests/cases/compiler/interfaceDeclaration2.ts(4,11): error TS2518: Only an ambient class can be merged with an interface. +tests/cases/compiler/interfaceDeclaration2.ts(5,7): error TS2518: Only an ambient class can be merged with an interface. ==== tests/cases/compiler/interfaceDeclaration2.ts (2 errors) ==== @@ -8,10 +8,10 @@ tests/cases/compiler/interfaceDeclaration2.ts(5,7): error TS2511: Only an ambien interface I2 { } ~~ -!!! error TS2511: Only an ambient class can be merged with an interface. +!!! error TS2518: Only an ambient class can be merged with an interface. class I2 { } ~~ -!!! error TS2511: Only an ambient class can be merged with an interface. +!!! error TS2518: Only an ambient class can be merged with an interface. interface I3 { } function I3() { } diff --git a/tests/baselines/reference/mergedClassInterface.errors.txt b/tests/baselines/reference/mergedClassInterface.errors.txt index 37bd595c0b736..5b23b046db75c 100644 --- a/tests/baselines/reference/mergedClassInterface.errors.txt +++ b/tests/baselines/reference/mergedClassInterface.errors.txt @@ -1,7 +1,7 @@ -tests/cases/conformance/classes/classDeclarations/file1.ts(11,7): error TS2511: Only an ambient class can be merged with an interface. -tests/cases/conformance/classes/classDeclarations/file1.ts(13,11): error TS2511: Only an ambient class can be merged with an interface. -tests/cases/conformance/classes/classDeclarations/file1.ts(15,11): error TS2511: Only an ambient class can be merged with an interface. -tests/cases/conformance/classes/classDeclarations/file1.ts(17,7): error TS2511: Only an ambient class can be merged with an interface. +tests/cases/conformance/classes/classDeclarations/file1.ts(11,7): error TS2518: Only an ambient class can be merged with an interface. +tests/cases/conformance/classes/classDeclarations/file1.ts(13,11): error TS2518: Only an ambient class can be merged with an interface. +tests/cases/conformance/classes/classDeclarations/file1.ts(15,11): error TS2518: Only an ambient class can be merged with an interface. +tests/cases/conformance/classes/classDeclarations/file1.ts(17,7): error TS2518: Only an ambient class can be merged with an interface. ==== tests/cases/conformance/classes/classDeclarations/file1.ts (4 errors) ==== @@ -17,19 +17,19 @@ tests/cases/conformance/classes/classDeclarations/file1.ts(17,7): error TS2511: class C3 { } // error -- cannot merge non-ambient class and interface ~~ -!!! error TS2511: Only an ambient class can be merged with an interface. +!!! error TS2518: Only an ambient class can be merged with an interface. interface C3 { } // error -- cannot merge non-ambient class and interface ~~ -!!! error TS2511: Only an ambient class can be merged with an interface. +!!! error TS2518: Only an ambient class can be merged with an interface. interface C4 { } // error -- cannot merge non-ambient class and interface ~~ -!!! error TS2511: Only an ambient class can be merged with an interface. +!!! error TS2518: Only an ambient class can be merged with an interface. class C4 { } // error -- cannot merge non-ambient class and interface ~~ -!!! error TS2511: Only an ambient class can be merged with an interface. +!!! error TS2518: Only an ambient class can be merged with an interface. interface C5 { x1: number; diff --git a/tests/baselines/reference/nameCollisions.errors.txt b/tests/baselines/reference/nameCollisions.errors.txt index 2aba1c43f86d3..5c32d4640705f 100644 --- a/tests/baselines/reference/nameCollisions.errors.txt +++ b/tests/baselines/reference/nameCollisions.errors.txt @@ -11,10 +11,10 @@ tests/cases/compiler/nameCollisions.ts(33,11): error TS2300: Duplicate identifie tests/cases/compiler/nameCollisions.ts(34,14): error TS2300: Duplicate identifier 'C'. tests/cases/compiler/nameCollisions.ts(36,14): error TS2300: Duplicate identifier 'C2'. tests/cases/compiler/nameCollisions.ts(37,11): error TS2300: Duplicate identifier 'C2'. -tests/cases/compiler/nameCollisions.ts(42,11): error TS2511: Only an ambient class can be merged with an interface. -tests/cases/compiler/nameCollisions.ts(43,15): error TS2511: Only an ambient class can be merged with an interface. -tests/cases/compiler/nameCollisions.ts(45,15): error TS2511: Only an ambient class can be merged with an interface. -tests/cases/compiler/nameCollisions.ts(46,11): error TS2511: Only an ambient class can be merged with an interface. +tests/cases/compiler/nameCollisions.ts(42,11): error TS2518: Only an ambient class can be merged with an interface. +tests/cases/compiler/nameCollisions.ts(43,15): error TS2518: Only an ambient class can be merged with an interface. +tests/cases/compiler/nameCollisions.ts(45,15): error TS2518: Only an ambient class can be merged with an interface. +tests/cases/compiler/nameCollisions.ts(46,11): error TS2518: Only an ambient class can be merged with an interface. ==== tests/cases/compiler/nameCollisions.ts (17 errors) ==== @@ -87,15 +87,15 @@ tests/cases/compiler/nameCollisions.ts(46,11): error TS2511: Only an ambient cla class cli { } ~~~ -!!! error TS2511: Only an ambient class can be merged with an interface. +!!! error TS2518: Only an ambient class can be merged with an interface. interface cli { } // error ~~~ -!!! error TS2511: Only an ambient class can be merged with an interface. +!!! error TS2518: Only an ambient class can be merged with an interface. interface cli2 { } ~~~~ -!!! error TS2511: Only an ambient class can be merged with an interface. +!!! error TS2518: Only an ambient class can be merged with an interface. class cli2 { } // error ~~~~ -!!! error TS2511: Only an ambient class can be merged with an interface. +!!! error TS2518: Only an ambient class can be merged with an interface. } \ No newline at end of file diff --git a/tests/baselines/reference/templateStringsArrayTypeDefinedInES5Mode.errors.txt b/tests/baselines/reference/templateStringsArrayTypeDefinedInES5Mode.errors.txt index a51eb18d98efc..69d686c31561a 100644 --- a/tests/baselines/reference/templateStringsArrayTypeDefinedInES5Mode.errors.txt +++ b/tests/baselines/reference/templateStringsArrayTypeDefinedInES5Mode.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/templateStringsArrayTypeDefinedInES5Mode.ts(2,7): error TS2511: Only an ambient class can be merged with an interface. +tests/cases/compiler/templateStringsArrayTypeDefinedInES5Mode.ts(2,7): error TS2518: Only an ambient class can be merged with an interface. tests/cases/compiler/templateStringsArrayTypeDefinedInES5Mode.ts(8,3): error TS2345: Argument of type '{}' is not assignable to parameter of type 'TemplateStringsArray'. Property 'raw' is missing in type '{}'. @@ -7,7 +7,7 @@ tests/cases/compiler/templateStringsArrayTypeDefinedInES5Mode.ts(8,3): error TS2 class TemplateStringsArray { ~~~~~~~~~~~~~~~~~~~~ -!!! error TS2511: Only an ambient class can be merged with an interface. +!!! error TS2518: Only an ambient class can be merged with an interface. } function f(x: TemplateStringsArray, y: number, z: number) { diff --git a/tests/baselines/reference/templateStringsArrayTypeRedefinedInES6Mode.errors.txt b/tests/baselines/reference/templateStringsArrayTypeRedefinedInES6Mode.errors.txt index d41c3d0cdbf03..02ccd7f2413f8 100644 --- a/tests/baselines/reference/templateStringsArrayTypeRedefinedInES6Mode.errors.txt +++ b/tests/baselines/reference/templateStringsArrayTypeRedefinedInES6Mode.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/templateStringsArrayTypeRedefinedInES6Mode.ts(2,7): error TS2511: Only an ambient class can be merged with an interface. +tests/cases/compiler/templateStringsArrayTypeRedefinedInES6Mode.ts(2,7): error TS2518: Only an ambient class can be merged with an interface. tests/cases/compiler/templateStringsArrayTypeRedefinedInES6Mode.ts(8,3): error TS2345: Argument of type '{}' is not assignable to parameter of type 'TemplateStringsArray'. Property 'raw' is missing in type '{}'. @@ -7,7 +7,7 @@ tests/cases/compiler/templateStringsArrayTypeRedefinedInES6Mode.ts(8,3): error T class TemplateStringsArray { ~~~~~~~~~~~~~~~~~~~~ -!!! error TS2511: Only an ambient class can be merged with an interface. +!!! error TS2518: Only an ambient class can be merged with an interface. } function f(x: TemplateStringsArray, y: number, z: number) {