mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-06 02:33:53 -06:00
Improve non-ambient class and function merge error (#44352)
* Improve non-ambient class and function merge error * Update baselines * Update tests Co-authored-by: Austin Cummings <austin@austincummings.com>
This commit is contained in:
parent
9d345e7734
commit
6baa1bec64
@ -34057,13 +34057,22 @@ namespace ts {
|
||||
});
|
||||
}
|
||||
|
||||
if (hasNonAmbientClass && !isConstructor && symbol.flags & SymbolFlags.Function) {
|
||||
// A non-ambient class cannot be an implementation for a non-constructor function/class merge
|
||||
// TODO: The below just replicates our older error from when classes and functions were
|
||||
// entirely unable to merge - a more helpful message like "Class declaration cannot implement overload list"
|
||||
// might be warranted. :shrug:
|
||||
if (hasNonAmbientClass && !isConstructor && symbol.flags & SymbolFlags.Function && declarations) {
|
||||
const relatedDiagnostics = filter(declarations, d => d.kind === SyntaxKind.ClassDeclaration)
|
||||
.map(d => createDiagnosticForNode(d, Diagnostics.Consider_adding_a_declare_modifier_to_this_class));
|
||||
|
||||
forEach(declarations, declaration => {
|
||||
addDuplicateDeclarationError(declaration, Diagnostics.Duplicate_identifier_0, symbolName(symbol), declarations);
|
||||
const diagnostic = declaration.kind === SyntaxKind.ClassDeclaration
|
||||
? Diagnostics.Class_declaration_cannot_implement_overload_list_for_0
|
||||
: declaration.kind === SyntaxKind.FunctionDeclaration
|
||||
? Diagnostics.Function_with_bodies_can_only_merge_with_classes_that_are_ambient
|
||||
: undefined;
|
||||
if (diagnostic) {
|
||||
addRelatedInfo(
|
||||
error(getNameOfDeclaration(declaration) || declaration, diagnostic, symbolName(symbol)),
|
||||
...relatedDiagnostics
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@ -3336,6 +3336,14 @@
|
||||
"category": "Error",
|
||||
"code": 2812
|
||||
},
|
||||
"Class declaration cannot implement overload list for '{0}'.": {
|
||||
"category": "Error",
|
||||
"code": 2813
|
||||
},
|
||||
"Function with bodies can only merge with classes that are ambient.": {
|
||||
"category": "Error",
|
||||
"code": 2814
|
||||
},
|
||||
|
||||
"Import declaration '{0}' is using private name '{1}'.": {
|
||||
"category": "Error",
|
||||
@ -5172,6 +5180,11 @@
|
||||
"category": "Message",
|
||||
"code": 6505
|
||||
},
|
||||
"Consider adding a 'declare' modifier to this class.": {
|
||||
"category": "Message",
|
||||
"code": 6506
|
||||
},
|
||||
|
||||
|
||||
"Include 'undefined' in index signature results": {
|
||||
"category": "Message",
|
||||
@ -5185,7 +5198,7 @@
|
||||
"category": "Message",
|
||||
"code": 6802
|
||||
},
|
||||
|
||||
|
||||
"Variable '{0}' implicitly has an '{1}' type.": {
|
||||
"category": "Error",
|
||||
"code": 7005
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
tests/cases/compiler/augmentedTypesClass2a.ts(2,7): error TS2300: Duplicate identifier 'c2'.
|
||||
tests/cases/compiler/augmentedTypesClass2a.ts(2,7): error TS2300: Duplicate identifier 'c2'.
|
||||
tests/cases/compiler/augmentedTypesClass2a.ts(3,10): error TS2300: Duplicate identifier 'c2'.
|
||||
tests/cases/compiler/augmentedTypesClass2a.ts(2,7): error TS2813: Class declaration cannot implement overload list for 'c2'.
|
||||
tests/cases/compiler/augmentedTypesClass2a.ts(3,10): error TS2300: Duplicate identifier 'c2'.
|
||||
tests/cases/compiler/augmentedTypesClass2a.ts(3,10): error TS2814: Function with bodies can only merge with classes that are ambient.
|
||||
tests/cases/compiler/augmentedTypesClass2a.ts(4,5): error TS2300: Duplicate identifier 'c2'.
|
||||
|
||||
|
||||
@ -10,15 +10,15 @@ tests/cases/compiler/augmentedTypesClass2a.ts(4,5): error TS2300: Duplicate iden
|
||||
class c2 { public foo() { } } // error
|
||||
~~
|
||||
!!! error TS2300: Duplicate identifier 'c2'.
|
||||
!!! related TS6203 tests/cases/compiler/augmentedTypesClass2a.ts:3:10: 'c2' was also declared here.
|
||||
~~
|
||||
!!! error TS2300: Duplicate identifier 'c2'.
|
||||
!!! error TS2813: Class declaration cannot implement overload list for 'c2'.
|
||||
!!! related TS6506 tests/cases/compiler/augmentedTypesClass2a.ts:2:7: Consider adding a 'declare' modifier to this class.
|
||||
function c2() { } // error
|
||||
~~
|
||||
!!! error TS2300: Duplicate identifier 'c2'.
|
||||
!!! related TS6203 tests/cases/compiler/augmentedTypesClass2a.ts:2:7: 'c2' was also declared here.
|
||||
~~
|
||||
!!! error TS2300: Duplicate identifier 'c2'.
|
||||
!!! error TS2814: Function with bodies can only merge with classes that are ambient.
|
||||
!!! related TS6506 tests/cases/compiler/augmentedTypesClass2a.ts:2:7: Consider adding a 'declare' modifier to this class.
|
||||
var c2 = () => { }
|
||||
~~
|
||||
!!! error TS2300: Duplicate identifier 'c2'.
|
||||
@ -4,10 +4,10 @@ tests/cases/compiler/augmentedTypesFunction.ts(6,10): error TS2393: Duplicate fu
|
||||
tests/cases/compiler/augmentedTypesFunction.ts(7,10): error TS2393: Duplicate function implementation.
|
||||
tests/cases/compiler/augmentedTypesFunction.ts(9,10): error TS2300: Duplicate identifier 'y2a'.
|
||||
tests/cases/compiler/augmentedTypesFunction.ts(10,5): error TS2300: Duplicate identifier 'y2a'.
|
||||
tests/cases/compiler/augmentedTypesFunction.ts(13,10): error TS2300: Duplicate identifier 'y3'.
|
||||
tests/cases/compiler/augmentedTypesFunction.ts(14,7): error TS2300: Duplicate identifier 'y3'.
|
||||
tests/cases/compiler/augmentedTypesFunction.ts(16,10): error TS2300: Duplicate identifier 'y3a'.
|
||||
tests/cases/compiler/augmentedTypesFunction.ts(17,7): error TS2300: Duplicate identifier 'y3a'.
|
||||
tests/cases/compiler/augmentedTypesFunction.ts(13,10): error TS2814: Function with bodies can only merge with classes that are ambient.
|
||||
tests/cases/compiler/augmentedTypesFunction.ts(14,7): error TS2813: Class declaration cannot implement overload list for 'y3'.
|
||||
tests/cases/compiler/augmentedTypesFunction.ts(16,10): error TS2814: Function with bodies can only merge with classes that are ambient.
|
||||
tests/cases/compiler/augmentedTypesFunction.ts(17,7): error TS2813: Class declaration cannot implement overload list for 'y3a'.
|
||||
tests/cases/compiler/augmentedTypesFunction.ts(20,10): error TS2567: Enum declarations can only merge with namespace or other enum declarations.
|
||||
tests/cases/compiler/augmentedTypesFunction.ts(21,6): error TS2567: Enum declarations can only merge with namespace or other enum declarations.
|
||||
|
||||
@ -39,21 +39,21 @@ tests/cases/compiler/augmentedTypesFunction.ts(21,6): error TS2567: Enum declara
|
||||
// function then class
|
||||
function y3() { } // error
|
||||
~~
|
||||
!!! error TS2300: Duplicate identifier 'y3'.
|
||||
!!! related TS6203 tests/cases/compiler/augmentedTypesFunction.ts:14:7: 'y3' was also declared here.
|
||||
!!! error TS2814: Function with bodies can only merge with classes that are ambient.
|
||||
!!! related TS6506 tests/cases/compiler/augmentedTypesFunction.ts:14:7: Consider adding a 'declare' modifier to this class.
|
||||
class y3 { } // error
|
||||
~~
|
||||
!!! error TS2300: Duplicate identifier 'y3'.
|
||||
!!! related TS6203 tests/cases/compiler/augmentedTypesFunction.ts:13:10: 'y3' was also declared here.
|
||||
!!! error TS2813: Class declaration cannot implement overload list for 'y3'.
|
||||
!!! related TS6506 tests/cases/compiler/augmentedTypesFunction.ts:14:7: Consider adding a 'declare' modifier to this class.
|
||||
|
||||
function y3a() { } // error
|
||||
~~~
|
||||
!!! error TS2300: Duplicate identifier 'y3a'.
|
||||
!!! related TS6203 tests/cases/compiler/augmentedTypesFunction.ts:17:7: 'y3a' was also declared here.
|
||||
!!! error TS2814: Function with bodies can only merge with classes that are ambient.
|
||||
!!! related TS6506 tests/cases/compiler/augmentedTypesFunction.ts:17:7: Consider adding a 'declare' modifier to this class.
|
||||
class y3a { public foo() { } } // error
|
||||
~~~
|
||||
!!! error TS2300: Duplicate identifier 'y3a'.
|
||||
!!! related TS6203 tests/cases/compiler/augmentedTypesFunction.ts:16:10: 'y3a' was also declared here.
|
||||
!!! error TS2813: Class declaration cannot implement overload list for 'y3a'.
|
||||
!!! related TS6506 tests/cases/compiler/augmentedTypesFunction.ts:17:7: Consider adding a 'declare' modifier to this class.
|
||||
|
||||
// function then enum
|
||||
function y4() { } // error
|
||||
|
||||
@ -1,13 +1,13 @@
|
||||
tests/cases/compiler/callOverloads1.ts(1,7): error TS2300: Duplicate identifier 'Foo'.
|
||||
tests/cases/compiler/callOverloads1.ts(9,10): error TS2300: Duplicate identifier 'Foo'.
|
||||
tests/cases/compiler/callOverloads1.ts(1,7): error TS2813: Class declaration cannot implement overload list for 'Foo'.
|
||||
tests/cases/compiler/callOverloads1.ts(9,10): error TS2391: Function implementation is missing or not immediately following the declaration.
|
||||
tests/cases/compiler/callOverloads1.ts(9,10): error TS2814: Function with bodies can only merge with classes that are ambient.
|
||||
|
||||
|
||||
==== tests/cases/compiler/callOverloads1.ts (3 errors) ====
|
||||
class Foo { // error
|
||||
~~~
|
||||
!!! error TS2300: Duplicate identifier 'Foo'.
|
||||
!!! related TS6203 tests/cases/compiler/callOverloads1.ts:9:10: 'Foo' was also declared here.
|
||||
!!! error TS2813: Class declaration cannot implement overload list for 'Foo'.
|
||||
!!! related TS6506 tests/cases/compiler/callOverloads1.ts:1:7: Consider adding a 'declare' modifier to this class.
|
||||
bar1() { /*WScript.Echo("bar1");*/ }
|
||||
|
||||
constructor(x: any) {
|
||||
@ -17,10 +17,10 @@ tests/cases/compiler/callOverloads1.ts(9,10): error TS2391: Function implementat
|
||||
|
||||
function Foo(); // error
|
||||
~~~
|
||||
!!! error TS2300: Duplicate identifier 'Foo'.
|
||||
!!! related TS6203 tests/cases/compiler/callOverloads1.ts:1:7: 'Foo' was also declared here.
|
||||
~~~
|
||||
!!! error TS2391: Function implementation is missing or not immediately following the declaration.
|
||||
~~~
|
||||
!!! error TS2814: Function with bodies can only merge with classes that are ambient.
|
||||
!!! related TS6506 tests/cases/compiler/callOverloads1.ts:1:7: Consider adding a 'declare' modifier to this class.
|
||||
function F1(s:string);
|
||||
function F1(a:any) { return a;}
|
||||
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
tests/cases/compiler/callOverloads2.ts(1,7): error TS2300: Duplicate identifier 'Foo'.
|
||||
tests/cases/compiler/callOverloads2.ts(9,10): error TS2300: Duplicate identifier 'Foo'.
|
||||
tests/cases/compiler/callOverloads2.ts(1,7): error TS2813: Class declaration cannot implement overload list for 'Foo'.
|
||||
tests/cases/compiler/callOverloads2.ts(9,10): error TS2814: Function with bodies can only merge with classes that are ambient.
|
||||
tests/cases/compiler/callOverloads2.ts(11,10): error TS2389: Function implementation name must be 'Foo'.
|
||||
tests/cases/compiler/callOverloads2.ts(11,10): error TS2393: Duplicate function implementation.
|
||||
tests/cases/compiler/callOverloads2.ts(12,10): error TS2393: Duplicate function implementation.
|
||||
@ -9,8 +9,8 @@ tests/cases/compiler/callOverloads2.ts(14,10): error TS2391: Function implementa
|
||||
==== tests/cases/compiler/callOverloads2.ts (6 errors) ====
|
||||
class Foo { // error
|
||||
~~~
|
||||
!!! error TS2300: Duplicate identifier 'Foo'.
|
||||
!!! related TS6203 tests/cases/compiler/callOverloads2.ts:9:10: 'Foo' was also declared here.
|
||||
!!! error TS2813: Class declaration cannot implement overload list for 'Foo'.
|
||||
!!! related TS6506 tests/cases/compiler/callOverloads2.ts:1:7: Consider adding a 'declare' modifier to this class.
|
||||
bar1() { /*WScript.Echo("bar1");*/ }
|
||||
|
||||
constructor(x: any) {
|
||||
@ -20,8 +20,8 @@ tests/cases/compiler/callOverloads2.ts(14,10): error TS2391: Function implementa
|
||||
|
||||
function Foo(); // error
|
||||
~~~
|
||||
!!! error TS2300: Duplicate identifier 'Foo'.
|
||||
!!! related TS6203 tests/cases/compiler/callOverloads2.ts:1:7: 'Foo' was also declared here.
|
||||
!!! error TS2814: Function with bodies can only merge with classes that are ambient.
|
||||
!!! related TS6506 tests/cases/compiler/callOverloads2.ts:1:7: Consider adding a 'declare' modifier to this class.
|
||||
|
||||
function F1(s:string) {return s;} // error
|
||||
~~
|
||||
|
||||
@ -1,27 +1,24 @@
|
||||
tests/cases/compiler/callOverloads3.ts(1,10): error TS2300: Duplicate identifier 'Foo'.
|
||||
tests/cases/compiler/callOverloads3.ts(2,10): error TS2300: Duplicate identifier 'Foo'.
|
||||
tests/cases/compiler/callOverloads3.ts(1,10): error TS2814: Function with bodies can only merge with classes that are ambient.
|
||||
tests/cases/compiler/callOverloads3.ts(2,10): error TS2391: Function implementation is missing or not immediately following the declaration.
|
||||
tests/cases/compiler/callOverloads3.ts(3,7): error TS2300: Duplicate identifier 'Foo'.
|
||||
tests/cases/compiler/callOverloads3.ts(2,10): error TS2814: Function with bodies can only merge with classes that are ambient.
|
||||
tests/cases/compiler/callOverloads3.ts(3,7): error TS2813: Class declaration cannot implement overload list for 'Foo'.
|
||||
|
||||
|
||||
==== tests/cases/compiler/callOverloads3.ts (4 errors) ====
|
||||
function Foo():Foo; // error
|
||||
~~~
|
||||
!!! error TS2300: Duplicate identifier 'Foo'.
|
||||
!!! related TS6203 tests/cases/compiler/callOverloads3.ts:2:10: 'Foo' was also declared here.
|
||||
!!! related TS6204 tests/cases/compiler/callOverloads3.ts:3:7: and here.
|
||||
!!! error TS2814: Function with bodies can only merge with classes that are ambient.
|
||||
!!! related TS6506 tests/cases/compiler/callOverloads3.ts:3:7: Consider adding a 'declare' modifier to this class.
|
||||
function Foo(s:string):Foo; // error
|
||||
~~~
|
||||
!!! error TS2300: Duplicate identifier 'Foo'.
|
||||
!!! related TS6203 tests/cases/compiler/callOverloads3.ts:1:10: 'Foo' was also declared here.
|
||||
!!! related TS6204 tests/cases/compiler/callOverloads3.ts:3:7: and here.
|
||||
~~~
|
||||
!!! error TS2391: Function implementation is missing or not immediately following the declaration.
|
||||
~~~
|
||||
!!! error TS2814: Function with bodies can only merge with classes that are ambient.
|
||||
!!! related TS6506 tests/cases/compiler/callOverloads3.ts:3:7: Consider adding a 'declare' modifier to this class.
|
||||
class Foo { // error
|
||||
~~~
|
||||
!!! error TS2300: Duplicate identifier 'Foo'.
|
||||
!!! related TS6203 tests/cases/compiler/callOverloads3.ts:1:10: 'Foo' was also declared here.
|
||||
!!! related TS6204 tests/cases/compiler/callOverloads3.ts:2:10: and here.
|
||||
!!! error TS2813: Class declaration cannot implement overload list for 'Foo'.
|
||||
!!! related TS6506 tests/cases/compiler/callOverloads3.ts:3:7: Consider adding a 'declare' modifier to this class.
|
||||
bar1() { /*WScript.Echo("bar1");*/ }
|
||||
constructor(x: any) {
|
||||
// WScript.Echo("Constructor function has executed");
|
||||
|
||||
@ -1,27 +1,24 @@
|
||||
tests/cases/compiler/callOverloads4.ts(1,10): error TS2300: Duplicate identifier 'Foo'.
|
||||
tests/cases/compiler/callOverloads4.ts(2,10): error TS2300: Duplicate identifier 'Foo'.
|
||||
tests/cases/compiler/callOverloads4.ts(1,10): error TS2814: Function with bodies can only merge with classes that are ambient.
|
||||
tests/cases/compiler/callOverloads4.ts(2,10): error TS2391: Function implementation is missing or not immediately following the declaration.
|
||||
tests/cases/compiler/callOverloads4.ts(3,7): error TS2300: Duplicate identifier 'Foo'.
|
||||
tests/cases/compiler/callOverloads4.ts(2,10): error TS2814: Function with bodies can only merge with classes that are ambient.
|
||||
tests/cases/compiler/callOverloads4.ts(3,7): error TS2813: Class declaration cannot implement overload list for 'Foo'.
|
||||
|
||||
|
||||
==== tests/cases/compiler/callOverloads4.ts (4 errors) ====
|
||||
function Foo():Foo; // error
|
||||
~~~
|
||||
!!! error TS2300: Duplicate identifier 'Foo'.
|
||||
!!! related TS6203 tests/cases/compiler/callOverloads4.ts:2:10: 'Foo' was also declared here.
|
||||
!!! related TS6204 tests/cases/compiler/callOverloads4.ts:3:7: and here.
|
||||
!!! error TS2814: Function with bodies can only merge with classes that are ambient.
|
||||
!!! related TS6506 tests/cases/compiler/callOverloads4.ts:3:7: Consider adding a 'declare' modifier to this class.
|
||||
function Foo(s:string):Foo; // error
|
||||
~~~
|
||||
!!! error TS2300: Duplicate identifier 'Foo'.
|
||||
!!! related TS6203 tests/cases/compiler/callOverloads4.ts:1:10: 'Foo' was also declared here.
|
||||
!!! related TS6204 tests/cases/compiler/callOverloads4.ts:3:7: and here.
|
||||
~~~
|
||||
!!! error TS2391: Function implementation is missing or not immediately following the declaration.
|
||||
~~~
|
||||
!!! error TS2814: Function with bodies can only merge with classes that are ambient.
|
||||
!!! related TS6506 tests/cases/compiler/callOverloads4.ts:3:7: Consider adding a 'declare' modifier to this class.
|
||||
class Foo { // error
|
||||
~~~
|
||||
!!! error TS2300: Duplicate identifier 'Foo'.
|
||||
!!! related TS6203 tests/cases/compiler/callOverloads4.ts:1:10: 'Foo' was also declared here.
|
||||
!!! related TS6204 tests/cases/compiler/callOverloads4.ts:2:10: and here.
|
||||
!!! error TS2813: Class declaration cannot implement overload list for 'Foo'.
|
||||
!!! related TS6506 tests/cases/compiler/callOverloads4.ts:3:7: Consider adding a 'declare' modifier to this class.
|
||||
bar1() { /*WScript.Echo("bar1");*/ }
|
||||
constructor(s: string);
|
||||
constructor(x: any) {
|
||||
|
||||
@ -1,27 +1,24 @@
|
||||
tests/cases/compiler/callOverloads5.ts(1,10): error TS2300: Duplicate identifier 'Foo'.
|
||||
tests/cases/compiler/callOverloads5.ts(2,10): error TS2300: Duplicate identifier 'Foo'.
|
||||
tests/cases/compiler/callOverloads5.ts(1,10): error TS2814: Function with bodies can only merge with classes that are ambient.
|
||||
tests/cases/compiler/callOverloads5.ts(2,10): error TS2391: Function implementation is missing or not immediately following the declaration.
|
||||
tests/cases/compiler/callOverloads5.ts(3,7): error TS2300: Duplicate identifier 'Foo'.
|
||||
tests/cases/compiler/callOverloads5.ts(2,10): error TS2814: Function with bodies can only merge with classes that are ambient.
|
||||
tests/cases/compiler/callOverloads5.ts(3,7): error TS2813: Class declaration cannot implement overload list for 'Foo'.
|
||||
|
||||
|
||||
==== tests/cases/compiler/callOverloads5.ts (4 errors) ====
|
||||
function Foo():Foo; // error
|
||||
~~~
|
||||
!!! error TS2300: Duplicate identifier 'Foo'.
|
||||
!!! related TS6203 tests/cases/compiler/callOverloads5.ts:2:10: 'Foo' was also declared here.
|
||||
!!! related TS6204 tests/cases/compiler/callOverloads5.ts:3:7: and here.
|
||||
!!! error TS2814: Function with bodies can only merge with classes that are ambient.
|
||||
!!! related TS6506 tests/cases/compiler/callOverloads5.ts:3:7: Consider adding a 'declare' modifier to this class.
|
||||
function Foo(s:string):Foo; // error
|
||||
~~~
|
||||
!!! error TS2300: Duplicate identifier 'Foo'.
|
||||
!!! related TS6203 tests/cases/compiler/callOverloads5.ts:1:10: 'Foo' was also declared here.
|
||||
!!! related TS6204 tests/cases/compiler/callOverloads5.ts:3:7: and here.
|
||||
~~~
|
||||
!!! error TS2391: Function implementation is missing or not immediately following the declaration.
|
||||
~~~
|
||||
!!! error TS2814: Function with bodies can only merge with classes that are ambient.
|
||||
!!! related TS6506 tests/cases/compiler/callOverloads5.ts:3:7: Consider adding a 'declare' modifier to this class.
|
||||
class Foo { // error
|
||||
~~~
|
||||
!!! error TS2300: Duplicate identifier 'Foo'.
|
||||
!!! related TS6203 tests/cases/compiler/callOverloads5.ts:1:10: 'Foo' was also declared here.
|
||||
!!! related TS6204 tests/cases/compiler/callOverloads5.ts:2:10: and here.
|
||||
!!! error TS2813: Class declaration cannot implement overload list for 'Foo'.
|
||||
!!! related TS6506 tests/cases/compiler/callOverloads5.ts:3:7: Consider adding a 'declare' modifier to this class.
|
||||
bar1(s:string);
|
||||
bar1(n:number);
|
||||
bar1(a:any) { /*WScript.Echo(a);*/ }
|
||||
|
||||
@ -1,14 +1,14 @@
|
||||
tests/cases/compiler/classOverloadForFunction.ts(1,7): error TS2300: Duplicate identifier 'foo'.
|
||||
tests/cases/compiler/classOverloadForFunction.ts(2,10): error TS2300: Duplicate identifier 'foo'.
|
||||
tests/cases/compiler/classOverloadForFunction.ts(1,7): error TS2813: Class declaration cannot implement overload list for 'foo'.
|
||||
tests/cases/compiler/classOverloadForFunction.ts(2,10): error TS2814: Function with bodies can only merge with classes that are ambient.
|
||||
|
||||
|
||||
==== tests/cases/compiler/classOverloadForFunction.ts (2 errors) ====
|
||||
class foo { };
|
||||
~~~
|
||||
!!! error TS2300: Duplicate identifier 'foo'.
|
||||
!!! related TS6203 tests/cases/compiler/classOverloadForFunction.ts:2:10: 'foo' was also declared here.
|
||||
!!! error TS2813: Class declaration cannot implement overload list for 'foo'.
|
||||
!!! related TS6506 tests/cases/compiler/classOverloadForFunction.ts:1:7: Consider adding a 'declare' modifier to this class.
|
||||
function foo() {}
|
||||
~~~
|
||||
!!! error TS2300: Duplicate identifier 'foo'.
|
||||
!!! related TS6203 tests/cases/compiler/classOverloadForFunction.ts:1:7: 'foo' was also declared here.
|
||||
!!! error TS2814: Function with bodies can only merge with classes that are ambient.
|
||||
!!! related TS6506 tests/cases/compiler/classOverloadForFunction.ts:1:7: Consider adding a 'declare' modifier to this class.
|
||||
|
||||
@ -1,16 +1,16 @@
|
||||
tests/cases/compiler/classOverloadForFunction2.ts(1,10): error TS2300: Duplicate identifier 'bar'.
|
||||
tests/cases/compiler/classOverloadForFunction2.ts(1,10): error TS2391: Function implementation is missing or not immediately following the declaration.
|
||||
tests/cases/compiler/classOverloadForFunction2.ts(2,7): error TS2300: Duplicate identifier 'bar'.
|
||||
tests/cases/compiler/classOverloadForFunction2.ts(1,10): error TS2814: Function with bodies can only merge with classes that are ambient.
|
||||
tests/cases/compiler/classOverloadForFunction2.ts(2,7): error TS2813: Class declaration cannot implement overload list for 'bar'.
|
||||
|
||||
|
||||
==== tests/cases/compiler/classOverloadForFunction2.ts (3 errors) ====
|
||||
function bar(): string;
|
||||
~~~
|
||||
!!! error TS2300: Duplicate identifier 'bar'.
|
||||
!!! related TS6203 tests/cases/compiler/classOverloadForFunction2.ts:2:7: 'bar' was also declared here.
|
||||
~~~
|
||||
!!! error TS2391: Function implementation is missing or not immediately following the declaration.
|
||||
~~~
|
||||
!!! error TS2814: Function with bodies can only merge with classes that are ambient.
|
||||
!!! related TS6506 tests/cases/compiler/classOverloadForFunction2.ts:2:7: Consider adding a 'declare' modifier to this class.
|
||||
class bar {}
|
||||
~~~
|
||||
!!! error TS2300: Duplicate identifier 'bar'.
|
||||
!!! related TS6203 tests/cases/compiler/classOverloadForFunction2.ts:1:10: 'bar' was also declared here.
|
||||
!!! error TS2813: Class declaration cannot implement overload list for 'bar'.
|
||||
!!! related TS6506 tests/cases/compiler/classOverloadForFunction2.ts:2:7: Consider adding a 'declare' modifier to this class.
|
||||
@ -1,5 +1,5 @@
|
||||
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(9,21): error TS2814: Function with bodies can only merge with classes that are ambient.
|
||||
tests/cases/compiler/duplicateIdentifiersAcrossContainerBoundaries.ts(12,18): error TS2813: Class declaration cannot implement overload list for 'f'.
|
||||
tests/cases/compiler/duplicateIdentifiersAcrossContainerBoundaries.ts(37,12): error TS2300: Duplicate identifier 'x'.
|
||||
tests/cases/compiler/duplicateIdentifiersAcrossContainerBoundaries.ts(41,16): error TS2300: Duplicate identifier 'x'.
|
||||
|
||||
@ -15,14 +15,14 @@ tests/cases/compiler/duplicateIdentifiersAcrossContainerBoundaries.ts(41,16): er
|
||||
module M {
|
||||
export function f() { }
|
||||
~
|
||||
!!! error TS2300: Duplicate identifier 'f'.
|
||||
!!! related TS6203 tests/cases/compiler/duplicateIdentifiersAcrossContainerBoundaries.ts:12:18: 'f' was also declared here.
|
||||
!!! error TS2814: Function with bodies can only merge with classes that are ambient.
|
||||
!!! related TS6506 tests/cases/compiler/duplicateIdentifiersAcrossContainerBoundaries.ts:12:18: Consider adding a 'declare' modifier to this class.
|
||||
}
|
||||
module M {
|
||||
export class f { } // error
|
||||
~
|
||||
!!! error TS2300: Duplicate identifier 'f'.
|
||||
!!! related TS6203 tests/cases/compiler/duplicateIdentifiersAcrossContainerBoundaries.ts:9:21: 'f' was also declared here.
|
||||
!!! error TS2813: Class declaration cannot implement overload list for 'f'.
|
||||
!!! related TS6506 tests/cases/compiler/duplicateIdentifiersAcrossContainerBoundaries.ts:12:18: Consider adding a 'declare' modifier to this class.
|
||||
}
|
||||
|
||||
module M {
|
||||
|
||||
@ -1,8 +1,8 @@
|
||||
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(3,7): error TS2813: Class declaration cannot implement overload list for 'C2'.
|
||||
tests/cases/compiler/file1.ts(4,10): error TS2814: Function with bodies can only merge with classes that are ambient.
|
||||
tests/cases/compiler/file1.ts(8,12): error TS2300: Duplicate identifier 'x'.
|
||||
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(3,10): error TS2814: Function with bodies can only merge with classes that are ambient.
|
||||
tests/cases/compiler/file2.ts(4,7): error TS2813: Class declaration cannot implement overload list for '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'.
|
||||
|
||||
@ -12,12 +12,12 @@ tests/cases/compiler/file2.ts(8,16): error TS2300: Duplicate identifier 'x'.
|
||||
class C1 { }
|
||||
class C2 { }
|
||||
~~
|
||||
!!! error TS2300: Duplicate identifier 'C2'.
|
||||
!!! related TS6203 tests/cases/compiler/file2.ts:3:10: 'C2' was also declared here.
|
||||
!!! error TS2813: Class declaration cannot implement overload list for 'C2'.
|
||||
!!! related TS6506 tests/cases/compiler/file1.ts:3:7: Consider adding a 'declare' modifier to this class.
|
||||
function f() { }
|
||||
~
|
||||
!!! error TS2300: Duplicate identifier 'f'.
|
||||
!!! related TS6203 tests/cases/compiler/file2.ts:4:7: 'f' was also declared here.
|
||||
!!! error TS2814: Function with bodies can only merge with classes that are ambient.
|
||||
!!! related TS6506 tests/cases/compiler/file2.ts:4:7: Consider adding a 'declare' modifier to this class.
|
||||
var v = 3;
|
||||
|
||||
class Foo {
|
||||
@ -38,12 +38,12 @@ tests/cases/compiler/file2.ts(8,16): error TS2300: Duplicate identifier 'x'.
|
||||
interface C1 { } // error -- cannot merge interface with non-ambient class
|
||||
function C2() { } // error -- cannot merge function with non-ambient class
|
||||
~~
|
||||
!!! error TS2300: Duplicate identifier 'C2'.
|
||||
!!! related TS6203 tests/cases/compiler/file1.ts:3:7: 'C2' was also declared here.
|
||||
!!! error TS2814: Function with bodies can only merge with classes that are ambient.
|
||||
!!! related TS6506 tests/cases/compiler/file1.ts:3:7: Consider adding a 'declare' modifier to this class.
|
||||
class f { } // error -- cannot merge function with non-ambient class
|
||||
~
|
||||
!!! error TS2300: Duplicate identifier 'f'.
|
||||
!!! related TS6203 tests/cases/compiler/file1.ts:4:10: 'f' was also declared here.
|
||||
!!! error TS2813: Class declaration cannot implement overload list for 'f'.
|
||||
!!! related TS6506 tests/cases/compiler/file2.ts:4:7: Consider adding a 'declare' modifier to this class.
|
||||
var v = 3;
|
||||
|
||||
module Foo {
|
||||
|
||||
@ -1,9 +1,8 @@
|
||||
tests/cases/compiler/funClodule.ts(15,10): error TS2300: Duplicate identifier 'foo3'.
|
||||
tests/cases/compiler/funClodule.ts(16,8): error TS2300: Duplicate identifier 'foo3'.
|
||||
tests/cases/compiler/funClodule.ts(19,7): error TS2300: Duplicate identifier 'foo3'.
|
||||
tests/cases/compiler/funClodule.ts(15,10): error TS2814: Function with bodies can only merge with classes that are ambient.
|
||||
tests/cases/compiler/funClodule.ts(19,7): error TS2813: Class declaration cannot implement overload list for 'foo3'.
|
||||
|
||||
|
||||
==== tests/cases/compiler/funClodule.ts (3 errors) ====
|
||||
==== tests/cases/compiler/funClodule.ts (2 errors) ====
|
||||
declare function foo();
|
||||
declare module foo {
|
||||
export function x(): any;
|
||||
@ -20,18 +19,12 @@ tests/cases/compiler/funClodule.ts(19,7): error TS2300: Duplicate identifier 'fo
|
||||
|
||||
function foo3() { }
|
||||
~~~~
|
||||
!!! error TS2300: Duplicate identifier 'foo3'.
|
||||
!!! related TS6203 tests/cases/compiler/funClodule.ts:16:8: 'foo3' was also declared here.
|
||||
!!! related TS6204 tests/cases/compiler/funClodule.ts:19:7: and here.
|
||||
!!! error TS2814: Function with bodies can only merge with classes that are ambient.
|
||||
!!! related TS6506 tests/cases/compiler/funClodule.ts:19:7: Consider adding a 'declare' modifier to this class.
|
||||
module foo3 {
|
||||
~~~~
|
||||
!!! error TS2300: Duplicate identifier 'foo3'.
|
||||
!!! related TS6203 tests/cases/compiler/funClodule.ts:15:10: 'foo3' was also declared here.
|
||||
!!! related TS6204 tests/cases/compiler/funClodule.ts:19:7: and here.
|
||||
export function x(): any { }
|
||||
}
|
||||
class foo3 { } // Should error
|
||||
~~~~
|
||||
!!! error TS2300: Duplicate identifier 'foo3'.
|
||||
!!! related TS6203 tests/cases/compiler/funClodule.ts:15:10: 'foo3' was also declared here.
|
||||
!!! related TS6204 tests/cases/compiler/funClodule.ts:16:8: and here.
|
||||
!!! error TS2813: Class declaration cannot implement overload list for 'foo3'.
|
||||
!!! related TS6506 tests/cases/compiler/funClodule.ts:19:7: Consider adding a 'declare' modifier to this class.
|
||||
@ -1,34 +1,34 @@
|
||||
tests/cases/conformance/es6/modules/m1.ts(1,22): error TS2300: Duplicate identifier 'default'.
|
||||
tests/cases/conformance/es6/modules/m1.ts(1,22): error TS2323: Cannot redeclare exported variable 'default'.
|
||||
tests/cases/conformance/es6/modules/m1.ts(1,22): error TS2528: A module cannot have multiple default exports.
|
||||
tests/cases/conformance/es6/modules/m1.ts(5,25): error TS2300: Duplicate identifier 'default'.
|
||||
tests/cases/conformance/es6/modules/m1.ts(1,22): error TS2813: Class declaration cannot implement overload list for 'default'.
|
||||
tests/cases/conformance/es6/modules/m1.ts(5,25): error TS2323: Cannot redeclare exported variable 'default'.
|
||||
tests/cases/conformance/es6/modules/m1.ts(5,25): error TS2528: A module cannot have multiple default exports.
|
||||
tests/cases/conformance/es6/modules/m1.ts(5,25): error TS2814: Function with bodies can only merge with classes that are ambient.
|
||||
tests/cases/conformance/es6/modules/m1.ts(10,16): error TS2528: A module cannot have multiple default exports.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/modules/m1.ts (7 errors) ====
|
||||
export default class foo {
|
||||
~~~
|
||||
!!! error TS2300: Duplicate identifier 'default'.
|
||||
!!! related TS6203 tests/cases/conformance/es6/modules/m1.ts:5:25: 'default' was also declared here.
|
||||
~~~
|
||||
!!! error TS2323: Cannot redeclare exported variable 'default'.
|
||||
~~~
|
||||
!!! error TS2528: A module cannot have multiple default exports.
|
||||
!!! related TS6204 tests/cases/conformance/es6/modules/m1.ts:10:16: and here.
|
||||
~~~
|
||||
!!! error TS2813: Class declaration cannot implement overload list for 'default'.
|
||||
!!! related TS6506 tests/cases/conformance/es6/modules/m1.ts:1:22: Consider adding a 'declare' modifier to this class.
|
||||
|
||||
}
|
||||
|
||||
export default function bar() {
|
||||
~~~
|
||||
!!! error TS2300: Duplicate identifier 'default'.
|
||||
!!! related TS6203 tests/cases/conformance/es6/modules/m1.ts:1:22: 'default' was also declared here.
|
||||
~~~
|
||||
!!! error TS2323: Cannot redeclare exported variable 'default'.
|
||||
~~~
|
||||
!!! error TS2528: A module cannot have multiple default exports.
|
||||
!!! related TS2753 tests/cases/conformance/es6/modules/m1.ts:10:16: Another export default is here.
|
||||
~~~
|
||||
!!! error TS2814: Function with bodies can only merge with classes that are ambient.
|
||||
!!! related TS6506 tests/cases/conformance/es6/modules/m1.ts:1:22: Consider adding a 'declare' modifier to this class.
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -1,19 +1,19 @@
|
||||
tests/cases/conformance/externalModules/multipleExportDefault5.ts(1,25): error TS2300: Duplicate identifier 'default'.
|
||||
tests/cases/conformance/externalModules/multipleExportDefault5.ts(1,25): error TS2323: Cannot redeclare exported variable 'default'.
|
||||
tests/cases/conformance/externalModules/multipleExportDefault5.ts(2,22): error TS2300: Duplicate identifier 'default'.
|
||||
tests/cases/conformance/externalModules/multipleExportDefault5.ts(1,25): error TS2814: Function with bodies can only merge with classes that are ambient.
|
||||
tests/cases/conformance/externalModules/multipleExportDefault5.ts(2,22): error TS2323: Cannot redeclare exported variable 'default'.
|
||||
tests/cases/conformance/externalModules/multipleExportDefault5.ts(2,22): error TS2813: Class declaration cannot implement overload list for 'default'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/externalModules/multipleExportDefault5.ts (4 errors) ====
|
||||
export default function bar() { }
|
||||
~~~
|
||||
!!! error TS2300: Duplicate identifier 'default'.
|
||||
!!! related TS6203 tests/cases/conformance/externalModules/multipleExportDefault5.ts:2:22: 'default' was also declared here.
|
||||
~~~
|
||||
!!! error TS2323: Cannot redeclare exported variable 'default'.
|
||||
~~~
|
||||
!!! error TS2814: Function with bodies can only merge with classes that are ambient.
|
||||
!!! related TS6506 tests/cases/conformance/externalModules/multipleExportDefault5.ts:2:22: Consider adding a 'declare' modifier to this class.
|
||||
export default class C {}
|
||||
~
|
||||
!!! error TS2300: Duplicate identifier 'default'.
|
||||
!!! related TS6203 tests/cases/conformance/externalModules/multipleExportDefault5.ts:1:25: 'default' was also declared here.
|
||||
!!! error TS2323: Cannot redeclare exported variable 'default'.
|
||||
~
|
||||
!!! error TS2323: Cannot redeclare exported variable 'default'.
|
||||
!!! error TS2813: Class declaration cannot implement overload list for 'default'.
|
||||
!!! related TS6506 tests/cases/conformance/externalModules/multipleExportDefault5.ts:2:22: Consider adding a 'declare' modifier to this class.
|
||||
@ -7,10 +7,10 @@ tests/cases/compiler/nameCollisions.ts(24,9): error TS2300: Duplicate identifier
|
||||
tests/cases/compiler/nameCollisions.ts(25,14): error TS2300: Duplicate identifier 'f'.
|
||||
tests/cases/compiler/nameCollisions.ts(27,14): error TS2300: Duplicate identifier 'f2'.
|
||||
tests/cases/compiler/nameCollisions.ts(28,9): error TS2300: Duplicate identifier 'f2'.
|
||||
tests/cases/compiler/nameCollisions.ts(33,11): error TS2300: Duplicate identifier 'C'.
|
||||
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(33,11): error TS2813: Class declaration cannot implement overload list for 'C'.
|
||||
tests/cases/compiler/nameCollisions.ts(34,14): error TS2814: Function with bodies can only merge with classes that are ambient.
|
||||
tests/cases/compiler/nameCollisions.ts(36,14): error TS2814: Function with bodies can only merge with classes that are ambient.
|
||||
tests/cases/compiler/nameCollisions.ts(37,11): error TS2813: Class declaration cannot implement overload list for 'C2'.
|
||||
|
||||
|
||||
==== tests/cases/compiler/nameCollisions.ts (13 errors) ====
|
||||
@ -66,21 +66,21 @@ tests/cases/compiler/nameCollisions.ts(37,11): error TS2300: Duplicate identifie
|
||||
|
||||
class C { }
|
||||
~
|
||||
!!! error TS2300: Duplicate identifier 'C'.
|
||||
!!! related TS6203 tests/cases/compiler/nameCollisions.ts:34:14: 'C' was also declared here.
|
||||
!!! error TS2813: Class declaration cannot implement overload list for 'C'.
|
||||
!!! related TS6506 tests/cases/compiler/nameCollisions.ts:33:11: Consider adding a 'declare' modifier to this class.
|
||||
function C() { } // error
|
||||
~
|
||||
!!! error TS2300: Duplicate identifier 'C'.
|
||||
!!! related TS6203 tests/cases/compiler/nameCollisions.ts:33:11: 'C' was also declared here.
|
||||
!!! error TS2814: Function with bodies can only merge with classes that are ambient.
|
||||
!!! related TS6506 tests/cases/compiler/nameCollisions.ts:33:11: Consider adding a 'declare' modifier to this class.
|
||||
|
||||
function C2() { }
|
||||
~~
|
||||
!!! error TS2300: Duplicate identifier 'C2'.
|
||||
!!! related TS6203 tests/cases/compiler/nameCollisions.ts:37:11: 'C2' was also declared here.
|
||||
!!! error TS2814: Function with bodies can only merge with classes that are ambient.
|
||||
!!! related TS6506 tests/cases/compiler/nameCollisions.ts:37:11: Consider adding a 'declare' modifier to this class.
|
||||
class C2 { } // error
|
||||
~~
|
||||
!!! error TS2300: Duplicate identifier 'C2'.
|
||||
!!! related TS6203 tests/cases/compiler/nameCollisions.ts:36:14: 'C2' was also declared here.
|
||||
!!! error TS2813: Class declaration cannot implement overload list for 'C2'.
|
||||
!!! related TS6506 tests/cases/compiler/nameCollisions.ts:37:11: Consider adding a 'declare' modifier to this class.
|
||||
|
||||
function fi() { }
|
||||
interface fi { } // ok
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
tests/cases/compiler/staticClassMemberError.ts(4,3): error TS2662: Cannot find name 's'. Did you mean the static member 'C.s'?
|
||||
tests/cases/compiler/staticClassMemberError.ts(9,10): error TS2300: Duplicate identifier 'Foo'.
|
||||
tests/cases/compiler/staticClassMemberError.ts(9,10): error TS2391: Function implementation is missing or not immediately following the declaration.
|
||||
tests/cases/compiler/staticClassMemberError.ts(10,7): error TS2300: Duplicate identifier 'Foo'.
|
||||
tests/cases/compiler/staticClassMemberError.ts(9,10): error TS2814: Function with bodies can only merge with classes that are ambient.
|
||||
tests/cases/compiler/staticClassMemberError.ts(10,7): error TS2813: Class declaration cannot implement overload list for 'Foo'.
|
||||
|
||||
|
||||
==== tests/cases/compiler/staticClassMemberError.ts (4 errors) ====
|
||||
@ -17,13 +17,13 @@ tests/cases/compiler/staticClassMemberError.ts(10,7): error TS2300: Duplicate id
|
||||
// just want to make sure this one doesn't crash the compiler
|
||||
function Foo();
|
||||
~~~
|
||||
!!! error TS2300: Duplicate identifier 'Foo'.
|
||||
!!! related TS6203 tests/cases/compiler/staticClassMemberError.ts:10:7: 'Foo' was also declared here.
|
||||
~~~
|
||||
!!! error TS2391: Function implementation is missing or not immediately following the declaration.
|
||||
~~~
|
||||
!!! error TS2814: Function with bodies can only merge with classes that are ambient.
|
||||
!!! related TS6506 tests/cases/compiler/staticClassMemberError.ts:10:7: Consider adding a 'declare' modifier to this class.
|
||||
class Foo {
|
||||
~~~
|
||||
!!! error TS2300: Duplicate identifier 'Foo'.
|
||||
!!! related TS6203 tests/cases/compiler/staticClassMemberError.ts:9:10: 'Foo' was also declared here.
|
||||
!!! error TS2813: Class declaration cannot implement overload list for 'Foo'.
|
||||
!!! related TS6506 tests/cases/compiler/staticClassMemberError.ts:10:7: Consider adding a 'declare' modifier to this class.
|
||||
static bar;
|
||||
}
|
||||
@ -5,10 +5,11 @@
|
||||
|
||||
goTo.marker();
|
||||
|
||||
// One error: duplicate identifier 'foo'
|
||||
verify.numberOfErrorsInCurrentFile(2);
|
||||
// Function with bodies can only merge with classes
|
||||
// Class declaration cannot implement overload list x 2
|
||||
verify.numberOfErrorsInCurrentFile(4);
|
||||
|
||||
// Shouldn't change the number of errors
|
||||
edit.insert('return null;');
|
||||
verify.numberOfErrorsInCurrentFile(2);
|
||||
verify.numberOfErrorsInCurrentFile(4);
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user