Allow functions and ambient classes to merge (#32584)

This commit is contained in:
Wesley Wigham 2019-08-09 16:10:10 -07:00 committed by GitHub
parent b84e65db4e
commit f2719f95b4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
78 changed files with 488 additions and 445 deletions

View File

@ -26276,8 +26276,9 @@ namespace ts {
let duplicateFunctionDeclaration = false;
let multipleConstructorImplementation = false;
let hasNonAmbientClass = false;
for (const current of declarations) {
const node = <SignatureDeclaration>current;
const node = <SignatureDeclaration | ClassDeclaration | ClassExpression>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[] {

View File

@ -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

View File

@ -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'.

View File

@ -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))

View File

@ -3,6 +3,6 @@ declare class foo{};
>foo : foo
function foo() { return null; }
>foo : () => any
>foo : typeof foo
>null : null

View File

@ -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,

View File

@ -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,

View File

@ -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 = () => { }
~~

View File

@ -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))

View File

@ -5,7 +5,7 @@ class c2 { public foo() { } } // error
>foo : () => void
function c2() { } // error
>c2 : () => void
>c2 : typeof c2
var c2 = () => { }
>c2 : () => void

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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))

View File

@ -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); }

View File

@ -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();

View File

@ -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))

View File

@ -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

View File

@ -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();

View File

@ -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))

View File

@ -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

View File

@ -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();

View File

@ -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))

View File

@ -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"

View File

@ -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();

View File

@ -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))

View File

@ -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"

View File

@ -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");

View File

@ -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))

View File

@ -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"

View File

@ -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);

View File

@ -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))

View File

@ -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

View File

@ -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.

View File

@ -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))

View File

@ -3,5 +3,5 @@ class foo { };
>foo : foo
function foo() {}
>foo : () => void
>foo : typeof foo

View File

@ -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'.
!!! error TS2300: Duplicate identifier 'bar'.
!!! related TS6203 tests/cases/compiler/classOverloadForFunction2.ts:1:10: 'bar' was also declared here.

View File

@ -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))

View File

@ -1,6 +1,6 @@
=== tests/cases/compiler/classOverloadForFunction2.ts ===
function bar(): string;
>bar : () => string
>bar : typeof bar
class bar {}
>bar : bar

View File

@ -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");

View File

@ -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))

View File

@ -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"

View File

@ -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;
}
}

View File

@ -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))

View File

@ -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

View File

@ -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;

View File

@ -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))

View File

@ -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

View File

@ -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 {

View File

@ -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 {

View File

@ -13,7 +13,7 @@ module M {
>M : typeof M
export function f() { }
>f : () => void
>f : typeof f
}
module M {
>M : typeof M

View File

@ -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))

View File

@ -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

View File

@ -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'.

View File

@ -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))

View File

@ -5,5 +5,5 @@ declare class foo();
> : any
function foo() {}
>foo : () => void
>foo : typeof foo

View File

@ -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'.
!!! 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.

View File

@ -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))

View File

@ -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 _<T>(value: Array<T>): _<T>;
~
!!! error TS2300: Duplicate identifier '_'.
~
!!! error TS2709: Cannot use namespace '_' as a type.
declare function _<T>(value: T): _<T>;
~
!!! error TS2300: Duplicate identifier '_'.
~
!!! error TS2709: Cannot use namespace '_' as a type.
declare module _ {
~
!!! error TS2300: Duplicate identifier '_'.
export function each<T>(
//list: List<T>,
//iterator: ListIterator<T, void>,
@ -33,8 +17,6 @@ tests/cases/compiler/getAccessorWithImpliedReturnTypeAndFunctionClassMerge.ts(21
}
declare class _<T> {
~
!!! error TS2300: Duplicate identifier '_'.
each(iterator: _.ListIterator<T, void>, context?: any): void;
}

View File

@ -1,21 +1,23 @@
=== tests/cases/compiler/getAccessorWithImpliedReturnTypeAndFunctionClassMerge.ts ===
declare function _<T>(value: Array<T>): _<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, 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 _<T>(value: T): _<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<T>(
>each : Symbol(each, Decl(getAccessorWithImpliedReturnTypeAndFunctionClassMerge.ts, 3, 18))
@ -42,13 +44,13 @@ declare module _ {
}
declare class _<T> {
>_ : 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<T, void>, 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))

View File

@ -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"

View File

@ -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))
}

View File

@ -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

View File

@ -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.
!!! 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'.

View File

@ -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))

View File

@ -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

View File

@ -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

View File

@ -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))

View File

@ -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

View File

@ -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;
}

View File

@ -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))

View File

@ -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

View File

@ -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;
}

View File

@ -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))

View File

@ -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
}
};

View File

@ -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);

View File

@ -1,6 +1,6 @@
/// <reference path="fourslash.ts" />
//// declare class foo { };
//// class foo { };
//// function foo() { /**/ }
goTo.marker();