diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 96b02a2dcea79..464c97d55192a 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -26276,8 +26276,9 @@ namespace ts { let duplicateFunctionDeclaration = false; let multipleConstructorImplementation = false; + let hasNonAmbientClass = false; for (const current of declarations) { - const node = current; + const node = current; const inAmbientContext = node.flags & NodeFlags.Ambient; const inAmbientContextOrInterface = node.parent.kind === SyntaxKind.InterfaceDeclaration || node.parent.kind === SyntaxKind.TypeLiteral || inAmbientContext; if (inAmbientContextOrInterface) { @@ -26291,6 +26292,10 @@ namespace ts { previousDeclaration = undefined; } + if ((node.kind === SyntaxKind.ClassDeclaration || node.kind === SyntaxKind.ClassExpression) && !inAmbientContext) { + hasNonAmbientClass = true; + } + if (node.kind === SyntaxKind.FunctionDeclaration || node.kind === SyntaxKind.MethodDeclaration || node.kind === SyntaxKind.MethodSignature || node.kind === SyntaxKind.Constructor) { const currentNodeFlags = getEffectiveDeclarationFlags(node, flagsToCheck); someNodeFlags |= currentNodeFlags; @@ -26339,6 +26344,16 @@ 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: + forEach(declarations, declaration => { + addDuplicateDeclarationError(getNameOfDeclaration(declaration) || declaration, Diagnostics.Duplicate_identifier_0, symbolName(symbol), filter(declarations, d => d !== declaration)); + }); + } + // Abstract methods can't have an implementation -- in particular, they don't need one. if (lastSeenNonAmbientDeclaration && !lastSeenNonAmbientDeclaration.body && !hasModifier(lastSeenNonAmbientDeclaration, ModifierFlags.Abstract) && !lastSeenNonAmbientDeclaration.questionToken) { @@ -31650,7 +31665,7 @@ namespace ts { if (!symbol || !(symbol.flags & SymbolFlags.Function)) { return false; } - return !!forEachEntry(getExportsOfSymbol(symbol), p => p.flags & SymbolFlags.Value && isPropertyAccessExpression(p.valueDeclaration)); + return !!forEachEntry(getExportsOfSymbol(symbol), p => p.flags & SymbolFlags.Value && p.valueDeclaration && isPropertyAccessExpression(p.valueDeclaration)); } function getPropertiesOfContainerFunction(node: Declaration): Symbol[] { diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 3f1b30feb4526..d31e011ebdc30 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -3678,8 +3678,8 @@ namespace ts { ParameterExcludes = Value, PropertyExcludes = None, EnumMemberExcludes = Value | Type, - FunctionExcludes = Value & ~(Function | ValueModule), - ClassExcludes = (Value | Type) & ~(ValueModule | Interface), // class-interface mergability done in checker.ts + FunctionExcludes = Value & ~(Function | ValueModule | Class), + ClassExcludes = (Value | Type) & ~(ValueModule | Interface | Function), // class-interface mergability done in checker.ts InterfaceExcludes = Type & ~(Interface | Class), RegularEnumExcludes = (Value | Type) & ~(RegularEnum | ValueModule), // regular enums merge only with regular enums and modules ConstEnumExcludes = (Value | Type) & ~ConstEnum, // const enums merge only with const enums diff --git a/tests/baselines/reference/ambientClassOverloadForFunction.errors.txt b/tests/baselines/reference/ambientClassOverloadForFunction.errors.txt deleted file mode 100644 index 16df32bb2c5fc..0000000000000 --- a/tests/baselines/reference/ambientClassOverloadForFunction.errors.txt +++ /dev/null @@ -1,12 +0,0 @@ -tests/cases/compiler/ambientClassOverloadForFunction.ts(1,15): error TS2300: Duplicate identifier 'foo'. -tests/cases/compiler/ambientClassOverloadForFunction.ts(2,10): error TS2300: Duplicate identifier 'foo'. - - -==== tests/cases/compiler/ambientClassOverloadForFunction.ts (2 errors) ==== - declare class foo{}; - ~~~ -!!! error TS2300: Duplicate identifier 'foo'. - function foo() { return null; } - ~~~ -!!! error TS2300: Duplicate identifier 'foo'. - \ No newline at end of file diff --git a/tests/baselines/reference/ambientClassOverloadForFunction.symbols b/tests/baselines/reference/ambientClassOverloadForFunction.symbols index 7ba3fa345938a..db83743745bd6 100644 --- a/tests/baselines/reference/ambientClassOverloadForFunction.symbols +++ b/tests/baselines/reference/ambientClassOverloadForFunction.symbols @@ -1,7 +1,7 @@ === tests/cases/compiler/ambientClassOverloadForFunction.ts === declare class foo{}; ->foo : Symbol(foo, Decl(ambientClassOverloadForFunction.ts, 0, 0)) +>foo : Symbol(foo, Decl(ambientClassOverloadForFunction.ts, 0, 20), Decl(ambientClassOverloadForFunction.ts, 0, 0)) function foo() { return null; } ->foo : Symbol(foo, Decl(ambientClassOverloadForFunction.ts, 0, 20)) +>foo : Symbol(foo, Decl(ambientClassOverloadForFunction.ts, 0, 20), Decl(ambientClassOverloadForFunction.ts, 0, 0)) diff --git a/tests/baselines/reference/ambientClassOverloadForFunction.types b/tests/baselines/reference/ambientClassOverloadForFunction.types index fef745bd97149..1e798690820e8 100644 --- a/tests/baselines/reference/ambientClassOverloadForFunction.types +++ b/tests/baselines/reference/ambientClassOverloadForFunction.types @@ -3,6 +3,6 @@ declare class foo{}; >foo : foo function foo() { return null; } ->foo : () => any +>foo : typeof foo >null : null diff --git a/tests/baselines/reference/api/tsserverlibrary.d.ts b/tests/baselines/reference/api/tsserverlibrary.d.ts index 2f5960f9c215d..f963783e4c7ba 100644 --- a/tests/baselines/reference/api/tsserverlibrary.d.ts +++ b/tests/baselines/reference/api/tsserverlibrary.d.ts @@ -2137,8 +2137,8 @@ declare namespace ts { ParameterExcludes = 111551, PropertyExcludes = 0, EnumMemberExcludes = 900095, - FunctionExcludes = 111023, - ClassExcludes = 899519, + FunctionExcludes = 110991, + ClassExcludes = 899503, InterfaceExcludes = 788872, RegularEnumExcludes = 899327, ConstEnumExcludes = 899967, diff --git a/tests/baselines/reference/api/typescript.d.ts b/tests/baselines/reference/api/typescript.d.ts index 0b7ee8d086de3..a1fe4a874a6f5 100644 --- a/tests/baselines/reference/api/typescript.d.ts +++ b/tests/baselines/reference/api/typescript.d.ts @@ -2137,8 +2137,8 @@ declare namespace ts { ParameterExcludes = 111551, PropertyExcludes = 0, EnumMemberExcludes = 900095, - FunctionExcludes = 111023, - ClassExcludes = 899519, + FunctionExcludes = 110991, + ClassExcludes = 899503, InterfaceExcludes = 788872, RegularEnumExcludes = 899327, ConstEnumExcludes = 899967, diff --git a/tests/baselines/reference/augmentedTypesClass2a.errors.txt b/tests/baselines/reference/augmentedTypesClass2a.errors.txt index b17ab32d408f7..6031558ac0ac4 100644 --- a/tests/baselines/reference/augmentedTypesClass2a.errors.txt +++ b/tests/baselines/reference/augmentedTypesClass2a.errors.txt @@ -1,15 +1,23 @@ 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(3,10): error TS2300: Duplicate identifier 'c2'. tests/cases/compiler/augmentedTypesClass2a.ts(4,5): error TS2300: Duplicate identifier 'c2'. -==== tests/cases/compiler/augmentedTypesClass2a.ts (3 errors) ==== +==== tests/cases/compiler/augmentedTypesClass2a.ts (5 errors) ==== //// class then function 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'. 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'. var c2 = () => { } ~~ diff --git a/tests/baselines/reference/augmentedTypesClass2a.symbols b/tests/baselines/reference/augmentedTypesClass2a.symbols index 78acabbbb4f90..ca5558cfbc503 100644 --- a/tests/baselines/reference/augmentedTypesClass2a.symbols +++ b/tests/baselines/reference/augmentedTypesClass2a.symbols @@ -1,11 +1,11 @@ === tests/cases/compiler/augmentedTypesClass2a.ts === //// class then function class c2 { public foo() { } } // error ->c2 : Symbol(c2, Decl(augmentedTypesClass2a.ts, 0, 0)) +>c2 : Symbol(c2, Decl(augmentedTypesClass2a.ts, 1, 29), Decl(augmentedTypesClass2a.ts, 0, 0)) >foo : Symbol(c2.foo, Decl(augmentedTypesClass2a.ts, 1, 10)) function c2() { } // error ->c2 : Symbol(c2, Decl(augmentedTypesClass2a.ts, 1, 29)) +>c2 : Symbol(c2, Decl(augmentedTypesClass2a.ts, 1, 29), Decl(augmentedTypesClass2a.ts, 0, 0)) var c2 = () => { } >c2 : Symbol(c2, Decl(augmentedTypesClass2a.ts, 3, 3)) diff --git a/tests/baselines/reference/augmentedTypesClass2a.types b/tests/baselines/reference/augmentedTypesClass2a.types index 156d4975d04ef..81cde2c99e4fc 100644 --- a/tests/baselines/reference/augmentedTypesClass2a.types +++ b/tests/baselines/reference/augmentedTypesClass2a.types @@ -5,7 +5,7 @@ class c2 { public foo() { } } // error >foo : () => void function c2() { } // error ->c2 : () => void +>c2 : typeof c2 var c2 = () => { } >c2 : () => void diff --git a/tests/baselines/reference/augmentedTypesFunction.errors.txt b/tests/baselines/reference/augmentedTypesFunction.errors.txt index 2b17ee912fb18..ff2ea23036a64 100644 --- a/tests/baselines/reference/augmentedTypesFunction.errors.txt +++ b/tests/baselines/reference/augmentedTypesFunction.errors.txt @@ -40,16 +40,20 @@ tests/cases/compiler/augmentedTypesFunction.ts(21,6): error TS2567: Enum declara function y3() { } // error ~~ !!! error TS2300: Duplicate identifier 'y3'. +!!! related TS6203 tests/cases/compiler/augmentedTypesFunction.ts:14:7: 'y3' was also declared here. class y3 { } // error ~~ !!! error TS2300: Duplicate identifier 'y3'. +!!! related TS6203 tests/cases/compiler/augmentedTypesFunction.ts:13:10: 'y3' was also declared here. function y3a() { } // error ~~~ !!! error TS2300: Duplicate identifier 'y3a'. +!!! related TS6203 tests/cases/compiler/augmentedTypesFunction.ts:17:7: 'y3a' was also declared here. class y3a { public foo() { } } // error ~~~ !!! error TS2300: Duplicate identifier 'y3a'. +!!! related TS6203 tests/cases/compiler/augmentedTypesFunction.ts:16:10: 'y3a' was also declared here. // function then enum function y4() { } // error diff --git a/tests/baselines/reference/augmentedTypesFunction.symbols b/tests/baselines/reference/augmentedTypesFunction.symbols index 8f202847cd362..007600e1f5b42 100644 --- a/tests/baselines/reference/augmentedTypesFunction.symbols +++ b/tests/baselines/reference/augmentedTypesFunction.symbols @@ -21,16 +21,16 @@ var y2a = () => { } // error // function then class function y3() { } // error ->y3 : Symbol(y3, Decl(augmentedTypesFunction.ts, 9, 19)) +>y3 : Symbol(y3, Decl(augmentedTypesFunction.ts, 9, 19), Decl(augmentedTypesFunction.ts, 12, 17)) class y3 { } // error ->y3 : Symbol(y3, Decl(augmentedTypesFunction.ts, 12, 17)) +>y3 : Symbol(y3, Decl(augmentedTypesFunction.ts, 9, 19), Decl(augmentedTypesFunction.ts, 12, 17)) function y3a() { } // error ->y3a : Symbol(y3a, Decl(augmentedTypesFunction.ts, 13, 12)) +>y3a : Symbol(y3a, Decl(augmentedTypesFunction.ts, 13, 12), Decl(augmentedTypesFunction.ts, 15, 18)) class y3a { public foo() { } } // error ->y3a : Symbol(y3a, Decl(augmentedTypesFunction.ts, 15, 18)) +>y3a : Symbol(y3a, Decl(augmentedTypesFunction.ts, 13, 12), Decl(augmentedTypesFunction.ts, 15, 18)) >foo : Symbol(y3a.foo, Decl(augmentedTypesFunction.ts, 16, 11)) // function then enum diff --git a/tests/baselines/reference/augmentedTypesFunction.types b/tests/baselines/reference/augmentedTypesFunction.types index e30d38179c623..91d6f4f11b1c5 100644 --- a/tests/baselines/reference/augmentedTypesFunction.types +++ b/tests/baselines/reference/augmentedTypesFunction.types @@ -23,13 +23,13 @@ var y2a = () => { } // error // function then class function y3() { } // error ->y3 : () => void +>y3 : typeof y3 class y3 { } // error >y3 : y3 function y3a() { } // error ->y3a : () => void +>y3a : typeof y3a class y3a { public foo() { } } // error >y3a : y3a diff --git a/tests/baselines/reference/callOnInstance.errors.txt b/tests/baselines/reference/callOnInstance.errors.txt index 62abe6fd1e096..15a03546e21b8 100644 --- a/tests/baselines/reference/callOnInstance.errors.txt +++ b/tests/baselines/reference/callOnInstance.errors.txt @@ -1,24 +1,20 @@ -tests/cases/compiler/callOnInstance.ts(1,18): error TS2300: Duplicate identifier 'D'. -tests/cases/compiler/callOnInstance.ts(3,15): error TS2300: Duplicate identifier 'D'. -tests/cases/compiler/callOnInstance.ts(7,25): error TS2554: Expected 0 arguments, but got 1. +tests/cases/compiler/callOnInstance.ts(7,18): error TS2349: This expression is not callable. + Type 'D' has no call signatures. tests/cases/compiler/callOnInstance.ts(10,1): error TS2349: This expression is not callable. Type 'C' has no call signatures. -==== tests/cases/compiler/callOnInstance.ts (4 errors) ==== +==== tests/cases/compiler/callOnInstance.ts (2 errors) ==== declare function D(): string; // error - ~ -!!! error TS2300: Duplicate identifier 'D'. declare class D { constructor (value: number); } // error - ~ -!!! error TS2300: Duplicate identifier 'D'. var s1: string = D(); // OK var s2: string = (new D(1))(); - ~ -!!! error TS2554: Expected 0 arguments, but got 1. + ~~~~~~~~~~ +!!! error TS2349: This expression is not callable. +!!! error TS2349: Type 'D' has no call signatures. declare class C { constructor(value: number); } (new C(1))(); // Error for calling an instance diff --git a/tests/baselines/reference/callOnInstance.symbols b/tests/baselines/reference/callOnInstance.symbols index 1bf147805fd83..060436d81b5bb 100644 --- a/tests/baselines/reference/callOnInstance.symbols +++ b/tests/baselines/reference/callOnInstance.symbols @@ -1,18 +1,18 @@ === tests/cases/compiler/callOnInstance.ts === declare function D(): string; // error ->D : Symbol(D, Decl(callOnInstance.ts, 0, 0)) +>D : Symbol(D, Decl(callOnInstance.ts, 0, 0), Decl(callOnInstance.ts, 0, 29)) declare class D { constructor (value: number); } // error ->D : Symbol(D, Decl(callOnInstance.ts, 0, 29)) +>D : Symbol(D, Decl(callOnInstance.ts, 0, 0), Decl(callOnInstance.ts, 0, 29)) >value : Symbol(value, Decl(callOnInstance.ts, 2, 31)) var s1: string = D(); // OK >s1 : Symbol(s1, Decl(callOnInstance.ts, 4, 3)) ->D : Symbol(D, Decl(callOnInstance.ts, 0, 0)) +>D : Symbol(D, Decl(callOnInstance.ts, 0, 0), Decl(callOnInstance.ts, 0, 29)) var s2: string = (new D(1))(); >s2 : Symbol(s2, Decl(callOnInstance.ts, 6, 3)) ->D : Symbol(D, Decl(callOnInstance.ts, 0, 0)) +>D : Symbol(D, Decl(callOnInstance.ts, 0, 0), Decl(callOnInstance.ts, 0, 29)) declare class C { constructor(value: number); } >C : Symbol(C, Decl(callOnInstance.ts, 6, 30)) diff --git a/tests/baselines/reference/callOnInstance.types b/tests/baselines/reference/callOnInstance.types index c90954ded07c8..5e49fe970c0a0 100644 --- a/tests/baselines/reference/callOnInstance.types +++ b/tests/baselines/reference/callOnInstance.types @@ -1,6 +1,6 @@ === tests/cases/compiler/callOnInstance.ts === declare function D(): string; // error ->D : () => string +>D : typeof D declare class D { constructor (value: number); } // error >D : D @@ -9,14 +9,14 @@ declare class D { constructor (value: number); } // error var s1: string = D(); // OK >s1 : string >D() : string ->D : () => string +>D : typeof D var s2: string = (new D(1))(); >s2 : string >(new D(1))() : any ->(new D(1)) : any ->new D(1) : any ->D : () => string +>(new D(1)) : D +>new D(1) : D +>D : typeof D >1 : 1 declare class C { constructor(value: number); } diff --git a/tests/baselines/reference/callOverloads1.errors.txt b/tests/baselines/reference/callOverloads1.errors.txt index 3e260cc4a959f..95b96aa7ec133 100644 --- a/tests/baselines/reference/callOverloads1.errors.txt +++ b/tests/baselines/reference/callOverloads1.errors.txt @@ -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(9,10): error TS2391: Function implementation is missing or not immediately following the declaration. -tests/cases/compiler/callOverloads1.ts(13,18): error TS2554: Expected 0 arguments, but got 1. -==== tests/cases/compiler/callOverloads1.ts (4 errors) ==== +==== 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. bar1() { /*WScript.Echo("bar1");*/ } constructor(x: any) { @@ -18,14 +18,13 @@ tests/cases/compiler/callOverloads1.ts(13,18): error TS2554: Expected 0 argument 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. function F1(s:string); function F1(a:any) { return a;} var f1 = new Foo("hey"); - ~~~~~ -!!! error TS2554: Expected 0 arguments, but got 1. f1.bar1(); diff --git a/tests/baselines/reference/callOverloads1.symbols b/tests/baselines/reference/callOverloads1.symbols index aadfcd4c06e06..d5f6149dac1a7 100644 --- a/tests/baselines/reference/callOverloads1.symbols +++ b/tests/baselines/reference/callOverloads1.symbols @@ -1,6 +1,6 @@ === tests/cases/compiler/callOverloads1.ts === class Foo { // error ->Foo : Symbol(Foo, Decl(callOverloads1.ts, 0, 0)) +>Foo : Symbol(Foo, Decl(callOverloads1.ts, 6, 1), Decl(callOverloads1.ts, 0, 0)) bar1() { /*WScript.Echo("bar1");*/ } >bar1 : Symbol(Foo.bar1, Decl(callOverloads1.ts, 0, 11)) @@ -13,7 +13,7 @@ class Foo { // error } function Foo(); // error ->Foo : Symbol(Foo, Decl(callOverloads1.ts, 6, 1)) +>Foo : Symbol(Foo, Decl(callOverloads1.ts, 6, 1), Decl(callOverloads1.ts, 0, 0)) function F1(s:string); >F1 : Symbol(F1, Decl(callOverloads1.ts, 8, 15), Decl(callOverloads1.ts, 9, 22)) @@ -26,12 +26,14 @@ function F1(a:any) { return a;} var f1 = new Foo("hey"); >f1 : Symbol(f1, Decl(callOverloads1.ts, 12, 3)) ->Foo : Symbol(Foo, Decl(callOverloads1.ts, 6, 1)) +>Foo : Symbol(Foo, Decl(callOverloads1.ts, 6, 1), Decl(callOverloads1.ts, 0, 0)) f1.bar1(); +>f1.bar1 : Symbol(Foo.bar1, Decl(callOverloads1.ts, 0, 11)) >f1 : Symbol(f1, Decl(callOverloads1.ts, 12, 3)) +>bar1 : Symbol(Foo.bar1, Decl(callOverloads1.ts, 0, 11)) Foo(); ->Foo : Symbol(Foo, Decl(callOverloads1.ts, 6, 1)) +>Foo : Symbol(Foo, Decl(callOverloads1.ts, 6, 1), Decl(callOverloads1.ts, 0, 0)) diff --git a/tests/baselines/reference/callOverloads1.types b/tests/baselines/reference/callOverloads1.types index 0eb8284d25725..34fc1ca20d433 100644 --- a/tests/baselines/reference/callOverloads1.types +++ b/tests/baselines/reference/callOverloads1.types @@ -13,7 +13,7 @@ class Foo { // error } function Foo(); // error ->Foo : () => any +>Foo : typeof Foo function F1(s:string); >F1 : (s: string) => any @@ -25,19 +25,19 @@ function F1(a:any) { return a;} >a : any var f1 = new Foo("hey"); ->f1 : any ->new Foo("hey") : any ->Foo : () => any +>f1 : Foo +>new Foo("hey") : Foo +>Foo : typeof Foo >"hey" : "hey" f1.bar1(); ->f1.bar1() : any ->f1.bar1 : any ->f1 : any ->bar1 : any +>f1.bar1() : void +>f1.bar1 : () => void +>f1 : Foo +>bar1 : () => void Foo(); >Foo() : any ->Foo : () => any +>Foo : typeof Foo diff --git a/tests/baselines/reference/callOverloads2.errors.txt b/tests/baselines/reference/callOverloads2.errors.txt index 360f351047947..8377e5fa4daad 100644 --- a/tests/baselines/reference/callOverloads2.errors.txt +++ b/tests/baselines/reference/callOverloads2.errors.txt @@ -4,13 +4,13 @@ tests/cases/compiler/callOverloads2.ts(11,10): error TS2389: Function implementa tests/cases/compiler/callOverloads2.ts(11,10): error TS2393: Duplicate function implementation. tests/cases/compiler/callOverloads2.ts(12,10): error TS2393: Duplicate function implementation. tests/cases/compiler/callOverloads2.ts(14,10): error TS2391: Function implementation is missing or not immediately following the declaration. -tests/cases/compiler/callOverloads2.ts(18,18): error TS2554: Expected 0 arguments, but got 1. -==== tests/cases/compiler/callOverloads2.ts (7 errors) ==== +==== 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. bar1() { /*WScript.Echo("bar1");*/ } constructor(x: any) { @@ -21,6 +21,7 @@ tests/cases/compiler/callOverloads2.ts(18,18): error TS2554: Expected 0 argument function Foo(); // error ~~~ !!! error TS2300: Duplicate identifier 'Foo'. +!!! related TS6203 tests/cases/compiler/callOverloads2.ts:1:7: 'Foo' was also declared here. function F1(s:string) {return s;} // error ~~ @@ -38,8 +39,6 @@ tests/cases/compiler/callOverloads2.ts(18,18): error TS2554: Expected 0 argument declare function Gar(s:String); // expect no error var f1 = new Foo("hey"); - ~~~~~ -!!! error TS2554: Expected 0 arguments, but got 1. f1.bar1(); diff --git a/tests/baselines/reference/callOverloads2.symbols b/tests/baselines/reference/callOverloads2.symbols index 7c3fe03398d9a..96b5533f7c336 100644 --- a/tests/baselines/reference/callOverloads2.symbols +++ b/tests/baselines/reference/callOverloads2.symbols @@ -1,6 +1,6 @@ === tests/cases/compiler/callOverloads2.ts === class Foo { // error ->Foo : Symbol(Foo, Decl(callOverloads2.ts, 0, 0)) +>Foo : Symbol(Foo, Decl(callOverloads2.ts, 6, 1), Decl(callOverloads2.ts, 0, 0)) bar1() { /*WScript.Echo("bar1");*/ } >bar1 : Symbol(Foo.bar1, Decl(callOverloads2.ts, 0, 11)) @@ -13,7 +13,7 @@ class Foo { // error } function Foo(); // error ->Foo : Symbol(Foo, Decl(callOverloads2.ts, 6, 1)) +>Foo : Symbol(Foo, Decl(callOverloads2.ts, 6, 1), Decl(callOverloads2.ts, 0, 0)) function F1(s:string) {return s;} // error >F1 : Symbol(F1, Decl(callOverloads2.ts, 8, 15), Decl(callOverloads2.ts, 10, 33)) @@ -36,12 +36,14 @@ declare function Gar(s:String); // expect no error var f1 = new Foo("hey"); >f1 : Symbol(f1, Decl(callOverloads2.ts, 17, 3)) ->Foo : Symbol(Foo, Decl(callOverloads2.ts, 6, 1)) +>Foo : Symbol(Foo, Decl(callOverloads2.ts, 6, 1), Decl(callOverloads2.ts, 0, 0)) f1.bar1(); +>f1.bar1 : Symbol(Foo.bar1, Decl(callOverloads2.ts, 0, 11)) >f1 : Symbol(f1, Decl(callOverloads2.ts, 17, 3)) +>bar1 : Symbol(Foo.bar1, Decl(callOverloads2.ts, 0, 11)) Foo(); ->Foo : Symbol(Foo, Decl(callOverloads2.ts, 6, 1)) +>Foo : Symbol(Foo, Decl(callOverloads2.ts, 6, 1), Decl(callOverloads2.ts, 0, 0)) diff --git a/tests/baselines/reference/callOverloads2.types b/tests/baselines/reference/callOverloads2.types index 6718d22a19195..f473ce23358dc 100644 --- a/tests/baselines/reference/callOverloads2.types +++ b/tests/baselines/reference/callOverloads2.types @@ -13,7 +13,7 @@ class Foo { // error } function Foo(); // error ->Foo : () => any +>Foo : typeof Foo function F1(s:string) {return s;} // error >F1 : (s: string) => string @@ -34,19 +34,19 @@ declare function Gar(s:String); // expect no error >s : String var f1 = new Foo("hey"); ->f1 : any ->new Foo("hey") : any ->Foo : () => any +>f1 : Foo +>new Foo("hey") : Foo +>Foo : typeof Foo >"hey" : "hey" f1.bar1(); ->f1.bar1() : any ->f1.bar1 : any ->f1 : any ->bar1 : any +>f1.bar1() : void +>f1.bar1 : () => void +>f1 : Foo +>bar1 : () => void Foo(); >Foo() : any ->Foo : () => any +>Foo : typeof Foo diff --git a/tests/baselines/reference/callOverloads3.errors.txt b/tests/baselines/reference/callOverloads3.errors.txt index 7a38d132cbbb1..7c064ba1775c5 100644 --- a/tests/baselines/reference/callOverloads3.errors.txt +++ b/tests/baselines/reference/callOverloads3.errors.txt @@ -1,28 +1,27 @@ tests/cases/compiler/callOverloads3.ts(1,10): error TS2300: Duplicate identifier 'Foo'. -tests/cases/compiler/callOverloads3.ts(1,16): error TS2749: 'Foo' refers to a value, but is being used as a type here. tests/cases/compiler/callOverloads3.ts(2,10): error TS2300: Duplicate identifier 'Foo'. tests/cases/compiler/callOverloads3.ts(2,10): error TS2391: Function implementation is missing or not immediately following the declaration. -tests/cases/compiler/callOverloads3.ts(2,24): error TS2749: 'Foo' refers to a value, but is being used as a type here. tests/cases/compiler/callOverloads3.ts(3,7): error TS2300: Duplicate identifier 'Foo'. -tests/cases/compiler/callOverloads3.ts(11,10): error TS2350: Only a void function can be called with the 'new' keyword. -==== tests/cases/compiler/callOverloads3.ts (7 errors) ==== +==== tests/cases/compiler/callOverloads3.ts (4 errors) ==== function Foo():Foo; // error ~~~ !!! error TS2300: Duplicate identifier 'Foo'. - ~~~ -!!! error TS2749: 'Foo' refers to a value, but is being used as a type here. +!!! 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. 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 TS2749: 'Foo' refers to a value, but is being used as a type here. 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. bar1() { /*WScript.Echo("bar1");*/ } constructor(x: any) { // WScript.Echo("Constructor function has executed"); @@ -31,8 +30,6 @@ tests/cases/compiler/callOverloads3.ts(11,10): error TS2350: Only a void functio //class Foo(s: String); var f1 = new Foo("hey"); - ~~~~~~~~~~~~~~ -!!! error TS2350: Only a void function can be called with the 'new' keyword. f1.bar1(); diff --git a/tests/baselines/reference/callOverloads3.symbols b/tests/baselines/reference/callOverloads3.symbols index f694684402a81..d0d5c3ef35b23 100644 --- a/tests/baselines/reference/callOverloads3.symbols +++ b/tests/baselines/reference/callOverloads3.symbols @@ -1,13 +1,15 @@ === tests/cases/compiler/callOverloads3.ts === function Foo():Foo; // error ->Foo : Symbol(Foo, Decl(callOverloads3.ts, 0, 0), Decl(callOverloads3.ts, 0, 19)) +>Foo : Symbol(Foo, Decl(callOverloads3.ts, 0, 0), Decl(callOverloads3.ts, 0, 19), Decl(callOverloads3.ts, 1, 27)) +>Foo : Symbol(Foo, Decl(callOverloads3.ts, 0, 0), Decl(callOverloads3.ts, 0, 19), Decl(callOverloads3.ts, 1, 27)) function Foo(s:string):Foo; // error ->Foo : Symbol(Foo, Decl(callOverloads3.ts, 0, 0), Decl(callOverloads3.ts, 0, 19)) +>Foo : Symbol(Foo, Decl(callOverloads3.ts, 0, 0), Decl(callOverloads3.ts, 0, 19), Decl(callOverloads3.ts, 1, 27)) >s : Symbol(s, Decl(callOverloads3.ts, 1, 13)) +>Foo : Symbol(Foo, Decl(callOverloads3.ts, 0, 0), Decl(callOverloads3.ts, 0, 19), Decl(callOverloads3.ts, 1, 27)) class Foo { // error ->Foo : Symbol(Foo, Decl(callOverloads3.ts, 1, 27)) +>Foo : Symbol(Foo, Decl(callOverloads3.ts, 0, 0), Decl(callOverloads3.ts, 0, 19), Decl(callOverloads3.ts, 1, 27)) bar1() { /*WScript.Echo("bar1");*/ } >bar1 : Symbol(Foo.bar1, Decl(callOverloads3.ts, 2, 11)) @@ -22,15 +24,17 @@ class Foo { // error var f1 = new Foo("hey"); >f1 : Symbol(f1, Decl(callOverloads3.ts, 10, 3)) ->Foo : Symbol(Foo, Decl(callOverloads3.ts, 0, 0), Decl(callOverloads3.ts, 0, 19)) +>Foo : Symbol(Foo, Decl(callOverloads3.ts, 0, 0), Decl(callOverloads3.ts, 0, 19), Decl(callOverloads3.ts, 1, 27)) f1.bar1(); +>f1.bar1 : Symbol(Foo.bar1, Decl(callOverloads3.ts, 2, 11)) >f1 : Symbol(f1, Decl(callOverloads3.ts, 10, 3)) +>bar1 : Symbol(Foo.bar1, Decl(callOverloads3.ts, 2, 11)) Foo(); ->Foo : Symbol(Foo, Decl(callOverloads3.ts, 0, 0), Decl(callOverloads3.ts, 0, 19)) +>Foo : Symbol(Foo, Decl(callOverloads3.ts, 0, 0), Decl(callOverloads3.ts, 0, 19), Decl(callOverloads3.ts, 1, 27)) Foo("s"); ->Foo : Symbol(Foo, Decl(callOverloads3.ts, 0, 0), Decl(callOverloads3.ts, 0, 19)) +>Foo : Symbol(Foo, Decl(callOverloads3.ts, 0, 0), Decl(callOverloads3.ts, 0, 19), Decl(callOverloads3.ts, 1, 27)) diff --git a/tests/baselines/reference/callOverloads3.types b/tests/baselines/reference/callOverloads3.types index eeef5edc33966..3b1c7166b4bd4 100644 --- a/tests/baselines/reference/callOverloads3.types +++ b/tests/baselines/reference/callOverloads3.types @@ -1,9 +1,9 @@ === tests/cases/compiler/callOverloads3.ts === function Foo():Foo; // error ->Foo : { (): any; (s: string): any; } +>Foo : typeof Foo function Foo(s:string):Foo; // error ->Foo : { (): any; (s: string): any; } +>Foo : typeof Foo >s : string class Foo { // error @@ -21,24 +21,24 @@ class Foo { // error //class Foo(s: String); var f1 = new Foo("hey"); ->f1 : any ->new Foo("hey") : any ->Foo : { (): any; (s: string): any; } +>f1 : Foo +>new Foo("hey") : Foo +>Foo : typeof Foo >"hey" : "hey" f1.bar1(); ->f1.bar1() : any ->f1.bar1 : any ->f1 : any ->bar1 : any +>f1.bar1() : void +>f1.bar1 : () => void +>f1 : Foo +>bar1 : () => void Foo(); ->Foo() : any ->Foo : { (): any; (s: string): any; } +>Foo() : Foo +>Foo : typeof Foo Foo("s"); ->Foo("s") : any ->Foo : { (): any; (s: string): any; } +>Foo("s") : Foo +>Foo : typeof Foo >"s" : "s" diff --git a/tests/baselines/reference/callOverloads4.errors.txt b/tests/baselines/reference/callOverloads4.errors.txt index dcecd65666e18..cf86024f99517 100644 --- a/tests/baselines/reference/callOverloads4.errors.txt +++ b/tests/baselines/reference/callOverloads4.errors.txt @@ -1,28 +1,27 @@ tests/cases/compiler/callOverloads4.ts(1,10): error TS2300: Duplicate identifier 'Foo'. -tests/cases/compiler/callOverloads4.ts(1,16): error TS2749: 'Foo' refers to a value, but is being used as a type here. tests/cases/compiler/callOverloads4.ts(2,10): error TS2300: Duplicate identifier 'Foo'. tests/cases/compiler/callOverloads4.ts(2,10): error TS2391: Function implementation is missing or not immediately following the declaration. -tests/cases/compiler/callOverloads4.ts(2,24): error TS2749: 'Foo' refers to a value, but is being used as a type here. tests/cases/compiler/callOverloads4.ts(3,7): error TS2300: Duplicate identifier 'Foo'. -tests/cases/compiler/callOverloads4.ts(11,10): error TS2350: Only a void function can be called with the 'new' keyword. -==== tests/cases/compiler/callOverloads4.ts (7 errors) ==== +==== tests/cases/compiler/callOverloads4.ts (4 errors) ==== function Foo():Foo; // error ~~~ !!! error TS2300: Duplicate identifier 'Foo'. - ~~~ -!!! error TS2749: 'Foo' refers to a value, but is being used as a type here. +!!! 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. 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 TS2749: 'Foo' refers to a value, but is being used as a type here. 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. bar1() { /*WScript.Echo("bar1");*/ } constructor(s: string); constructor(x: any) { @@ -31,8 +30,6 @@ tests/cases/compiler/callOverloads4.ts(11,10): error TS2350: Only a void functio } var f1 = new Foo("hey"); - ~~~~~~~~~~~~~~ -!!! error TS2350: Only a void function can be called with the 'new' keyword. f1.bar1(); diff --git a/tests/baselines/reference/callOverloads4.symbols b/tests/baselines/reference/callOverloads4.symbols index 2d898dbdbcc1a..99e49b775bd03 100644 --- a/tests/baselines/reference/callOverloads4.symbols +++ b/tests/baselines/reference/callOverloads4.symbols @@ -1,13 +1,15 @@ === tests/cases/compiler/callOverloads4.ts === function Foo():Foo; // error ->Foo : Symbol(Foo, Decl(callOverloads4.ts, 0, 0), Decl(callOverloads4.ts, 0, 19)) +>Foo : Symbol(Foo, Decl(callOverloads4.ts, 0, 0), Decl(callOverloads4.ts, 0, 19), Decl(callOverloads4.ts, 1, 27)) +>Foo : Symbol(Foo, Decl(callOverloads4.ts, 0, 0), Decl(callOverloads4.ts, 0, 19), Decl(callOverloads4.ts, 1, 27)) function Foo(s:string):Foo; // error ->Foo : Symbol(Foo, Decl(callOverloads4.ts, 0, 0), Decl(callOverloads4.ts, 0, 19)) +>Foo : Symbol(Foo, Decl(callOverloads4.ts, 0, 0), Decl(callOverloads4.ts, 0, 19), Decl(callOverloads4.ts, 1, 27)) >s : Symbol(s, Decl(callOverloads4.ts, 1, 13)) +>Foo : Symbol(Foo, Decl(callOverloads4.ts, 0, 0), Decl(callOverloads4.ts, 0, 19), Decl(callOverloads4.ts, 1, 27)) class Foo { // error ->Foo : Symbol(Foo, Decl(callOverloads4.ts, 1, 27)) +>Foo : Symbol(Foo, Decl(callOverloads4.ts, 0, 0), Decl(callOverloads4.ts, 0, 19), Decl(callOverloads4.ts, 1, 27)) bar1() { /*WScript.Echo("bar1");*/ } >bar1 : Symbol(Foo.bar1, Decl(callOverloads4.ts, 2, 11)) @@ -24,15 +26,17 @@ class Foo { // error var f1 = new Foo("hey"); >f1 : Symbol(f1, Decl(callOverloads4.ts, 10, 3)) ->Foo : Symbol(Foo, Decl(callOverloads4.ts, 0, 0), Decl(callOverloads4.ts, 0, 19)) +>Foo : Symbol(Foo, Decl(callOverloads4.ts, 0, 0), Decl(callOverloads4.ts, 0, 19), Decl(callOverloads4.ts, 1, 27)) f1.bar1(); +>f1.bar1 : Symbol(Foo.bar1, Decl(callOverloads4.ts, 2, 11)) >f1 : Symbol(f1, Decl(callOverloads4.ts, 10, 3)) +>bar1 : Symbol(Foo.bar1, Decl(callOverloads4.ts, 2, 11)) Foo(); ->Foo : Symbol(Foo, Decl(callOverloads4.ts, 0, 0), Decl(callOverloads4.ts, 0, 19)) +>Foo : Symbol(Foo, Decl(callOverloads4.ts, 0, 0), Decl(callOverloads4.ts, 0, 19), Decl(callOverloads4.ts, 1, 27)) Foo("s"); ->Foo : Symbol(Foo, Decl(callOverloads4.ts, 0, 0), Decl(callOverloads4.ts, 0, 19)) +>Foo : Symbol(Foo, Decl(callOverloads4.ts, 0, 0), Decl(callOverloads4.ts, 0, 19), Decl(callOverloads4.ts, 1, 27)) diff --git a/tests/baselines/reference/callOverloads4.types b/tests/baselines/reference/callOverloads4.types index 45a84ed10c635..3b72dfd6b749e 100644 --- a/tests/baselines/reference/callOverloads4.types +++ b/tests/baselines/reference/callOverloads4.types @@ -1,9 +1,9 @@ === tests/cases/compiler/callOverloads4.ts === function Foo():Foo; // error ->Foo : { (): any; (s: string): any; } +>Foo : typeof Foo function Foo(s:string):Foo; // error ->Foo : { (): any; (s: string): any; } +>Foo : typeof Foo >s : string class Foo { // error @@ -23,24 +23,24 @@ class Foo { // error } var f1 = new Foo("hey"); ->f1 : any ->new Foo("hey") : any ->Foo : { (): any; (s: string): any; } +>f1 : Foo +>new Foo("hey") : Foo +>Foo : typeof Foo >"hey" : "hey" f1.bar1(); ->f1.bar1() : any ->f1.bar1 : any ->f1 : any ->bar1 : any +>f1.bar1() : void +>f1.bar1 : () => void +>f1 : Foo +>bar1 : () => void Foo(); ->Foo() : any ->Foo : { (): any; (s: string): any; } +>Foo() : Foo +>Foo : typeof Foo Foo("s"); ->Foo("s") : any ->Foo : { (): any; (s: string): any; } +>Foo("s") : Foo +>Foo : typeof Foo >"s" : "s" diff --git a/tests/baselines/reference/callOverloads5.errors.txt b/tests/baselines/reference/callOverloads5.errors.txt index e9ebdc8a52443..bbf4b4bad8b22 100644 --- a/tests/baselines/reference/callOverloads5.errors.txt +++ b/tests/baselines/reference/callOverloads5.errors.txt @@ -1,28 +1,27 @@ tests/cases/compiler/callOverloads5.ts(1,10): error TS2300: Duplicate identifier 'Foo'. -tests/cases/compiler/callOverloads5.ts(1,16): error TS2749: 'Foo' refers to a value, but is being used as a type here. tests/cases/compiler/callOverloads5.ts(2,10): error TS2300: Duplicate identifier 'Foo'. tests/cases/compiler/callOverloads5.ts(2,10): error TS2391: Function implementation is missing or not immediately following the declaration. -tests/cases/compiler/callOverloads5.ts(2,24): error TS2749: 'Foo' refers to a value, but is being used as a type here. tests/cases/compiler/callOverloads5.ts(3,7): error TS2300: Duplicate identifier 'Foo'. -tests/cases/compiler/callOverloads5.ts(13,10): error TS2350: Only a void function can be called with the 'new' keyword. -==== tests/cases/compiler/callOverloads5.ts (7 errors) ==== +==== tests/cases/compiler/callOverloads5.ts (4 errors) ==== function Foo():Foo; // error ~~~ !!! error TS2300: Duplicate identifier 'Foo'. - ~~~ -!!! error TS2749: 'Foo' refers to a value, but is being used as a type here. +!!! 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. 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 TS2749: 'Foo' refers to a value, but is being used as a type here. 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. bar1(s:string); bar1(n:number); bar1(a:any) { /*WScript.Echo(a);*/ } @@ -33,8 +32,6 @@ tests/cases/compiler/callOverloads5.ts(13,10): error TS2350: Only a void functio //class Foo(s: String); var f1 = new Foo("hey"); - ~~~~~~~~~~~~~~ -!!! error TS2350: Only a void function can be called with the 'new' keyword. f1.bar1("a"); diff --git a/tests/baselines/reference/callOverloads5.symbols b/tests/baselines/reference/callOverloads5.symbols index 0f63d3edf06be..649233ce14379 100644 --- a/tests/baselines/reference/callOverloads5.symbols +++ b/tests/baselines/reference/callOverloads5.symbols @@ -1,13 +1,15 @@ === tests/cases/compiler/callOverloads5.ts === function Foo():Foo; // error ->Foo : Symbol(Foo, Decl(callOverloads5.ts, 0, 0), Decl(callOverloads5.ts, 0, 19)) +>Foo : Symbol(Foo, Decl(callOverloads5.ts, 0, 0), Decl(callOverloads5.ts, 0, 19), Decl(callOverloads5.ts, 1, 27)) +>Foo : Symbol(Foo, Decl(callOverloads5.ts, 0, 0), Decl(callOverloads5.ts, 0, 19), Decl(callOverloads5.ts, 1, 27)) function Foo(s:string):Foo; // error ->Foo : Symbol(Foo, Decl(callOverloads5.ts, 0, 0), Decl(callOverloads5.ts, 0, 19)) +>Foo : Symbol(Foo, Decl(callOverloads5.ts, 0, 0), Decl(callOverloads5.ts, 0, 19), Decl(callOverloads5.ts, 1, 27)) >s : Symbol(s, Decl(callOverloads5.ts, 1, 13)) +>Foo : Symbol(Foo, Decl(callOverloads5.ts, 0, 0), Decl(callOverloads5.ts, 0, 19), Decl(callOverloads5.ts, 1, 27)) class Foo { // error ->Foo : Symbol(Foo, Decl(callOverloads5.ts, 1, 27)) +>Foo : Symbol(Foo, Decl(callOverloads5.ts, 0, 0), Decl(callOverloads5.ts, 0, 19), Decl(callOverloads5.ts, 1, 27)) bar1(s:string); >bar1 : Symbol(Foo.bar1, Decl(callOverloads5.ts, 2, 11), Decl(callOverloads5.ts, 3, 16), Decl(callOverloads5.ts, 4, 16)) @@ -31,15 +33,17 @@ class Foo { // error var f1 = new Foo("hey"); >f1 : Symbol(f1, Decl(callOverloads5.ts, 12, 3)) ->Foo : Symbol(Foo, Decl(callOverloads5.ts, 0, 0), Decl(callOverloads5.ts, 0, 19)) +>Foo : Symbol(Foo, Decl(callOverloads5.ts, 0, 0), Decl(callOverloads5.ts, 0, 19), Decl(callOverloads5.ts, 1, 27)) f1.bar1("a"); +>f1.bar1 : Symbol(Foo.bar1, Decl(callOverloads5.ts, 2, 11), Decl(callOverloads5.ts, 3, 16), Decl(callOverloads5.ts, 4, 16)) >f1 : Symbol(f1, Decl(callOverloads5.ts, 12, 3)) +>bar1 : Symbol(Foo.bar1, Decl(callOverloads5.ts, 2, 11), Decl(callOverloads5.ts, 3, 16), Decl(callOverloads5.ts, 4, 16)) Foo(); ->Foo : Symbol(Foo, Decl(callOverloads5.ts, 0, 0), Decl(callOverloads5.ts, 0, 19)) +>Foo : Symbol(Foo, Decl(callOverloads5.ts, 0, 0), Decl(callOverloads5.ts, 0, 19), Decl(callOverloads5.ts, 1, 27)) Foo("s"); ->Foo : Symbol(Foo, Decl(callOverloads5.ts, 0, 0), Decl(callOverloads5.ts, 0, 19)) +>Foo : Symbol(Foo, Decl(callOverloads5.ts, 0, 0), Decl(callOverloads5.ts, 0, 19), Decl(callOverloads5.ts, 1, 27)) diff --git a/tests/baselines/reference/callOverloads5.types b/tests/baselines/reference/callOverloads5.types index 45e5d77d5aad1..400d20b772f21 100644 --- a/tests/baselines/reference/callOverloads5.types +++ b/tests/baselines/reference/callOverloads5.types @@ -1,9 +1,9 @@ === tests/cases/compiler/callOverloads5.ts === function Foo():Foo; // error ->Foo : { (): any; (s: string): any; } +>Foo : typeof Foo function Foo(s:string):Foo; // error ->Foo : { (): any; (s: string): any; } +>Foo : typeof Foo >s : string class Foo { // error @@ -30,25 +30,25 @@ class Foo { // error //class Foo(s: String); var f1 = new Foo("hey"); ->f1 : any ->new Foo("hey") : any ->Foo : { (): any; (s: string): any; } +>f1 : Foo +>new Foo("hey") : Foo +>Foo : typeof Foo >"hey" : "hey" f1.bar1("a"); >f1.bar1("a") : any ->f1.bar1 : any ->f1 : any ->bar1 : any +>f1.bar1 : { (s: string): any; (n: number): any; } +>f1 : Foo +>bar1 : { (s: string): any; (n: number): any; } >"a" : "a" Foo(); ->Foo() : any ->Foo : { (): any; (s: string): any; } +>Foo() : Foo +>Foo : typeof Foo Foo("s"); ->Foo("s") : any ->Foo : { (): any; (s: string): any; } +>Foo("s") : Foo +>Foo : typeof Foo >"s" : "s" diff --git a/tests/baselines/reference/classFunctionMerging.js b/tests/baselines/reference/classFunctionMerging.js new file mode 100644 index 0000000000000..7da31c1bbd07d --- /dev/null +++ b/tests/baselines/reference/classFunctionMerging.js @@ -0,0 +1,17 @@ +//// [classFunctionMerging.ts] +// We allow ambient classes and functions to merge, this way callable classes +// which are also namespaces can be represented in declaration files +declare function Foo (x: number): Foo.Inst; +declare class Foo { + constructor(x: string); +} +declare namespace Foo { + export type Inst = number; +} + +const a = new Foo(""); +const b = Foo(12); + +//// [classFunctionMerging.js] +var a = new Foo(""); +var b = Foo(12); diff --git a/tests/baselines/reference/classFunctionMerging.symbols b/tests/baselines/reference/classFunctionMerging.symbols new file mode 100644 index 0000000000000..48e17e4fec3f6 --- /dev/null +++ b/tests/baselines/reference/classFunctionMerging.symbols @@ -0,0 +1,30 @@ +=== tests/cases/compiler/classFunctionMerging.ts === +// We allow ambient classes and functions to merge, this way callable classes +// which are also namespaces can be represented in declaration files +declare function Foo (x: number): Foo.Inst; +>Foo : Symbol(Foo, Decl(classFunctionMerging.ts, 0, 0), Decl(classFunctionMerging.ts, 2, 43), Decl(classFunctionMerging.ts, 5, 1)) +>x : Symbol(x, Decl(classFunctionMerging.ts, 2, 22)) +>Foo : Symbol(Foo, Decl(classFunctionMerging.ts, 0, 0), Decl(classFunctionMerging.ts, 2, 43), Decl(classFunctionMerging.ts, 5, 1)) +>Inst : Symbol(Foo.Inst, Decl(classFunctionMerging.ts, 6, 23)) + +declare class Foo { +>Foo : Symbol(Foo, Decl(classFunctionMerging.ts, 0, 0), Decl(classFunctionMerging.ts, 2, 43), Decl(classFunctionMerging.ts, 5, 1)) + + constructor(x: string); +>x : Symbol(x, Decl(classFunctionMerging.ts, 4, 16)) +} +declare namespace Foo { +>Foo : Symbol(Foo, Decl(classFunctionMerging.ts, 0, 0), Decl(classFunctionMerging.ts, 2, 43), Decl(classFunctionMerging.ts, 5, 1)) + + export type Inst = number; +>Inst : Symbol(Inst, Decl(classFunctionMerging.ts, 6, 23)) +} + +const a = new Foo(""); +>a : Symbol(a, Decl(classFunctionMerging.ts, 10, 5)) +>Foo : Symbol(Foo, Decl(classFunctionMerging.ts, 0, 0), Decl(classFunctionMerging.ts, 2, 43), Decl(classFunctionMerging.ts, 5, 1)) + +const b = Foo(12); +>b : Symbol(b, Decl(classFunctionMerging.ts, 11, 5)) +>Foo : Symbol(Foo, Decl(classFunctionMerging.ts, 0, 0), Decl(classFunctionMerging.ts, 2, 43), Decl(classFunctionMerging.ts, 5, 1)) + diff --git a/tests/baselines/reference/classFunctionMerging.types b/tests/baselines/reference/classFunctionMerging.types new file mode 100644 index 0000000000000..0e1bc79a707c6 --- /dev/null +++ b/tests/baselines/reference/classFunctionMerging.types @@ -0,0 +1,31 @@ +=== tests/cases/compiler/classFunctionMerging.ts === +// We allow ambient classes and functions to merge, this way callable classes +// which are also namespaces can be represented in declaration files +declare function Foo (x: number): Foo.Inst; +>Foo : typeof Foo +>x : number +>Foo : any + +declare class Foo { +>Foo : Foo + + constructor(x: string); +>x : string +} +declare namespace Foo { + export type Inst = number; +>Inst : number +} + +const a = new Foo(""); +>a : Foo +>new Foo("") : Foo +>Foo : typeof Foo +>"" : "" + +const b = Foo(12); +>b : number +>Foo(12) : number +>Foo : typeof Foo +>12 : 12 + diff --git a/tests/baselines/reference/classOverloadForFunction.errors.txt b/tests/baselines/reference/classOverloadForFunction.errors.txt index 14bc27fb5cafd..70e4d5d7b4f9d 100644 --- a/tests/baselines/reference/classOverloadForFunction.errors.txt +++ b/tests/baselines/reference/classOverloadForFunction.errors.txt @@ -6,7 +6,9 @@ tests/cases/compiler/classOverloadForFunction.ts(2,10): error TS2300: Duplicate class foo { }; ~~~ !!! error TS2300: Duplicate identifier 'foo'. +!!! related TS6203 tests/cases/compiler/classOverloadForFunction.ts:2:10: 'foo' was also declared here. function foo() {} ~~~ !!! error TS2300: Duplicate identifier 'foo'. +!!! related TS6203 tests/cases/compiler/classOverloadForFunction.ts:1:7: 'foo' was also declared here. \ No newline at end of file diff --git a/tests/baselines/reference/classOverloadForFunction.symbols b/tests/baselines/reference/classOverloadForFunction.symbols index 063215b5fefcc..90a62747e4917 100644 --- a/tests/baselines/reference/classOverloadForFunction.symbols +++ b/tests/baselines/reference/classOverloadForFunction.symbols @@ -1,7 +1,7 @@ === tests/cases/compiler/classOverloadForFunction.ts === class foo { }; ->foo : Symbol(foo, Decl(classOverloadForFunction.ts, 0, 0)) +>foo : Symbol(foo, Decl(classOverloadForFunction.ts, 0, 14), Decl(classOverloadForFunction.ts, 0, 0)) function foo() {} ->foo : Symbol(foo, Decl(classOverloadForFunction.ts, 0, 14)) +>foo : Symbol(foo, Decl(classOverloadForFunction.ts, 0, 14), Decl(classOverloadForFunction.ts, 0, 0)) diff --git a/tests/baselines/reference/classOverloadForFunction.types b/tests/baselines/reference/classOverloadForFunction.types index fd98ba7bc8111..b1c4565242d14 100644 --- a/tests/baselines/reference/classOverloadForFunction.types +++ b/tests/baselines/reference/classOverloadForFunction.types @@ -3,5 +3,5 @@ class foo { }; >foo : foo function foo() {} ->foo : () => void +>foo : typeof foo diff --git a/tests/baselines/reference/classOverloadForFunction2.errors.txt b/tests/baselines/reference/classOverloadForFunction2.errors.txt index 4dd459c48ec3c..447be14c4f97d 100644 --- a/tests/baselines/reference/classOverloadForFunction2.errors.txt +++ b/tests/baselines/reference/classOverloadForFunction2.errors.txt @@ -7,8 +7,10 @@ tests/cases/compiler/classOverloadForFunction2.ts(2,7): error TS2300: Duplicate 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. class bar {} ~~~ -!!! error TS2300: Duplicate identifier 'bar'. \ No newline at end of file +!!! error TS2300: Duplicate identifier 'bar'. +!!! related TS6203 tests/cases/compiler/classOverloadForFunction2.ts:1:10: 'bar' was also declared here. \ No newline at end of file diff --git a/tests/baselines/reference/classOverloadForFunction2.symbols b/tests/baselines/reference/classOverloadForFunction2.symbols index df135e383bedf..daaea300ba325 100644 --- a/tests/baselines/reference/classOverloadForFunction2.symbols +++ b/tests/baselines/reference/classOverloadForFunction2.symbols @@ -1,7 +1,7 @@ === tests/cases/compiler/classOverloadForFunction2.ts === function bar(): string; ->bar : Symbol(bar, Decl(classOverloadForFunction2.ts, 0, 0)) +>bar : Symbol(bar, Decl(classOverloadForFunction2.ts, 0, 0), Decl(classOverloadForFunction2.ts, 0, 23)) class bar {} ->bar : Symbol(bar, Decl(classOverloadForFunction2.ts, 0, 23)) +>bar : Symbol(bar, Decl(classOverloadForFunction2.ts, 0, 0), Decl(classOverloadForFunction2.ts, 0, 23)) diff --git a/tests/baselines/reference/classOverloadForFunction2.types b/tests/baselines/reference/classOverloadForFunction2.types index 13e785694e5e7..db0a9be0c7396 100644 --- a/tests/baselines/reference/classOverloadForFunction2.types +++ b/tests/baselines/reference/classOverloadForFunction2.types @@ -1,6 +1,6 @@ === tests/cases/compiler/classOverloadForFunction2.ts === function bar(): string; ->bar : () => string +>bar : typeof bar class bar {} >bar : bar diff --git a/tests/baselines/reference/constructorOverloads4.errors.txt b/tests/baselines/reference/constructorOverloads4.errors.txt index 9a02c67361b03..595023f2a4c39 100644 --- a/tests/baselines/reference/constructorOverloads4.errors.txt +++ b/tests/baselines/reference/constructorOverloads4.errors.txt @@ -1,27 +1,20 @@ -tests/cases/compiler/constructorOverloads4.ts(2,18): error TS2300: Duplicate identifier 'Function'. -tests/cases/compiler/constructorOverloads4.ts(5,21): error TS2300: Duplicate identifier 'Function'. -tests/cases/compiler/constructorOverloads4.ts(6,21): error TS2300: Duplicate identifier 'Function'. -tests/cases/compiler/constructorOverloads4.ts(10,2): error TS2350: Only a void function can be called with the 'new' keyword. +tests/cases/compiler/constructorOverloads4.ts(10,1): error TS2349: This expression is not callable. + Type 'Function' has no call signatures. -==== tests/cases/compiler/constructorOverloads4.ts (4 errors) ==== +==== tests/cases/compiler/constructorOverloads4.ts (1 errors) ==== declare module M { export class Function { - ~~~~~~~~ -!!! error TS2300: Duplicate identifier 'Function'. constructor(...args: string[]); } export function Function(...args: any[]): any; - ~~~~~~~~ -!!! error TS2300: Duplicate identifier 'Function'. export function Function(...args: string[]): Function; - ~~~~~~~~ -!!! error TS2300: Duplicate identifier 'Function'. } (new M.Function("return 5"))(); - ~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2350: Only a void function can be called with the 'new' keyword. + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2349: This expression is not callable. +!!! error TS2349: Type 'Function' has no call signatures. M.Function("yo"); \ No newline at end of file diff --git a/tests/baselines/reference/constructorOverloads4.symbols b/tests/baselines/reference/constructorOverloads4.symbols index cb008ba6883c4..a215282b96849 100644 --- a/tests/baselines/reference/constructorOverloads4.symbols +++ b/tests/baselines/reference/constructorOverloads4.symbols @@ -3,29 +3,29 @@ declare module M { >M : Symbol(M, Decl(constructorOverloads4.ts, 0, 0)) export class Function { ->Function : Symbol(Function, Decl(constructorOverloads4.ts, 0, 18)) +>Function : Symbol(Function, Decl(constructorOverloads4.ts, 3, 5), Decl(constructorOverloads4.ts, 4, 50), Decl(constructorOverloads4.ts, 0, 18)) constructor(...args: string[]); >args : Symbol(args, Decl(constructorOverloads4.ts, 2, 20)) } export function Function(...args: any[]): any; ->Function : Symbol(Function, Decl(constructorOverloads4.ts, 3, 5), Decl(constructorOverloads4.ts, 4, 50)) +>Function : Symbol(Function, Decl(constructorOverloads4.ts, 3, 5), Decl(constructorOverloads4.ts, 4, 50), Decl(constructorOverloads4.ts, 0, 18)) >args : Symbol(args, Decl(constructorOverloads4.ts, 4, 29)) export function Function(...args: string[]): Function; ->Function : Symbol(Function, Decl(constructorOverloads4.ts, 3, 5), Decl(constructorOverloads4.ts, 4, 50)) +>Function : Symbol(Function, Decl(constructorOverloads4.ts, 3, 5), Decl(constructorOverloads4.ts, 4, 50), Decl(constructorOverloads4.ts, 0, 18)) >args : Symbol(args, Decl(constructorOverloads4.ts, 5, 29)) ->Function : Symbol(Function, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>Function : Symbol(Function, Decl(constructorOverloads4.ts, 3, 5), Decl(constructorOverloads4.ts, 4, 50), Decl(constructorOverloads4.ts, 0, 18)) } (new M.Function("return 5"))(); ->M.Function : Symbol(M.Function, Decl(constructorOverloads4.ts, 3, 5), Decl(constructorOverloads4.ts, 4, 50)) +>M.Function : Symbol(M.Function, Decl(constructorOverloads4.ts, 3, 5), Decl(constructorOverloads4.ts, 4, 50), Decl(constructorOverloads4.ts, 0, 18)) >M : Symbol(M, Decl(constructorOverloads4.ts, 0, 0)) ->Function : Symbol(M.Function, Decl(constructorOverloads4.ts, 3, 5), Decl(constructorOverloads4.ts, 4, 50)) +>Function : Symbol(M.Function, Decl(constructorOverloads4.ts, 3, 5), Decl(constructorOverloads4.ts, 4, 50), Decl(constructorOverloads4.ts, 0, 18)) M.Function("yo"); ->M.Function : Symbol(M.Function, Decl(constructorOverloads4.ts, 3, 5), Decl(constructorOverloads4.ts, 4, 50)) +>M.Function : Symbol(M.Function, Decl(constructorOverloads4.ts, 3, 5), Decl(constructorOverloads4.ts, 4, 50), Decl(constructorOverloads4.ts, 0, 18)) >M : Symbol(M, Decl(constructorOverloads4.ts, 0, 0)) ->Function : Symbol(M.Function, Decl(constructorOverloads4.ts, 3, 5), Decl(constructorOverloads4.ts, 4, 50)) +>Function : Symbol(M.Function, Decl(constructorOverloads4.ts, 3, 5), Decl(constructorOverloads4.ts, 4, 50), Decl(constructorOverloads4.ts, 0, 18)) diff --git a/tests/baselines/reference/constructorOverloads4.types b/tests/baselines/reference/constructorOverloads4.types index faf28b5e682da..7e2fbd9a84808 100644 --- a/tests/baselines/reference/constructorOverloads4.types +++ b/tests/baselines/reference/constructorOverloads4.types @@ -3,34 +3,34 @@ declare module M { >M : typeof M export class Function { ->Function : M.Function +>Function : Function constructor(...args: string[]); >args : string[] } export function Function(...args: any[]): any; ->Function : { (...args: any[]): any; (...args: string[]): Function; } +>Function : typeof Function >args : any[] export function Function(...args: string[]): Function; ->Function : { (...args: any[]): any; (...args: string[]): Function; } +>Function : typeof Function >args : string[] } (new M.Function("return 5"))(); >(new M.Function("return 5"))() : any ->(new M.Function("return 5")) : any ->new M.Function("return 5") : any ->M.Function : { (...args: any[]): any; (...args: string[]): Function; } +>(new M.Function("return 5")) : M.Function +>new M.Function("return 5") : M.Function +>M.Function : typeof M.Function >M : typeof M ->Function : { (...args: any[]): any; (...args: string[]): Function; } +>Function : typeof M.Function >"return 5" : "return 5" M.Function("yo"); >M.Function("yo") : any ->M.Function : { (...args: any[]): any; (...args: string[]): Function; } +>M.Function : typeof M.Function >M : typeof M ->Function : { (...args: any[]): any; (...args: string[]): Function; } +>Function : typeof M.Function >"yo" : "yo" diff --git a/tests/baselines/reference/constructorOverloads5.errors.txt b/tests/baselines/reference/constructorOverloads5.errors.txt deleted file mode 100644 index 0a695fc001c94..0000000000000 --- a/tests/baselines/reference/constructorOverloads5.errors.txt +++ /dev/null @@ -1,30 +0,0 @@ -tests/cases/compiler/constructorOverloads5.ts(4,21): error TS2300: Duplicate identifier 'RegExp'. -tests/cases/compiler/constructorOverloads5.ts(5,21): error TS2300: Duplicate identifier 'RegExp'. -tests/cases/compiler/constructorOverloads5.ts(6,18): error TS2300: Duplicate identifier 'RegExp'. - - -==== tests/cases/compiler/constructorOverloads5.ts (3 errors) ==== - interface IArguments {} - - declare module M { - export function RegExp(pattern: string): RegExp; - ~~~~~~ -!!! error TS2300: Duplicate identifier 'RegExp'. - export function RegExp(pattern: string, flags: string): RegExp; - ~~~~~~ -!!! error TS2300: Duplicate identifier 'RegExp'. - export class RegExp { - ~~~~~~ -!!! error TS2300: Duplicate identifier 'RegExp'. - constructor(pattern: string); - constructor(pattern: string, flags: string); - exec(string: string): string[]; - test(string: string): boolean; - source: string; - global: boolean; - ignoreCase: boolean; - multiline: boolean; - lastIndex: boolean; - } - } - \ No newline at end of file diff --git a/tests/baselines/reference/constructorOverloads5.symbols b/tests/baselines/reference/constructorOverloads5.symbols index 1f0e4160b99f6..c6c9fedbbefae 100644 --- a/tests/baselines/reference/constructorOverloads5.symbols +++ b/tests/baselines/reference/constructorOverloads5.symbols @@ -6,18 +6,18 @@ >M : Symbol(M, Decl(constructorOverloads5.ts, 0, 24)) export function RegExp(pattern: string): RegExp; ->RegExp : Symbol(RegExp, Decl(constructorOverloads5.ts, 2, 19), Decl(constructorOverloads5.ts, 3, 52)) +>RegExp : Symbol(RegExp, Decl(constructorOverloads5.ts, 2, 19), Decl(constructorOverloads5.ts, 3, 52), Decl(constructorOverloads5.ts, 4, 67)) >pattern : Symbol(pattern, Decl(constructorOverloads5.ts, 3, 27)) ->RegExp : Symbol(RegExp, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>RegExp : Symbol(RegExp, Decl(constructorOverloads5.ts, 2, 19), Decl(constructorOverloads5.ts, 3, 52), Decl(constructorOverloads5.ts, 4, 67)) export function RegExp(pattern: string, flags: string): RegExp; ->RegExp : Symbol(RegExp, Decl(constructorOverloads5.ts, 2, 19), Decl(constructorOverloads5.ts, 3, 52)) +>RegExp : Symbol(RegExp, Decl(constructorOverloads5.ts, 2, 19), Decl(constructorOverloads5.ts, 3, 52), Decl(constructorOverloads5.ts, 4, 67)) >pattern : Symbol(pattern, Decl(constructorOverloads5.ts, 4, 27)) >flags : Symbol(flags, Decl(constructorOverloads5.ts, 4, 43)) ->RegExp : Symbol(RegExp, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>RegExp : Symbol(RegExp, Decl(constructorOverloads5.ts, 2, 19), Decl(constructorOverloads5.ts, 3, 52), Decl(constructorOverloads5.ts, 4, 67)) export class RegExp { ->RegExp : Symbol(RegExp, Decl(constructorOverloads5.ts, 4, 67)) +>RegExp : Symbol(RegExp, Decl(constructorOverloads5.ts, 2, 19), Decl(constructorOverloads5.ts, 3, 52), Decl(constructorOverloads5.ts, 4, 67)) constructor(pattern: string); >pattern : Symbol(pattern, Decl(constructorOverloads5.ts, 6, 20)) diff --git a/tests/baselines/reference/constructorOverloads5.types b/tests/baselines/reference/constructorOverloads5.types index 27f5e09e157e5..69a1d835d5fec 100644 --- a/tests/baselines/reference/constructorOverloads5.types +++ b/tests/baselines/reference/constructorOverloads5.types @@ -5,16 +5,16 @@ >M : typeof M export function RegExp(pattern: string): RegExp; ->RegExp : { (pattern: string): RegExp; (pattern: string, flags: string): RegExp; } +>RegExp : typeof RegExp >pattern : string export function RegExp(pattern: string, flags: string): RegExp; ->RegExp : { (pattern: string): RegExp; (pattern: string, flags: string): RegExp; } +>RegExp : typeof RegExp >pattern : string >flags : string export class RegExp { ->RegExp : M.RegExp +>RegExp : RegExp constructor(pattern: string); >pattern : string diff --git a/tests/baselines/reference/constructorOverloads7.errors.txt b/tests/baselines/reference/constructorOverloads7.errors.txt index 81aeaaf24ff1e..c6d2341a9e53f 100644 --- a/tests/baselines/reference/constructorOverloads7.errors.txt +++ b/tests/baselines/reference/constructorOverloads7.errors.txt @@ -1,25 +1,15 @@ -tests/cases/compiler/constructorOverloads7.ts(1,15): error TS2300: Duplicate identifier 'Point'. -tests/cases/compiler/constructorOverloads7.ts(7,35): error TS2749: 'Point' refers to a value, but is being used as a type here. -tests/cases/compiler/constructorOverloads7.ts(8,14): error TS2749: 'Point' refers to a value, but is being used as a type here. -tests/cases/compiler/constructorOverloads7.ts(15,10): error TS2300: Duplicate identifier 'Point'. tests/cases/compiler/constructorOverloads7.ts(22,18): error TS2384: Overload signatures must all be ambient or non-ambient. -==== tests/cases/compiler/constructorOverloads7.ts (5 errors) ==== +==== tests/cases/compiler/constructorOverloads7.ts (1 errors) ==== declare class Point - ~~~~~ -!!! error TS2300: Duplicate identifier 'Point'. { x: number; y: number; constructor(x: number, y: number); add(dx: number, dy: number): Point; - ~~~~~ -!!! error TS2749: 'Point' refers to a value, but is being used as a type here. origin: Point; - ~~~~~ -!!! error TS2749: 'Point' refers to a value, but is being used as a type here. } @@ -27,8 +17,6 @@ tests/cases/compiler/constructorOverloads7.ts(22,18): error TS2384: Overload sig // Because Point is a constructor function, this is inferred // to be Point and return type is inferred to be void function Point(x, y) { - ~~~~~ -!!! error TS2300: Duplicate identifier 'Point'. this.x = x; this.y = y; diff --git a/tests/baselines/reference/constructorOverloads7.symbols b/tests/baselines/reference/constructorOverloads7.symbols index fe2d6cb7817c3..8381d29066d46 100644 --- a/tests/baselines/reference/constructorOverloads7.symbols +++ b/tests/baselines/reference/constructorOverloads7.symbols @@ -1,6 +1,6 @@ === tests/cases/compiler/constructorOverloads7.ts === declare class Point ->Point : Symbol(Point, Decl(constructorOverloads7.ts, 0, 0)) +>Point : Symbol(Point, Decl(constructorOverloads7.ts, 9, 1), Decl(constructorOverloads7.ts, 0, 0)) { x: number; >x : Symbol(Point.x, Decl(constructorOverloads7.ts, 1, 1)) @@ -16,9 +16,11 @@ declare class Point >add : Symbol(Point.add, Decl(constructorOverloads7.ts, 4, 38)) >dx : Symbol(dx, Decl(constructorOverloads7.ts, 6, 9)) >dy : Symbol(dy, Decl(constructorOverloads7.ts, 6, 20)) +>Point : Symbol(Point, Decl(constructorOverloads7.ts, 9, 1), Decl(constructorOverloads7.ts, 0, 0)) origin: Point; >origin : Symbol(Point.origin, Decl(constructorOverloads7.ts, 6, 40)) +>Point : Symbol(Point, Decl(constructorOverloads7.ts, 9, 1), Decl(constructorOverloads7.ts, 0, 0)) } @@ -26,7 +28,7 @@ declare class Point // Because Point is a constructor function, this is inferred // to be Point and return type is inferred to be void function Point(x, y) { ->Point : Symbol(Point, Decl(constructorOverloads7.ts, 9, 1)) +>Point : Symbol(Point, Decl(constructorOverloads7.ts, 9, 1), Decl(constructorOverloads7.ts, 0, 0)) >x : Symbol(x, Decl(constructorOverloads7.ts, 14, 15)) >y : Symbol(y, Decl(constructorOverloads7.ts, 14, 17)) diff --git a/tests/baselines/reference/constructorOverloads7.types b/tests/baselines/reference/constructorOverloads7.types index f5873284d8980..360bf6f023fea 100644 --- a/tests/baselines/reference/constructorOverloads7.types +++ b/tests/baselines/reference/constructorOverloads7.types @@ -13,12 +13,12 @@ declare class Point >y : number add(dx: number, dy: number): Point; ->add : (dx: number, dy: number) => any +>add : (dx: number, dy: number) => Point >dx : number >dy : number origin: Point; ->origin : any +>origin : Point } @@ -26,7 +26,7 @@ declare class Point // Because Point is a constructor function, this is inferred // to be Point and return type is inferred to be void function Point(x, y) { ->Point : (x: any, y: any) => any +>Point : typeof Point >x : any >y : any diff --git a/tests/baselines/reference/duplicateIdentifiersAcrossContainerBoundaries.errors.txt b/tests/baselines/reference/duplicateIdentifiersAcrossContainerBoundaries.errors.txt index 684c123ebd7cd..d4792e6b2d0e4 100644 --- a/tests/baselines/reference/duplicateIdentifiersAcrossContainerBoundaries.errors.txt +++ b/tests/baselines/reference/duplicateIdentifiersAcrossContainerBoundaries.errors.txt @@ -16,11 +16,13 @@ tests/cases/compiler/duplicateIdentifiersAcrossContainerBoundaries.ts(41,16): er export function f() { } ~ !!! error TS2300: Duplicate identifier 'f'. +!!! related TS6203 tests/cases/compiler/duplicateIdentifiersAcrossContainerBoundaries.ts:12:18: 'f' was also declared here. } 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. } module M { diff --git a/tests/baselines/reference/duplicateIdentifiersAcrossContainerBoundaries.symbols b/tests/baselines/reference/duplicateIdentifiersAcrossContainerBoundaries.symbols index 61fde6458d816..c3e7efaf6e6cc 100644 --- a/tests/baselines/reference/duplicateIdentifiersAcrossContainerBoundaries.symbols +++ b/tests/baselines/reference/duplicateIdentifiersAcrossContainerBoundaries.symbols @@ -16,13 +16,13 @@ module M { >M : Symbol(M, Decl(duplicateIdentifiersAcrossContainerBoundaries.ts, 0, 0), Decl(duplicateIdentifiersAcrossContainerBoundaries.ts, 2, 1), Decl(duplicateIdentifiersAcrossContainerBoundaries.ts, 5, 1), Decl(duplicateIdentifiersAcrossContainerBoundaries.ts, 9, 1), Decl(duplicateIdentifiersAcrossContainerBoundaries.ts, 12, 1) ... and 5 more) export function f() { } ->f : Symbol(f, Decl(duplicateIdentifiersAcrossContainerBoundaries.ts, 7, 10)) +>f : Symbol(f, Decl(duplicateIdentifiersAcrossContainerBoundaries.ts, 7, 10), Decl(duplicateIdentifiersAcrossContainerBoundaries.ts, 10, 10)) } module M { >M : Symbol(M, Decl(duplicateIdentifiersAcrossContainerBoundaries.ts, 0, 0), Decl(duplicateIdentifiersAcrossContainerBoundaries.ts, 2, 1), Decl(duplicateIdentifiersAcrossContainerBoundaries.ts, 5, 1), Decl(duplicateIdentifiersAcrossContainerBoundaries.ts, 9, 1), Decl(duplicateIdentifiersAcrossContainerBoundaries.ts, 12, 1) ... and 5 more) export class f { } // error ->f : Symbol(f, Decl(duplicateIdentifiersAcrossContainerBoundaries.ts, 10, 10)) +>f : Symbol(f, Decl(duplicateIdentifiersAcrossContainerBoundaries.ts, 7, 10), Decl(duplicateIdentifiersAcrossContainerBoundaries.ts, 10, 10)) } module M { diff --git a/tests/baselines/reference/duplicateIdentifiersAcrossContainerBoundaries.types b/tests/baselines/reference/duplicateIdentifiersAcrossContainerBoundaries.types index bd24ae4ab372b..24eb8637e233f 100644 --- a/tests/baselines/reference/duplicateIdentifiersAcrossContainerBoundaries.types +++ b/tests/baselines/reference/duplicateIdentifiersAcrossContainerBoundaries.types @@ -13,7 +13,7 @@ module M { >M : typeof M export function f() { } ->f : () => void +>f : typeof f } module M { >M : typeof M diff --git a/tests/baselines/reference/duplicateIdentifiersAcrossFileBoundaries.symbols b/tests/baselines/reference/duplicateIdentifiersAcrossFileBoundaries.symbols index 608dfbfc96fe9..431c87dd38381 100644 --- a/tests/baselines/reference/duplicateIdentifiersAcrossFileBoundaries.symbols +++ b/tests/baselines/reference/duplicateIdentifiersAcrossFileBoundaries.symbols @@ -6,10 +6,10 @@ class C1 { } >C1 : Symbol(C1, Decl(file1.ts, 0, 15), Decl(file2.ts, 0, 11)) class C2 { } ->C2 : Symbol(C2, Decl(file1.ts, 1, 12)) +>C2 : Symbol(C2, Decl(file1.ts, 1, 12), Decl(file2.ts, 1, 16)) function f() { } ->f : Symbol(f, Decl(file1.ts, 2, 12)) +>f : Symbol(f, Decl(file1.ts, 2, 12), Decl(file2.ts, 2, 17)) var v = 3; >v : Symbol(v, Decl(file1.ts, 4, 3), Decl(file2.ts, 4, 3)) @@ -40,10 +40,10 @@ interface C1 { } // error -- cannot merge interface with non-ambient class >C1 : Symbol(C1, Decl(file1.ts, 0, 15), Decl(file2.ts, 0, 11)) function C2() { } // error -- cannot merge function with non-ambient class ->C2 : Symbol(C2, Decl(file2.ts, 1, 16)) +>C2 : Symbol(C2, Decl(file1.ts, 1, 12), Decl(file2.ts, 1, 16)) class f { } // error -- cannot merge function with non-ambient class ->f : Symbol(f, Decl(file2.ts, 2, 17)) +>f : Symbol(f, Decl(file1.ts, 2, 12), Decl(file2.ts, 2, 17)) var v = 3; >v : Symbol(v, Decl(file1.ts, 4, 3), Decl(file2.ts, 4, 3)) diff --git a/tests/baselines/reference/duplicateIdentifiersAcrossFileBoundaries.types b/tests/baselines/reference/duplicateIdentifiersAcrossFileBoundaries.types index e4da45b187340..9449853ee2a01 100644 --- a/tests/baselines/reference/duplicateIdentifiersAcrossFileBoundaries.types +++ b/tests/baselines/reference/duplicateIdentifiersAcrossFileBoundaries.types @@ -7,7 +7,7 @@ class C2 { } >C2 : C2 function f() { } ->f : () => void +>f : typeof f var v = 3; >v : number @@ -37,7 +37,7 @@ 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 ->C2 : () => void +>C2 : typeof C2 class f { } // error -- cannot merge function with non-ambient class >f : f diff --git a/tests/baselines/reference/es6ClassTest9.errors.txt b/tests/baselines/reference/es6ClassTest9.errors.txt index 21d9fccc2e509..de13f242bff22 100644 --- a/tests/baselines/reference/es6ClassTest9.errors.txt +++ b/tests/baselines/reference/es6ClassTest9.errors.txt @@ -1,18 +1,12 @@ -tests/cases/compiler/es6ClassTest9.ts(1,15): error TS2300: Duplicate identifier 'foo'. tests/cases/compiler/es6ClassTest9.ts(1,18): error TS1005: '{' expected. tests/cases/compiler/es6ClassTest9.ts(1,19): error TS1109: Expression expected. -tests/cases/compiler/es6ClassTest9.ts(2,10): error TS2300: Duplicate identifier 'foo'. -==== tests/cases/compiler/es6ClassTest9.ts (4 errors) ==== +==== tests/cases/compiler/es6ClassTest9.ts (2 errors) ==== declare class foo(); - ~~~ -!!! error TS2300: Duplicate identifier 'foo'. ~ !!! error TS1005: '{' expected. ~ !!! error TS1109: Expression expected. function foo() {} - ~~~ -!!! error TS2300: Duplicate identifier 'foo'. \ No newline at end of file diff --git a/tests/baselines/reference/es6ClassTest9.symbols b/tests/baselines/reference/es6ClassTest9.symbols index 03deef02379de..7b362f29e48f7 100644 --- a/tests/baselines/reference/es6ClassTest9.symbols +++ b/tests/baselines/reference/es6ClassTest9.symbols @@ -1,7 +1,7 @@ === tests/cases/compiler/es6ClassTest9.ts === declare class foo(); ->foo : Symbol(foo, Decl(es6ClassTest9.ts, 0, 0)) +>foo : Symbol(foo, Decl(es6ClassTest9.ts, 0, 20), Decl(es6ClassTest9.ts, 0, 0)) function foo() {} ->foo : Symbol(foo, Decl(es6ClassTest9.ts, 0, 20)) +>foo : Symbol(foo, Decl(es6ClassTest9.ts, 0, 20), Decl(es6ClassTest9.ts, 0, 0)) diff --git a/tests/baselines/reference/es6ClassTest9.types b/tests/baselines/reference/es6ClassTest9.types index 47b80cffcfa12..c3872cc05c022 100644 --- a/tests/baselines/reference/es6ClassTest9.types +++ b/tests/baselines/reference/es6ClassTest9.types @@ -5,5 +5,5 @@ declare class foo(); > : any function foo() {} ->foo : () => void +>foo : typeof foo diff --git a/tests/baselines/reference/funClodule.errors.txt b/tests/baselines/reference/funClodule.errors.txt index c55e7391bfe5a..a86c3ed89bf14 100644 --- a/tests/baselines/reference/funClodule.errors.txt +++ b/tests/baselines/reference/funClodule.errors.txt @@ -1,46 +1,37 @@ -tests/cases/compiler/funClodule.ts(1,18): error TS2300: Duplicate identifier 'foo'. -tests/cases/compiler/funClodule.ts(2,16): error TS2300: Duplicate identifier 'foo'. -tests/cases/compiler/funClodule.ts(5,15): error TS2300: Duplicate identifier 'foo'. -tests/cases/compiler/funClodule.ts(8,15): error TS2300: Duplicate identifier 'foo2'. -tests/cases/compiler/funClodule.ts(12,18): error TS2300: Duplicate identifier 'foo2'. 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 (8 errors) ==== +==== tests/cases/compiler/funClodule.ts (3 errors) ==== declare function foo(); - ~~~ -!!! error TS2300: Duplicate identifier 'foo'. declare module foo { - ~~~ -!!! error TS2300: Duplicate identifier 'foo'. export function x(): any; } declare class foo { } // Should error - ~~~ -!!! error TS2300: Duplicate identifier 'foo'. declare class foo2 { } - ~~~~ -!!! error TS2300: Duplicate identifier 'foo2'. declare module foo2 { export function x(): any; } declare function foo2(); // Should error - ~~~~ -!!! error TS2300: Duplicate identifier 'foo2'. 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. 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'. \ No newline at end of file +!!! 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. \ No newline at end of file diff --git a/tests/baselines/reference/funClodule.symbols b/tests/baselines/reference/funClodule.symbols index 4e342b4bac3ba..83f7ff12bebc5 100644 --- a/tests/baselines/reference/funClodule.symbols +++ b/tests/baselines/reference/funClodule.symbols @@ -1,39 +1,39 @@ === tests/cases/compiler/funClodule.ts === declare function foo(); ->foo : Symbol(foo, Decl(funClodule.ts, 0, 0), Decl(funClodule.ts, 0, 23)) +>foo : Symbol(foo, Decl(funClodule.ts, 0, 0), Decl(funClodule.ts, 0, 23), Decl(funClodule.ts, 3, 1)) declare module foo { ->foo : Symbol(foo, Decl(funClodule.ts, 0, 0), Decl(funClodule.ts, 0, 23)) +>foo : Symbol(foo, Decl(funClodule.ts, 0, 0), Decl(funClodule.ts, 0, 23), Decl(funClodule.ts, 3, 1)) export function x(): any; >x : Symbol(x, Decl(funClodule.ts, 1, 20)) } declare class foo { } // Should error ->foo : Symbol(foo, Decl(funClodule.ts, 3, 1)) +>foo : Symbol(foo, Decl(funClodule.ts, 0, 0), Decl(funClodule.ts, 0, 23), Decl(funClodule.ts, 3, 1)) declare class foo2 { } ->foo2 : Symbol(foo2, Decl(funClodule.ts, 4, 21)) +>foo2 : Symbol(foo2, Decl(funClodule.ts, 10, 1), Decl(funClodule.ts, 4, 21), Decl(funClodule.ts, 7, 22)) declare module foo2 { ->foo2 : Symbol(foo2, Decl(funClodule.ts, 10, 1), Decl(funClodule.ts, 7, 22)) +>foo2 : Symbol(foo2, Decl(funClodule.ts, 10, 1), Decl(funClodule.ts, 4, 21), Decl(funClodule.ts, 7, 22)) export function x(): any; >x : Symbol(x, Decl(funClodule.ts, 8, 21)) } declare function foo2(); // Should error ->foo2 : Symbol(foo2, Decl(funClodule.ts, 10, 1), Decl(funClodule.ts, 7, 22)) +>foo2 : Symbol(foo2, Decl(funClodule.ts, 10, 1), Decl(funClodule.ts, 4, 21), Decl(funClodule.ts, 7, 22)) function foo3() { } ->foo3 : Symbol(foo3, Decl(funClodule.ts, 11, 24), Decl(funClodule.ts, 14, 19)) +>foo3 : Symbol(foo3, Decl(funClodule.ts, 11, 24), Decl(funClodule.ts, 14, 19), Decl(funClodule.ts, 17, 1)) module foo3 { ->foo3 : Symbol(foo3, Decl(funClodule.ts, 11, 24), Decl(funClodule.ts, 14, 19)) +>foo3 : Symbol(foo3, Decl(funClodule.ts, 11, 24), Decl(funClodule.ts, 14, 19), Decl(funClodule.ts, 17, 1)) export function x(): any { } >x : Symbol(x, Decl(funClodule.ts, 15, 13)) } class foo3 { } // Should error ->foo3 : Symbol(foo3, Decl(funClodule.ts, 17, 1)) +>foo3 : Symbol(foo3, Decl(funClodule.ts, 11, 24), Decl(funClodule.ts, 14, 19), Decl(funClodule.ts, 17, 1)) diff --git a/tests/baselines/reference/getAccessorWithImpliedReturnTypeAndFunctionClassMerge.errors.txt b/tests/baselines/reference/getAccessorWithImpliedReturnTypeAndFunctionClassMerge.errors.txt index e7ceb8acea29e..7ec8f614edbd3 100644 --- a/tests/baselines/reference/getAccessorWithImpliedReturnTypeAndFunctionClassMerge.errors.txt +++ b/tests/baselines/reference/getAccessorWithImpliedReturnTypeAndFunctionClassMerge.errors.txt @@ -1,27 +1,11 @@ -tests/cases/compiler/getAccessorWithImpliedReturnTypeAndFunctionClassMerge.ts(1,18): error TS2300: Duplicate identifier '_'. -tests/cases/compiler/getAccessorWithImpliedReturnTypeAndFunctionClassMerge.ts(1,41): error TS2709: Cannot use namespace '_' as a type. -tests/cases/compiler/getAccessorWithImpliedReturnTypeAndFunctionClassMerge.ts(2,18): error TS2300: Duplicate identifier '_'. -tests/cases/compiler/getAccessorWithImpliedReturnTypeAndFunctionClassMerge.ts(2,34): error TS2709: Cannot use namespace '_' as a type. -tests/cases/compiler/getAccessorWithImpliedReturnTypeAndFunctionClassMerge.ts(4,16): error TS2300: Duplicate identifier '_'. -tests/cases/compiler/getAccessorWithImpliedReturnTypeAndFunctionClassMerge.ts(15,15): error TS2300: Duplicate identifier '_'. tests/cases/compiler/getAccessorWithImpliedReturnTypeAndFunctionClassMerge.ts(21,20): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -==== tests/cases/compiler/getAccessorWithImpliedReturnTypeAndFunctionClassMerge.ts (7 errors) ==== +==== tests/cases/compiler/getAccessorWithImpliedReturnTypeAndFunctionClassMerge.ts (1 errors) ==== declare function _(value: Array): _; - ~ -!!! error TS2300: Duplicate identifier '_'. - ~ -!!! error TS2709: Cannot use namespace '_' as a type. declare function _(value: T): _; - ~ -!!! error TS2300: Duplicate identifier '_'. - ~ -!!! error TS2709: Cannot use namespace '_' as a type. declare module _ { - ~ -!!! error TS2300: Duplicate identifier '_'. export function each( //list: List, //iterator: ListIterator, @@ -33,8 +17,6 @@ tests/cases/compiler/getAccessorWithImpliedReturnTypeAndFunctionClassMerge.ts(21 } declare class _ { - ~ -!!! error TS2300: Duplicate identifier '_'. each(iterator: _.ListIterator, context?: any): void; } diff --git a/tests/baselines/reference/getAccessorWithImpliedReturnTypeAndFunctionClassMerge.symbols b/tests/baselines/reference/getAccessorWithImpliedReturnTypeAndFunctionClassMerge.symbols index 39516807c4dec..68ec0b7989c30 100644 --- a/tests/baselines/reference/getAccessorWithImpliedReturnTypeAndFunctionClassMerge.symbols +++ b/tests/baselines/reference/getAccessorWithImpliedReturnTypeAndFunctionClassMerge.symbols @@ -1,21 +1,23 @@ === tests/cases/compiler/getAccessorWithImpliedReturnTypeAndFunctionClassMerge.ts === declare function _(value: Array): _; ->_ : Symbol(_, Decl(getAccessorWithImpliedReturnTypeAndFunctionClassMerge.ts, 0, 0), Decl(getAccessorWithImpliedReturnTypeAndFunctionClassMerge.ts, 0, 45), Decl(getAccessorWithImpliedReturnTypeAndFunctionClassMerge.ts, 1, 38)) +>_ : Symbol(_, Decl(getAccessorWithImpliedReturnTypeAndFunctionClassMerge.ts, 0, 0), Decl(getAccessorWithImpliedReturnTypeAndFunctionClassMerge.ts, 0, 45), Decl(getAccessorWithImpliedReturnTypeAndFunctionClassMerge.ts, 1, 38), Decl(getAccessorWithImpliedReturnTypeAndFunctionClassMerge.ts, 12, 1)) >T : Symbol(T, Decl(getAccessorWithImpliedReturnTypeAndFunctionClassMerge.ts, 0, 19)) >value : Symbol(value, Decl(getAccessorWithImpliedReturnTypeAndFunctionClassMerge.ts, 0, 22)) >Array : Symbol(Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) >T : Symbol(T, Decl(getAccessorWithImpliedReturnTypeAndFunctionClassMerge.ts, 0, 19)) +>_ : Symbol(_, Decl(getAccessorWithImpliedReturnTypeAndFunctionClassMerge.ts, 0, 0), Decl(getAccessorWithImpliedReturnTypeAndFunctionClassMerge.ts, 0, 45), Decl(getAccessorWithImpliedReturnTypeAndFunctionClassMerge.ts, 1, 38), Decl(getAccessorWithImpliedReturnTypeAndFunctionClassMerge.ts, 12, 1)) >T : Symbol(T, Decl(getAccessorWithImpliedReturnTypeAndFunctionClassMerge.ts, 0, 19)) declare function _(value: T): _; ->_ : Symbol(_, Decl(getAccessorWithImpliedReturnTypeAndFunctionClassMerge.ts, 0, 0), Decl(getAccessorWithImpliedReturnTypeAndFunctionClassMerge.ts, 0, 45), Decl(getAccessorWithImpliedReturnTypeAndFunctionClassMerge.ts, 1, 38)) +>_ : Symbol(_, Decl(getAccessorWithImpliedReturnTypeAndFunctionClassMerge.ts, 0, 0), Decl(getAccessorWithImpliedReturnTypeAndFunctionClassMerge.ts, 0, 45), Decl(getAccessorWithImpliedReturnTypeAndFunctionClassMerge.ts, 1, 38), Decl(getAccessorWithImpliedReturnTypeAndFunctionClassMerge.ts, 12, 1)) >T : Symbol(T, Decl(getAccessorWithImpliedReturnTypeAndFunctionClassMerge.ts, 1, 19)) >value : Symbol(value, Decl(getAccessorWithImpliedReturnTypeAndFunctionClassMerge.ts, 1, 22)) >T : Symbol(T, Decl(getAccessorWithImpliedReturnTypeAndFunctionClassMerge.ts, 1, 19)) +>_ : Symbol(_, Decl(getAccessorWithImpliedReturnTypeAndFunctionClassMerge.ts, 0, 0), Decl(getAccessorWithImpliedReturnTypeAndFunctionClassMerge.ts, 0, 45), Decl(getAccessorWithImpliedReturnTypeAndFunctionClassMerge.ts, 1, 38), Decl(getAccessorWithImpliedReturnTypeAndFunctionClassMerge.ts, 12, 1)) >T : Symbol(T, Decl(getAccessorWithImpliedReturnTypeAndFunctionClassMerge.ts, 1, 19)) declare module _ { ->_ : Symbol(_, Decl(getAccessorWithImpliedReturnTypeAndFunctionClassMerge.ts, 0, 0), Decl(getAccessorWithImpliedReturnTypeAndFunctionClassMerge.ts, 0, 45), Decl(getAccessorWithImpliedReturnTypeAndFunctionClassMerge.ts, 1, 38)) +>_ : Symbol(_, Decl(getAccessorWithImpliedReturnTypeAndFunctionClassMerge.ts, 0, 0), Decl(getAccessorWithImpliedReturnTypeAndFunctionClassMerge.ts, 0, 45), Decl(getAccessorWithImpliedReturnTypeAndFunctionClassMerge.ts, 1, 38), Decl(getAccessorWithImpliedReturnTypeAndFunctionClassMerge.ts, 12, 1)) export function each( >each : Symbol(each, Decl(getAccessorWithImpliedReturnTypeAndFunctionClassMerge.ts, 3, 18)) @@ -42,13 +44,13 @@ declare module _ { } declare class _ { ->_ : Symbol(_, Decl(getAccessorWithImpliedReturnTypeAndFunctionClassMerge.ts, 12, 1)) +>_ : Symbol(_, Decl(getAccessorWithImpliedReturnTypeAndFunctionClassMerge.ts, 0, 0), Decl(getAccessorWithImpliedReturnTypeAndFunctionClassMerge.ts, 0, 45), Decl(getAccessorWithImpliedReturnTypeAndFunctionClassMerge.ts, 1, 38), Decl(getAccessorWithImpliedReturnTypeAndFunctionClassMerge.ts, 12, 1)) >T : Symbol(T, Decl(getAccessorWithImpliedReturnTypeAndFunctionClassMerge.ts, 14, 16)) each(iterator: _.ListIterator, context?: any): void; >each : Symbol(_.each, Decl(getAccessorWithImpliedReturnTypeAndFunctionClassMerge.ts, 14, 20)) >iterator : Symbol(iterator, Decl(getAccessorWithImpliedReturnTypeAndFunctionClassMerge.ts, 15, 9)) ->_ : Symbol(_, Decl(getAccessorWithImpliedReturnTypeAndFunctionClassMerge.ts, 0, 0), Decl(getAccessorWithImpliedReturnTypeAndFunctionClassMerge.ts, 0, 45), Decl(getAccessorWithImpliedReturnTypeAndFunctionClassMerge.ts, 1, 38)) +>_ : Symbol(_, Decl(getAccessorWithImpliedReturnTypeAndFunctionClassMerge.ts, 0, 0), Decl(getAccessorWithImpliedReturnTypeAndFunctionClassMerge.ts, 0, 45), Decl(getAccessorWithImpliedReturnTypeAndFunctionClassMerge.ts, 1, 38), Decl(getAccessorWithImpliedReturnTypeAndFunctionClassMerge.ts, 12, 1)) >ListIterator : Symbol(_.ListIterator, Decl(getAccessorWithImpliedReturnTypeAndFunctionClassMerge.ts, 7, 29)) >T : Symbol(T, Decl(getAccessorWithImpliedReturnTypeAndFunctionClassMerge.ts, 14, 16)) >context : Symbol(context, Decl(getAccessorWithImpliedReturnTypeAndFunctionClassMerge.ts, 15, 43)) diff --git a/tests/baselines/reference/multipleDefaultExports01.errors.txt b/tests/baselines/reference/multipleDefaultExports01.errors.txt index 8500a542aa749..37865bc30e0af 100644 --- a/tests/baselines/reference/multipleDefaultExports01.errors.txt +++ b/tests/baselines/reference/multipleDefaultExports01.errors.txt @@ -1,21 +1,31 @@ +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 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(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(10,16): error TS2528: A module cannot have multiple default exports. -==== tests/cases/conformance/es6/modules/m1.ts (4 errors) ==== +==== 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 TS2752 tests/cases/conformance/es6/modules/m1.ts:5:25: The first export default is here. +!!! related TS6204 tests/cases/conformance/es6/modules/m1.ts:10:16: and here. } export default function bar() { ~~~ -!!! error TS2528: A module cannot have multiple default exports. -!!! related TS2753 tests/cases/conformance/es6/modules/m1.ts:1:22: Another export default is here. +!!! 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. @@ -27,6 +37,7 @@ tests/cases/conformance/es6/modules/m1.ts(10,16): error TS2528: A module cannot ~ !!! error TS2528: A module cannot have multiple default exports. !!! related TS2752 tests/cases/conformance/es6/modules/m1.ts:5:25: The first export default is here. +!!! related TS2752 tests/cases/conformance/es6/modules/m1.ts:1:22: The first export default is here. ==== tests/cases/conformance/es6/modules/m2.ts (0 errors) ==== import Entity from "./m1" diff --git a/tests/baselines/reference/multipleDefaultExports01.symbols b/tests/baselines/reference/multipleDefaultExports01.symbols index 8336963df9bc2..f8565768b7292 100644 --- a/tests/baselines/reference/multipleDefaultExports01.symbols +++ b/tests/baselines/reference/multipleDefaultExports01.symbols @@ -1,11 +1,11 @@ === tests/cases/conformance/es6/modules/m1.ts === export default class foo { ->foo : Symbol(foo, Decl(m1.ts, 0, 0)) +>foo : Symbol(bar, Decl(m1.ts, 2, 1), Decl(m1.ts, 0, 0)) } export default function bar() { ->bar : Symbol(bar, Decl(m1.ts, 2, 1)) +>bar : Symbol(bar, Decl(m1.ts, 2, 1), Decl(m1.ts, 0, 0)) } diff --git a/tests/baselines/reference/multipleDefaultExports01.types b/tests/baselines/reference/multipleDefaultExports01.types index 3b34a7a5cc8ec..58c89d0609b3c 100644 --- a/tests/baselines/reference/multipleDefaultExports01.types +++ b/tests/baselines/reference/multipleDefaultExports01.types @@ -1,11 +1,11 @@ === tests/cases/conformance/es6/modules/m1.ts === export default class foo { ->foo : import("tests/cases/conformance/es6/modules/m1").default +>foo : bar } export default function bar() { ->bar : () => void +>bar : typeof bar } @@ -18,9 +18,9 @@ export default x; === tests/cases/conformance/es6/modules/m2.ts === import Entity from "./m1" ->Entity : () => void +>Entity : typeof Entity Entity(); >Entity() : void ->Entity : () => void +>Entity : typeof Entity diff --git a/tests/baselines/reference/multipleExportDefault5.errors.txt b/tests/baselines/reference/multipleExportDefault5.errors.txt index f846248bf3818..b03ba7f7ac612 100644 --- a/tests/baselines/reference/multipleExportDefault5.errors.txt +++ b/tests/baselines/reference/multipleExportDefault5.errors.txt @@ -1,13 +1,19 @@ -tests/cases/conformance/externalModules/multipleExportDefault5.ts(1,25): error TS2528: A module cannot have multiple default exports. -tests/cases/conformance/externalModules/multipleExportDefault5.ts(2,22): error TS2528: A module cannot have multiple default exports. +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(2,22): error TS2323: Cannot redeclare exported variable 'default'. -==== tests/cases/conformance/externalModules/multipleExportDefault5.ts (2 errors) ==== +==== tests/cases/conformance/externalModules/multipleExportDefault5.ts (4 errors) ==== export default function bar() { } ~~~ -!!! error TS2528: A module cannot have multiple default exports. -!!! related TS2753 tests/cases/conformance/externalModules/multipleExportDefault5.ts:2:22: Another export default is here. +!!! 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'. export default class C {} ~ -!!! error TS2528: A module cannot have multiple default exports. -!!! related TS2752 tests/cases/conformance/externalModules/multipleExportDefault5.ts:1:25: The first export default is here. \ No newline at end of file +!!! 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'. \ No newline at end of file diff --git a/tests/baselines/reference/multipleExportDefault5.symbols b/tests/baselines/reference/multipleExportDefault5.symbols index 56f6fd335e8cb..91f90c4783aad 100644 --- a/tests/baselines/reference/multipleExportDefault5.symbols +++ b/tests/baselines/reference/multipleExportDefault5.symbols @@ -1,7 +1,7 @@ === tests/cases/conformance/externalModules/multipleExportDefault5.ts === export default function bar() { } ->bar : Symbol(bar, Decl(multipleExportDefault5.ts, 0, 0)) +>bar : Symbol(bar, Decl(multipleExportDefault5.ts, 0, 0), Decl(multipleExportDefault5.ts, 0, 33)) export default class C {} ->C : Symbol(C, Decl(multipleExportDefault5.ts, 0, 33)) +>C : Symbol(bar, Decl(multipleExportDefault5.ts, 0, 0), Decl(multipleExportDefault5.ts, 0, 33)) diff --git a/tests/baselines/reference/multipleExportDefault5.types b/tests/baselines/reference/multipleExportDefault5.types index ab7b3ed9b0cc4..aaada9ea28ae5 100644 --- a/tests/baselines/reference/multipleExportDefault5.types +++ b/tests/baselines/reference/multipleExportDefault5.types @@ -1,7 +1,7 @@ === tests/cases/conformance/externalModules/multipleExportDefault5.ts === export default function bar() { } ->bar : () => void +>bar : typeof bar export default class C {} ->C : import("tests/cases/conformance/externalModules/multipleExportDefault5").default +>C : bar diff --git a/tests/baselines/reference/nameCollisions.errors.txt b/tests/baselines/reference/nameCollisions.errors.txt index 6a7e1114aa22e..484444226b42e 100644 --- a/tests/baselines/reference/nameCollisions.errors.txt +++ b/tests/baselines/reference/nameCollisions.errors.txt @@ -67,16 +67,20 @@ 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. function C() { } // error ~ !!! error TS2300: Duplicate identifier 'C'. +!!! related TS6203 tests/cases/compiler/nameCollisions.ts:33:11: 'C' was also declared here. function C2() { } ~~ !!! error TS2300: Duplicate identifier 'C2'. +!!! related TS6203 tests/cases/compiler/nameCollisions.ts:37:11: 'C2' was also declared here. class C2 { } // error ~~ !!! error TS2300: Duplicate identifier 'C2'. +!!! related TS6203 tests/cases/compiler/nameCollisions.ts:36:14: 'C2' was also declared here. function fi() { } interface fi { } // ok diff --git a/tests/baselines/reference/nameCollisions.symbols b/tests/baselines/reference/nameCollisions.symbols index 414d074a717b7..aabbefd6b7a7f 100644 --- a/tests/baselines/reference/nameCollisions.symbols +++ b/tests/baselines/reference/nameCollisions.symbols @@ -60,16 +60,16 @@ module T { >i : Symbol(i, Decl(nameCollisions.ts, 29, 7), Decl(nameCollisions.ts, 29, 10)) class C { } ->C : Symbol(C, Decl(nameCollisions.ts, 30, 19)) +>C : Symbol(C, Decl(nameCollisions.ts, 32, 15), Decl(nameCollisions.ts, 30, 19)) function C() { } // error ->C : Symbol(C, Decl(nameCollisions.ts, 32, 15)) +>C : Symbol(C, Decl(nameCollisions.ts, 32, 15), Decl(nameCollisions.ts, 30, 19)) function C2() { } ->C2 : Symbol(C2, Decl(nameCollisions.ts, 33, 20)) +>C2 : Symbol(C2, Decl(nameCollisions.ts, 33, 20), Decl(nameCollisions.ts, 35, 21)) class C2 { } // error ->C2 : Symbol(C2, Decl(nameCollisions.ts, 35, 21)) +>C2 : Symbol(C2, Decl(nameCollisions.ts, 33, 20), Decl(nameCollisions.ts, 35, 21)) function fi() { } >fi : Symbol(fi, Decl(nameCollisions.ts, 36, 16), Decl(nameCollisions.ts, 38, 21)) diff --git a/tests/baselines/reference/nameCollisions.types b/tests/baselines/reference/nameCollisions.types index e4eae83a915cf..3ab39ae08b09d 100644 --- a/tests/baselines/reference/nameCollisions.types +++ b/tests/baselines/reference/nameCollisions.types @@ -62,10 +62,10 @@ module T { >C : C function C() { } // error ->C : () => void +>C : typeof C function C2() { } ->C2 : () => void +>C2 : typeof C2 class C2 { } // error >C2 : C2 diff --git a/tests/baselines/reference/staticClassMemberError.errors.txt b/tests/baselines/reference/staticClassMemberError.errors.txt index 43a2cd6934de3..b82eb78b1d645 100644 --- a/tests/baselines/reference/staticClassMemberError.errors.txt +++ b/tests/baselines/reference/staticClassMemberError.errors.txt @@ -18,10 +18,12 @@ tests/cases/compiler/staticClassMemberError.ts(10,7): error TS2300: Duplicate id 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. class Foo { ~~~ !!! error TS2300: Duplicate identifier 'Foo'. +!!! related TS6203 tests/cases/compiler/staticClassMemberError.ts:9:10: 'Foo' was also declared here. static bar; } \ No newline at end of file diff --git a/tests/baselines/reference/staticClassMemberError.symbols b/tests/baselines/reference/staticClassMemberError.symbols index ec11f50bb0301..e70f26e7d5a5a 100644 --- a/tests/baselines/reference/staticClassMemberError.symbols +++ b/tests/baselines/reference/staticClassMemberError.symbols @@ -14,10 +14,10 @@ class C { // just want to make sure this one doesn't crash the compiler function Foo(); ->Foo : Symbol(Foo, Decl(staticClassMemberError.ts, 5, 1)) +>Foo : Symbol(Foo, Decl(staticClassMemberError.ts, 5, 1), Decl(staticClassMemberError.ts, 8, 15)) class Foo { ->Foo : Symbol(Foo, Decl(staticClassMemberError.ts, 8, 15)) +>Foo : Symbol(Foo, Decl(staticClassMemberError.ts, 5, 1), Decl(staticClassMemberError.ts, 8, 15)) static bar; >bar : Symbol(Foo.bar, Decl(staticClassMemberError.ts, 9, 11)) diff --git a/tests/baselines/reference/staticClassMemberError.types b/tests/baselines/reference/staticClassMemberError.types index d3ff5ca1c67bd..ae2d778aaf040 100644 --- a/tests/baselines/reference/staticClassMemberError.types +++ b/tests/baselines/reference/staticClassMemberError.types @@ -17,7 +17,7 @@ class C { // just want to make sure this one doesn't crash the compiler function Foo(); ->Foo : () => any +>Foo : typeof Foo class Foo { >Foo : Foo diff --git a/tests/baselines/reference/targetTypeTest1.errors.txt b/tests/baselines/reference/targetTypeTest1.errors.txt index 03a4f0018b355..8ba9f0981f34e 100644 --- a/tests/baselines/reference/targetTypeTest1.errors.txt +++ b/tests/baselines/reference/targetTypeTest1.errors.txt @@ -1,26 +1,14 @@ -tests/cases/compiler/targetTypeTest1.ts(1,15): error TS2300: Duplicate identifier 'Point'. -tests/cases/compiler/targetTypeTest1.ts(6,43): error TS2709: Cannot use namespace 'Point' as a type. -tests/cases/compiler/targetTypeTest1.ts(7,22): error TS2709: Cannot use namespace 'Point' as a type. -tests/cases/compiler/targetTypeTest1.ts(14,10): error TS2300: Duplicate identifier 'Point'. tests/cases/compiler/targetTypeTest1.ts(19,18): error TS2384: Overload signatures must all be ambient or non-ambient. -tests/cases/compiler/targetTypeTest1.ts(53,15): error TS2300: Duplicate identifier 'C'. -tests/cases/compiler/targetTypeTest1.ts(60,10): error TS2300: Duplicate identifier 'C'. -==== tests/cases/compiler/targetTypeTest1.ts (7 errors) ==== +==== tests/cases/compiler/targetTypeTest1.ts (1 errors) ==== declare class Point - ~~~~~ -!!! error TS2300: Duplicate identifier 'Point'. { constructor(x: number, y: number); public x: number; public y: number; public add(dx: number, dy: number): Point; - ~~~~~ -!!! error TS2709: Cannot use namespace 'Point' as a type. static origin: Point; - ~~~~~ -!!! error TS2709: Cannot use namespace 'Point' as a type. } @@ -28,8 +16,6 @@ tests/cases/compiler/targetTypeTest1.ts(60,10): error TS2300: Duplicate identifi // Because Point is a constructor function, this is inferred // to be Point and return type is inferred to be void function Point(x, y) { - ~~~~~ -!!! error TS2300: Duplicate identifier 'Point'. this.x = x; this.y = y; } @@ -71,8 +57,6 @@ tests/cases/compiler/targetTypeTest1.ts(60,10): error TS2300: Duplicate identifi } declare class C { - ~ -!!! error TS2300: Duplicate identifier 'C'. constructor(a:number, b:number); public a : number; public b: number; @@ -80,8 +64,6 @@ tests/cases/compiler/targetTypeTest1.ts(60,10): error TS2300: Duplicate identifi } function C(a,b) { - ~ -!!! error TS2300: Duplicate identifier 'C'. this.a=a; this.b=b; } diff --git a/tests/baselines/reference/targetTypeTest1.symbols b/tests/baselines/reference/targetTypeTest1.symbols index 9bbad1ef89ad9..cb96adec2e340 100644 --- a/tests/baselines/reference/targetTypeTest1.symbols +++ b/tests/baselines/reference/targetTypeTest1.symbols @@ -1,6 +1,6 @@ === tests/cases/compiler/targetTypeTest1.ts === declare class Point ->Point : Symbol(Point, Decl(targetTypeTest1.ts, 0, 0)) +>Point : Symbol(Point, Decl(targetTypeTest1.ts, 8, 1), Decl(targetTypeTest1.ts, 0, 0), Decl(targetTypeTest1.ts, 22, 17)) { constructor(x: number, y: number); >x : Symbol(x, Decl(targetTypeTest1.ts, 2, 18)) @@ -16,9 +16,11 @@ declare class Point >add : Symbol(Point.add, Decl(targetTypeTest1.ts, 4, 23)) >dx : Symbol(dx, Decl(targetTypeTest1.ts, 5, 17)) >dy : Symbol(dy, Decl(targetTypeTest1.ts, 5, 28)) +>Point : Symbol(Point, Decl(targetTypeTest1.ts, 8, 1), Decl(targetTypeTest1.ts, 0, 0), Decl(targetTypeTest1.ts, 22, 17)) static origin: Point; ->origin : Symbol(Point.origin, Decl(targetTypeTest1.ts, 5, 48)) +>origin : Symbol(Point.origin, Decl(targetTypeTest1.ts, 5, 48), Decl(targetTypeTest1.ts, 22, 17)) +>Point : Symbol(Point, Decl(targetTypeTest1.ts, 8, 1), Decl(targetTypeTest1.ts, 0, 0), Decl(targetTypeTest1.ts, 22, 17)) } @@ -26,7 +28,7 @@ declare class Point // Because Point is a constructor function, this is inferred // to be Point and return type is inferred to be void function Point(x, y) { ->Point : Symbol(Point, Decl(targetTypeTest1.ts, 8, 1), Decl(targetTypeTest1.ts, 22, 17)) +>Point : Symbol(Point, Decl(targetTypeTest1.ts, 8, 1), Decl(targetTypeTest1.ts, 0, 0), Decl(targetTypeTest1.ts, 22, 17)) >x : Symbol(x, Decl(targetTypeTest1.ts, 13, 15)) >y : Symbol(y, Decl(targetTypeTest1.ts, 13, 17)) @@ -55,23 +57,25 @@ var x = EF1(1,2); // Point.origin declared as type Point Point.origin = new Point(0, 0); ->Point.origin : Symbol(Point.origin, Decl(targetTypeTest1.ts, 22, 17)) ->Point : Symbol(Point, Decl(targetTypeTest1.ts, 8, 1), Decl(targetTypeTest1.ts, 22, 17)) ->origin : Symbol(Point.origin, Decl(targetTypeTest1.ts, 22, 17)) ->Point : Symbol(Point, Decl(targetTypeTest1.ts, 8, 1), Decl(targetTypeTest1.ts, 22, 17)) +>Point.origin : Symbol(Point.origin, Decl(targetTypeTest1.ts, 5, 48), Decl(targetTypeTest1.ts, 22, 17)) +>Point : Symbol(Point, Decl(targetTypeTest1.ts, 8, 1), Decl(targetTypeTest1.ts, 0, 0), Decl(targetTypeTest1.ts, 22, 17)) +>origin : Symbol(Point.origin, Decl(targetTypeTest1.ts, 5, 48), Decl(targetTypeTest1.ts, 22, 17)) +>Point : Symbol(Point, Decl(targetTypeTest1.ts, 8, 1), Decl(targetTypeTest1.ts, 0, 0), Decl(targetTypeTest1.ts, 22, 17)) // Point.prototype declared as type Point // this inferred as Point because of obj.prop assignment // dx, dy, and return type inferred using target typing Point.prototype.add = function(dx, dy) { ->Point.prototype : Symbol(Function.prototype, Decl(lib.es5.d.ts, --, --)) ->Point : Symbol(Point, Decl(targetTypeTest1.ts, 8, 1), Decl(targetTypeTest1.ts, 22, 17)) ->prototype : Symbol(Function.prototype, Decl(lib.es5.d.ts, --, --)) +>Point.prototype.add : Symbol(Point.add, Decl(targetTypeTest1.ts, 4, 23)) +>Point.prototype : Symbol(Point.prototype) +>Point : Symbol(Point, Decl(targetTypeTest1.ts, 8, 1), Decl(targetTypeTest1.ts, 0, 0), Decl(targetTypeTest1.ts, 22, 17)) +>prototype : Symbol(Point.prototype) +>add : Symbol(Point.add, Decl(targetTypeTest1.ts, 4, 23)) >dx : Symbol(dx, Decl(targetTypeTest1.ts, 30, 31)) >dy : Symbol(dy, Decl(targetTypeTest1.ts, 30, 34)) return new Point(this.x + dx, this.y + dy); ->Point : Symbol(Point, Decl(targetTypeTest1.ts, 8, 1), Decl(targetTypeTest1.ts, 22, 17)) +>Point : Symbol(Point, Decl(targetTypeTest1.ts, 8, 1), Decl(targetTypeTest1.ts, 0, 0), Decl(targetTypeTest1.ts, 22, 17)) >dx : Symbol(dx, Decl(targetTypeTest1.ts, 30, 31)) >dy : Symbol(dy, Decl(targetTypeTest1.ts, 30, 34)) @@ -84,9 +88,9 @@ var f : number = 5; // this in function add inferred to be type of object literal (i.e. Point) // dx, dy, and return type of add inferred using target typing Point.prototype = { ->Point.prototype : Symbol(Function.prototype, Decl(lib.es5.d.ts, --, --)) ->Point : Symbol(Point, Decl(targetTypeTest1.ts, 8, 1), Decl(targetTypeTest1.ts, 22, 17)) ->prototype : Symbol(Function.prototype, Decl(lib.es5.d.ts, --, --)) +>Point.prototype : Symbol(Point.prototype) +>Point : Symbol(Point, Decl(targetTypeTest1.ts, 8, 1), Decl(targetTypeTest1.ts, 0, 0), Decl(targetTypeTest1.ts, 22, 17)) +>prototype : Symbol(Point.prototype) x: 0, >x : Symbol(x, Decl(targetTypeTest1.ts, 39, 19)) @@ -100,7 +104,7 @@ Point.prototype = { >dy : Symbol(dy, Decl(targetTypeTest1.ts, 42, 21)) return new Point(this.x + dx, this.y + dy); ->Point : Symbol(Point, Decl(targetTypeTest1.ts, 8, 1), Decl(targetTypeTest1.ts, 22, 17)) +>Point : Symbol(Point, Decl(targetTypeTest1.ts, 8, 1), Decl(targetTypeTest1.ts, 0, 0), Decl(targetTypeTest1.ts, 22, 17)) >dx : Symbol(dx, Decl(targetTypeTest1.ts, 42, 18)) >dy : Symbol(dy, Decl(targetTypeTest1.ts, 42, 21)) } @@ -118,7 +122,7 @@ z = function(a: number) { } declare class C { ->C : Symbol(C, Decl(targetTypeTest1.ts, 50, 1)) +>C : Symbol(C, Decl(targetTypeTest1.ts, 57, 1), Decl(targetTypeTest1.ts, 50, 1)) constructor(a:number, b:number); >a : Symbol(a, Decl(targetTypeTest1.ts, 53, 16)) @@ -137,7 +141,7 @@ declare class C { } function C(a,b) { ->C : Symbol(C, Decl(targetTypeTest1.ts, 57, 1)) +>C : Symbol(C, Decl(targetTypeTest1.ts, 57, 1), Decl(targetTypeTest1.ts, 50, 1)) >a : Symbol(a, Decl(targetTypeTest1.ts, 59, 11)) >b : Symbol(b, Decl(targetTypeTest1.ts, 59, 13)) @@ -149,9 +153,9 @@ function C(a,b) { } C.prototype = ->C.prototype : Symbol(Function.prototype, Decl(lib.es5.d.ts, --, --)) ->C : Symbol(C, Decl(targetTypeTest1.ts, 57, 1)) ->prototype : Symbol(Function.prototype, Decl(lib.es5.d.ts, --, --)) +>C.prototype : Symbol(C.prototype) +>C : Symbol(C, Decl(targetTypeTest1.ts, 57, 1), Decl(targetTypeTest1.ts, 50, 1)) +>prototype : Symbol(C.prototype) { a:0, >a : Symbol(a, Decl(targetTypeTest1.ts, 65, 2)) diff --git a/tests/baselines/reference/targetTypeTest1.types b/tests/baselines/reference/targetTypeTest1.types index fcf994b941a56..3dbb1e0a8469a 100644 --- a/tests/baselines/reference/targetTypeTest1.types +++ b/tests/baselines/reference/targetTypeTest1.types @@ -13,12 +13,12 @@ declare class Point >y : number public add(dx: number, dy: number): Point; ->add : (dx: number, dy: number) => any +>add : (dx: number, dy: number) => Point >dx : number >dy : number static origin: Point; ->origin : any +>origin : Point } @@ -67,11 +67,11 @@ var x = EF1(1,2); // Point.origin declared as type Point Point.origin = new Point(0, 0); ->Point.origin = new Point(0, 0) : any ->Point.origin : any +>Point.origin = new Point(0, 0) : Point +>Point.origin : Point >Point : typeof Point ->origin : any ->new Point(0, 0) : any +>origin : Point +>new Point(0, 0) : Point >Point : typeof Point >0 : 0 >0 : 0 @@ -80,29 +80,29 @@ Point.origin = new Point(0, 0); // this inferred as Point because of obj.prop assignment // dx, dy, and return type inferred using target typing Point.prototype.add = function(dx, dy) { ->Point.prototype.add = function(dx, dy) { return new Point(this.x + dx, this.y + dy);} : (dx: any, dy: any) => any ->Point.prototype.add : any ->Point.prototype : any +>Point.prototype.add = function(dx, dy) { return new Point(this.x + dx, this.y + dy);} : (dx: number, dy: number) => Point +>Point.prototype.add : (dx: number, dy: number) => Point +>Point.prototype : Point >Point : typeof Point ->prototype : any ->add : any ->function(dx, dy) { return new Point(this.x + dx, this.y + dy);} : (dx: any, dy: any) => any ->dx : any ->dy : any +>prototype : Point +>add : (dx: number, dy: number) => Point +>function(dx, dy) { return new Point(this.x + dx, this.y + dy);} : (dx: number, dy: number) => Point +>dx : number +>dy : number return new Point(this.x + dx, this.y + dy); ->new Point(this.x + dx, this.y + dy) : any +>new Point(this.x + dx, this.y + dy) : Point >Point : typeof Point >this.x + dx : any >this.x : any >this : any >x : any ->dx : any +>dx : number >this.y + dy : any >this.y : any >this : any >y : any ->dy : any +>dy : number }; @@ -114,11 +114,11 @@ var f : number = 5; // this in function add inferred to be type of object literal (i.e. Point) // dx, dy, and return type of add inferred using target typing Point.prototype = { ->Point.prototype = { x: 0, y: 0, add: function(dx, dy) { return new Point(this.x + dx, this.y + dy); }} : { x: number; y: number; add: (dx: any, dy: any) => any; } ->Point.prototype : any +>Point.prototype = { x: 0, y: 0, add: function(dx, dy) { return new Point(this.x + dx, this.y + dy); }} : { x: number; y: number; add: (dx: number, dy: number) => Point; } +>Point.prototype : Point >Point : typeof Point ->prototype : any ->{ x: 0, y: 0, add: function(dx, dy) { return new Point(this.x + dx, this.y + dy); }} : { x: number; y: number; add: (dx: any, dy: any) => any; } +>prototype : Point +>{ x: 0, y: 0, add: function(dx, dy) { return new Point(this.x + dx, this.y + dy); }} : { x: number; y: number; add: (dx: number, dy: number) => Point; } x: 0, >x : number @@ -129,24 +129,24 @@ Point.prototype = { >0 : 0 add: function(dx, dy) { ->add : (dx: any, dy: any) => any ->function(dx, dy) { return new Point(this.x + dx, this.y + dy); } : (dx: any, dy: any) => any ->dx : any ->dy : any +>add : (dx: number, dy: number) => Point +>function(dx, dy) { return new Point(this.x + dx, this.y + dy); } : (dx: number, dy: number) => Point +>dx : number +>dy : number return new Point(this.x + dx, this.y + dy); ->new Point(this.x + dx, this.y + dy) : any +>new Point(this.x + dx, this.y + dy) : Point >Point : typeof Point >this.x + dx : any >this.x : any >this : any >x : any ->dx : any +>dx : number >this.y + dy : any >this.y : any >this : any >y : any ->dy : any +>dy : number } }; @@ -183,7 +183,7 @@ declare class C { } function C(a,b) { ->C : (a: any, b: any) => void +>C : typeof C >a : any >b : any @@ -203,13 +203,13 @@ function C(a,b) { } C.prototype = ->C.prototype = { a:0, b:0, C1M1: function(c,d) { return (this.a + c) + (this.b + d); } } : { a: number; b: number; C1M1: (c: any, d: any) => any; } ->C.prototype : any ->C : (a: any, b: any) => void ->prototype : any +>C.prototype = { a:0, b:0, C1M1: function(c,d) { return (this.a + c) + (this.b + d); } } : { a: number; b: number; C1M1: (c: number, d: number) => any; } +>C.prototype : C +>C : typeof C +>prototype : C { a:0, ->{ a:0, b:0, C1M1: function(c,d) { return (this.a + c) + (this.b + d); } } : { a: number; b: number; C1M1: (c: any, d: any) => any; } +>{ a:0, b:0, C1M1: function(c,d) { return (this.a + c) + (this.b + d); } } : { a: number; b: number; C1M1: (c: number, d: number) => any; } >a : number >0 : 0 @@ -218,10 +218,10 @@ C.prototype = >0 : 0 C1M1: function(c,d) { ->C1M1 : (c: any, d: any) => any ->function(c,d) { return (this.a + c) + (this.b + d); } : (c: any, d: any) => any ->c : any ->d : any +>C1M1 : (c: number, d: number) => any +>function(c,d) { return (this.a + c) + (this.b + d); } : (c: number, d: number) => any +>c : number +>d : number return (this.a + c) + (this.b + d); >(this.a + c) + (this.b + d) : any @@ -230,13 +230,13 @@ C.prototype = >this.a : any >this : any >a : any ->c : any +>c : number >(this.b + d) : any >this.b + d : any >this.b : any >this : any >b : any ->d : any +>d : number } }; diff --git a/tests/cases/compiler/classFunctionMerging.ts b/tests/cases/compiler/classFunctionMerging.ts new file mode 100644 index 0000000000000..5b8dadc23dd35 --- /dev/null +++ b/tests/cases/compiler/classFunctionMerging.ts @@ -0,0 +1,12 @@ +// We allow ambient classes and functions to merge, this way callable classes +// which are also namespaces can be represented in declaration files +declare function Foo (x: number): Foo.Inst; +declare class Foo { + constructor(x: string); +} +declare namespace Foo { + export type Inst = number; +} + +const a = new Foo(""); +const b = Foo(12); \ No newline at end of file diff --git a/tests/cases/fourslash/insertReturnStatementInDuplicateIdentifierFunction.ts b/tests/cases/fourslash/insertReturnStatementInDuplicateIdentifierFunction.ts index 8abdac6d20643..cd5b08034d42e 100644 --- a/tests/cases/fourslash/insertReturnStatementInDuplicateIdentifierFunction.ts +++ b/tests/cases/fourslash/insertReturnStatementInDuplicateIdentifierFunction.ts @@ -1,6 +1,6 @@ /// -//// declare class foo { }; +//// class foo { }; //// function foo() { /**/ } goTo.marker();