Accepting new baselines

The new baselines all look correct to me, but obviously a number of the
tests need to be updated to reflect union types and the new behavior of
best common type. This commit does not cover that.
This commit is contained in:
Anders Hejlsberg 2014-10-08 13:48:44 -07:00
parent 95584e9104
commit fd5b80805e
93 changed files with 1293 additions and 2754 deletions

View file

@ -294,22 +294,22 @@ class f {
>base2 : typeof base2
var b1 = [ baseObj, base2Obj, ifaceObj ];
>b1 : base[]
>[ baseObj, base2Obj, ifaceObj ] : base[]
>b1 : iface[]
>[ baseObj, base2Obj, ifaceObj ] : iface[]
>baseObj : base
>base2Obj : base2
>ifaceObj : iface
var b2 = [ base2Obj, baseObj, ifaceObj ];
>b2 : base2[]
>[ base2Obj, baseObj, ifaceObj ] : base2[]
>b2 : iface[]
>[ base2Obj, baseObj, ifaceObj ] : iface[]
>base2Obj : base2
>baseObj : base
>ifaceObj : iface
var b3 = [ baseObj, ifaceObj, base2Obj ];
>b3 : base[]
>[ baseObj, ifaceObj, base2Obj ] : base[]
>b3 : iface[]
>[ baseObj, ifaceObj, base2Obj ] : iface[]
>baseObj : base
>ifaceObj : iface
>base2Obj : base2

View file

@ -1,40 +0,0 @@
tests/cases/compiler/arrayLiteralContextualType.ts(28,5): error TS2345: Argument of type '{}[]' is not assignable to parameter of type 'IAnimal[]'.
Type '{}' is not assignable to type 'IAnimal'.
tests/cases/compiler/arrayLiteralContextualType.ts(29,5): error TS2345: Argument of type '{}[]' is not assignable to parameter of type '{ [x: number]: IAnimal; }'.
==== tests/cases/compiler/arrayLiteralContextualType.ts (2 errors) ====
interface IAnimal {
name: string;
}
class Giraffe {
name = "Giraffe";
neckLength = "3m";
}
class Elephant {
name = "Elephant";
trunkDiameter = "20cm";
}
function foo(animals: IAnimal[]) { }
function bar(animals: { [n: number]: IAnimal }) { }
foo([
new Giraffe(),
new Elephant()
]); // Legal because of the contextual type IAnimal provided by the parameter
bar([
new Giraffe(),
new Elephant()
]); // Legal because of the contextual type IAnimal provided by the parameter
var arr = [new Giraffe(), new Elephant()];
foo(arr); // Error because of no contextual type
~~~
!!! error TS2345: Argument of type '{}[]' is not assignable to parameter of type 'IAnimal[]'.
!!! error TS2345: Type '{}' is not assignable to type 'IAnimal'.
bar(arr); // Error because of no contextual type
~~~
!!! error TS2345: Argument of type '{}[]' is not assignable to parameter of type '{ [x: number]: IAnimal; }'.

View file

@ -0,0 +1,86 @@
=== tests/cases/compiler/arrayLiteralContextualType.ts ===
interface IAnimal {
>IAnimal : IAnimal
name: string;
>name : string
}
class Giraffe {
>Giraffe : Giraffe
name = "Giraffe";
>name : string
neckLength = "3m";
>neckLength : string
}
class Elephant {
>Elephant : Elephant
name = "Elephant";
>name : string
trunkDiameter = "20cm";
>trunkDiameter : string
}
function foo(animals: IAnimal[]) { }
>foo : (animals: IAnimal[]) => void
>animals : IAnimal[]
>IAnimal : IAnimal
function bar(animals: { [n: number]: IAnimal }) { }
>bar : (animals: { [x: number]: IAnimal; }) => void
>animals : { [x: number]: IAnimal; }
>n : number
>IAnimal : IAnimal
foo([
>foo([ new Giraffe(), new Elephant()]) : void
>foo : (animals: IAnimal[]) => void
>[ new Giraffe(), new Elephant()] : IAnimal[]
new Giraffe(),
>new Giraffe() : Giraffe
>Giraffe : typeof Giraffe
new Elephant()
>new Elephant() : Elephant
>Elephant : typeof Elephant
]); // Legal because of the contextual type IAnimal provided by the parameter
bar([
>bar([ new Giraffe(), new Elephant()]) : void
>bar : (animals: { [x: number]: IAnimal; }) => void
>[ new Giraffe(), new Elephant()] : IAnimal[]
new Giraffe(),
>new Giraffe() : Giraffe
>Giraffe : typeof Giraffe
new Elephant()
>new Elephant() : Elephant
>Elephant : typeof Elephant
]); // Legal because of the contextual type IAnimal provided by the parameter
var arr = [new Giraffe(), new Elephant()];
>arr : Array<Giraffe | Elephant>
>[new Giraffe(), new Elephant()] : Array<Giraffe | Elephant>
>new Giraffe() : Giraffe
>Giraffe : typeof Giraffe
>new Elephant() : Elephant
>Elephant : typeof Elephant
foo(arr); // Error because of no contextual type
>foo(arr) : void
>foo : (animals: IAnimal[]) => void
>arr : Array<Giraffe | Elephant>
bar(arr); // Error because of no contextual type
>bar(arr) : void
>bar : (animals: { [x: number]: IAnimal; }) => void
>arr : Array<Giraffe | Elephant>

View file

@ -23,8 +23,8 @@ var as = [a, b]; // { x: number; y?: number };[]
>b : { x: number; z?: number; }
var bs = [b, a]; // { x: number; z?: number };[]
>bs : { x: number; z?: number; }[]
>[b, a] : { x: number; z?: number; }[]
>bs : { x: number; y?: number; }[]
>[b, a] : { x: number; y?: number; }[]
>b : { x: number; z?: number; }
>a : { x: number; y?: number; }

View file

@ -0,0 +1,56 @@
tests/cases/conformance/expressions/arrayLiterals/arrayLiterals.ts(4,5): error TS2403: Subsequent variable declarations must have the same type. Variable 'arr1' must be of type 'Array<string[] | number[]>', but here has type '{}[]'.
tests/cases/conformance/expressions/arrayLiterals/arrayLiterals.ts(7,5): error TS2403: Subsequent variable declarations must have the same type. Variable 'arr2' must be of type 'Array<string[] | number[]>', but here has type '{}[]'.
tests/cases/conformance/expressions/arrayLiterals/arrayLiterals.ts(33,5): error TS2403: Subsequent variable declarations must have the same type. Variable 'context2' must be of type 'Array<{ a: string; b: number; c: string; } | { a: string; b: number; c: number; }>', but here has type '{}[]'.
==== tests/cases/conformance/expressions/arrayLiterals/arrayLiterals.ts (3 errors) ====
// Empty array literal with no contextual type has type Undefined[]
var arr1= [[], [1], ['']];
var arr1: {}[]; // Bug 825172: Error ({}[] does not match {}[]), but should be OK
~~~~
!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'arr1' must be of type 'Array<string[] | number[]>', but here has type '{}[]'.
var arr2 = [[null], [1], ['']];
var arr2: {}[]; // Bug 825172: Error ({}[] does not match {}[]), but should be OK
~~~~
!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'arr2' must be of type 'Array<string[] | number[]>', but here has type '{}[]'.
// Array literal with elements of only EveryType E has type E[]
var stringArrArr = [[''], [""]];
var stringArrArr: string[][];
var stringArr = ['', ""];
var stringArr: string[];
var numberArr = [0, 0.0, 0x00, 1e1];
var numberArr: number[];
var boolArr = [false, true, false, true];
var boolArr: boolean[];
class C { private p; }
var classArr = [new C(), new C()];
var classArr: C[]; // Should be OK
var classTypeArray = [C, C, C];
var classTypeArray: Array<typeof C>; // Should OK, not be a parse error
// Contextual type C with numeric index signature makes array literal of EveryType E of type BCT(E,C)[]
var context1: { [n: number]: { a: string; b: number; }; } = [{ a: '', b: 0, c: '' }, { a: "", b: 3, c: 0 }];
var context2 = [{ a: '', b: 0, c: '' }, { a: "", b: 3, c: 0 }];
var context2: Array<{}>; // Should be OK
~~~~~~~~
!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'context2' must be of type 'Array<{ a: string; b: number; c: string; } | { a: string; b: number; c: number; }>', but here has type '{}[]'.
// Contextual type C with numeric index signature of type Base makes array literal of Derived have type Base[]
class Base { private p; }
class Derived1 extends Base { private m };
class Derived2 extends Base { private n };
var context3: Base[] = [new Derived1(), new Derived2()];
// Contextual type C with numeric index signature of type Base makes array literal of Derived1 and Derived2 have type Base[]
var context4: Base[] = [new Derived1(), new Derived1()];

View file

@ -1,150 +0,0 @@
=== tests/cases/conformance/expressions/arrayLiterals/arrayLiterals.ts ===
// Empty array literal with no contextual type has type Undefined[]
var arr1= [[], [1], ['']];
>arr1 : {}[]
>[[], [1], ['']] : {}[]
>[] : undefined[]
>[1] : number[]
>[''] : string[]
var arr1: {}[]; // Bug 825172: Error ({}[] does not match {}[]), but should be OK
>arr1 : {}[]
var arr2 = [[null], [1], ['']];
>arr2 : {}[]
>[[null], [1], ['']] : {}[]
>[null] : null[]
>[1] : number[]
>[''] : string[]
var arr2: {}[]; // Bug 825172: Error ({}[] does not match {}[]), but should be OK
>arr2 : {}[]
// Array literal with elements of only EveryType E has type E[]
var stringArrArr = [[''], [""]];
>stringArrArr : string[][]
>[[''], [""]] : string[][]
>[''] : string[]
>[""] : string[]
var stringArrArr: string[][];
>stringArrArr : string[][]
var stringArr = ['', ""];
>stringArr : string[]
>['', ""] : string[]
var stringArr: string[];
>stringArr : string[]
var numberArr = [0, 0.0, 0x00, 1e1];
>numberArr : number[]
>[0, 0.0, 0x00, 1e1] : number[]
var numberArr: number[];
>numberArr : number[]
var boolArr = [false, true, false, true];
>boolArr : boolean[]
>[false, true, false, true] : boolean[]
var boolArr: boolean[];
>boolArr : boolean[]
class C { private p; }
>C : C
>p : any
var classArr = [new C(), new C()];
>classArr : C[]
>[new C(), new C()] : C[]
>new C() : C
>C : typeof C
>new C() : C
>C : typeof C
var classArr: C[]; // Should be OK
>classArr : C[]
>C : C
var classTypeArray = [C, C, C];
>classTypeArray : typeof C[]
>[C, C, C] : typeof C[]
>C : typeof C
>C : typeof C
>C : typeof C
var classTypeArray: Array<typeof C>; // Should OK, not be a parse error
>classTypeArray : typeof C[]
>Array : T[]
>C : typeof C
// Contextual type C with numeric index signature makes array literal of EveryType E of type BCT(E,C)[]
var context1: { [n: number]: { a: string; b: number; }; } = [{ a: '', b: 0, c: '' }, { a: "", b: 3, c: 0 }];
>context1 : { [x: number]: { a: string; b: number; }; }
>n : number
>a : string
>b : number
>[{ a: '', b: 0, c: '' }, { a: "", b: 3, c: 0 }] : { a: string; b: number; }[]
>{ a: '', b: 0, c: '' } : { a: string; b: number; c: string; }
>a : string
>b : number
>c : string
>{ a: "", b: 3, c: 0 } : { a: string; b: number; c: number; }
>a : string
>b : number
>c : number
var context2 = [{ a: '', b: 0, c: '' }, { a: "", b: 3, c: 0 }];
>context2 : {}[]
>[{ a: '', b: 0, c: '' }, { a: "", b: 3, c: 0 }] : {}[]
>{ a: '', b: 0, c: '' } : { a: string; b: number; c: string; }
>a : string
>b : number
>c : string
>{ a: "", b: 3, c: 0 } : { a: string; b: number; c: number; }
>a : string
>b : number
>c : number
var context2: Array<{}>; // Should be OK
>context2 : {}[]
>Array : T[]
// Contextual type C with numeric index signature of type Base makes array literal of Derived have type Base[]
class Base { private p; }
>Base : Base
>p : any
class Derived1 extends Base { private m };
>Derived1 : Derived1
>Base : Base
>m : any
class Derived2 extends Base { private n };
>Derived2 : Derived2
>Base : Base
>n : any
var context3: Base[] = [new Derived1(), new Derived2()];
>context3 : Base[]
>Base : Base
>[new Derived1(), new Derived2()] : Base[]
>new Derived1() : Derived1
>Derived1 : typeof Derived1
>new Derived2() : Derived2
>Derived2 : typeof Derived2
// Contextual type C with numeric index signature of type Base makes array literal of Derived1 and Derived2 have type Base[]
var context4: Base[] = [new Derived1(), new Derived1()];
>context4 : Base[]
>Base : Base
>[new Derived1(), new Derived1()] : Base[]
>new Derived1() : Derived1
>Derived1 : typeof Derived1
>new Derived1() : Derived1
>Derived1 : typeof Derived1

View file

@ -61,8 +61,8 @@ var xs = [list, myList]; // {}[]
>myList : MyList<number>
var ys = [list, list2]; // {}[]
>ys : {}[]
>[list, list2] : {}[]
>ys : Array<List<number> | List<string>>
>[list, list2] : Array<List<number> | List<string>>
>list : List<number>
>list2 : List<string>

View file

@ -54,8 +54,8 @@ var r4 = true ? a : b; // typeof a
>b : { x: number; z?: number; }
var r5 = true ? b : a; // typeof b
>r5 : { x: number; z?: number; }
>true ? b : a : { x: number; z?: number; }
>r5 : { x: number; y?: number; }
>true ? b : a : { x: number; y?: number; }
>b : { x: number; z?: number; }
>a : { x: number; y?: number; }

View file

@ -1,14 +1,9 @@
tests/cases/conformance/types/typeRelationships/bestCommonType/bestCommonTypeOfConditionalExpressions2.ts(11,10): error TS2367: No best common type exists between 'number' and 'string'.
tests/cases/conformance/types/typeRelationships/bestCommonType/bestCommonTypeOfConditionalExpressions2.ts(12,10): error TS2367: No best common type exists between 'Derived' and 'Derived2'.
tests/cases/conformance/types/typeRelationships/bestCommonType/bestCommonTypeOfConditionalExpressions2.ts(15,12): error TS2367: No best common type exists between 'T' and 'U'.
tests/cases/conformance/types/typeRelationships/bestCommonType/bestCommonTypeOfConditionalExpressions2.ts(18,15): error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list.
tests/cases/conformance/types/typeRelationships/bestCommonType/bestCommonTypeOfConditionalExpressions2.ts(19,12): error TS2367: No best common type exists between 'T' and 'U'.
tests/cases/conformance/types/typeRelationships/bestCommonType/bestCommonTypeOfConditionalExpressions2.ts(22,15): error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list.
tests/cases/conformance/types/typeRelationships/bestCommonType/bestCommonTypeOfConditionalExpressions2.ts(22,28): error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list.
tests/cases/conformance/types/typeRelationships/bestCommonType/bestCommonTypeOfConditionalExpressions2.ts(23,12): error TS2367: No best common type exists between 'T' and 'U'.
==== tests/cases/conformance/types/typeRelationships/bestCommonType/bestCommonTypeOfConditionalExpressions2.ts (8 errors) ====
==== tests/cases/conformance/types/typeRelationships/bestCommonType/bestCommonTypeOfConditionalExpressions2.ts (3 errors) ====
// conditional expressions return the best common type of the branches plus contextual type (using the first candidate if multiple BCTs exist)
// these are errors
@ -20,24 +15,16 @@ tests/cases/conformance/types/typeRelationships/bestCommonType/bestCommonTypeOfC
var derived2: Derived2;
var r2 = true ? 1 : '';
~~~~~~~~~~~~~
!!! error TS2367: No best common type exists between 'number' and 'string'.
var r9 = true ? derived : derived2;
~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2367: No best common type exists between 'Derived' and 'Derived2'.
function foo<T, U>(t: T, u: U) {
return true ? t : u;
~~~~~~~~~~~~
!!! error TS2367: No best common type exists between 'T' and 'U'.
}
function foo2<T extends U, U>(t: T, u: U) { // Error for referencing own type parameter
~~~~~~~~~~~
!!! error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list.
return true ? t : u; // Ok because BCT(T, U) = U
~~~~~~~~~~~~
!!! error TS2367: No best common type exists between 'T' and 'U'.
}
function foo3<T extends U, U extends V, V>(t: T, u: U) {
@ -46,6 +33,4 @@ tests/cases/conformance/types/typeRelationships/bestCommonType/bestCommonTypeOfC
~~~~~~~~~~~
!!! error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list.
return true ? t : u;
~~~~~~~~~~~~
!!! error TS2367: No best common type exists between 'T' and 'U'.
}

View file

@ -1,10 +1,9 @@
tests/cases/compiler/conditionalExpression1.ts(1,5): error TS2323: Type '{}' is not assignable to type 'boolean'.
tests/cases/compiler/conditionalExpression1.ts(1,19): error TS2367: No best common type exists between 'number' and 'string'.
tests/cases/compiler/conditionalExpression1.ts(1,5): error TS2322: Type 'string | number' is not assignable to type 'boolean':
Type 'string' is not assignable to type 'boolean'.
==== tests/cases/compiler/conditionalExpression1.ts (2 errors) ====
==== tests/cases/compiler/conditionalExpression1.ts (1 errors) ====
var x: boolean = (true ? 1 : ""); // should be an error
~
!!! error TS2323: Type '{}' is not assignable to type 'boolean'.
~~~~~~~~~~~~~
!!! error TS2367: No best common type exists between 'number' and 'string'.
!!! error TS2322: Type 'string | number' is not assignable to type 'boolean':
!!! error TS2322: Type 'string' is not assignable to type 'boolean'.

View file

@ -1,20 +1,21 @@
tests/cases/conformance/expressions/conditonalOperator/conditionalOperatorWithoutIdenticalBCT.ts(12,1): error TS2367: No best common type exists between 'A' and 'B'.
tests/cases/conformance/expressions/conditonalOperator/conditionalOperatorWithoutIdenticalBCT.ts(13,15): error TS2367: No best common type exists between 'A' and 'B'.
tests/cases/conformance/expressions/conditonalOperator/conditionalOperatorWithoutIdenticalBCT.ts(16,5): error TS2322: Type '{}' is not assignable to type 'A':
Property 'propertyA' is missing in type '{}'.
tests/cases/conformance/expressions/conditonalOperator/conditionalOperatorWithoutIdenticalBCT.ts(16,18): error TS2366: No best common type exists between 'A', 'A', and 'B'.
tests/cases/conformance/expressions/conditonalOperator/conditionalOperatorWithoutIdenticalBCT.ts(17,5): error TS2322: Type '{}' is not assignable to type 'B':
Property 'propertyB' is missing in type '{}'.
tests/cases/conformance/expressions/conditonalOperator/conditionalOperatorWithoutIdenticalBCT.ts(17,18): error TS2366: No best common type exists between 'B', 'A', and 'B'.
tests/cases/conformance/expressions/conditonalOperator/conditionalOperatorWithoutIdenticalBCT.ts(19,5): error TS2323: Type '{}' is not assignable to type '(t: X) => number'.
tests/cases/conformance/expressions/conditonalOperator/conditionalOperatorWithoutIdenticalBCT.ts(19,33): error TS2366: No best common type exists between '(t: X) => number', '(m: X) => number', and '(n: X) => string'.
tests/cases/conformance/expressions/conditonalOperator/conditionalOperatorWithoutIdenticalBCT.ts(20,5): error TS2323: Type '{}' is not assignable to type '(t: X) => string'.
tests/cases/conformance/expressions/conditonalOperator/conditionalOperatorWithoutIdenticalBCT.ts(20,33): error TS2366: No best common type exists between '(t: X) => string', '(m: X) => number', and '(n: X) => string'.
tests/cases/conformance/expressions/conditonalOperator/conditionalOperatorWithoutIdenticalBCT.ts(21,5): error TS2323: Type '{}' is not assignable to type '(t: X) => boolean'.
tests/cases/conformance/expressions/conditonalOperator/conditionalOperatorWithoutIdenticalBCT.ts(21,34): error TS2366: No best common type exists between '(t: X) => boolean', '(m: X) => number', and '(n: X) => string'.
tests/cases/conformance/expressions/conditonalOperator/conditionalOperatorWithoutIdenticalBCT.ts(16,5): error TS2322: Type 'A | B' is not assignable to type 'A':
Type 'B' is not assignable to type 'A':
Property 'propertyA' is missing in type 'B'.
tests/cases/conformance/expressions/conditonalOperator/conditionalOperatorWithoutIdenticalBCT.ts(17,5): error TS2322: Type 'A | B' is not assignable to type 'B':
Type 'A' is not assignable to type 'B':
Property 'propertyB' is missing in type 'A'.
tests/cases/conformance/expressions/conditonalOperator/conditionalOperatorWithoutIdenticalBCT.ts(19,5): error TS2322: Type '{ (m: X): number; } | { (n: X): string; }' is not assignable to type '(t: X) => number':
Type '(n: X) => string' is not assignable to type '(t: X) => number':
Type 'string' is not assignable to type 'number'.
tests/cases/conformance/expressions/conditonalOperator/conditionalOperatorWithoutIdenticalBCT.ts(20,5): error TS2322: Type '{ (m: X): number; } | { (n: X): string; }' is not assignable to type '(t: X) => string':
Type '(m: X) => number' is not assignable to type '(t: X) => string':
Type 'number' is not assignable to type 'string'.
tests/cases/conformance/expressions/conditonalOperator/conditionalOperatorWithoutIdenticalBCT.ts(21,5): error TS2322: Type '{ (m: X): number; } | { (n: X): string; }' is not assignable to type '(t: X) => boolean':
Type '(m: X) => number' is not assignable to type '(t: X) => boolean':
Type 'number' is not assignable to type 'boolean'.
==== tests/cases/conformance/expressions/conditonalOperator/conditionalOperatorWithoutIdenticalBCT.ts (12 errors) ====
==== tests/cases/conformance/expressions/conditonalOperator/conditionalOperatorWithoutIdenticalBCT.ts (5 errors) ====
//Cond ? Expr1 : Expr2, Expr1 and Expr2 have no identical best common type
class X { propertyX: any; propertyX1: number; propertyX2: string };
class A extends X { propertyA: number };
@ -27,38 +28,32 @@ tests/cases/conformance/expressions/conditonalOperator/conditionalOperatorWithou
//Expect to have compiler errors
//Be not contextually typed
true ? a : b;
~~~~~~~~~~~~
!!! error TS2367: No best common type exists between 'A' and 'B'.
var result1 = true ? a : b;
~~~~~~~~~~~~
!!! error TS2367: No best common type exists between 'A' and 'B'.
//Be contextually typed and and bct is not identical
var result2: A = true ? a : b;
~~~~~~~
!!! error TS2322: Type '{}' is not assignable to type 'A':
!!! error TS2322: Property 'propertyA' is missing in type '{}'.
~~~~~~~~~~~~
!!! error TS2366: No best common type exists between 'A', 'A', and 'B'.
!!! error TS2322: Type 'A | B' is not assignable to type 'A':
!!! error TS2322: Type 'B' is not assignable to type 'A':
!!! error TS2322: Property 'propertyA' is missing in type 'B'.
var result3: B = true ? a : b;
~~~~~~~
!!! error TS2322: Type '{}' is not assignable to type 'B':
!!! error TS2322: Property 'propertyB' is missing in type '{}'.
~~~~~~~~~~~~
!!! error TS2366: No best common type exists between 'B', 'A', and 'B'.
!!! error TS2322: Type 'A | B' is not assignable to type 'B':
!!! error TS2322: Type 'A' is not assignable to type 'B':
!!! error TS2322: Property 'propertyB' is missing in type 'A'.
var result4: (t: X) => number = true ? (m) => m.propertyX1 : (n) => n.propertyX2;
~~~~~~~
!!! error TS2323: Type '{}' is not assignable to type '(t: X) => number'.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2366: No best common type exists between '(t: X) => number', '(m: X) => number', and '(n: X) => string'.
!!! error TS2322: Type '{ (m: X): number; } | { (n: X): string; }' is not assignable to type '(t: X) => number':
!!! error TS2322: Type '(n: X) => string' is not assignable to type '(t: X) => number':
!!! error TS2322: Type 'string' is not assignable to type 'number'.
var result5: (t: X) => string = true ? (m) => m.propertyX1 : (n) => n.propertyX2;
~~~~~~~
!!! error TS2323: Type '{}' is not assignable to type '(t: X) => string'.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2366: No best common type exists between '(t: X) => string', '(m: X) => number', and '(n: X) => string'.
!!! error TS2322: Type '{ (m: X): number; } | { (n: X): string; }' is not assignable to type '(t: X) => string':
!!! error TS2322: Type '(m: X) => number' is not assignable to type '(t: X) => string':
!!! error TS2322: Type 'number' is not assignable to type 'string'.
var result6: (t: X) => boolean = true ? (m) => m.propertyX1 : (n) => n.propertyX2;
~~~~~~~
!!! error TS2323: Type '{}' is not assignable to type '(t: X) => boolean'.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2366: No best common type exists between '(t: X) => boolean', '(m: X) => number', and '(n: X) => string'.
!!! error TS2322: Type '{ (m: X): number; } | { (n: X): string; }' is not assignable to type '(t: X) => boolean':
!!! error TS2322: Type '(m: X) => number' is not assignable to type '(t: X) => boolean':
!!! error TS2322: Type 'number' is not assignable to type 'boolean'.

View file

@ -1,11 +1,13 @@
tests/cases/compiler/contextualTyping21.ts(1,36): error TS2322: Type '{}[]' is not assignable to type '{ id: number; }[]':
Type '{}' is not assignable to type '{ id: number; }':
Property 'id' is missing in type '{}'.
tests/cases/compiler/contextualTyping21.ts(1,36): error TS2322: Type 'Array<number | { id: number; }>' is not assignable to type '{ id: number; }[]':
Type 'number | { id: number; }' is not assignable to type '{ id: number; }':
Type 'number' is not assignable to type '{ id: number; }':
Property 'id' is missing in type 'Number'.
==== tests/cases/compiler/contextualTyping21.ts (1 errors) ====
var foo:{id:number;}[] = [{id:1}]; foo = [{id:1}, 1];
~~~
!!! error TS2322: Type '{}[]' is not assignable to type '{ id: number; }[]':
!!! error TS2322: Type '{}' is not assignable to type '{ id: number; }':
!!! error TS2322: Property 'id' is missing in type '{}'.
!!! error TS2322: Type 'Array<number | { id: number; }>' is not assignable to type '{ id: number; }[]':
!!! error TS2322: Type 'number | { id: number; }' is not assignable to type '{ id: number; }':
!!! error TS2322: Type 'number' is not assignable to type '{ id: number; }':
!!! error TS2322: Property 'id' is missing in type 'Number'.

View file

@ -1,9 +1,11 @@
tests/cases/compiler/contextualTyping30.ts(1,37): error TS2345: Argument of type '{}[]' is not assignable to parameter of type 'number[]'.
Type '{}' is not assignable to type 'number'.
tests/cases/compiler/contextualTyping30.ts(1,37): error TS2345: Argument of type 'Array<string | number>' is not assignable to parameter of type 'number[]'.
Type 'string | number' is not assignable to type 'number':
Type 'string' is not assignable to type 'number'.
==== tests/cases/compiler/contextualTyping30.ts (1 errors) ====
function foo(param:number[]){}; foo([1, "a"]);
~~~~~~~~
!!! error TS2345: Argument of type '{}[]' is not assignable to parameter of type 'number[]'.
!!! error TS2345: Type '{}' is not assignable to type 'number'.
!!! error TS2345: Argument of type 'Array<string | number>' is not assignable to parameter of type 'number[]'.
!!! error TS2345: Type 'string | number' is not assignable to type 'number':
!!! error TS2345: Type 'string' is not assignable to type 'number'.

View file

@ -1,9 +1,11 @@
tests/cases/compiler/contextualTyping33.ts(1,66): error TS2345: Argument of type '{}[]' is not assignable to parameter of type '{ (): number; (i: number): number; }[]'.
Type '{}' is not assignable to type '{ (): number; (i: number): number; }'.
tests/cases/compiler/contextualTyping33.ts(1,66): error TS2345: Argument of type 'Array<{ (): number; } | { (): string; }>' is not assignable to parameter of type '{ (): number; (i: number): number; }[]'.
Type '{ (): number; } | { (): string; }' is not assignable to type '{ (): number; (i: number): number; }':
Type '() => string' is not assignable to type '{ (): number; (i: number): number; }'.
==== tests/cases/compiler/contextualTyping33.ts (1 errors) ====
function foo(param: {():number; (i:number):number; }[]) { }; foo([function(){return 1;}, function(){return "foo"}]);
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2345: Argument of type '{}[]' is not assignable to parameter of type '{ (): number; (i: number): number; }[]'.
!!! error TS2345: Type '{}' is not assignable to type '{ (): number; (i: number): number; }'.
!!! error TS2345: Argument of type 'Array<{ (): number; } | { (): string; }>' is not assignable to parameter of type '{ (): number; (i: number): number; }[]'.
!!! error TS2345: Type '{ (): number; } | { (): string; }' is not assignable to type '{ (): number; (i: number): number; }':
!!! error TS2345: Type '() => string' is not assignable to type '{ (): number; (i: number): number; }'.

View file

@ -1,7 +1,8 @@
tests/cases/compiler/contextualTypingOfArrayLiterals1.ts(5,5): error TS2322: Type '{}[]' is not assignable to type 'I':
tests/cases/compiler/contextualTypingOfArrayLiterals1.ts(5,5): error TS2322: Type 'Array<number | Date>' is not assignable to type 'I':
Index signatures are incompatible:
Type '{}' is not assignable to type 'Date':
Property 'toDateString' is missing in type '{}'.
Type 'number | Date' is not assignable to type 'Date':
Type 'number' is not assignable to type 'Date':
Property 'toDateString' is missing in type 'Number'.
==== tests/cases/compiler/contextualTypingOfArrayLiterals1.ts (1 errors) ====
@ -11,10 +12,11 @@ tests/cases/compiler/contextualTypingOfArrayLiterals1.ts(5,5): error TS2322: Typ
var x3: I = [new Date(), 1];
~~
!!! error TS2322: Type '{}[]' is not assignable to type 'I':
!!! error TS2322: Type 'Array<number | Date>' is not assignable to type 'I':
!!! error TS2322: Index signatures are incompatible:
!!! error TS2322: Type '{}' is not assignable to type 'Date':
!!! error TS2322: Property 'toDateString' is missing in type '{}'.
!!! error TS2322: Type 'number | Date' is not assignable to type 'Date':
!!! error TS2322: Type 'number' is not assignable to type 'Date':
!!! error TS2322: Property 'toDateString' is missing in type 'Number'.
var r2 = x3[1];
r2.getDate();

View file

@ -1,8 +1,11 @@
tests/cases/compiler/contextualTypingOfConditionalExpression2.ts(11,5): error TS2323: Type '{}' is not assignable to type '(a: A) => void'.
tests/cases/compiler/contextualTypingOfConditionalExpression2.ts(11,26): error TS2366: No best common type exists between '(a: A) => void', '(a: C) => number', and '(b: number) => void'.
tests/cases/compiler/contextualTypingOfConditionalExpression2.ts(11,5): error TS2322: Type '{ (a: C): number; } | { (b: number): void; }' is not assignable to type '(a: A) => void':
Type '(b: number) => void' is not assignable to type '(a: A) => void':
Types of parameters 'b' and 'a' are incompatible:
Type 'number' is not assignable to type 'A':
Property 'foo' is missing in type 'Number'.
==== tests/cases/compiler/contextualTypingOfConditionalExpression2.ts (2 errors) ====
==== tests/cases/compiler/contextualTypingOfConditionalExpression2.ts (1 errors) ====
class A {
foo: number;
}
@ -15,7 +18,9 @@ tests/cases/compiler/contextualTypingOfConditionalExpression2.ts(11,26): error T
var x2: (a: A) => void = true ? (a: C) => a.foo : (b: number) => { };
~~
!!! error TS2323: Type '{}' is not assignable to type '(a: A) => void'.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2366: No best common type exists between '(a: A) => void', '(a: C) => number', and '(b: number) => void'.
!!! error TS2322: Type '{ (a: C): number; } | { (b: number): void; }' is not assignable to type '(a: A) => void':
!!! error TS2322: Type '(b: number) => void' is not assignable to type '(a: A) => void':
!!! error TS2322: Types of parameters 'b' and 'a' are incompatible:
!!! error TS2322: Type 'number' is not assignable to type 'A':
!!! error TS2322: Property 'foo' is missing in type 'Number'.

View file

@ -1,9 +1,12 @@
tests/cases/compiler/contextualTypingWithFixedTypeParameters1.ts(2,22): error TS2339: Property 'foo' does not exist on type 'string'.
tests/cases/compiler/contextualTypingWithFixedTypeParameters1.ts(3,10): error TS2346: Supplied parameters do not match any signature of call target.
==== tests/cases/compiler/contextualTypingWithFixedTypeParameters1.ts (1 errors) ====
==== tests/cases/compiler/contextualTypingWithFixedTypeParameters1.ts (2 errors) ====
var f10: <T>(x: T, b: () => (a: T) => void, y: T) => T;
f10('', () => a => a.foo, ''); // a is string, fixed by first parameter
~~~
!!! error TS2339: Property 'foo' does not exist on type 'string'.
var r9 = f10('', () => (a => a.foo), 1); // now a should be any
var r9 = f10('', () => (a => a.foo), 1); // now a should be any
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2346: Supplied parameters do not match any signature of call target.

View file

@ -17,10 +17,10 @@ var v: { a: (_: string) => number } = { a: s => s.length } || { a: s => 1 };
>s : string
var v2 = (s: string) => s.length || function (s) { s.length };
>v2 : (s: string) => {}
>(s: string) => s.length || function (s) { s.length } : (s: string) => {}
>v2 : (s: string) => number | { (s: any): void; }
>(s: string) => s.length || function (s) { s.length } : (s: string) => number | { (s: any): void; }
>s : string
>s.length || function (s) { s.length } : {}
>s.length || function (s) { s.length } : number | { (s: any): void; }
>s.length : number
>s : string
>length : number
@ -31,10 +31,10 @@ var v2 = (s: string) => s.length || function (s) { s.length };
>length : any
var v3 = (s: string) => s.length || function (s: number) { return 1 };
>v3 : (s: string) => {}
>(s: string) => s.length || function (s: number) { return 1 } : (s: string) => {}
>v3 : (s: string) => number | { (s: number): number; }
>(s: string) => s.length || function (s: number) { return 1 } : (s: string) => number | { (s: number): number; }
>s : string
>s.length || function (s: number) { return 1 } : {}
>s.length || function (s: number) { return 1 } : number | { (s: number): number; }
>s.length : number
>s : string
>length : number
@ -42,10 +42,10 @@ var v3 = (s: string) => s.length || function (s: number) { return 1 };
>s : number
var v4 = (s: number) => 1 || function (s: string) { return s.length };
>v4 : (s: number) => {}
>(s: number) => 1 || function (s: string) { return s.length } : (s: number) => {}
>v4 : (s: number) => number | { (s: string): number; }
>(s: number) => 1 || function (s: string) { return s.length } : (s: number) => number | { (s: string): number; }
>s : number
>1 || function (s: string) { return s.length } : {}
>1 || function (s: string) { return s.length } : number | { (s: string): number; }
>function (s: string) { return s.length } : (s: string) => number
>s : string
>s.length : number

View file

@ -17,10 +17,10 @@ var v: { a: (_: string) => number } = { a: s => s.length } || { a: s => 1 };
>s : string
var v2 = (s: string) => s.length || function (s) { s.aaa };
>v2 : (s: string) => {}
>(s: string) => s.length || function (s) { s.aaa } : (s: string) => {}
>v2 : (s: string) => number | { (s: any): void; }
>(s: string) => s.length || function (s) { s.aaa } : (s: string) => number | { (s: any): void; }
>s : string
>s.length || function (s) { s.aaa } : {}
>s.length || function (s) { s.aaa } : number | { (s: any): void; }
>s.length : number
>s : string
>length : number

View file

@ -1,6 +1,6 @@
tests/cases/compiler/defaultBestCommonTypesHaveDecls.ts(4,6): error TS2339: Property 'length' does not exist on type '{}'.
tests/cases/compiler/defaultBestCommonTypesHaveDecls.ts(10,6): error TS2339: Property 'length' does not exist on type 'Object'.
tests/cases/compiler/defaultBestCommonTypesHaveDecls.ts(18,27): error TS2339: Property 'length' does not exist on type '{}'.
tests/cases/compiler/defaultBestCommonTypesHaveDecls.ts(16,14): error TS2346: Supplied parameters do not match any signature of call target.
==== tests/cases/compiler/defaultBestCommonTypesHaveDecls.ts (3 errors) ====
@ -24,8 +24,8 @@ tests/cases/compiler/defaultBestCommonTypesHaveDecls.ts(18,27): error TS2339: Pr
function concat<T>(x: T, y: T): T { return null; }
var result = concat(1, "");
~~~~~~~~~~~~~
!!! error TS2346: Supplied parameters do not match any signature of call target.
var elementCount = result.length; // would like to get an error by now
~~~~~~
!!! error TS2339: Property 'length' does not exist on type '{}'.

View file

@ -157,8 +157,8 @@ enum E9 {
// (refer to .js to validate)
// Enum constant members are propagated
var doNotPropagate = [
>doNotPropagate : {}[]
>[ E8.B, E7.A, E4.Z, E3.X, E3.Y, E3.Z] : {}[]
>doNotPropagate : Array<E3 | E4 | E7 | E8>
>[ E8.B, E7.A, E4.Z, E3.X, E3.Y, E3.Z] : Array<E3 | E4 | E7 | E8>
E8.B, E7.A, E4.Z, E3.X, E3.Y, E3.Z
>E8.B : E8
@ -183,8 +183,8 @@ var doNotPropagate = [
];
// Enum computed members are not propagated
var doPropagate = [
>doPropagate : {}[]
>[ E9.A, E9.B, E6.B, E6.C, E6.A, E5.A, E5.B, E5.C] : {}[]
>doPropagate : Array<E5 | E6 | E9>
>[ E9.A, E9.B, E6.B, E6.C, E6.A, E5.A, E5.B, E5.C] : Array<E5 | E6 | E9>
E9.A, E9.B, E6.B, E6.C, E6.A, E5.A, E5.B, E5.C
>E9.A : E9

View file

@ -0,0 +1,8 @@
tests/cases/compiler/fixTypeParameterInSignatureWithRestParameters.ts(2,1): error TS2346: Supplied parameters do not match any signature of call target.
==== tests/cases/compiler/fixTypeParameterInSignatureWithRestParameters.ts (1 errors) ====
function bar<T>(item1: T, item2: T) { }
bar(1, ""); // Should be ok
~~~~~~~~~~
!!! error TS2346: Supplied parameters do not match any signature of call target.

View file

@ -1,13 +0,0 @@
=== tests/cases/compiler/fixTypeParameterInSignatureWithRestParameters.ts ===
function bar<T>(item1: T, item2: T) { }
>bar : <T>(item1: T, item2: T) => void
>T : T
>item1 : T
>T : T
>item2 : T
>T : T
bar(1, ""); // Should be ok
>bar(1, "") : void
>bar : <T>(item1: T, item2: T) => void

View file

@ -7,7 +7,7 @@ tests/cases/conformance/statements/forStatements/forStatementsMultipleInvalidDec
tests/cases/conformance/statements/forStatements/forStatementsMultipleInvalidDecl.ts(40,10): error TS2403: Subsequent variable declarations must have the same type. Variable 'b' must be of type 'I', but here has type 'C2'.
tests/cases/conformance/statements/forStatements/forStatementsMultipleInvalidDecl.ts(43,10): error TS2403: Subsequent variable declarations must have the same type. Variable 'f' must be of type '(x: string) => number', but here has type '(x: number) => string'.
tests/cases/conformance/statements/forStatements/forStatementsMultipleInvalidDecl.ts(46,10): error TS2403: Subsequent variable declarations must have the same type. Variable 'arr' must be of type 'string[]', but here has type 'number[]'.
tests/cases/conformance/statements/forStatements/forStatementsMultipleInvalidDecl.ts(47,10): error TS2403: Subsequent variable declarations must have the same type. Variable 'arr' must be of type 'string[]', but here has type '{}[]'.
tests/cases/conformance/statements/forStatements/forStatementsMultipleInvalidDecl.ts(47,10): error TS2403: Subsequent variable declarations must have the same type. Variable 'arr' must be of type 'string[]', but here has type 'Array<C | D<string>>'.
tests/cases/conformance/statements/forStatements/forStatementsMultipleInvalidDecl.ts(50,10): error TS2403: Subsequent variable declarations must have the same type. Variable 'arr2' must be of type 'D<string>[]', but here has type 'D<number>[]'.
tests/cases/conformance/statements/forStatements/forStatementsMultipleInvalidDecl.ts(53,10): error TS2403: Subsequent variable declarations must have the same type. Variable 'm' must be of type 'typeof M', but here has type 'typeof A'.
@ -79,7 +79,7 @@ tests/cases/conformance/statements/forStatements/forStatementsMultipleInvalidDec
!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'arr' must be of type 'string[]', but here has type 'number[]'.
for( var arr = [new C(), new C2(), new D<string>()];;){}
~~~
!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'arr' must be of type 'string[]', but here has type '{}[]'.
!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'arr' must be of type 'string[]', but here has type 'Array<C | D<string>>'.
for(var arr2 = [new D<string>()];;){}
for( var arr2 = new Array<D<number>>();;){}

View file

@ -127,11 +127,11 @@ var x12: Genric<Base> = { func: n => { return [d1, d2]; } };
>x12 : Genric<Base>
>Genric : Genric<T>
>Base : Base
>{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => {}[]; }
>func : (n: Base[]) => {}[]
>n => { return [d1, d2]; } : (n: Base[]) => {}[]
>{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => Array<Derived1 | Derived2>; }
>func : (n: Base[]) => Array<Derived1 | Derived2>
>n => { return [d1, d2]; } : (n: Base[]) => Array<Derived1 | Derived2>
>n : Base[]
>[d1, d2] : {}[]
>[d1, d2] : Array<Derived1 | Derived2>
>d1 : Derived1
>d2 : Derived2
@ -243,11 +243,11 @@ class x24 { member: Genric<Base> = { func: n => { return [d1, d2]; } } }
>member : Genric<Base>
>Genric : Genric<T>
>Base : Base
>{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => {}[]; }
>func : (n: Base[]) => {}[]
>n => { return [d1, d2]; } : (n: Base[]) => {}[]
>{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => Array<Derived1 | Derived2>; }
>func : (n: Base[]) => Array<Derived1 | Derived2>
>n => { return [d1, d2]; } : (n: Base[]) => Array<Derived1 | Derived2>
>n : Base[]
>[d1, d2] : {}[]
>[d1, d2] : Array<Derived1 | Derived2>
>d1 : Derived1
>d2 : Derived2
@ -359,11 +359,11 @@ class x36 { private member: Genric<Base> = { func: n => { return [d1, d2]; } } }
>member : Genric<Base>
>Genric : Genric<T>
>Base : Base
>{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => {}[]; }
>func : (n: Base[]) => {}[]
>n => { return [d1, d2]; } : (n: Base[]) => {}[]
>{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => Array<Derived1 | Derived2>; }
>func : (n: Base[]) => Array<Derived1 | Derived2>
>n => { return [d1, d2]; } : (n: Base[]) => Array<Derived1 | Derived2>
>n : Base[]
>[d1, d2] : {}[]
>[d1, d2] : Array<Derived1 | Derived2>
>d1 : Derived1
>d2 : Derived2
@ -475,11 +475,11 @@ class x48 { public member: Genric<Base> = { func: n => { return [d1, d2]; } } }
>member : Genric<Base>
>Genric : Genric<T>
>Base : Base
>{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => {}[]; }
>func : (n: Base[]) => {}[]
>n => { return [d1, d2]; } : (n: Base[]) => {}[]
>{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => Array<Derived1 | Derived2>; }
>func : (n: Base[]) => Array<Derived1 | Derived2>
>n => { return [d1, d2]; } : (n: Base[]) => Array<Derived1 | Derived2>
>n : Base[]
>[d1, d2] : {}[]
>[d1, d2] : Array<Derived1 | Derived2>
>d1 : Derived1
>d2 : Derived2
@ -591,11 +591,11 @@ class x60 { static member: Genric<Base> = { func: n => { return [d1, d2]; } } }
>member : Genric<Base>
>Genric : Genric<T>
>Base : Base
>{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => {}[]; }
>func : (n: Base[]) => {}[]
>n => { return [d1, d2]; } : (n: Base[]) => {}[]
>{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => Array<Derived1 | Derived2>; }
>func : (n: Base[]) => Array<Derived1 | Derived2>
>n => { return [d1, d2]; } : (n: Base[]) => Array<Derived1 | Derived2>
>n : Base[]
>[d1, d2] : {}[]
>[d1, d2] : Array<Derived1 | Derived2>
>d1 : Derived1
>d2 : Derived2
@ -707,11 +707,11 @@ class x72 { private static member: Genric<Base> = { func: n => { return [d1, d2]
>member : Genric<Base>
>Genric : Genric<T>
>Base : Base
>{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => {}[]; }
>func : (n: Base[]) => {}[]
>n => { return [d1, d2]; } : (n: Base[]) => {}[]
>{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => Array<Derived1 | Derived2>; }
>func : (n: Base[]) => Array<Derived1 | Derived2>
>n => { return [d1, d2]; } : (n: Base[]) => Array<Derived1 | Derived2>
>n : Base[]
>[d1, d2] : {}[]
>[d1, d2] : Array<Derived1 | Derived2>
>d1 : Derived1
>d2 : Derived2
@ -823,11 +823,11 @@ class x84 { public static member: Genric<Base> = { func: n => { return [d1, d2];
>member : Genric<Base>
>Genric : Genric<T>
>Base : Base
>{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => {}[]; }
>func : (n: Base[]) => {}[]
>n => { return [d1, d2]; } : (n: Base[]) => {}[]
>{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => Array<Derived1 | Derived2>; }
>func : (n: Base[]) => Array<Derived1 | Derived2>
>n => { return [d1, d2]; } : (n: Base[]) => Array<Derived1 | Derived2>
>n : Base[]
>[d1, d2] : {}[]
>[d1, d2] : Array<Derived1 | Derived2>
>d1 : Derived1
>d2 : Derived2
@ -939,11 +939,11 @@ class x96 { constructor(parm: Genric<Base> = { func: n => { return [d1, d2]; } }
>parm : Genric<Base>
>Genric : Genric<T>
>Base : Base
>{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => {}[]; }
>func : (n: Base[]) => {}[]
>n => { return [d1, d2]; } : (n: Base[]) => {}[]
>{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => Array<Derived1 | Derived2>; }
>func : (n: Base[]) => Array<Derived1 | Derived2>
>n => { return [d1, d2]; } : (n: Base[]) => Array<Derived1 | Derived2>
>n : Base[]
>[d1, d2] : {}[]
>[d1, d2] : Array<Derived1 | Derived2>
>d1 : Derived1
>d2 : Derived2
@ -1055,11 +1055,11 @@ class x108 { constructor(public parm: Genric<Base> = { func: n => { return [d1,
>parm : Genric<Base>
>Genric : Genric<T>
>Base : Base
>{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => {}[]; }
>func : (n: Base[]) => {}[]
>n => { return [d1, d2]; } : (n: Base[]) => {}[]
>{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => Array<Derived1 | Derived2>; }
>func : (n: Base[]) => Array<Derived1 | Derived2>
>n => { return [d1, d2]; } : (n: Base[]) => Array<Derived1 | Derived2>
>n : Base[]
>[d1, d2] : {}[]
>[d1, d2] : Array<Derived1 | Derived2>
>d1 : Derived1
>d2 : Derived2
@ -1171,11 +1171,11 @@ class x120 { constructor(private parm: Genric<Base> = { func: n => { return [d1,
>parm : Genric<Base>
>Genric : Genric<T>
>Base : Base
>{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => {}[]; }
>func : (n: Base[]) => {}[]
>n => { return [d1, d2]; } : (n: Base[]) => {}[]
>{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => Array<Derived1 | Derived2>; }
>func : (n: Base[]) => Array<Derived1 | Derived2>
>n => { return [d1, d2]; } : (n: Base[]) => Array<Derived1 | Derived2>
>n : Base[]
>[d1, d2] : {}[]
>[d1, d2] : Array<Derived1 | Derived2>
>d1 : Derived1
>d2 : Derived2
@ -1287,11 +1287,11 @@ function x132(parm: Genric<Base> = { func: n => { return [d1, d2]; } }) { }
>parm : Genric<Base>
>Genric : Genric<T>
>Base : Base
>{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => {}[]; }
>func : (n: Base[]) => {}[]
>n => { return [d1, d2]; } : (n: Base[]) => {}[]
>{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => Array<Derived1 | Derived2>; }
>func : (n: Base[]) => Array<Derived1 | Derived2>
>n => { return [d1, d2]; } : (n: Base[]) => Array<Derived1 | Derived2>
>n : Base[]
>[d1, d2] : {}[]
>[d1, d2] : Array<Derived1 | Derived2>
>d1 : Derived1
>d2 : Derived2
@ -1391,11 +1391,11 @@ function x144(): Genric<Base> { return { func: n => { return [d1, d2]; } }; }
>x144 : () => Genric<Base>
>Genric : Genric<T>
>Base : Base
>{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => {}[]; }
>func : (n: Base[]) => {}[]
>n => { return [d1, d2]; } : (n: Base[]) => {}[]
>{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => Array<Derived1 | Derived2>; }
>func : (n: Base[]) => Array<Derived1 | Derived2>
>n => { return [d1, d2]; } : (n: Base[]) => Array<Derived1 | Derived2>
>n : Base[]
>[d1, d2] : {}[]
>[d1, d2] : Array<Derived1 | Derived2>
>d1 : Derived1
>d2 : Derived2
@ -1539,18 +1539,18 @@ function x156(): Genric<Base> { return { func: n => { return [d1, d2]; } }; retu
>x156 : () => Genric<Base>
>Genric : Genric<T>
>Base : Base
>{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => {}[]; }
>func : (n: Base[]) => {}[]
>n => { return [d1, d2]; } : (n: Base[]) => {}[]
>{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => Array<Derived1 | Derived2>; }
>func : (n: Base[]) => Array<Derived1 | Derived2>
>n => { return [d1, d2]; } : (n: Base[]) => Array<Derived1 | Derived2>
>n : Base[]
>[d1, d2] : {}[]
>[d1, d2] : Array<Derived1 | Derived2>
>d1 : Derived1
>d2 : Derived2
>{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => {}[]; }
>func : (n: Base[]) => {}[]
>n => { return [d1, d2]; } : (n: Base[]) => {}[]
>{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => Array<Derived1 | Derived2>; }
>func : (n: Base[]) => Array<Derived1 | Derived2>
>n => { return [d1, d2]; } : (n: Base[]) => Array<Derived1 | Derived2>
>n : Base[]
>[d1, d2] : {}[]
>[d1, d2] : Array<Derived1 | Derived2>
>d1 : Derived1
>d2 : Derived2
@ -1661,12 +1661,12 @@ var x168: () => Genric<Base> = () => { return { func: n => { return [d1, d2]; }
>x168 : () => Genric<Base>
>Genric : Genric<T>
>Base : Base
>() => { return { func: n => { return [d1, d2]; } }; } : () => { func: (n: Base[]) => {}[]; }
>{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => {}[]; }
>func : (n: Base[]) => {}[]
>n => { return [d1, d2]; } : (n: Base[]) => {}[]
>() => { return { func: n => { return [d1, d2]; } }; } : () => { func: (n: Base[]) => Array<Derived1 | Derived2>; }
>{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => Array<Derived1 | Derived2>; }
>func : (n: Base[]) => Array<Derived1 | Derived2>
>n => { return [d1, d2]; } : (n: Base[]) => Array<Derived1 | Derived2>
>n : Base[]
>[d1, d2] : {}[]
>[d1, d2] : Array<Derived1 | Derived2>
>d1 : Derived1
>d2 : Derived2
@ -1777,12 +1777,12 @@ var x180: () => Genric<Base> = function() { return { func: n => { return [d1, d2
>x180 : () => Genric<Base>
>Genric : Genric<T>
>Base : Base
>function() { return { func: n => { return [d1, d2]; } }; } : () => { func: (n: Base[]) => {}[]; }
>{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => {}[]; }
>func : (n: Base[]) => {}[]
>n => { return [d1, d2]; } : (n: Base[]) => {}[]
>function() { return { func: n => { return [d1, d2]; } }; } : () => { func: (n: Base[]) => Array<Derived1 | Derived2>; }
>{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => Array<Derived1 | Derived2>; }
>func : (n: Base[]) => Array<Derived1 | Derived2>
>n => { return [d1, d2]; } : (n: Base[]) => Array<Derived1 | Derived2>
>n : Base[]
>[d1, d2] : {}[]
>[d1, d2] : Array<Derived1 | Derived2>
>d1 : Derived1
>d2 : Derived2
@ -1894,11 +1894,11 @@ module x192 { var t: Genric<Base> = { func: n => { return [d1, d2]; } }; }
>t : Genric<Base>
>Genric : Genric<T>
>Base : Base
>{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => {}[]; }
>func : (n: Base[]) => {}[]
>n => { return [d1, d2]; } : (n: Base[]) => {}[]
>{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => Array<Derived1 | Derived2>; }
>func : (n: Base[]) => Array<Derived1 | Derived2>
>n => { return [d1, d2]; } : (n: Base[]) => Array<Derived1 | Derived2>
>n : Base[]
>[d1, d2] : {}[]
>[d1, d2] : Array<Derived1 | Derived2>
>d1 : Derived1
>d2 : Derived2
@ -2010,11 +2010,11 @@ module x204 { export var t: Genric<Base> = { func: n => { return [d1, d2]; } };
>t : Genric<Base>
>Genric : Genric<T>
>Base : Base
>{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => {}[]; }
>func : (n: Base[]) => {}[]
>n => { return [d1, d2]; } : (n: Base[]) => {}[]
>{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => Array<Derived1 | Derived2>; }
>func : (n: Base[]) => Array<Derived1 | Derived2>
>n => { return [d1, d2]; } : (n: Base[]) => Array<Derived1 | Derived2>
>n : Base[]
>[d1, d2] : {}[]
>[d1, d2] : Array<Derived1 | Derived2>
>d1 : Derived1
>d2 : Derived2
@ -2098,11 +2098,11 @@ var x216 = <Genric<Base>>{ func: n => { return [d1, d2]; } };
><Genric<Base>>{ func: n => { return [d1, d2]; } } : Genric<Base>
>Genric : Genric<T>
>Base : Base
>{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => {}[]; }
>func : (n: Base[]) => {}[]
>n => { return [d1, d2]; } : (n: Base[]) => {}[]
>{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => Array<Derived1 | Derived2>; }
>func : (n: Base[]) => Array<Derived1 | Derived2>
>n => { return [d1, d2]; } : (n: Base[]) => Array<Derived1 | Derived2>
>n : Base[]
>[d1, d2] : {}[]
>[d1, d2] : Array<Derived1 | Derived2>
>d1 : Derived1
>d2 : Derived2
@ -2323,13 +2323,13 @@ var x236: Genric<Base>; x236 = { func: n => { return [d1, d2]; } };
>x236 : Genric<Base>
>Genric : Genric<T>
>Base : Base
>x236 = { func: n => { return [d1, d2]; } } : { func: (n: Base[]) => {}[]; }
>x236 = { func: n => { return [d1, d2]; } } : { func: (n: Base[]) => Array<Derived1 | Derived2>; }
>x236 : Genric<Base>
>{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => {}[]; }
>func : (n: Base[]) => {}[]
>n => { return [d1, d2]; } : (n: Base[]) => {}[]
>{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => Array<Derived1 | Derived2>; }
>func : (n: Base[]) => Array<Derived1 | Derived2>
>n => { return [d1, d2]; } : (n: Base[]) => Array<Derived1 | Derived2>
>n : Base[]
>[d1, d2] : {}[]
>[d1, d2] : Array<Derived1 | Derived2>
>d1 : Derived1
>d2 : Derived2
@ -2463,13 +2463,13 @@ var x248: { n: Genric<Base>; } = { n: { func: n => { return [d1, d2]; } } };
>n : Genric<Base>
>Genric : Genric<T>
>Base : Base
>{ n: { func: n => { return [d1, d2]; } } } : { n: { func: (n: Base[]) => {}[]; }; }
>n : { func: (n: Base[]) => {}[]; }
>{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => {}[]; }
>func : (n: Base[]) => {}[]
>n => { return [d1, d2]; } : (n: Base[]) => {}[]
>{ n: { func: n => { return [d1, d2]; } } } : { n: { func: (n: Base[]) => Array<Derived1 | Derived2>; }; }
>n : { func: (n: Base[]) => Array<Derived1 | Derived2>; }
>{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => Array<Derived1 | Derived2>; }
>func : (n: Base[]) => Array<Derived1 | Derived2>
>n => { return [d1, d2]; } : (n: Base[]) => Array<Derived1 | Derived2>
>n : Base[]
>[d1, d2] : {}[]
>[d1, d2] : Array<Derived1 | Derived2>
>d1 : Derived1
>d2 : Derived2
@ -2543,11 +2543,11 @@ var x260: Genric<Base>[] = [{ func: n => { return [d1, d2]; } }];
>Genric : Genric<T>
>Base : Base
>[{ func: n => { return [d1, d2]; } }] : Genric<Base>[]
>{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => {}[]; }
>func : (n: Base[]) => {}[]
>n => { return [d1, d2]; } : (n: Base[]) => {}[]
>{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => Array<Derived1 | Derived2>; }
>func : (n: Base[]) => Array<Derived1 | Derived2>
>n => { return [d1, d2]; } : (n: Base[]) => Array<Derived1 | Derived2>
>n : Base[]
>[d1, d2] : {}[]
>[d1, d2] : Array<Derived1 | Derived2>
>d1 : Derived1
>d2 : Derived2
@ -2976,18 +2976,18 @@ var x296: Genric<Base> = true ? { func: n => { return [d1, d2]; } } : { func: n
>Genric : Genric<T>
>Base : Base
>true ? { func: n => { return [d1, d2]; } } : { func: n => { return [d1, d2]; } } : Genric<Base>
>{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => {}[]; }
>func : (n: Base[]) => {}[]
>n => { return [d1, d2]; } : (n: Base[]) => {}[]
>{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => Array<Derived1 | Derived2>; }
>func : (n: Base[]) => Array<Derived1 | Derived2>
>n => { return [d1, d2]; } : (n: Base[]) => Array<Derived1 | Derived2>
>n : Base[]
>[d1, d2] : {}[]
>[d1, d2] : Array<Derived1 | Derived2>
>d1 : Derived1
>d2 : Derived2
>{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => {}[]; }
>func : (n: Base[]) => {}[]
>n => { return [d1, d2]; } : (n: Base[]) => {}[]
>{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => Array<Derived1 | Derived2>; }
>func : (n: Base[]) => Array<Derived1 | Derived2>
>n => { return [d1, d2]; } : (n: Base[]) => Array<Derived1 | Derived2>
>n : Base[]
>[d1, d2] : {}[]
>[d1, d2] : Array<Derived1 | Derived2>
>d1 : Derived1
>d2 : Derived2
@ -3111,11 +3111,11 @@ var x308: Genric<Base> = true ? undefined : { func: n => { return [d1, d2]; } };
>Base : Base
>true ? undefined : { func: n => { return [d1, d2]; } } : Genric<Base>
>undefined : undefined
>{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => {}[]; }
>func : (n: Base[]) => {}[]
>n => { return [d1, d2]; } : (n: Base[]) => {}[]
>{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => Array<Derived1 | Derived2>; }
>func : (n: Base[]) => Array<Derived1 | Derived2>
>n => { return [d1, d2]; } : (n: Base[]) => Array<Derived1 | Derived2>
>n : Base[]
>[d1, d2] : {}[]
>[d1, d2] : Array<Derived1 | Derived2>
>d1 : Derived1
>d2 : Derived2
@ -3238,11 +3238,11 @@ var x320: Genric<Base> = true ? { func: n => { return [d1, d2]; } } : undefined;
>Genric : Genric<T>
>Base : Base
>true ? { func: n => { return [d1, d2]; } } : undefined : Genric<Base>
>{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => {}[]; }
>func : (n: Base[]) => {}[]
>n => { return [d1, d2]; } : (n: Base[]) => {}[]
>{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => Array<Derived1 | Derived2>; }
>func : (n: Base[]) => Array<Derived1 | Derived2>
>n => { return [d1, d2]; } : (n: Base[]) => Array<Derived1 | Derived2>
>n : Base[]
>[d1, d2] : {}[]
>[d1, d2] : Array<Derived1 | Derived2>
>d1 : Derived1
>d2 : Derived2
>undefined : undefined
@ -3379,11 +3379,11 @@ function x332(n: Genric<Base>) { }; x332({ func: n => { return [d1, d2]; } });
>Base : Base
>x332({ func: n => { return [d1, d2]; } }) : void
>x332 : (n: Genric<Base>) => void
>{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => {}[]; }
>func : (n: Base[]) => {}[]
>n => { return [d1, d2]; } : (n: Base[]) => {}[]
>{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => Array<Derived1 | Derived2>; }
>func : (n: Base[]) => Array<Derived1 | Derived2>
>n => { return [d1, d2]; } : (n: Base[]) => Array<Derived1 | Derived2>
>n : Base[]
>[d1, d2] : {}[]
>[d1, d2] : Array<Derived1 | Derived2>
>d1 : Derived1
>d2 : Derived2
@ -3543,11 +3543,11 @@ var x344 = (n: Genric<Base>) => n; x344({ func: n => { return [d1, d2]; } });
>n : Genric<Base>
>x344({ func: n => { return [d1, d2]; } }) : Genric<Base>
>x344 : (n: Genric<Base>) => Genric<Base>
>{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => {}[]; }
>func : (n: Base[]) => {}[]
>n => { return [d1, d2]; } : (n: Base[]) => {}[]
>{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => Array<Derived1 | Derived2>; }
>func : (n: Base[]) => Array<Derived1 | Derived2>
>n => { return [d1, d2]; } : (n: Base[]) => Array<Derived1 | Derived2>
>n : Base[]
>[d1, d2] : {}[]
>[d1, d2] : Array<Derived1 | Derived2>
>d1 : Derived1
>d2 : Derived2
@ -3695,11 +3695,11 @@ var x356 = function(n: Genric<Base>) { }; x356({ func: n => { return [d1, d2]; }
>Base : Base
>x356({ func: n => { return [d1, d2]; } }) : void
>x356 : (n: Genric<Base>) => void
>{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => {}[]; }
>func : (n: Base[]) => {}[]
>n => { return [d1, d2]; } : (n: Base[]) => {}[]
>{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => Array<Derived1 | Derived2>; }
>func : (n: Base[]) => Array<Derived1 | Derived2>
>n => { return [d1, d2]; } : (n: Base[]) => Array<Derived1 | Derived2>
>n : Base[]
>[d1, d2] : {}[]
>[d1, d2] : Array<Derived1 | Derived2>
>d1 : Derived1
>d2 : Derived2

View file

@ -49,7 +49,7 @@ _.all([true, 1, null, 'yes'], _.identity);
>_.all : <T>(list: T[], iterator?: Underscore.Iterator<T, boolean>, context?: any) => boolean
>_ : Underscore.Static
>all : <T>(list: T[], iterator?: Underscore.Iterator<T, boolean>, context?: any) => boolean
>[true, 1, null, 'yes'] : {}[]
>[true, 1, null, 'yes'] : Array<string | number | boolean>
>_.identity : <T>(value: T) => T
>_ : Underscore.Static
>identity : <T>(value: T) => T

View file

@ -40,10 +40,10 @@ var r3 = foo<number[]>([]); // number[]
>[] : number[]
var r4 = foo([1, '']); // {}[]
>r4 : {}[]
>foo([1, '']) : {}[]
>r4 : Array<string | number>
>foo([1, '']) : Array<string | number>
>foo : <T>(t: T) => T
>[1, ''] : {}[]
>[1, ''] : Array<string | number>
var r5 = foo<any[]>([1, '']); // any[]
>r5 : any[]

View file

@ -0,0 +1,58 @@
tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithFunctionTypedArguments.ts(26,18): error TS2345: Argument of type '(a: number) => string' is not assignable to parameter of type '(a: number) => number'.
Type 'string' is not assignable to type 'number'.
tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithFunctionTypedArguments.ts(30,15): error TS2346: Supplied parameters do not match any signature of call target.
tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithFunctionTypedArguments.ts(33,15): error TS2346: Supplied parameters do not match any signature of call target.
tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithFunctionTypedArguments.ts(34,16): error TS2346: Supplied parameters do not match any signature of call target.
tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithFunctionTypedArguments.ts(35,23): error TS2345: Argument of type '(a: number) => string' is not assignable to parameter of type '(a: number) => number'.
Type 'string' is not assignable to type 'number'.
==== tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithFunctionTypedArguments.ts (5 errors) ====
// Generic functions used as arguments for function typed parameters are not used to make inferences from
// Using function arguments, no errors expected
function foo<T>(x: (a: T) => T) {
return x(null);
}
var r = foo(<U>(x: U) => ''); // {}
var r2 = foo<string>(<U>(x: U) => ''); // string
var r3 = foo(x => ''); // {}
function foo2<T, U>(x: T, cb: (a: T) => U) {
return cb(x);
}
var r4 = foo2(1, function <Z>(a: Z) { return '' }); // string, contextual signature instantiation is applied to generic functions
var r5 = foo2(1, (a) => ''); // string
var r6 = foo2<string, number>('', <Z>(a: Z) => 1);
function foo3<T, U>(x: T, cb: (a: T) => U, y: U) {
return cb(x);
}
var r7 = foo3(1, <Z>(a: Z) => '', ''); // string
var r8 = foo3(1, function (a) { return '' }, 1); // {}
~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2345: Argument of type '(a: number) => string' is not assignable to parameter of type '(a: number) => number'.
!!! error TS2345: Type 'string' is not assignable to type 'number'.
var r9 = foo3<number, string>(1, (a) => '', ''); // string
function other<T, U>(t: T, u: U) {
var r10 = foo2(1, (x: T) => ''); // string, non-generic signature allows inferences to be made
~~~~~~~~~~~~~~~~~~~~~
!!! error TS2346: Supplied parameters do not match any signature of call target.
var r10 = foo2(1, (x) => ''); // string
var r11 = foo3(1, (x: T) => '', ''); // string
~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2346: Supplied parameters do not match any signature of call target.
var r11b = foo3(1, (x: T) => '', 1); // {}
~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2346: Supplied parameters do not match any signature of call target.
var r12 = foo3(1, function (a) { return '' }, 1); // {}
~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2345: Argument of type '(a: number) => string' is not assignable to parameter of type '(a: number) => number'.
!!! error TS2345: Type 'string' is not assignable to type 'number'.
}

View file

@ -1,173 +0,0 @@
=== tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithFunctionTypedArguments.ts ===
// Generic functions used as arguments for function typed parameters are not used to make inferences from
// Using function arguments, no errors expected
function foo<T>(x: (a: T) => T) {
>foo : <T>(x: (a: T) => T) => T
>T : T
>x : (a: T) => T
>a : T
>T : T
>T : T
return x(null);
>x(null) : T
>x : (a: T) => T
}
var r = foo(<U>(x: U) => ''); // {}
>r : {}
>foo(<U>(x: U) => '') : {}
>foo : <T>(x: (a: T) => T) => T
><U>(x: U) => '' : <U>(x: U) => string
>U : U
>x : U
>U : U
var r2 = foo<string>(<U>(x: U) => ''); // string
>r2 : string
>foo<string>(<U>(x: U) => '') : string
>foo : <T>(x: (a: T) => T) => T
><U>(x: U) => '' : <U>(x: U) => string
>U : U
>x : U
>U : U
var r3 = foo(x => ''); // {}
>r3 : {}
>foo(x => '') : {}
>foo : <T>(x: (a: T) => T) => T
>x => '' : (x: {}) => string
>x : {}
function foo2<T, U>(x: T, cb: (a: T) => U) {
>foo2 : <T, U>(x: T, cb: (a: T) => U) => U
>T : T
>U : U
>x : T
>T : T
>cb : (a: T) => U
>a : T
>T : T
>U : U
return cb(x);
>cb(x) : U
>cb : (a: T) => U
>x : T
}
var r4 = foo2(1, function <Z>(a: Z) { return '' }); // string, contextual signature instantiation is applied to generic functions
>r4 : string
>foo2(1, function <Z>(a: Z) { return '' }) : string
>foo2 : <T, U>(x: T, cb: (a: T) => U) => U
>function <Z>(a: Z) { return '' } : <Z>(a: Z) => string
>Z : Z
>a : Z
>Z : Z
var r5 = foo2(1, (a) => ''); // string
>r5 : string
>foo2(1, (a) => '') : string
>foo2 : <T, U>(x: T, cb: (a: T) => U) => U
>(a) => '' : (a: number) => string
>a : number
var r6 = foo2<string, number>('', <Z>(a: Z) => 1);
>r6 : number
>foo2<string, number>('', <Z>(a: Z) => 1) : number
>foo2 : <T, U>(x: T, cb: (a: T) => U) => U
><Z>(a: Z) => 1 : <Z>(a: Z) => number
>Z : Z
>a : Z
>Z : Z
function foo3<T, U>(x: T, cb: (a: T) => U, y: U) {
>foo3 : <T, U>(x: T, cb: (a: T) => U, y: U) => U
>T : T
>U : U
>x : T
>T : T
>cb : (a: T) => U
>a : T
>T : T
>U : U
>y : U
>U : U
return cb(x);
>cb(x) : U
>cb : (a: T) => U
>x : T
}
var r7 = foo3(1, <Z>(a: Z) => '', ''); // string
>r7 : string
>foo3(1, <Z>(a: Z) => '', '') : string
>foo3 : <T, U>(x: T, cb: (a: T) => U, y: U) => U
><Z>(a: Z) => '' : <Z>(a: Z) => string
>Z : Z
>a : Z
>Z : Z
var r8 = foo3(1, function (a) { return '' }, 1); // {}
>r8 : {}
>foo3(1, function (a) { return '' }, 1) : {}
>foo3 : <T, U>(x: T, cb: (a: T) => U, y: U) => U
>function (a) { return '' } : (a: number) => string
>a : number
var r9 = foo3<number, string>(1, (a) => '', ''); // string
>r9 : string
>foo3<number, string>(1, (a) => '', '') : string
>foo3 : <T, U>(x: T, cb: (a: T) => U, y: U) => U
>(a) => '' : (a: number) => string
>a : number
function other<T, U>(t: T, u: U) {
>other : <T, U>(t: T, u: U) => void
>T : T
>U : U
>t : T
>T : T
>u : U
>U : U
var r10 = foo2(1, (x: T) => ''); // string, non-generic signature allows inferences to be made
>r10 : string
>foo2(1, (x: T) => '') : string
>foo2 : <T, U>(x: T, cb: (a: T) => U) => U
>(x: T) => '' : (x: T) => string
>x : T
>T : T
var r10 = foo2(1, (x) => ''); // string
>r10 : string
>foo2(1, (x) => '') : string
>foo2 : <T, U>(x: T, cb: (a: T) => U) => U
>(x) => '' : (x: number) => string
>x : number
var r11 = foo3(1, (x: T) => '', ''); // string
>r11 : string
>foo3(1, (x: T) => '', '') : string
>foo3 : <T, U>(x: T, cb: (a: T) => U, y: U) => U
>(x: T) => '' : (x: T) => string
>x : T
>T : T
var r11b = foo3(1, (x: T) => '', 1); // {}
>r11b : {}
>foo3(1, (x: T) => '', 1) : {}
>foo3 : <T, U>(x: T, cb: (a: T) => U, y: U) => U
>(x: T) => '' : (x: T) => string
>x : T
>T : T
var r12 = foo3(1, function (a) { return '' }, 1); // {}
>r12 : {}
>foo3(1, function (a) { return '' }, 1) : {}
>foo3 : <T, U>(x: T, cb: (a: T) => U, y: U) => U
>function (a) { return '' } : (a: number) => string
>a : number
}

View file

@ -0,0 +1,50 @@
tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithFunctionTypedArguments2.ts(29,10): error TS2346: Supplied parameters do not match any signature of call target.
tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithFunctionTypedArguments2.ts(40,10): error TS2346: Supplied parameters do not match any signature of call target.
==== tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithFunctionTypedArguments2.ts (2 errors) ====
// Generic functions used as arguments for function typed parameters are not used to make inferences from
// Using construct signature arguments, no errors expected
function foo<T>(x: new(a: T) => T) {
return new x(null);
}
interface I {
new <T>(x: T): T;
}
interface I2<T> {
new (x: T): T;
}
var i: I;
var i2: I2<string>;
var a: {
new <T>(x: T): T;
}
var r = foo(i); // any
var r2 = foo<string>(i); // string
var r3 = foo(i2); // string
var r3b = foo(a); // any
function foo2<T, U>(x: T, cb: new(a: T) => U) {
return new cb(x);
}
var r4 = foo2(1, i2); // string, instantiated generic
~~~~~~~~~~~
!!! error TS2346: Supplied parameters do not match any signature of call target.
var r4b = foo2(1, a); // any
var r5 = foo2(1, i); // any
var r6 = foo2<string, string>('', i2); // string
function foo3<T, U>(x: T, cb: new(a: T) => U, y: U) {
return new cb(x);
}
var r7 = foo3(null, i, ''); // any
var r7b = foo3(null, a, ''); // any
var r8 = foo3(1, i2, 1); // {}
~~~~~~~~~~~~~~
!!! error TS2346: Supplied parameters do not match any signature of call target.
var r9 = foo3<string, string>('', i2, ''); // string

View file

@ -1,161 +0,0 @@
=== tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithFunctionTypedArguments2.ts ===
// Generic functions used as arguments for function typed parameters are not used to make inferences from
// Using construct signature arguments, no errors expected
function foo<T>(x: new(a: T) => T) {
>foo : <T>(x: new (a: T) => T) => T
>T : T
>x : new (a: T) => T
>a : T
>T : T
>T : T
return new x(null);
>new x(null) : T
>x : new (a: T) => T
}
interface I {
>I : I
new <T>(x: T): T;
>T : T
>x : T
>T : T
>T : T
}
interface I2<T> {
>I2 : I2<T>
>T : T
new (x: T): T;
>x : T
>T : T
>T : T
}
var i: I;
>i : I
>I : I
var i2: I2<string>;
>i2 : I2<string>
>I2 : I2<T>
var a: {
>a : new <T>(x: T) => T
new <T>(x: T): T;
>T : T
>x : T
>T : T
>T : T
}
var r = foo(i); // any
>r : any
>foo(i) : any
>foo : <T>(x: new (a: T) => T) => T
>i : I
var r2 = foo<string>(i); // string
>r2 : string
>foo<string>(i) : string
>foo : <T>(x: new (a: T) => T) => T
>i : I
var r3 = foo(i2); // string
>r3 : string
>foo(i2) : string
>foo : <T>(x: new (a: T) => T) => T
>i2 : I2<string>
var r3b = foo(a); // any
>r3b : any
>foo(a) : any
>foo : <T>(x: new (a: T) => T) => T
>a : new <T>(x: T) => T
function foo2<T, U>(x: T, cb: new(a: T) => U) {
>foo2 : <T, U>(x: T, cb: new (a: T) => U) => U
>T : T
>U : U
>x : T
>T : T
>cb : new (a: T) => U
>a : T
>T : T
>U : U
return new cb(x);
>new cb(x) : U
>cb : new (a: T) => U
>x : T
}
var r4 = foo2(1, i2); // string, instantiated generic
>r4 : string
>foo2(1, i2) : string
>foo2 : <T, U>(x: T, cb: new (a: T) => U) => U
>i2 : I2<string>
var r4b = foo2(1, a); // any
>r4b : any
>foo2(1, a) : any
>foo2 : <T, U>(x: T, cb: new (a: T) => U) => U
>a : new <T>(x: T) => T
var r5 = foo2(1, i); // any
>r5 : any
>foo2(1, i) : any
>foo2 : <T, U>(x: T, cb: new (a: T) => U) => U
>i : I
var r6 = foo2<string, string>('', i2); // string
>r6 : string
>foo2<string, string>('', i2) : string
>foo2 : <T, U>(x: T, cb: new (a: T) => U) => U
>i2 : I2<string>
function foo3<T, U>(x: T, cb: new(a: T) => U, y: U) {
>foo3 : <T, U>(x: T, cb: new (a: T) => U, y: U) => U
>T : T
>U : U
>x : T
>T : T
>cb : new (a: T) => U
>a : T
>T : T
>U : U
>y : U
>U : U
return new cb(x);
>new cb(x) : U
>cb : new (a: T) => U
>x : T
}
var r7 = foo3(null, i, ''); // any
>r7 : any
>foo3(null, i, '') : any
>foo3 : <T, U>(x: T, cb: new (a: T) => U, y: U) => U
>i : I
var r7b = foo3(null, a, ''); // any
>r7b : any
>foo3(null, a, '') : any
>foo3 : <T, U>(x: T, cb: new (a: T) => U, y: U) => U
>a : new <T>(x: T) => T
var r8 = foo3(1, i2, 1); // {}
>r8 : {}
>foo3(1, i2, 1) : {}
>foo3 : <T, U>(x: T, cb: new (a: T) => U, y: U) => U
>i2 : I2<string>
var r9 = foo3<string, string>('', i2, ''); // string
>r9 : string
>foo3<string, string>('', i2, '') : string
>foo3 : <T, U>(x: T, cb: new (a: T) => U, y: U) => U
>i2 : I2<string>

View file

@ -1,10 +1,11 @@
tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithGenericSignatureArguments2.ts(9,25): error TS2346: Supplied parameters do not match any signature of call target.
tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithGenericSignatureArguments2.ts(14,17): error TS2345: Argument of type 'Date' is not assignable to parameter of type 'T'.
tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithGenericSignatureArguments2.ts(15,18): error TS2345: Argument of type 'number' is not assignable to parameter of type 'T'.
tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithGenericSignatureArguments2.ts(24,19): error TS2345: Argument of type '(a: T) => T' is not assignable to parameter of type '(x: Date) => Date'.
tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithGenericSignatureArguments2.ts(36,32): error TS2345: Argument of type '(x: E) => F' is not assignable to parameter of type '(x: E) => E'.
==== tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithGenericSignatureArguments2.ts (4 errors) ====
==== tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithGenericSignatureArguments2.ts (5 errors) ====
// When a function expression is inferentially typed (section 4.9.3) and a type assigned to a parameter in that expression references type parameters for which inferences are being made,
// the corresponding inferred type arguments to become fixed and no further candidate inferences are made for them.
@ -14,6 +15,8 @@ tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithGen
}
var r1: (x: {}) => {} = foo((x: number) => 1, (x: string) => '');
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2346: Supplied parameters do not match any signature of call target.
function other2<T extends Date>(x: T) {
var r7 = foo((a: T) => a, (b: T) => b); // T => T

View file

@ -0,0 +1,42 @@
tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithGenericSignatureArguments3.ts(32,11): error TS2346: Supplied parameters do not match any signature of call target.
tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithGenericSignatureArguments3.ts(33,11): error TS2346: Supplied parameters do not match any signature of call target.
==== tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithGenericSignatureArguments3.ts (2 errors) ====
// When a function expression is inferentially typed (section 4.9.3) and a type assigned to a parameter in that expression references type parameters for which inferences are being made,
// the corresponding inferred type arguments to become fixed and no further candidate inferences are made for them.
function foo<T>(x: T, a: (x: T) => T, b: (x: T) => T) {
var r: (x: T) => T;
return r;
}
var r1 = foo('', (x: string) => '', (x: Object) => null); // any => any
var r1ii = foo('', (x) => '', (x) => null); // string => string
var r2 = foo('', (x: string) => '', (x: Object) => ''); // string => string
var r3 = foo(null, (x: Object) => '', (x: string) => ''); // Object => Object
var r4 = foo(null, (x) => '', (x) => ''); // any => any
var r5 = foo(new Object(), (x) => '', (x) => ''); // Object => Object
enum E { A }
enum F { A }
var r6 = foo(E.A, (x: number) => E.A, (x: F) => F.A); // number => number
function foo2<T, U>(x: T, a: (x: T) => U, b: (x: T) => U) {
var r: (x: T) => U;
return r;
}
var r8 = foo2('', (x) => '', (x) => null); // string => string
var r9 = foo2(null, (x) => '', (x) => ''); // any => any
var r10 = foo2(null, (x: Object) => '', (x: string) => ''); // Object => Object
var x: (a: string) => boolean;
var r11 = foo2(x, (a1: (y: string) => string) => (n: Object) => 1, (a2: (z: string) => string) => 2); // {} => {}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2346: Supplied parameters do not match any signature of call target.
var r12 = foo2(x, (a1: (y: string) => boolean) => (n: Object) => 1, (a2: (z: string) => boolean) => 2); // (string => boolean) => {}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2346: Supplied parameters do not match any signature of call target.

View file

@ -1,202 +0,0 @@
=== tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithGenericSignatureArguments3.ts ===
// When a function expression is inferentially typed (section 4.9.3) and a type assigned to a parameter in that expression references type parameters for which inferences are being made,
// the corresponding inferred type arguments to become fixed and no further candidate inferences are made for them.
function foo<T>(x: T, a: (x: T) => T, b: (x: T) => T) {
>foo : <T>(x: T, a: (x: T) => T, b: (x: T) => T) => (x: T) => T
>T : T
>x : T
>T : T
>a : (x: T) => T
>x : T
>T : T
>T : T
>b : (x: T) => T
>x : T
>T : T
>T : T
var r: (x: T) => T;
>r : (x: T) => T
>x : T
>T : T
>T : T
return r;
>r : (x: T) => T
}
var r1 = foo('', (x: string) => '', (x: Object) => null); // any => any
>r1 : (x: any) => any
>foo('', (x: string) => '', (x: Object) => null) : (x: any) => any
>foo : <T>(x: T, a: (x: T) => T, b: (x: T) => T) => (x: T) => T
>(x: string) => '' : (x: string) => string
>x : string
>(x: Object) => null : (x: Object) => any
>x : Object
>Object : Object
var r1ii = foo('', (x) => '', (x) => null); // string => string
>r1ii : (x: string) => string
>foo('', (x) => '', (x) => null) : (x: string) => string
>foo : <T>(x: T, a: (x: T) => T, b: (x: T) => T) => (x: T) => T
>(x) => '' : (x: string) => string
>x : string
>(x) => null : (x: string) => any
>x : string
var r2 = foo('', (x: string) => '', (x: Object) => ''); // string => string
>r2 : (x: Object) => Object
>foo('', (x: string) => '', (x: Object) => '') : (x: Object) => Object
>foo : <T>(x: T, a: (x: T) => T, b: (x: T) => T) => (x: T) => T
>(x: string) => '' : (x: string) => string
>x : string
>(x: Object) => '' : (x: Object) => string
>x : Object
>Object : Object
var r3 = foo(null, (x: Object) => '', (x: string) => ''); // Object => Object
>r3 : (x: Object) => Object
>foo(null, (x: Object) => '', (x: string) => '') : (x: Object) => Object
>foo : <T>(x: T, a: (x: T) => T, b: (x: T) => T) => (x: T) => T
>(x: Object) => '' : (x: Object) => string
>x : Object
>Object : Object
>(x: string) => '' : (x: string) => string
>x : string
var r4 = foo(null, (x) => '', (x) => ''); // any => any
>r4 : (x: any) => any
>foo(null, (x) => '', (x) => '') : (x: any) => any
>foo : <T>(x: T, a: (x: T) => T, b: (x: T) => T) => (x: T) => T
>(x) => '' : (x: any) => string
>x : any
>(x) => '' : (x: any) => string
>x : any
var r5 = foo(new Object(), (x) => '', (x) => ''); // Object => Object
>r5 : (x: Object) => Object
>foo(new Object(), (x) => '', (x) => '') : (x: Object) => Object
>foo : <T>(x: T, a: (x: T) => T, b: (x: T) => T) => (x: T) => T
>new Object() : Object
>Object : { (): any; (value: any): any; new (value?: any): Object; prototype: Object; getPrototypeOf(o: any): any; getOwnPropertyDescriptor(o: any, p: string): PropertyDescriptor; getOwnPropertyNames(o: any): string[]; create(o: any, properties?: PropertyDescriptorMap): any; defineProperty(o: any, p: string, attributes: PropertyDescriptor): any; defineProperties(o: any, properties: PropertyDescriptorMap): any; seal(o: any): any; freeze(o: any): any; preventExtensions(o: any): any; isSealed(o: any): boolean; isFrozen(o: any): boolean; isExtensible(o: any): boolean; keys(o: any): string[]; }
>(x) => '' : (x: Object) => string
>x : Object
>(x) => '' : (x: Object) => string
>x : Object
enum E { A }
>E : E
>A : E
enum F { A }
>F : F
>A : F
var r6 = foo(E.A, (x: number) => E.A, (x: F) => F.A); // number => number
>r6 : (x: number) => number
>foo(E.A, (x: number) => E.A, (x: F) => F.A) : (x: number) => number
>foo : <T>(x: T, a: (x: T) => T, b: (x: T) => T) => (x: T) => T
>E.A : E
>E : typeof E
>A : E
>(x: number) => E.A : (x: number) => E
>x : number
>E.A : E
>E : typeof E
>A : E
>(x: F) => F.A : (x: F) => F
>x : F
>F : F
>F.A : F
>F : typeof F
>A : F
function foo2<T, U>(x: T, a: (x: T) => U, b: (x: T) => U) {
>foo2 : <T, U>(x: T, a: (x: T) => U, b: (x: T) => U) => (x: T) => U
>T : T
>U : U
>x : T
>T : T
>a : (x: T) => U
>x : T
>T : T
>U : U
>b : (x: T) => U
>x : T
>T : T
>U : U
var r: (x: T) => U;
>r : (x: T) => U
>x : T
>T : T
>U : U
return r;
>r : (x: T) => U
}
var r8 = foo2('', (x) => '', (x) => null); // string => string
>r8 : (x: string) => any
>foo2('', (x) => '', (x) => null) : (x: string) => any
>foo2 : <T, U>(x: T, a: (x: T) => U, b: (x: T) => U) => (x: T) => U
>(x) => '' : (x: string) => string
>x : string
>(x) => null : (x: string) => any
>x : string
var r9 = foo2(null, (x) => '', (x) => ''); // any => any
>r9 : (x: any) => string
>foo2(null, (x) => '', (x) => '') : (x: any) => string
>foo2 : <T, U>(x: T, a: (x: T) => U, b: (x: T) => U) => (x: T) => U
>(x) => '' : (x: any) => string
>x : any
>(x) => '' : (x: any) => string
>x : any
var r10 = foo2(null, (x: Object) => '', (x: string) => ''); // Object => Object
>r10 : (x: Object) => string
>foo2(null, (x: Object) => '', (x: string) => '') : (x: Object) => string
>foo2 : <T, U>(x: T, a: (x: T) => U, b: (x: T) => U) => (x: T) => U
>(x: Object) => '' : (x: Object) => string
>x : Object
>Object : Object
>(x: string) => '' : (x: string) => string
>x : string
var x: (a: string) => boolean;
>x : (a: string) => boolean
>a : string
var r11 = foo2(x, (a1: (y: string) => string) => (n: Object) => 1, (a2: (z: string) => string) => 2); // {} => {}
>r11 : (x: {}) => {}
>foo2(x, (a1: (y: string) => string) => (n: Object) => 1, (a2: (z: string) => string) => 2) : (x: {}) => {}
>foo2 : <T, U>(x: T, a: (x: T) => U, b: (x: T) => U) => (x: T) => U
>x : (a: string) => boolean
>(a1: (y: string) => string) => (n: Object) => 1 : (a1: (y: string) => string) => (n: Object) => number
>a1 : (y: string) => string
>y : string
>(n: Object) => 1 : (n: Object) => number
>n : Object
>Object : Object
>(a2: (z: string) => string) => 2 : (a2: (z: string) => string) => number
>a2 : (z: string) => string
>z : string
var r12 = foo2(x, (a1: (y: string) => boolean) => (n: Object) => 1, (a2: (z: string) => boolean) => 2); // (string => boolean) => {}
>r12 : (x: (a: string) => boolean) => {}
>foo2(x, (a1: (y: string) => boolean) => (n: Object) => 1, (a2: (z: string) => boolean) => 2) : (x: (a: string) => boolean) => {}
>foo2 : <T, U>(x: T, a: (x: T) => U, b: (x: T) => U) => (x: T) => U
>x : (a: string) => boolean
>(a1: (y: string) => boolean) => (n: Object) => 1 : (a1: (y: string) => boolean) => (n: Object) => number
>a1 : (y: string) => boolean
>y : string
>(n: Object) => 1 : (n: Object) => number
>n : Object
>Object : Object
>(a2: (z: string) => boolean) => 2 : (a2: (z: string) => boolean) => number
>a2 : (z: string) => boolean
>z : string

View file

@ -0,0 +1,14 @@
tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithObjectLiteralArgs.ts(5,9): error TS2346: Supplied parameters do not match any signature of call target.
==== tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithObjectLiteralArgs.ts (1 errors) ====
function foo<T>(x: { bar: T; baz: T }) {
return x;
}
var r = foo({ bar: 1, baz: '' }); // T = {}
~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2346: Supplied parameters do not match any signature of call target.
var r2 = foo({ bar: 1, baz: 1 }); // T = number
var r3 = foo({ bar: foo, baz: foo }); // T = typeof foo
var r4 = foo<Object>({ bar: 1, baz: '' }); // T = Object

View file

@ -1,49 +0,0 @@
=== tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithObjectLiteralArgs.ts ===
function foo<T>(x: { bar: T; baz: T }) {
>foo : <T>(x: { bar: T; baz: T; }) => { bar: T; baz: T; }
>T : T
>x : { bar: T; baz: T; }
>bar : T
>T : T
>baz : T
>T : T
return x;
>x : { bar: T; baz: T; }
}
var r = foo({ bar: 1, baz: '' }); // T = {}
>r : { bar: {}; baz: {}; }
>foo({ bar: 1, baz: '' }) : { bar: {}; baz: {}; }
>foo : <T>(x: { bar: T; baz: T; }) => { bar: T; baz: T; }
>{ bar: 1, baz: '' } : { bar: number; baz: string; }
>bar : number
>baz : string
var r2 = foo({ bar: 1, baz: 1 }); // T = number
>r2 : { bar: number; baz: number; }
>foo({ bar: 1, baz: 1 }) : { bar: number; baz: number; }
>foo : <T>(x: { bar: T; baz: T; }) => { bar: T; baz: T; }
>{ bar: 1, baz: 1 } : { bar: number; baz: number; }
>bar : number
>baz : number
var r3 = foo({ bar: foo, baz: foo }); // T = typeof foo
>r3 : { bar: <T>(x: { bar: T; baz: T; }) => { bar: T; baz: T; }; baz: <T>(x: { bar: T; baz: T; }) => { bar: T; baz: T; }; }
>foo({ bar: foo, baz: foo }) : { bar: <T>(x: { bar: T; baz: T; }) => { bar: T; baz: T; }; baz: <T>(x: { bar: T; baz: T; }) => { bar: T; baz: T; }; }
>foo : <T>(x: { bar: T; baz: T; }) => { bar: T; baz: T; }
>{ bar: foo, baz: foo } : { bar: <T>(x: { bar: T; baz: T; }) => { bar: T; baz: T; }; baz: <T>(x: { bar: T; baz: T; }) => { bar: T; baz: T; }; }
>bar : <T>(x: { bar: T; baz: T; }) => { bar: T; baz: T; }
>foo : <T>(x: { bar: T; baz: T; }) => { bar: T; baz: T; }
>baz : <T>(x: { bar: T; baz: T; }) => { bar: T; baz: T; }
>foo : <T>(x: { bar: T; baz: T; }) => { bar: T; baz: T; }
var r4 = foo<Object>({ bar: 1, baz: '' }); // T = Object
>r4 : { bar: Object; baz: Object; }
>foo<Object>({ bar: 1, baz: '' }) : { bar: Object; baz: Object; }
>foo : <T>(x: { bar: T; baz: T; }) => { bar: T; baz: T; }
>Object : Object
>{ bar: 1, baz: '' } : { bar: number; baz: string; }
>bar : number
>baz : string

View file

@ -1,3 +1,4 @@
tests/cases/compiler/genericCallWithObjectLiteralArguments1.ts(2,9): error TS2346: Supplied parameters do not match any signature of call target.
tests/cases/compiler/genericCallWithObjectLiteralArguments1.ts(4,22): error TS2345: Argument of type '{ x: number; y: string; }' is not assignable to parameter of type '{ x: number; y: number; }'.
Types of property 'y' are incompatible:
Type 'string' is not assignable to type 'number'.
@ -12,9 +13,11 @@ tests/cases/compiler/genericCallWithObjectLiteralArguments1.ts(7,22): error TS23
Type 'number' is not assignable to type 'string'.
==== tests/cases/compiler/genericCallWithObjectLiteralArguments1.ts (4 errors) ====
==== tests/cases/compiler/genericCallWithObjectLiteralArguments1.ts (5 errors) ====
function foo<T>(n: { x: T; y: T }, m: T) { return m; }
var x = foo({ x: 3, y: "" }, 4); // no error, x is Object, the best common type
~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2346: Supplied parameters do not match any signature of call target.
// these are all errors
var x2 = foo<number>({ x: 3, y: "" }, 4);
~~~~~~~~~~~~~~~

View file

@ -0,0 +1,27 @@
tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithObjectTypeArgs.ts(20,9): error TS2346: Supplied parameters do not match any signature of call target.
==== tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithObjectTypeArgs.ts (1 errors) ====
class C {
private x: string;
}
class D {
private x: string;
}
class X<T> {
x: T;
}
function foo<T>(t: X<T>, t2: X<T>) {
var x: T;
return x;
}
var c1 = new X<C>();
var d1 = new X<D>();
var r = foo(c1, d1); // error
~~~~~~~~~~~
!!! error TS2346: Supplied parameters do not match any signature of call target.
var r2 = foo(c1, c1); // ok

View file

@ -1,68 +0,0 @@
=== tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithObjectTypeArgs.ts ===
class C {
>C : C
private x: string;
>x : string
}
class D {
>D : D
private x: string;
>x : string
}
class X<T> {
>X : X<T>
>T : T
x: T;
>x : T
>T : T
}
function foo<T>(t: X<T>, t2: X<T>) {
>foo : <T>(t: X<T>, t2: X<T>) => T
>T : T
>t : X<T>
>X : X<T>
>T : T
>t2 : X<T>
>X : X<T>
>T : T
var x: T;
>x : T
>T : T
return x;
>x : T
}
var c1 = new X<C>();
>c1 : X<C>
>new X<C>() : X<C>
>X : typeof X
>C : C
var d1 = new X<D>();
>d1 : X<D>
>new X<D>() : X<D>
>X : typeof X
>D : D
var r = foo(c1, d1); // error
>r : {}
>foo(c1, d1) : {}
>foo : <T>(t: X<T>, t2: X<T>) => T
>c1 : X<C>
>d1 : X<D>
var r2 = foo(c1, c1); // ok
>r2 : C
>foo(c1, c1) : C
>foo : <T>(t: X<T>, t2: X<T>) => T
>c1 : X<C>
>c1 : X<C>

View file

@ -22,7 +22,7 @@ class Derived2 extends Base {
// returns {}[]
function f<T extends Base, U extends Base>(a: { x: T; y: U }) {
>f : <T extends Base, U extends Base>(a: { x: T; y: U; }) => {}[]
>f : <T extends Base, U extends Base>(a: { x: T; y: U; }) => Array<T | U>
>T : T
>Base : Base
>U : U
@ -34,7 +34,7 @@ function f<T extends Base, U extends Base>(a: { x: T; y: U }) {
>U : U
return [a.x, a.y];
>[a.x, a.y] : {}[]
>[a.x, a.y] : Array<T | U>
>a.x : T
>a : { x: T; y: U; }
>x : T
@ -44,9 +44,9 @@ function f<T extends Base, U extends Base>(a: { x: T; y: U }) {
}
var r = f({ x: new Derived(), y: new Derived2() }); // {}[]
>r : {}[]
>f({ x: new Derived(), y: new Derived2() }) : {}[]
>f : <T extends Base, U extends Base>(a: { x: T; y: U; }) => {}[]
>r : Array<Derived | Derived2>
>f({ x: new Derived(), y: new Derived2() }) : Array<Derived | Derived2>
>f : <T extends Base, U extends Base>(a: { x: T; y: U; }) => Array<T | U>
>{ x: new Derived(), y: new Derived2() } : { x: Derived; y: Derived2; }
>x : Derived
>new Derived() : Derived
@ -56,9 +56,9 @@ var r = f({ x: new Derived(), y: new Derived2() }); // {}[]
>Derived2 : typeof Derived2
var r2 = f({ x: new Base(), y: new Derived2() }); // {}[]
>r2 : {}[]
>f({ x: new Base(), y: new Derived2() }) : {}[]
>f : <T extends Base, U extends Base>(a: { x: T; y: U; }) => {}[]
>r2 : Base[]
>f({ x: new Base(), y: new Derived2() }) : Base[]
>f : <T extends Base, U extends Base>(a: { x: T; y: U; }) => Array<T | U>
>{ x: new Base(), y: new Derived2() } : { x: Base; y: Derived2; }
>x : Base
>new Base() : Base

View file

@ -1,7 +1,8 @@
tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithObjectTypeArgsAndConstraints3.ts(18,10): error TS2346: Supplied parameters do not match any signature of call target.
tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithObjectTypeArgsAndConstraints3.ts(20,29): error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list.
==== tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithObjectTypeArgsAndConstraints3.ts (1 errors) ====
==== tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithObjectTypeArgsAndConstraints3.ts (2 errors) ====
// Generic call with constraints infering type parameter from object member properties
class Base {
@ -20,6 +21,8 @@ tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithObj
}
var r1 = f({ x: new Derived(), y: new Derived2() }); // ok, both extend Base
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2346: Supplied parameters do not match any signature of call target.
function f2<T extends Base, U extends { x: T; y: T }>(a: U) {
~~~~~~~~~~~~~~~~~~~~~~~~

View file

@ -0,0 +1,54 @@
tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithOverloadedConstructorTypedArguments.ts(36,14): error TS2346: Supplied parameters do not match any signature of call target.
==== tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithOverloadedConstructorTypedArguments.ts (1 errors) ====
// Function typed arguments with multiple signatures must be passed an implementation that matches all of them
// Inferences are made quadratic-pairwise to and from these overload sets
module NonGenericParameter {
var a: {
new(x: boolean): boolean;
new(x: string): string;
}
function foo4(cb: typeof a) {
return new cb(null);
}
var r = foo4(a);
var b: { new <T>(x: T): T };
var r2 = foo4(b);
}
module GenericParameter {
function foo5<T>(cb: { new(x: T): string; new(x: number): T }) {
return cb;
}
var a: {
new (x: boolean): string;
new (x: number): boolean;
}
var r5 = foo5(a); // new{} => string; new(x:number) => {}
var b: { new<T>(x: T): string; new<T>(x: number): T; }
var r7 = foo5(b); // new any => string; new(x:number) => any
function foo6<T>(cb: { new(x: T): string; new(x: T, y?: T): string }) {
return cb;
}
var r8 = foo6(a); // new{} => string; new(x:{}, y?:{}) => string
~~~~~~~
!!! error TS2346: Supplied parameters do not match any signature of call target.
var r9 = foo6(b); // new any => string; new(x:any, y?:any) => string
function foo7<T>(x:T, cb: { new(x: T): string; new(x: T, y?: T): string }) {
return cb;
}
var r13 = foo7(1, b); // new any => string; new(x:any, y?:any) => string
var c: { new <T>(x: T): string; <T>(x: number): T; }
var c2: { new <T>(x: T): string; new<T>(x: number): T; }
var r14 = foo7(1, c); // new any => string; new(x:any, y?:any) => string
var r15 = foo7(1, c2); // new any => string; new(x:any, y?:any) => string
}

View file

@ -1,173 +0,0 @@
=== tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithOverloadedConstructorTypedArguments.ts ===
// Function typed arguments with multiple signatures must be passed an implementation that matches all of them
// Inferences are made quadratic-pairwise to and from these overload sets
module NonGenericParameter {
>NonGenericParameter : typeof NonGenericParameter
var a: {
>a : { new (x: boolean): boolean; new (x: string): string; }
new(x: boolean): boolean;
>x : boolean
new(x: string): string;
>x : string
}
function foo4(cb: typeof a) {
>foo4 : (cb: { new (x: boolean): boolean; new (x: string): string; }) => boolean
>cb : { new (x: boolean): boolean; new (x: string): string; }
>a : { new (x: boolean): boolean; new (x: string): string; }
return new cb(null);
>new cb(null) : boolean
>cb : { new (x: boolean): boolean; new (x: string): string; }
}
var r = foo4(a);
>r : boolean
>foo4(a) : boolean
>foo4 : (cb: { new (x: boolean): boolean; new (x: string): string; }) => boolean
>a : { new (x: boolean): boolean; new (x: string): string; }
var b: { new <T>(x: T): T };
>b : new <T>(x: T) => T
>T : T
>x : T
>T : T
>T : T
var r2 = foo4(b);
>r2 : boolean
>foo4(b) : boolean
>foo4 : (cb: { new (x: boolean): boolean; new (x: string): string; }) => boolean
>b : new <T>(x: T) => T
}
module GenericParameter {
>GenericParameter : typeof GenericParameter
function foo5<T>(cb: { new(x: T): string; new(x: number): T }) {
>foo5 : <T>(cb: { new (x: T): string; new (x: number): T; }) => { new (x: T): string; new (x: number): T; }
>T : T
>cb : { new (x: T): string; new (x: number): T; }
>x : T
>T : T
>x : number
>T : T
return cb;
>cb : { new (x: T): string; new (x: number): T; }
}
var a: {
>a : { new (x: boolean): string; new (x: number): boolean; }
new (x: boolean): string;
>x : boolean
new (x: number): boolean;
>x : number
}
var r5 = foo5(a); // new{} => string; new(x:number) => {}
>r5 : { new (x: boolean): string; new (x: number): boolean; }
>foo5(a) : { new (x: boolean): string; new (x: number): boolean; }
>foo5 : <T>(cb: { new (x: T): string; new (x: number): T; }) => { new (x: T): string; new (x: number): T; }
>a : { new (x: boolean): string; new (x: number): boolean; }
var b: { new<T>(x: T): string; new<T>(x: number): T; }
>b : { new <T>(x: T): string; new <T>(x: number): T; }
>T : T
>x : T
>T : T
>T : T
>x : number
>T : T
var r7 = foo5(b); // new any => string; new(x:number) => any
>r7 : { new (x: any): string; new (x: number): any; }
>foo5(b) : { new (x: any): string; new (x: number): any; }
>foo5 : <T>(cb: { new (x: T): string; new (x: number): T; }) => { new (x: T): string; new (x: number): T; }
>b : { new <T>(x: T): string; new <T>(x: number): T; }
function foo6<T>(cb: { new(x: T): string; new(x: T, y?: T): string }) {
>foo6 : <T>(cb: { new (x: T): string; new (x: T, y?: T): string; }) => { new (x: T): string; new (x: T, y?: T): string; }
>T : T
>cb : { new (x: T): string; new (x: T, y?: T): string; }
>x : T
>T : T
>x : T
>T : T
>y : T
>T : T
return cb;
>cb : { new (x: T): string; new (x: T, y?: T): string; }
}
var r8 = foo6(a); // new{} => string; new(x:{}, y?:{}) => string
>r8 : { new (x: {}): string; new (x: {}, y?: {}): string; }
>foo6(a) : { new (x: {}): string; new (x: {}, y?: {}): string; }
>foo6 : <T>(cb: { new (x: T): string; new (x: T, y?: T): string; }) => { new (x: T): string; new (x: T, y?: T): string; }
>a : { new (x: boolean): string; new (x: number): boolean; }
var r9 = foo6(b); // new any => string; new(x:any, y?:any) => string
>r9 : { new (x: any): string; new (x: any, y?: any): string; }
>foo6(b) : { new (x: any): string; new (x: any, y?: any): string; }
>foo6 : <T>(cb: { new (x: T): string; new (x: T, y?: T): string; }) => { new (x: T): string; new (x: T, y?: T): string; }
>b : { new <T>(x: T): string; new <T>(x: number): T; }
function foo7<T>(x:T, cb: { new(x: T): string; new(x: T, y?: T): string }) {
>foo7 : <T>(x: T, cb: { new (x: T): string; new (x: T, y?: T): string; }) => { new (x: T): string; new (x: T, y?: T): string; }
>T : T
>x : T
>T : T
>cb : { new (x: T): string; new (x: T, y?: T): string; }
>x : T
>T : T
>x : T
>T : T
>y : T
>T : T
return cb;
>cb : { new (x: T): string; new (x: T, y?: T): string; }
}
var r13 = foo7(1, b); // new any => string; new(x:any, y?:any) => string
>r13 : { new (x: any): string; new (x: any, y?: any): string; }
>foo7(1, b) : { new (x: any): string; new (x: any, y?: any): string; }
>foo7 : <T>(x: T, cb: { new (x: T): string; new (x: T, y?: T): string; }) => { new (x: T): string; new (x: T, y?: T): string; }
>b : { new <T>(x: T): string; new <T>(x: number): T; }
var c: { new <T>(x: T): string; <T>(x: number): T; }
>c : { <T>(x: number): T; new <T>(x: T): string; }
>T : T
>x : T
>T : T
>T : T
>x : number
>T : T
var c2: { new <T>(x: T): string; new<T>(x: number): T; }
>c2 : { new <T>(x: T): string; new <T>(x: number): T; }
>T : T
>x : T
>T : T
>T : T
>x : number
>T : T
var r14 = foo7(1, c); // new any => string; new(x:any, y?:any) => string
>r14 : { new (x: any): string; new (x: any, y?: any): string; }
>foo7(1, c) : { new (x: any): string; new (x: any, y?: any): string; }
>foo7 : <T>(x: T, cb: { new (x: T): string; new (x: T, y?: T): string; }) => { new (x: T): string; new (x: T, y?: T): string; }
>c : { <T>(x: number): T; new <T>(x: T): string; }
var r15 = foo7(1, c2); // new any => string; new(x:any, y?:any) => string
>r15 : { new (x: any): string; new (x: any, y?: any): string; }
>foo7(1, c2) : { new (x: any): string; new (x: any, y?: any): string; }
>foo7 : <T>(x: T, cb: { new (x: T): string; new (x: T, y?: T): string; }) => { new (x: T): string; new (x: T, y?: T): string; }
>c2 : { new <T>(x: T): string; new <T>(x: number): T; }
}

View file

@ -0,0 +1,81 @@
tests/cases/conformance/types/typeRelationships/typeInference/genericClassWithFunctionTypedMemberArguments.ts(57,19): error TS2346: Supplied parameters do not match any signature of call target.
tests/cases/conformance/types/typeRelationships/typeInference/genericClassWithFunctionTypedMemberArguments.ts(60,19): error TS2346: Supplied parameters do not match any signature of call target.
tests/cases/conformance/types/typeRelationships/typeInference/genericClassWithFunctionTypedMemberArguments.ts(61,20): error TS2346: Supplied parameters do not match any signature of call target.
tests/cases/conformance/types/typeRelationships/typeInference/genericClassWithFunctionTypedMemberArguments.ts(62,30): error TS2345: Argument of type '(a: number) => string' is not assignable to parameter of type '(a: number) => number'.
Type 'string' is not assignable to type 'number'.
==== tests/cases/conformance/types/typeRelationships/typeInference/genericClassWithFunctionTypedMemberArguments.ts (4 errors) ====
// Generic functions used as arguments for function typed parameters are not used to make inferences from
// Using function arguments, no errors expected
module ImmediatelyFix {
class C<T> {
foo<T>(x: (a: T) => T) {
return x(null);
}
}
var c = new C<number>();
var r = c.foo(<U>(x: U) => ''); // {}
var r2 = c.foo<string>(<U>(x: U) => ''); // string
var r3 = c.foo(x => ''); // {}
class C2<T> {
foo(x: (a: T) => T) {
return x(null);
}
}
var c2 = new C2<number>();
var ra = c2.foo(<U>(x: U) => 1); // number
var r3a = c2.foo(x => 1); // number
}
module WithCandidates {
class C<T> {
foo2<T, U>(x: T, cb: (a: T) => U) {
return cb(x);
}
}
var c: C<number>;
var r4 = c.foo2(1, function <Z>(a: Z) { return '' }); // string, contextual signature instantiation is applied to generic functions
var r5 = c.foo2(1, (a) => ''); // string
var r6 = c.foo2<string, number>('', <Z>(a: Z) => 1); // number
class C2<T, U> {
foo3(x: T, cb: (a: T) => U, y: U) {
return cb(x);
}
}
var c2: C2<number, string>;
var r7 = c2.foo3(1, <Z>(a: Z) => '', ''); // string
var r8 = c2.foo3(1, function (a) { return '' }, ''); // string
class C3<T, U> {
foo3<T,U>(x: T, cb: (a: T) => U, y: U) {
return cb(x);
}
}
var c3: C3<number, string>;
function other<T, U>(t: T, u: U) {
var r10 = c.foo2(1, (x: T) => ''); // string, non-generic signature allows inferences to be made
~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2346: Supplied parameters do not match any signature of call target.
var r10 = c.foo2(1, (x) => ''); // string
var r11 = c3.foo3(1, (x: T) => '', ''); // string
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2346: Supplied parameters do not match any signature of call target.
var r11b = c3.foo3(1, (x: T) => '', 1); // {}
~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2346: Supplied parameters do not match any signature of call target.
var r12 = c3.foo3(1, function (a) { return '' }, 1); // {}
~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2345: Argument of type '(a: number) => string' is not assignable to parameter of type '(a: number) => number'.
!!! error TS2345: Type 'string' is not assignable to type 'number'.
}
}

View file

@ -1,297 +0,0 @@
=== tests/cases/conformance/types/typeRelationships/typeInference/genericClassWithFunctionTypedMemberArguments.ts ===
// Generic functions used as arguments for function typed parameters are not used to make inferences from
// Using function arguments, no errors expected
module ImmediatelyFix {
>ImmediatelyFix : typeof ImmediatelyFix
class C<T> {
>C : C<T>
>T : T
foo<T>(x: (a: T) => T) {
>foo : <T>(x: (a: T) => T) => T
>T : T
>x : (a: T) => T
>a : T
>T : T
>T : T
return x(null);
>x(null) : T
>x : (a: T) => T
}
}
var c = new C<number>();
>c : C<number>
>new C<number>() : C<number>
>C : typeof C
var r = c.foo(<U>(x: U) => ''); // {}
>r : {}
>c.foo(<U>(x: U) => '') : {}
>c.foo : <T>(x: (a: T) => T) => T
>c : C<number>
>foo : <T>(x: (a: T) => T) => T
><U>(x: U) => '' : <U>(x: U) => string
>U : U
>x : U
>U : U
var r2 = c.foo<string>(<U>(x: U) => ''); // string
>r2 : string
>c.foo<string>(<U>(x: U) => '') : string
>c.foo : <T>(x: (a: T) => T) => T
>c : C<number>
>foo : <T>(x: (a: T) => T) => T
><U>(x: U) => '' : <U>(x: U) => string
>U : U
>x : U
>U : U
var r3 = c.foo(x => ''); // {}
>r3 : {}
>c.foo(x => '') : {}
>c.foo : <T>(x: (a: T) => T) => T
>c : C<number>
>foo : <T>(x: (a: T) => T) => T
>x => '' : (x: {}) => string
>x : {}
class C2<T> {
>C2 : C2<T>
>T : T
foo(x: (a: T) => T) {
>foo : (x: (a: T) => T) => T
>x : (a: T) => T
>a : T
>T : T
>T : T
return x(null);
>x(null) : T
>x : (a: T) => T
}
}
var c2 = new C2<number>();
>c2 : C2<number>
>new C2<number>() : C2<number>
>C2 : typeof C2
var ra = c2.foo(<U>(x: U) => 1); // number
>ra : number
>c2.foo(<U>(x: U) => 1) : number
>c2.foo : (x: (a: number) => number) => number
>c2 : C2<number>
>foo : (x: (a: number) => number) => number
><U>(x: U) => 1 : <U>(x: U) => number
>U : U
>x : U
>U : U
var r3a = c2.foo(x => 1); // number
>r3a : number
>c2.foo(x => 1) : number
>c2.foo : (x: (a: number) => number) => number
>c2 : C2<number>
>foo : (x: (a: number) => number) => number
>x => 1 : (x: number) => number
>x : number
}
module WithCandidates {
>WithCandidates : typeof WithCandidates
class C<T> {
>C : C<T>
>T : T
foo2<T, U>(x: T, cb: (a: T) => U) {
>foo2 : <T, U>(x: T, cb: (a: T) => U) => U
>T : T
>U : U
>x : T
>T : T
>cb : (a: T) => U
>a : T
>T : T
>U : U
return cb(x);
>cb(x) : U
>cb : (a: T) => U
>x : T
}
}
var c: C<number>;
>c : C<number>
>C : C<T>
var r4 = c.foo2(1, function <Z>(a: Z) { return '' }); // string, contextual signature instantiation is applied to generic functions
>r4 : string
>c.foo2(1, function <Z>(a: Z) { return '' }) : string
>c.foo2 : <T, U>(x: T, cb: (a: T) => U) => U
>c : C<number>
>foo2 : <T, U>(x: T, cb: (a: T) => U) => U
>function <Z>(a: Z) { return '' } : <Z>(a: Z) => string
>Z : Z
>a : Z
>Z : Z
var r5 = c.foo2(1, (a) => ''); // string
>r5 : string
>c.foo2(1, (a) => '') : string
>c.foo2 : <T, U>(x: T, cb: (a: T) => U) => U
>c : C<number>
>foo2 : <T, U>(x: T, cb: (a: T) => U) => U
>(a) => '' : (a: number) => string
>a : number
var r6 = c.foo2<string, number>('', <Z>(a: Z) => 1); // number
>r6 : number
>c.foo2<string, number>('', <Z>(a: Z) => 1) : number
>c.foo2 : <T, U>(x: T, cb: (a: T) => U) => U
>c : C<number>
>foo2 : <T, U>(x: T, cb: (a: T) => U) => U
><Z>(a: Z) => 1 : <Z>(a: Z) => number
>Z : Z
>a : Z
>Z : Z
class C2<T, U> {
>C2 : C2<T, U>
>T : T
>U : U
foo3(x: T, cb: (a: T) => U, y: U) {
>foo3 : (x: T, cb: (a: T) => U, y: U) => U
>x : T
>T : T
>cb : (a: T) => U
>a : T
>T : T
>U : U
>y : U
>U : U
return cb(x);
>cb(x) : U
>cb : (a: T) => U
>x : T
}
}
var c2: C2<number, string>;
>c2 : C2<number, string>
>C2 : C2<T, U>
var r7 = c2.foo3(1, <Z>(a: Z) => '', ''); // string
>r7 : string
>c2.foo3(1, <Z>(a: Z) => '', '') : string
>c2.foo3 : (x: number, cb: (a: number) => string, y: string) => string
>c2 : C2<number, string>
>foo3 : (x: number, cb: (a: number) => string, y: string) => string
><Z>(a: Z) => '' : <Z>(a: Z) => string
>Z : Z
>a : Z
>Z : Z
var r8 = c2.foo3(1, function (a) { return '' }, ''); // string
>r8 : string
>c2.foo3(1, function (a) { return '' }, '') : string
>c2.foo3 : (x: number, cb: (a: number) => string, y: string) => string
>c2 : C2<number, string>
>foo3 : (x: number, cb: (a: number) => string, y: string) => string
>function (a) { return '' } : (a: number) => string
>a : number
class C3<T, U> {
>C3 : C3<T, U>
>T : T
>U : U
foo3<T,U>(x: T, cb: (a: T) => U, y: U) {
>foo3 : <T, U>(x: T, cb: (a: T) => U, y: U) => U
>T : T
>U : U
>x : T
>T : T
>cb : (a: T) => U
>a : T
>T : T
>U : U
>y : U
>U : U
return cb(x);
>cb(x) : U
>cb : (a: T) => U
>x : T
}
}
var c3: C3<number, string>;
>c3 : C3<number, string>
>C3 : C3<T, U>
function other<T, U>(t: T, u: U) {
>other : <T, U>(t: T, u: U) => void
>T : T
>U : U
>t : T
>T : T
>u : U
>U : U
var r10 = c.foo2(1, (x: T) => ''); // string, non-generic signature allows inferences to be made
>r10 : string
>c.foo2(1, (x: T) => '') : string
>c.foo2 : <T, U>(x: T, cb: (a: T) => U) => U
>c : C<number>
>foo2 : <T, U>(x: T, cb: (a: T) => U) => U
>(x: T) => '' : (x: T) => string
>x : T
>T : T
var r10 = c.foo2(1, (x) => ''); // string
>r10 : string
>c.foo2(1, (x) => '') : string
>c.foo2 : <T, U>(x: T, cb: (a: T) => U) => U
>c : C<number>
>foo2 : <T, U>(x: T, cb: (a: T) => U) => U
>(x) => '' : (x: number) => string
>x : number
var r11 = c3.foo3(1, (x: T) => '', ''); // string
>r11 : string
>c3.foo3(1, (x: T) => '', '') : string
>c3.foo3 : <T, U>(x: T, cb: (a: T) => U, y: U) => U
>c3 : C3<number, string>
>foo3 : <T, U>(x: T, cb: (a: T) => U, y: U) => U
>(x: T) => '' : (x: T) => string
>x : T
>T : T
var r11b = c3.foo3(1, (x: T) => '', 1); // {}
>r11b : {}
>c3.foo3(1, (x: T) => '', 1) : {}
>c3.foo3 : <T, U>(x: T, cb: (a: T) => U, y: U) => U
>c3 : C3<number, string>
>foo3 : <T, U>(x: T, cb: (a: T) => U, y: U) => U
>(x: T) => '' : (x: T) => string
>x : T
>T : T
var r12 = c3.foo3(1, function (a) { return '' }, 1); // {}
>r12 : {}
>c3.foo3(1, function (a) { return '' }, 1) : {}
>c3.foo3 : <T, U>(x: T, cb: (a: T) => U, y: U) => U
>c3 : C3<number, string>
>foo3 : <T, U>(x: T, cb: (a: T) => U, y: U) => U
>function (a) { return '' } : (a: number) => string
>a : number
}
}

View file

@ -1,10 +1,14 @@
tests/cases/compiler/genericRestArgs.ts(2,12): error TS2346: Supplied parameters do not match any signature of call target.
tests/cases/compiler/genericRestArgs.ts(5,34): error TS2345: Argument of type 'string' is not assignable to parameter of type 'number'.
tests/cases/compiler/genericRestArgs.ts(10,12): error TS2346: Supplied parameters do not match any signature of call target.
tests/cases/compiler/genericRestArgs.ts(12,30): error TS2345: Argument of type 'number' is not assignable to parameter of type 'any[]'.
==== tests/cases/compiler/genericRestArgs.ts (2 errors) ====
==== tests/cases/compiler/genericRestArgs.ts (4 errors) ====
function makeArrayG<T>(...items: T[]): T[] { return items; }
var a1Ga = makeArrayG(1, ""); // no error
~~~~~~~~~~~~~~~~~
!!! error TS2346: Supplied parameters do not match any signature of call target.
var a1Gb = makeArrayG<any>(1, "");
var a1Gc = makeArrayG<Object>(1, "");
var a1Gd = makeArrayG<number>(1, ""); // error
@ -15,6 +19,8 @@ tests/cases/compiler/genericRestArgs.ts(12,30): error TS2345: Argument of type '
return [item1, item2, item3];
}
var a2Ga = makeArrayGOpt(1, "");
~~~~~~~~~~~~~~~~~~~~
!!! error TS2346: Supplied parameters do not match any signature of call target.
var a2Gb = makeArrayG<any>(1, "");
var a2Gc = makeArrayG<any[]>(1, ""); // error
~

View file

@ -42,12 +42,12 @@ declare var _: Underscore.Static;
>Static : Underscore.Static
var r = _.all([true, 1, null, 'yes'], _.identity);
>r : {}
>_.all([true, 1, null, 'yes'], _.identity) : {}
>r : string | number | boolean
>_.all([true, 1, null, 'yes'], _.identity) : string | number | boolean
>_.all : <T>(list: T[], iterator?: Underscore.Iterator<T, boolean>, context?: any) => T
>_ : Underscore.Static
>all : <T>(list: T[], iterator?: Underscore.Iterator<T, boolean>, context?: any) => T
>[true, 1, null, 'yes'] : {}[]
>[true, 1, null, 'yes'] : Array<string | number | boolean>
>_.identity : <T>(value: T) => T
>_ : Underscore.Static
>identity : <T>(value: T) => T

View file

@ -1,6 +1,6 @@
=== tests/cases/compiler/genericsManyTypeParameters.ts ===
function Foo<
>Foo : <a1, a21, a31, a41, a51, a61, a119, a22, a32, a42, a52, a62, a219, a23, a33, a43, a53, a63, a319, a24, a34, a44, a54, a64, a419, a25, a35, a45, a55, a65, a519, a26, a36, a46, a56, a66, a619, a27, a37, a47, a57, a67, a71, a28, a38, a48, a58, a68, a81, a29, a39, a49, a59, a69, a91, a210, a310, a410, a510, a610, a111, a211, a311, a411, a511, a611, a112, a212, a312, a412, a512, a612, a113, a213, a313, a413, a513, a613, a114, a214, a314, a414, a514, a614, a115, a215, a315, a415, a515, a615, a116, a216, a316, a416, a516, a616, a117, a217, a317, a417, a517, a617, a118, a218, a318, a418, a518, a618>(x1: a1, y1: a21, z1: a31, a1: a41, b1: a51, c1: a61, x2: a119, y2: a22, z2: a32, a2: a42, b2: a52, c2: a62, x3: a219, y3: a23, z3: a33, a3: a43, b3: a53, c3: a63, x4: a319, y4: a24, z4: a34, a4: a44, b4: a54, c4: a64, x5: a419, y5: a25, z5: a35, a5: a45, b5: a55, c5: a65, x6: a519, y6: a26, z6: a36, a6: a46, b6: a56, c6: a66, x7: a619, y7: a27, z7: a37, a7: a47, b7: a57, c7: a67, x8: a71, y8: a28, z8: a38, a8: a48, b8: a58, c8: a68, x9: a81, y9: a29, z9: a39, a9: a49, b9: a59, c9: a69, x10: a91, y12: a210, z10: a310, a10: a410, b10: a510, c10: a610, x11: a111, y13: a211, z11: a311, a11: a411, b11: a511, c11: a611, x12: a112, y14: a212, z12: a312, a12: a412, b12: a512, c12: a612, x13: a113, y15: a213, z13: a313, a13: a413, b13: a513, c13: a613, x14: a114, y16: a214, z14: a314, a14: a414, b14: a514, c14: a614, x15: a115, y17: a215, z15: a315, a15: a415, b15: a515, c15: a615, x16: a116, y18: a216, z16: a316, a16: a416, b16: a516, c16: a616, x17: a117, y19: a217, z17: a317, a17: a417, b17: a517, c17: a617, x18: a118, y10: a218, z18: a318, a18: a418, b18: a518, c18: a618) => {}[]
>Foo : <a1, a21, a31, a41, a51, a61, a119, a22, a32, a42, a52, a62, a219, a23, a33, a43, a53, a63, a319, a24, a34, a44, a54, a64, a419, a25, a35, a45, a55, a65, a519, a26, a36, a46, a56, a66, a619, a27, a37, a47, a57, a67, a71, a28, a38, a48, a58, a68, a81, a29, a39, a49, a59, a69, a91, a210, a310, a410, a510, a610, a111, a211, a311, a411, a511, a611, a112, a212, a312, a412, a512, a612, a113, a213, a313, a413, a513, a613, a114, a214, a314, a414, a514, a614, a115, a215, a315, a415, a515, a615, a116, a216, a316, a416, a516, a616, a117, a217, a317, a417, a517, a617, a118, a218, a318, a418, a518, a618>(x1: a1, y1: a21, z1: a31, a1: a41, b1: a51, c1: a61, x2: a119, y2: a22, z2: a32, a2: a42, b2: a52, c2: a62, x3: a219, y3: a23, z3: a33, a3: a43, b3: a53, c3: a63, x4: a319, y4: a24, z4: a34, a4: a44, b4: a54, c4: a64, x5: a419, y5: a25, z5: a35, a5: a45, b5: a55, c5: a65, x6: a519, y6: a26, z6: a36, a6: a46, b6: a56, c6: a66, x7: a619, y7: a27, z7: a37, a7: a47, b7: a57, c7: a67, x8: a71, y8: a28, z8: a38, a8: a48, b8: a58, c8: a68, x9: a81, y9: a29, z9: a39, a9: a49, b9: a59, c9: a69, x10: a91, y12: a210, z10: a310, a10: a410, b10: a510, c10: a610, x11: a111, y13: a211, z11: a311, a11: a411, b11: a511, c11: a611, x12: a112, y14: a212, z12: a312, a12: a412, b12: a512, c12: a612, x13: a113, y15: a213, z13: a313, a13: a413, b13: a513, c13: a613, x14: a114, y16: a214, z14: a314, a14: a414, b14: a514, c14: a614, x15: a115, y17: a215, z15: a315, a15: a415, b15: a515, c15: a615, x16: a116, y18: a216, z16: a316, a16: a416, b16: a516, c16: a616, x17: a117, y19: a217, z17: a317, a17: a417, b17: a517, c17: a617, x18: a118, y10: a218, z18: a318, a18: a418, b18: a518, c18: a618) => Array<a1 | a21 | a31 | a41 | a51 | a61 | a119 | a22 | a32 | a42 | a52 | a62 | a219 | a23 | a33 | a43 | a53 | a63 | a319 | a24 | a34 | a44 | a54 | a64 | a419 | a25 | a35 | a45 | a55 | a65 | a519 | a26 | a36 | a46 | a56 | a66 | a619 | a27 | a37 | a47 | a57 | a67 | a71 | a28 | a38 | a48 | a58 | a68 | a81 | a29 | a39 | a49 | a59 | a69 | a91 | a210 | a310 | a410 | a510 | a610 | a111 | a211 | a311 | a411 | a511 | a611 | a112 | a212 | a312 | a412 | a512 | a612 | a113 | a213 | a313 | a413 | a513 | a613 | a114 | a214 | a314 | a414 | a514 | a614 | a115 | a215 | a315 | a415 | a515 | a615 | a116 | a216 | a316 | a416 | a516 | a616 | a117 | a217 | a317 | a417 | a517 | a617 | a118 | a218 | a318 | a418 | a518 | a618>
a1, a21, a31, a41, a51, a61,
>a1 : a1
@ -402,7 +402,7 @@ function Foo<
)
{
return [x1 , y1 , z1 , a1 , b1 , c1,
>[x1 , y1 , z1 , a1 , b1 , c1, x2 , y2 , z2 , a2 , b2 , c2, x3 , y3 , z3 , a3 , b3 , c3, x4 , y4 , z4 , a4 , b4 , c4, x5 , y5 , z5 , a5 , b5 , c5, x6 , y6 , z6 , a6 , b6 , c6, x7 , y7 , z7 , a7 , b7 , c7, x8 , y8 , z8 , a8 , b8 , c8, x9 , y9 , z9 , a9 , b9 , c9, x10 , y12 , z10 , a10 , b10 , c10, x11 , y13 , z11 , a11 , b11 , c11, x12 , y14 , z12 , a12 , b12 , c12, x13 , y15 , z13 , a13 , b13 , c13, x14 , y16 , z14 , a14 , b14 , c14, x15 , y17 , z15 , a15 , b15 , c15, x16 , y18 , z16 , a16 , b16 , c16, x17 , y19 , z17 , a17 , b17 , c17, x18 , y10 , z18 , a18 , b18 , c18] : {}[]
>[x1 , y1 , z1 , a1 , b1 , c1, x2 , y2 , z2 , a2 , b2 , c2, x3 , y3 , z3 , a3 , b3 , c3, x4 , y4 , z4 , a4 , b4 , c4, x5 , y5 , z5 , a5 , b5 , c5, x6 , y6 , z6 , a6 , b6 , c6, x7 , y7 , z7 , a7 , b7 , c7, x8 , y8 , z8 , a8 , b8 , c8, x9 , y9 , z9 , a9 , b9 , c9, x10 , y12 , z10 , a10 , b10 , c10, x11 , y13 , z11 , a11 , b11 , c11, x12 , y14 , z12 , a12 , b12 , c12, x13 , y15 , z13 , a13 , b13 , c13, x14 , y16 , z14 , a14 , b14 , c14, x15 , y17 , z15 , a15 , b15 , c15, x16 , y18 , z16 , a16 , b16 , c16, x17 , y19 , z17 , a17 , b17 , c17, x18 , y10 , z18 , a18 , b18 , c18] : Array<a1 | a21 | a31 | a41 | a51 | a61 | a119 | a22 | a32 | a42 | a52 | a62 | a219 | a23 | a33 | a43 | a53 | a63 | a319 | a24 | a34 | a44 | a54 | a64 | a419 | a25 | a35 | a45 | a55 | a65 | a519 | a26 | a36 | a46 | a56 | a66 | a619 | a27 | a37 | a47 | a57 | a67 | a71 | a28 | a38 | a48 | a58 | a68 | a81 | a29 | a39 | a49 | a59 | a69 | a91 | a210 | a310 | a410 | a510 | a610 | a111 | a211 | a311 | a411 | a511 | a611 | a112 | a212 | a312 | a412 | a512 | a612 | a113 | a213 | a313 | a413 | a513 | a613 | a114 | a214 | a314 | a414 | a514 | a614 | a115 | a215 | a315 | a415 | a515 | a615 | a116 | a216 | a316 | a416 | a516 | a616 | a117 | a217 | a317 | a417 | a517 | a617 | a118 | a218 | a318 | a418 | a518 | a618>
>x1 : a1
>y1 : a21
>z1 : a31

View file

@ -1,5 +1,6 @@
tests/cases/compiler/heterogeneousArrayAndOverloads.ts(9,19): error TS2345: Argument of type '{}[]' is not assignable to parameter of type 'string[]'.
Type '{}' is not assignable to type 'string'.
tests/cases/compiler/heterogeneousArrayAndOverloads.ts(9,19): error TS2345: Argument of type 'Array<string | number>' is not assignable to parameter of type 'string[]'.
Type 'string | number' is not assignable to type 'string':
Type 'number' is not assignable to type 'string'.
==== tests/cases/compiler/heterogeneousArrayAndOverloads.ts (1 errors) ====
@ -13,7 +14,8 @@ tests/cases/compiler/heterogeneousArrayAndOverloads.ts(9,19): error TS2345: Argu
this.test([]);
this.test([1, 2, "hi", 5]); // Error
~~~~~~~~~~~~~~~
!!! error TS2345: Argument of type '{}[]' is not assignable to parameter of type 'string[]'.
!!! error TS2345: Type '{}' is not assignable to type 'string'.
!!! error TS2345: Argument of type 'Array<string | number>' is not assignable to parameter of type 'string[]'.
!!! error TS2345: Type 'string | number' is not assignable to type 'string':
!!! error TS2345: Type 'number' is not assignable to type 'string'.
}
}

View file

@ -2,16 +2,16 @@
// type of an array is the best common type of its elements (plus its contextual type if it exists)
var a = [1, '']; // {}[]
>a : {}[]
>[1, ''] : {}[]
>a : Array<string | number>
>[1, ''] : Array<string | number>
var b = [1, null]; // number[]
>b : number[]
>[1, null] : number[]
var c = [1, '', null]; // {}[]
>c : {}[]
>[1, '', null] : {}[]
>c : Array<string | number>
>[1, '', null] : Array<string | number>
var d = [{}, 1]; // {}[]
>d : {}[]
@ -31,8 +31,8 @@ var f = [[], [1]]; // number[][]
>[1] : number[]
var g = [[1], ['']]; // {}[]
>g : {}[]
>[[1], ['']] : {}[]
>g : Array<string[] | number[]>
>[[1], ['']] : Array<string[] | number[]>
>[1] : number[]
>[''] : string[]
@ -46,8 +46,8 @@ var h = [{ foo: 1, bar: '' }, { foo: 2 }]; // {foo: number}[]
>foo : number
var i = [{ foo: 1, bar: '' }, { foo: '' }]; // {}[]
>i : {}[]
>[{ foo: 1, bar: '' }, { foo: '' }] : {}[]
>i : Array<{ foo: number; bar: string; } | { foo: string; }>
>[{ foo: 1, bar: '' }, { foo: '' }] : Array<{ foo: number; bar: string; } | { foo: string; }>
>{ foo: 1, bar: '' } : { foo: number; bar: string; }
>foo : number
>bar : string
@ -55,8 +55,8 @@ var i = [{ foo: 1, bar: '' }, { foo: '' }]; // {}[]
>foo : string
var j = [() => 1, () => '']; // {}[]
>j : {}[]
>[() => 1, () => ''] : {}[]
>j : Array<{ (): number; } | { (): string; }>
>[() => 1, () => ''] : Array<{ (): number; } | { (): string; }>
>() => 1 : () => number
>() => '' : () => string
@ -80,8 +80,8 @@ var m = [() => 1, () => '', () => null]; // { (): any }[]
>() => null : () => any
var n = [[() => 1], [() => '']]; // {}[]
>n : {}[]
>[[() => 1], [() => '']] : {}[]
>n : Array<{ (): number; }[] | { (): string; }[]>
>[[() => 1], [() => '']] : Array<{ (): number; }[] | { (): string; }[]>
>[() => 1] : { (): number; }[]
>() => 1 : () => number
>[() => ''] : { (): string; }[]
@ -129,8 +129,8 @@ module Derived {
>base : Base
var i = [{ foo: base, basear: derived }, { foo: derived }]; // {foo: Derived}[]
>i : {}[]
>[{ foo: base, basear: derived }, { foo: derived }] : {}[]
>i : Array<{ foo: Base; basear: Derived; } | { foo: Derived; }>
>[{ foo: base, basear: derived }, { foo: derived }] : Array<{ foo: Base; basear: Derived; } | { foo: Derived; }>
>{ foo: base, basear: derived } : { foo: Base; basear: Derived; }
>foo : Base
>base : Base
@ -149,8 +149,8 @@ module Derived {
>derived : Derived
var k = [() => base, () => 1]; // {}[]~
>k : {}[]
>[() => base, () => 1] : {}[]
>k : Array<{ (): Base; } | { (): number; }>
>[() => base, () => 1] : Array<{ (): Base; } | { (): number; }>
>() => base : () => Base
>base : Base
>() => 1 : () => number
@ -182,8 +182,8 @@ module Derived {
>derived : Derived
var o = [derived, derived2]; // {}[]
>o : {}[]
>[derived, derived2] : {}[]
>o : Array<Derived | Derived2>
>[derived, derived2] : Array<Derived | Derived2>
>derived : Derived
>derived2 : Derived2
@ -195,8 +195,8 @@ module Derived {
>base : Base
var q = [[() => derived2], [() => derived]]; // {}[]
>q : {}[]
>[[() => derived2], [() => derived]] : {}[]
>q : Array<{ (): Derived2; }[] | { (): Derived; }[]>
>[[() => derived2], [() => derived]] : Array<{ (): Derived2; }[] | { (): Derived; }[]>
>[() => derived2] : { (): Derived2; }[]
>() => derived2 : () => Derived2
>derived2 : Derived2
@ -257,19 +257,19 @@ function foo<T, U>(t: T, u: U) {
>t : T
var c = [t, u]; // {}[]
>c : {}[]
>[t, u] : {}[]
>c : Array<T | U>
>[t, u] : Array<T | U>
>t : T
>u : U
var d = [t, 1]; // {}[]
>d : {}[]
>[t, 1] : {}[]
>d : Array<number | T>
>[t, 1] : Array<number | T>
>t : T
var e = [() => t, () => u]; // {}[]
>e : {}[]
>[() => t, () => u] : {}[]
>e : Array<{ (): T; } | { (): U; }>
>[() => t, () => u] : Array<{ (): T; } | { (): U; }>
>() => t : () => T
>t : T
>() => u : () => U
@ -308,19 +308,19 @@ function foo2<T extends Base, U extends Derived>(t: T, u: U) {
>t : T
var c = [t, u]; // {}[]
>c : {}[]
>[t, u] : {}[]
>c : Array<T | U>
>[t, u] : Array<T | U>
>t : T
>u : U
var d = [t, 1]; // {}[]
>d : {}[]
>[t, 1] : {}[]
>d : Array<number | T>
>[t, 1] : Array<number | T>
>t : T
var e = [() => t, () => u]; // {}[]
>e : {}[]
>[() => t, () => u] : {}[]
>e : Array<{ (): T; } | { (): U; }>
>[() => t, () => u] : Array<{ (): T; } | { (): U; }>
>() => t : () => T
>t : T
>() => u : () => U
@ -342,8 +342,8 @@ function foo2<T extends Base, U extends Derived>(t: T, u: U) {
>base : Base
var h = [t, derived]; // Derived[]
>h : {}[]
>[t, derived] : {}[]
>h : Array<Derived | T>
>[t, derived] : Array<Derived | T>
>t : T
>derived : Derived
@ -383,19 +383,19 @@ function foo3<T extends Derived, U extends Derived>(t: T, u: U) {
>t : T
var c = [t, u]; // {}[]
>c : {}[]
>[t, u] : {}[]
>c : Array<T | U>
>[t, u] : Array<T | U>
>t : T
>u : U
var d = [t, 1]; // {}[]
>d : {}[]
>[t, 1] : {}[]
>d : Array<number | T>
>[t, 1] : Array<number | T>
>t : T
var e = [() => t, () => u]; // {}[]
>e : {}[]
>[() => t, () => u] : {}[]
>e : Array<{ (): T; } | { (): U; }>
>[() => t, () => u] : Array<{ (): T; } | { (): U; }>
>() => t : () => T
>t : T
>() => u : () => U
@ -458,19 +458,19 @@ function foo4<T extends Base, U extends Base>(t: T, u: U) {
>t : T
var c = [t, u]; // BUG 821629
>c : {}[]
>[t, u] : {}[]
>c : Array<T | U>
>[t, u] : Array<T | U>
>t : T
>u : U
var d = [t, 1]; // {}[]
>d : {}[]
>[t, 1] : {}[]
>d : Array<number | T>
>[t, 1] : Array<number | T>
>t : T
var e = [() => t, () => u]; // {}[]
>e : {}[]
>[() => t, () => u] : {}[]
>e : Array<{ (): T; } | { (): U; }>
>[() => t, () => u] : Array<{ (): T; } | { (): U; }>
>() => t : () => T
>t : T
>() => u : () => U
@ -492,8 +492,8 @@ function foo4<T extends Base, U extends Base>(t: T, u: U) {
>base : Base
var h = [t, derived]; // Derived[]
>h : {}[]
>[t, derived] : {}[]
>h : Array<Derived | T>
>[t, derived] : Array<Derived | T>
>t : T
>derived : Derived
@ -504,8 +504,8 @@ function foo4<T extends Base, U extends Base>(t: T, u: U) {
>base : Base
var j = [u, derived]; // Derived[]
>j : {}[]
>[u, derived] : {}[]
>j : Array<Derived | U>
>[u, derived] : Array<Derived | U>
>u : U
>derived : Derived

View file

@ -7,7 +7,7 @@ tests/cases/conformance/statements/VariableStatements/invalidMultipleVariableDec
tests/cases/conformance/statements/VariableStatements/invalidMultipleVariableDeclarations.ts(40,5): error TS2403: Subsequent variable declarations must have the same type. Variable 'b' must be of type 'I', but here has type 'C2'.
tests/cases/conformance/statements/VariableStatements/invalidMultipleVariableDeclarations.ts(43,5): error TS2403: Subsequent variable declarations must have the same type. Variable 'f' must be of type '(x: string) => number', but here has type '(x: number) => string'.
tests/cases/conformance/statements/VariableStatements/invalidMultipleVariableDeclarations.ts(46,5): error TS2403: Subsequent variable declarations must have the same type. Variable 'arr' must be of type 'string[]', but here has type 'number[]'.
tests/cases/conformance/statements/VariableStatements/invalidMultipleVariableDeclarations.ts(47,5): error TS2403: Subsequent variable declarations must have the same type. Variable 'arr' must be of type 'string[]', but here has type '{}[]'.
tests/cases/conformance/statements/VariableStatements/invalidMultipleVariableDeclarations.ts(47,5): error TS2403: Subsequent variable declarations must have the same type. Variable 'arr' must be of type 'string[]', but here has type 'Array<C | D<string>>'.
tests/cases/conformance/statements/VariableStatements/invalidMultipleVariableDeclarations.ts(50,5): error TS2403: Subsequent variable declarations must have the same type. Variable 'arr2' must be of type 'D<string>[]', but here has type 'D<number>[]'.
tests/cases/conformance/statements/VariableStatements/invalidMultipleVariableDeclarations.ts(53,5): error TS2403: Subsequent variable declarations must have the same type. Variable 'm' must be of type 'typeof M', but here has type 'typeof A'.
@ -79,7 +79,7 @@ tests/cases/conformance/statements/VariableStatements/invalidMultipleVariableDec
!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'arr' must be of type 'string[]', but here has type 'number[]'.
var arr = [new C(), new C2(), new D<string>()];
~~~
!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'arr' must be of type 'string[]', but here has type '{}[]'.
!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'arr' must be of type 'string[]', but here has type 'Array<C | D<string>>'.
var arr2 = [new D<string>()];
var arr2 = new Array<D<number>>();

View file

@ -108,38 +108,38 @@ var rb2 = a2 || a2; // boolean || boolean is boolean
>a2 : boolean
var rb3 = a3 || a2; // number || boolean is {}
>rb3 : {}
>a3 || a2 : {}
>rb3 : number | boolean
>a3 || a2 : number | boolean
>a3 : number
>a2 : boolean
var rb4 = a4 || a2; // string || boolean is {}
>rb4 : {}
>a4 || a2 : {}
>rb4 : string | boolean
>a4 || a2 : string | boolean
>a4 : string
>a2 : boolean
var rb5 = a5 || a2; // void || boolean is {}
>rb5 : {}
>a5 || a2 : {}
>rb5 : boolean | void
>a5 || a2 : boolean | void
>a5 : void
>a2 : boolean
var rb6 = a6 || a2; // enum || boolean is {}
>rb6 : {}
>a6 || a2 : {}
>rb6 : boolean | E
>a6 || a2 : boolean | E
>a6 : E
>a2 : boolean
var rb7 = a7 || a2; // object || boolean is {}
>rb7 : {}
>a7 || a2 : {}
>rb7 : boolean | { a: string; }
>a7 || a2 : boolean | { a: string; }
>a7 : { a: string; }
>a2 : boolean
var rb8 = a8 || a2; // array || boolean is {}
>rb8 : {}
>a8 || a2 : {}
>rb8 : boolean | string[]
>a8 || a2 : boolean | string[]
>a8 : string[]
>a2 : boolean
@ -161,8 +161,8 @@ var rc1 = a1 || a3; // any || number is any
>a3 : number
var rc2 = a2 || a3; // boolean || number is {}
>rc2 : {}
>a2 || a3 : {}
>rc2 : number | boolean
>a2 || a3 : number | boolean
>a2 : boolean
>a3 : number
@ -173,14 +173,14 @@ var rc3 = a3 || a3; // number || number is number
>a3 : number
var rc4 = a4 || a3; // string || number is {}
>rc4 : {}
>a4 || a3 : {}
>rc4 : string | number
>a4 || a3 : string | number
>a4 : string
>a3 : number
var rc5 = a5 || a3; // void || number is {}
>rc5 : {}
>a5 || a3 : {}
>rc5 : number | void
>a5 || a3 : number | void
>a5 : void
>a3 : number
@ -191,14 +191,14 @@ var rc6 = a6 || a3; // enum || number is number
>a3 : number
var rc7 = a7 || a3; // object || number is {}
>rc7 : {}
>a7 || a3 : {}
>rc7 : number | { a: string; }
>a7 || a3 : number | { a: string; }
>a7 : { a: string; }
>a3 : number
var rc8 = a8 || a3; // array || number is {}
>rc8 : {}
>a8 || a3 : {}
>rc8 : number | string[]
>a8 || a3 : number | string[]
>a8 : string[]
>a3 : number
@ -220,14 +220,14 @@ var rd1 = a1 || a4; // any || string is any
>a4 : string
var rd2 = a2 || a4; // boolean || string is {}
>rd2 : {}
>a2 || a4 : {}
>rd2 : string | boolean
>a2 || a4 : string | boolean
>a2 : boolean
>a4 : string
var rd3 = a3 || a4; // number || string is {}
>rd3 : {}
>a3 || a4 : {}
>rd3 : string | number
>a3 || a4 : string | number
>a3 : number
>a4 : string
@ -238,26 +238,26 @@ var rd4 = a4 || a4; // string || string is string
>a4 : string
var rd5 = a5 || a4; // void || string is {}
>rd5 : {}
>a5 || a4 : {}
>rd5 : string | void
>a5 || a4 : string | void
>a5 : void
>a4 : string
var rd6 = a6 || a4; // enum || string is {}
>rd6 : {}
>a6 || a4 : {}
>rd6 : string | E
>a6 || a4 : string | E
>a6 : E
>a4 : string
var rd7 = a7 || a4; // object || string is {}
>rd7 : {}
>a7 || a4 : {}
>rd7 : string | { a: string; }
>a7 || a4 : string | { a: string; }
>a7 : { a: string; }
>a4 : string
var rd8 = a8 || a4; // array || string is {}
>rd8 : {}
>a8 || a4 : {}
>rd8 : string | string[]
>a8 || a4 : string | string[]
>a8 : string[]
>a4 : string
@ -279,20 +279,20 @@ var re1 = a1 || a5; // any || void is any
>a5 : void
var re2 = a2 || a5; // boolean || void is {}
>re2 : {}
>a2 || a5 : {}
>re2 : boolean | void
>a2 || a5 : boolean | void
>a2 : boolean
>a5 : void
var re3 = a3 || a5; // number || void is {}
>re3 : {}
>a3 || a5 : {}
>re3 : number | void
>a3 || a5 : number | void
>a3 : number
>a5 : void
var re4 = a4 || a5; // string || void is {}
>re4 : {}
>a4 || a5 : {}
>re4 : string | void
>a4 || a5 : string | void
>a4 : string
>a5 : void
@ -303,20 +303,20 @@ var re5 = a5 || a5; // void || void is void
>a5 : void
var re6 = a6 || a5; // enum || void is {}
>re6 : {}
>a6 || a5 : {}
>re6 : void | E
>a6 || a5 : void | E
>a6 : E
>a5 : void
var re7 = a7 || a5; // object || void is {}
>re7 : {}
>a7 || a5 : {}
>re7 : void | { a: string; }
>a7 || a5 : void | { a: string; }
>a7 : { a: string; }
>a5 : void
var re8 = a8 || a5; // array || void is {}
>re8 : {}
>a8 || a5 : {}
>re8 : void | string[]
>a8 || a5 : void | string[]
>a8 : string[]
>a5 : void
@ -338,8 +338,8 @@ var rg1 = a1 || a6; // any || enum is any
>a6 : E
var rg2 = a2 || a6; // boolean || enum is {}
>rg2 : {}
>a2 || a6 : {}
>rg2 : boolean | E
>a2 || a6 : boolean | E
>a2 : boolean
>a6 : E
@ -350,14 +350,14 @@ var rg3 = a3 || a6; // number || enum is number
>a6 : E
var rg4 = a4 || a6; // string || enum is {}
>rg4 : {}
>a4 || a6 : {}
>rg4 : string | E
>a4 || a6 : string | E
>a4 : string
>a6 : E
var rg5 = a5 || a6; // void || enum is {}
>rg5 : {}
>a5 || a6 : {}
>rg5 : void | E
>a5 || a6 : void | E
>a5 : void
>a6 : E
@ -368,14 +368,14 @@ var rg6 = a6 || a6; // enum || enum is E
>a6 : E
var rg7 = a7 || a6; // object || enum is {}
>rg7 : {}
>a7 || a6 : {}
>rg7 : E | { a: string; }
>a7 || a6 : E | { a: string; }
>a7 : { a: string; }
>a6 : E
var rg8 = a8 || a6; // array || enum is {}
>rg8 : {}
>a8 || a6 : {}
>rg8 : string[] | E
>a8 || a6 : string[] | E
>a8 : string[]
>a6 : E
@ -397,32 +397,32 @@ var rh1 = a1 || a7; // any || object is any
>a7 : { a: string; }
var rh2 = a2 || a7; // boolean || object is {}
>rh2 : {}
>a2 || a7 : {}
>rh2 : boolean | { a: string; }
>a2 || a7 : boolean | { a: string; }
>a2 : boolean
>a7 : { a: string; }
var rh3 = a3 || a7; // number || object is {}
>rh3 : {}
>a3 || a7 : {}
>rh3 : number | { a: string; }
>a3 || a7 : number | { a: string; }
>a3 : number
>a7 : { a: string; }
var rh4 = a4 || a7; // string || object is {}
>rh4 : {}
>a4 || a7 : {}
>rh4 : string | { a: string; }
>a4 || a7 : string | { a: string; }
>a4 : string
>a7 : { a: string; }
var rh5 = a5 || a7; // void || object is {}
>rh5 : {}
>a5 || a7 : {}
>rh5 : void | { a: string; }
>a5 || a7 : void | { a: string; }
>a5 : void
>a7 : { a: string; }
var rh6 = a6 || a7; // enum || object is {}
>rh6 : {}
>a6 || a7 : {}
>rh6 : E | { a: string; }
>a6 || a7 : E | { a: string; }
>a6 : E
>a7 : { a: string; }
@ -433,8 +433,8 @@ var rh7 = a7 || a7; // object || object is object
>a7 : { a: string; }
var rh8 = a8 || a7; // array || object is {}
>rh8 : {}
>a8 || a7 : {}
>rh8 : string[] | { a: string; }
>a8 || a7 : string[] | { a: string; }
>a8 : string[]
>a7 : { a: string; }
@ -456,38 +456,38 @@ var ri1 = a1 || a8; // any || array is any
>a8 : string[]
var ri2 = a2 || a8; // boolean || array is {}
>ri2 : {}
>a2 || a8 : {}
>ri2 : boolean | string[]
>a2 || a8 : boolean | string[]
>a2 : boolean
>a8 : string[]
var ri3 = a3 || a8; // number || array is {}
>ri3 : {}
>a3 || a8 : {}
>ri3 : number | string[]
>a3 || a8 : number | string[]
>a3 : number
>a8 : string[]
var ri4 = a4 || a8; // string || array is {}
>ri4 : {}
>a4 || a8 : {}
>ri4 : string | string[]
>a4 || a8 : string | string[]
>a4 : string
>a8 : string[]
var ri5 = a5 || a8; // void || array is {}
>ri5 : {}
>a5 || a8 : {}
>ri5 : void | string[]
>a5 || a8 : void | string[]
>a5 : void
>a8 : string[]
var ri6 = a6 || a8; // enum || array is {}
>ri6 : {}
>a6 || a8 : {}
>ri6 : string[] | E
>a6 || a8 : string[] | E
>a6 : E
>a8 : string[]
var ri7 = a7 || a8; // object || array is {}
>ri7 : {}
>a7 || a8 : {}
>ri7 : string[] | { a: string; }
>a7 || a8 : string[] | { a: string; }
>a7 : { a: string; }
>a8 : string[]

View file

@ -22,8 +22,8 @@ function fn1<T, U>(t: T, u: U) {
>t : T
var r3 = t || u;
>r3 : {}
>t || u : {}
>r3 : T | U
>t || u : T | U
>t : T
>u : U
@ -47,8 +47,8 @@ function fn2<T, U/* extends T*/, V/* extends T*/>(t: T, u: U, v: V) {
>V : V
var r1 = t || u;
>r1 : {}
>t || u : {}
>r1 : T | U
>t || u : T | U
>t : T
>u : U
@ -67,8 +67,8 @@ function fn2<T, U/* extends T*/, V/* extends T*/>(t: T, u: U, v: V) {
>u : U
var r5 = u || v;
>r5 : {}
>u || v : {}
>r5 : U | V
>u || v : U | V
>u : U
>v : V
@ -95,8 +95,8 @@ function fn3<T extends { a: string; b: string }, U extends { a: string; b: numbe
>U : U
var r1 = t || u;
>r1 : {}
>t || u : {}
>r1 : T | U
>t || u : T | U
>t : T
>u : U

View file

@ -1,5 +1,6 @@
tests/cases/compiler/mismatchedExplicitTypeParameterAndArgumentType.ts(10,30): error TS2345: Argument of type '{}[]' is not assignable to parameter of type 'number[]'.
Type '{}' is not assignable to type 'number'.
tests/cases/compiler/mismatchedExplicitTypeParameterAndArgumentType.ts(10,30): error TS2345: Argument of type 'Array<string | number>' is not assignable to parameter of type 'number[]'.
Type 'string | number' is not assignable to type 'number':
Type 'string' is not assignable to type 'number'.
tests/cases/compiler/mismatchedExplicitTypeParameterAndArgumentType.ts(11,11): error TS2346: Supplied parameters do not match any signature of call target.
@ -15,8 +16,9 @@ tests/cases/compiler/mismatchedExplicitTypeParameterAndArgumentType.ts(11,11): e
var r6 = map<Object, Object>([1, ""], (x) => x.toString());
var r7 = map<number, string>([1, ""], (x) => x.toString()); // error
~~~~~~~
!!! error TS2345: Argument of type '{}[]' is not assignable to parameter of type 'number[]'.
!!! error TS2345: Type '{}' is not assignable to type 'number'.
!!! error TS2345: Argument of type 'Array<string | number>' is not assignable to parameter of type 'number[]'.
!!! error TS2345: Type 'string | number' is not assignable to type 'number':
!!! error TS2345: Type 'string' is not assignable to type 'number'.
var r7b = map<number>([1, ""], (x) => x.toString()); // error
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2346: Supplied parameters do not match any signature of call target.

View file

@ -1,22 +0,0 @@
tests/cases/compiler/nonContextuallyTypedLogicalOr.ts(16,10): error TS2339: Property 'dummy' does not exist on type '{}'.
==== tests/cases/compiler/nonContextuallyTypedLogicalOr.ts (1 errors) ====
interface Contextual {
dummy;
p?: number;
}
interface Ellement {
dummy;
p: any;
}
var c: Contextual;
var e: Ellement;
// This should error. Even though we are contextually typing e with Contextual, the RHS still
// needs to be a supertype of the LHS to win as the best common type.
(c || e).dummy;
~~~~~
!!! error TS2339: Property 'dummy' does not exist on type '{}'.

View file

@ -0,0 +1,39 @@
=== tests/cases/compiler/nonContextuallyTypedLogicalOr.ts ===
interface Contextual {
>Contextual : Contextual
dummy;
>dummy : any
p?: number;
>p : number
}
interface Ellement {
>Ellement : Ellement
dummy;
>dummy : any
p: any;
>p : any
}
var c: Contextual;
>c : Contextual
>Contextual : Contextual
var e: Ellement;
>e : Ellement
>Ellement : Ellement
// This should error. Even though we are contextually typing e with Contextual, the RHS still
// needs to be a supertype of the LHS to win as the best common type.
(c || e).dummy;
>(c || e).dummy : any
>(c || e) : Contextual | Ellement
>c || e : Contextual | Ellement
>c : Contextual
>e : Ellement
>dummy : any

View file

@ -10,9 +10,10 @@ tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexerCo
tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexerConstrainsPropertyDeclarations.ts(55,5): error TS2412: Property '"4.0"' of type 'number' is not assignable to numeric index type 'string'.
tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexerConstrainsPropertyDeclarations.ts(68,5): error TS2412: Property '2.0' of type 'number' is not assignable to numeric index type 'string'.
tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexerConstrainsPropertyDeclarations.ts(73,5): error TS2412: Property '"4.0"' of type 'number' is not assignable to numeric index type 'string'.
tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexerConstrainsPropertyDeclarations.ts(78,5): error TS2322: Type '{ [x: number]: {}; 1.0: string; 2.0: number; a: string; b: number; c: () => void; "d": string; "e": number; "3.0": string; "4.0": number; f: unknown; X: string; foo: () => string; }' is not assignable to type '{ [x: number]: string; }':
tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexerConstrainsPropertyDeclarations.ts(78,5): error TS2322: Type '{ [x: number]: string | number; 1.0: string; 2.0: number; a: string; b: number; c: () => void; "d": string; "e": number; "3.0": string; "4.0": number; f: unknown; X: string; foo: () => string; }' is not assignable to type '{ [x: number]: string; }':
Index signatures are incompatible:
Type '{}' is not assignable to type 'string'.
Type 'string | number' is not assignable to type 'string':
Type 'number' is not assignable to type 'string'.
tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexerConstrainsPropertyDeclarations.ts(88,9): error TS2304: Cannot find name 'Myn'.
@ -116,9 +117,10 @@ tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexerCo
// error
var b: { [x: number]: string; } = {
~
!!! error TS2322: Type '{ [x: number]: {}; 1.0: string; 2.0: number; a: string; b: number; c: () => void; "d": string; "e": number; "3.0": string; "4.0": number; f: unknown; X: string; foo: () => string; }' is not assignable to type '{ [x: number]: string; }':
!!! error TS2322: Type '{ [x: number]: string | number; 1.0: string; 2.0: number; a: string; b: number; c: () => void; "d": string; "e": number; "3.0": string; "4.0": number; f: unknown; X: string; foo: () => string; }' is not assignable to type '{ [x: number]: string; }':
!!! error TS2322: Index signatures are incompatible:
!!! error TS2322: Type '{}' is not assignable to type 'string'.
!!! error TS2322: Type 'string | number' is not assignable to type 'string':
!!! error TS2322: Type 'number' is not assignable to type 'string'.
a: '',
b: 1,
c: () => { },

View file

@ -4,10 +4,10 @@ tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexerCo
tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexerConstrainsPropertyDeclarations2.ts(26,5): error TS2412: Property '"4.0"' of type 'string' is not assignable to numeric index type 'A'.
tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexerConstrainsPropertyDeclarations2.ts(34,5): error TS2412: Property '3.0' of type 'number' is not assignable to numeric index type 'A'.
tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexerConstrainsPropertyDeclarations2.ts(35,5): error TS2412: Property '"4.0"' of type 'string' is not assignable to numeric index type 'A'.
tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexerConstrainsPropertyDeclarations2.ts(39,5): error TS2322: Type '{ [x: number]: {}; 1.0: A; 2.0: B; 3.0: number; "2.5": B; "4.0": string; }' is not assignable to type '{ [x: number]: A; }':
tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexerConstrainsPropertyDeclarations2.ts(39,5): error TS2322: Type '{ [x: number]: string | number | A; 1.0: A; 2.0: B; 3.0: number; "2.5": B; "4.0": string; }' is not assignable to type '{ [x: number]: A; }':
Index signatures are incompatible:
Type '{}' is not assignable to type 'A':
Property 'foo' is missing in type '{}'.
Type 'string | number | A' is not assignable to type 'A':
Type 'string' is not assignable to type 'A'.
==== tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexerConstrainsPropertyDeclarations2.ts (7 errors) ====
@ -63,10 +63,10 @@ tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexerCo
// error
var b: { [x: number]: A } = {
~
!!! error TS2322: Type '{ [x: number]: {}; 1.0: A; 2.0: B; 3.0: number; "2.5": B; "4.0": string; }' is not assignable to type '{ [x: number]: A; }':
!!! error TS2322: Type '{ [x: number]: string | number | A; 1.0: A; 2.0: B; 3.0: number; "2.5": B; "4.0": string; }' is not assignable to type '{ [x: number]: A; }':
!!! error TS2322: Index signatures are incompatible:
!!! error TS2322: Type '{}' is not assignable to type 'A':
!!! error TS2322: Property 'foo' is missing in type '{}'.
!!! error TS2322: Type 'string | number | A' is not assignable to type 'A':
!!! error TS2322: Type 'string' is not assignable to type 'A'.
1.0: new A(),
2.0: new B(),
"2.5": new B(),

View file

@ -1,7 +1,8 @@
tests/cases/conformance/parser/ecmascript5/parser15.4.4.14-9-2.ts(16,11): error TS2346: Supplied parameters do not match any signature of call target.
tests/cases/conformance/parser/ecmascript5/parser15.4.4.14-9-2.ts(25,1): error TS2304: Cannot find name 'runTestCase'.
==== tests/cases/conformance/parser/ecmascript5/parser15.4.4.14-9-2.ts (1 errors) ====
==== tests/cases/conformance/parser/ecmascript5/parser15.4.4.14-9-2.ts (2 errors) ====
/// Copyright (c) 2012 Ecma International. All rights reserved.
/// Ecma International makes this code available under the terms and conditions set
/// forth on http://hg.ecmascript.org/tests/test262/raw-file/tip/LICENSE (the
@ -18,6 +19,8 @@ tests/cases/conformance/parser/ecmascript5/parser15.4.4.14-9-2.ts(25,1): error T
var one = 1;
var _float = -(4/3);
var a = new Array(false,undefined,null,"0",obj,-1.3333333333333, "str",-0,true,+0, one, 1,0, false, _float, -(4/3));
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2346: Supplied parameters do not match any signature of call target.
if (a.indexOf(-(4/3)) === 14 && // a[14]=_float===-(4/3)
a.indexOf(0) === 7 && // a[7] = +0, 0===+0
a.indexOf(-0) === 7 && // a[7] = +0, -0===+0

View file

@ -1,3 +1,4 @@
tests/cases/compiler/promisePermutations.ts(74,70): error TS2345: Argument of type '(x: number) => IPromise<number>' is not assignable to parameter of type '(value: IPromise<number>) => IPromise<number>'.
tests/cases/compiler/promisePermutations.ts(79,19): error TS2345: Argument of type '(x: number, y?: string) => IPromise<string>' is not assignable to parameter of type '(value: string) => IPromise<string>'.
tests/cases/compiler/promisePermutations.ts(82,19): error TS2345: Argument of type '(x: number, y?: string) => IPromise<string>' is not assignable to parameter of type '(value: string) => IPromise<string>'.
tests/cases/compiler/promisePermutations.ts(83,19): error TS2345: Argument of type '(x: number, y?: string) => Promise<string>' is not assignable to parameter of type '(value: string) => Promise<string>'.
@ -19,13 +20,20 @@ tests/cases/compiler/promisePermutations.ts(120,19): error TS2345: Argument of t
tests/cases/compiler/promisePermutations.ts(121,19): error TS2345: Argument of type '<T>(x: T, cb: (a: T) => T) => Promise<T>' is not assignable to parameter of type '(value: number) => Promise<number>'.
tests/cases/compiler/promisePermutations.ts(122,19): error TS2345: Argument of type '<T>(x: T, cb: (a: T) => T) => Promise<T>' is not assignable to parameter of type '(value: number) => IPromise<any>'.
tests/cases/compiler/promisePermutations.ts(126,19): error TS2345: Argument of type '<T>(x: T, cb: <U>(a: U) => U) => IPromise<T>' is not assignable to parameter of type '(value: number) => IPromise<number>'.
tests/cases/compiler/promisePermutations.ts(129,11): error TS2346: Supplied parameters do not match any signature of call target.
tests/cases/compiler/promisePermutations.ts(132,19): error TS2345: Argument of type '<T>(x: T, cb: <U>(a: U) => U) => IPromise<T>' is not assignable to parameter of type '(value: number) => IPromise<number>'.
tests/cases/compiler/promisePermutations.ts(133,19): error TS2345: Argument of type '<T>(x: T, cb: <U>(a: U) => U) => Promise<T>' is not assignable to parameter of type '(value: number) => Promise<number>'.
tests/cases/compiler/promisePermutations.ts(134,19): error TS2345: Argument of type '<T>(x: T, cb: <U>(a: U) => U) => Promise<T>' is not assignable to parameter of type '(value: number) => IPromise<any>'.
tests/cases/compiler/promisePermutations.ts(137,11): error TS2346: Supplied parameters do not match any signature of call target.
tests/cases/compiler/promisePermutations.ts(144,12): error TS2346: Supplied parameters do not match any signature of call target.
tests/cases/compiler/promisePermutations.ts(152,12): error TS2346: Supplied parameters do not match any signature of call target.
tests/cases/compiler/promisePermutations.ts(156,21): error TS2345: Argument of type '{ (x: number): IPromise<number>; (x: string): IPromise<string>; }' is not assignable to parameter of type '(value: number) => IPromise<string>'.
tests/cases/compiler/promisePermutations.ts(158,21): error TS2345: Argument of type '{ (x: number): IPromise<number>; (x: string): IPromise<string>; }' is not assignable to parameter of type '(value: number) => IPromise<string>'.
tests/cases/compiler/promisePermutations.ts(159,21): error TS2345: Argument of type '{ (x: number): Promise<number>; (x: string): Promise<string>; }' is not assignable to parameter of type '(value: number) => Promise<string>'.
tests/cases/compiler/promisePermutations.ts(160,21): error TS2345: Argument of type '{ (x: number): Promise<number>; (x: string): Promise<string>; }' is not assignable to parameter of type '(value: number) => IPromise<string>'.
==== tests/cases/compiler/promisePermutations.ts (25 errors) ====
==== tests/cases/compiler/promisePermutations.ts (33 errors) ====
interface Promise<T> {
then<U>(success?: (value: T) => Promise<U>, error?: (error: any) => Promise<U>, progress?: (progress: any) => void): Promise<U>;
then<U>(success?: (value: T) => Promise<U>, error?: (error: any) => U, progress?: (progress: any) => void): Promise<U>;
@ -100,6 +108,8 @@ tests/cases/compiler/promisePermutations.ts(158,21): error TS2345: Argument of t
var s3b = s3.then(testFunction3P, testFunction3P, testFunction3P);
var s3c = s3.then(testFunction3P, testFunction3, testFunction3);
var s3d = s3.then(testFunction3P, testFunction3, testFunction3).then(testFunction3, testFunction3, testFunction3);
~~~~~~~~~~~~~
!!! error TS2345: Argument of type '(x: number) => IPromise<number>' is not assignable to parameter of type '(value: IPromise<number>) => IPromise<number>'.
var r4: IPromise<string>;
var sIPromise: (x: any) => IPromise<string>;
@ -197,6 +207,8 @@ tests/cases/compiler/promisePermutations.ts(158,21): error TS2345: Argument of t
var r9b = r9.then(sIPromise, sIPromise, sIPromise); // ok
var r9c = r9.then(nIPromise, nIPromise, nIPromise); // ok
var r9d = r9.then(testFunction, sIPromise, nIPromise); // ok
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2346: Supplied parameters do not match any signature of call target.
var r9e = r9.then(testFunction, nIPromise, sIPromise).then(sIPromise, sIPromise, sIPromise); // ok
var s9: Promise<number>;
var s9a = s9.then(testFunction9, testFunction9, testFunction9); // error
@ -211,6 +223,8 @@ tests/cases/compiler/promisePermutations.ts(158,21): error TS2345: Argument of t
var s9d = s9.then(sPromise, sPromise, sPromise); // ok
var s9e = s9.then(nPromise, nPromise, nPromise); // ok
var s9f = s9.then(testFunction, sIPromise, nIPromise); // ok
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2346: Supplied parameters do not match any signature of call target.
var s9g = s9.then(testFunction, nIPromise, sIPromise).then(sIPromise, sIPromise, sIPromise); // ok
var r10 = testFunction10(x => x);
@ -218,6 +232,8 @@ tests/cases/compiler/promisePermutations.ts(158,21): error TS2345: Argument of t
var r10b = r10.then(sIPromise, sIPromise, sIPromise); // ok
var r10c = r10.then(nIPromise, nIPromise, nIPromise); // ok
var r10d = r10.then(testFunction, sIPromise, nIPromise); // ok
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2346: Supplied parameters do not match any signature of call target.
var r10e = r10.then(testFunction, nIPromise, sIPromise).then(sIPromise, sIPromise, sIPromise); // ok
var s10 = testFunction10P(x => x);
var s10a = s10.then(testFunction10, testFunction10, testFunction10); // ok
@ -226,16 +242,24 @@ tests/cases/compiler/promisePermutations.ts(158,21): error TS2345: Argument of t
var s10d = s10.then(sPromise, sPromise, sPromise); // ok
var s10e = s10.then(nIPromise, nPromise, nIPromise); // ok
var s10f = s10.then(testFunctionP, sIPromise, nIPromise); // ok
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2346: Supplied parameters do not match any signature of call target.
var s10g = s10.then(testFunctionP, nIPromise, sIPromise).then(sPromise, sIPromise, sIPromise); // ok
var r11: IPromise<number>;
var r11a = r11.then(testFunction11, testFunction11, testFunction11); // ok
~~~~~~~~~~~~~~
!!! error TS2345: Argument of type '{ (x: number): IPromise<number>; (x: string): IPromise<string>; }' is not assignable to parameter of type '(value: number) => IPromise<string>'.
var s11: Promise<number>;
var s11a = s11.then(testFunction11, testFunction11, testFunction11); // ok
~~~~~~~~~~~~~~
!!! error TS2345: Argument of type '{ (x: number): IPromise<number>; (x: string): IPromise<string>; }' is not assignable to parameter of type '(value: number) => IPromise<string>'.
var s11b = s11.then(testFunction11P, testFunction11P, testFunction11P); // ok
~~~~~~~~~~~~~~~
!!! error TS2345: Argument of type '{ (x: number): Promise<number>; (x: string): Promise<string>; }' is not assignable to parameter of type '(value: number) => Promise<string>'.
var s11c = s11.then(testFunction11P, testFunction11, testFunction11); // ok
~~~~~~~~~~~~~~~
!!! error TS2345: Argument of type '{ (x: number): Promise<number>; (x: string): Promise<string>; }' is not assignable to parameter of type '(value: number) => IPromise<string>'.
var r12 = testFunction12(x => x);
var r12a = r12.then(testFunction12, testFunction12, testFunction12); // ok

View file

@ -20,15 +20,20 @@ tests/cases/compiler/promisePermutations2.ts(119,19): error TS2345: Argument of
tests/cases/compiler/promisePermutations2.ts(120,19): error TS2345: Argument of type '<T>(x: T, cb: (a: T) => T) => Promise<T>' is not assignable to parameter of type '(value: number) => Promise<number>'.
tests/cases/compiler/promisePermutations2.ts(121,19): error TS2345: Argument of type '<T>(x: T, cb: (a: T) => T) => Promise<T>' is not assignable to parameter of type '(value: number) => IPromise<any>'.
tests/cases/compiler/promisePermutations2.ts(125,19): error TS2345: Argument of type '<T>(x: T, cb: <U>(a: U) => U) => IPromise<T>' is not assignable to parameter of type '(value: number) => IPromise<number>'.
tests/cases/compiler/promisePermutations2.ts(128,11): error TS2346: Supplied parameters do not match any signature of call target.
tests/cases/compiler/promisePermutations2.ts(131,19): error TS2345: Argument of type '<T>(x: T, cb: <U>(a: U) => U) => IPromise<T>' is not assignable to parameter of type '(value: number) => IPromise<number>'.
tests/cases/compiler/promisePermutations2.ts(132,19): error TS2345: Argument of type '<T>(x: T, cb: <U>(a: U) => U) => Promise<T>' is not assignable to parameter of type '(value: number) => Promise<number>'.
tests/cases/compiler/promisePermutations2.ts(133,19): error TS2345: Argument of type '<T>(x: T, cb: <U>(a: U) => U) => Promise<T>' is not assignable to parameter of type '(value: number) => IPromise<any>'.
tests/cases/compiler/promisePermutations2.ts(136,11): error TS2346: Supplied parameters do not match any signature of call target.
tests/cases/compiler/promisePermutations2.ts(143,12): error TS2346: Supplied parameters do not match any signature of call target.
tests/cases/compiler/promisePermutations2.ts(151,12): error TS2346: Supplied parameters do not match any signature of call target.
tests/cases/compiler/promisePermutations2.ts(155,21): error TS2345: Argument of type '{ (x: number): IPromise<number>; (x: string): IPromise<string>; }' is not assignable to parameter of type '(value: number) => IPromise<string>'.
tests/cases/compiler/promisePermutations2.ts(157,21): error TS2345: Argument of type '{ (x: number): IPromise<number>; (x: string): IPromise<string>; }' is not assignable to parameter of type '(value: number) => IPromise<string>'.
tests/cases/compiler/promisePermutations2.ts(158,21): error TS2345: Argument of type '{ (x: number): Promise<number>; (x: string): Promise<string>; }' is not assignable to parameter of type '(value: number) => Promise<string>'.
tests/cases/compiler/promisePermutations2.ts(159,21): error TS2345: Argument of type '{ (x: number): Promise<number>; (x: string): Promise<string>; }' is not assignable to parameter of type '(value: number) => IPromise<string>'.
==== tests/cases/compiler/promisePermutations2.ts (28 errors) ====
==== tests/cases/compiler/promisePermutations2.ts (33 errors) ====
// same as promisePermutations but without the same overloads in Promise<T>
interface Promise<T> {
@ -201,6 +206,8 @@ tests/cases/compiler/promisePermutations2.ts(159,21): error TS2345: Argument of
var r9b = r9.then(sIPromise, sIPromise, sIPromise); // ok
var r9c = r9.then(nIPromise, nIPromise, nIPromise); // ok
var r9d = r9.then(testFunction, sIPromise, nIPromise); // ok
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2346: Supplied parameters do not match any signature of call target.
var r9e = r9.then(testFunction, nIPromise, sIPromise).then(sIPromise, sIPromise, sIPromise); // ok
var s9: Promise<number>;
var s9a = s9.then(testFunction9, testFunction9, testFunction9); // error
@ -215,6 +222,8 @@ tests/cases/compiler/promisePermutations2.ts(159,21): error TS2345: Argument of
var s9d = s9.then(sPromise, sPromise, sPromise); // ok
var s9e = s9.then(nPromise, nPromise, nPromise); // ok
var s9f = s9.then(testFunction, sIPromise, nIPromise); // ok
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2346: Supplied parameters do not match any signature of call target.
var s9g = s9.then(testFunction, nIPromise, sIPromise).then(sIPromise, sIPromise, sIPromise); // ok
var r10 = testFunction10(x => x);
@ -222,6 +231,8 @@ tests/cases/compiler/promisePermutations2.ts(159,21): error TS2345: Argument of
var r10b = r10.then(sIPromise, sIPromise, sIPromise); // ok
var r10c = r10.then(nIPromise, nIPromise, nIPromise); // ok
var r10d = r10.then(testFunction, sIPromise, nIPromise); // ok
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2346: Supplied parameters do not match any signature of call target.
var r10e = r10.then(testFunction, nIPromise, sIPromise).then(sIPromise, sIPromise, sIPromise); // ok
var s10 = testFunction10P(x => x);
var s10a = s10.then(testFunction10, testFunction10, testFunction10); // ok
@ -230,10 +241,14 @@ tests/cases/compiler/promisePermutations2.ts(159,21): error TS2345: Argument of
var s10d = s10.then(sPromise, sPromise, sPromise); // ok
var s10e = s10.then(nIPromise, nPromise, nIPromise); // ok
var s10f = s10.then(testFunctionP, sIPromise, nIPromise); // ok
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2346: Supplied parameters do not match any signature of call target.
var s10g = s10.then(testFunctionP, nIPromise, sIPromise).then(sPromise, sIPromise, sIPromise); // ok
var r11: IPromise<number>;
var r11a = r11.then(testFunction11, testFunction11, testFunction11); // ok
~~~~~~~~~~~~~~
!!! error TS2345: Argument of type '{ (x: number): IPromise<number>; (x: string): IPromise<string>; }' is not assignable to parameter of type '(value: number) => IPromise<string>'.
var s11: Promise<number>;
var s11a = s11.then(testFunction11, testFunction11, testFunction11); // ok
~~~~~~~~~~~~~~

View file

@ -1,4 +1,5 @@
tests/cases/compiler/promisePermutations3.ts(68,69): error TS2345: Argument of type '(x: number) => IPromise<number>' is not assignable to parameter of type '(value: IPromise<number>) => IPromise<number>'.
tests/cases/compiler/promisePermutations3.ts(73,70): error TS2345: Argument of type '(x: number) => IPromise<number>' is not assignable to parameter of type '(value: IPromise<number>) => IPromise<number>'.
tests/cases/compiler/promisePermutations3.ts(78,19): error TS2345: Argument of type '(x: number, y?: string) => IPromise<string>' is not assignable to parameter of type '(value: string) => IPromise<string>'.
tests/cases/compiler/promisePermutations3.ts(81,19): error TS2345: Argument of type '(x: number, y?: string) => IPromise<string>' is not assignable to parameter of type '(value: string) => IPromise<string>'.
tests/cases/compiler/promisePermutations3.ts(82,19): error TS2345: Argument of type '(x: number, y?: string) => Promise<string>' is not assignable to parameter of type '(value: string) => Promise<string>'.
@ -20,15 +21,21 @@ tests/cases/compiler/promisePermutations3.ts(119,19): error TS2345: Argument of
tests/cases/compiler/promisePermutations3.ts(120,19): error TS2345: Argument of type '<T>(x: T, cb: (a: T) => T) => Promise<T>' is not assignable to parameter of type '(value: number) => Promise<number>'.
tests/cases/compiler/promisePermutations3.ts(121,19): error TS2345: Argument of type '<T>(x: T, cb: (a: T) => T) => Promise<T>' is not assignable to parameter of type '(value: number) => IPromise<any>'.
tests/cases/compiler/promisePermutations3.ts(125,19): error TS2345: Argument of type '<T>(x: T, cb: <U>(a: U) => U) => IPromise<T>' is not assignable to parameter of type '(value: number) => IPromise<number>'.
tests/cases/compiler/promisePermutations3.ts(128,11): error TS2346: Supplied parameters do not match any signature of call target.
tests/cases/compiler/promisePermutations3.ts(131,19): error TS2345: Argument of type '<T>(x: T, cb: <U>(a: U) => U) => IPromise<T>' is not assignable to parameter of type '(value: number) => IPromise<number>'.
tests/cases/compiler/promisePermutations3.ts(132,19): error TS2345: Argument of type '<T>(x: T, cb: <U>(a: U) => U) => Promise<T>' is not assignable to parameter of type '(value: number) => Promise<number>'.
tests/cases/compiler/promisePermutations3.ts(133,19): error TS2345: Argument of type '<T>(x: T, cb: <U>(a: U) => U) => Promise<T>' is not assignable to parameter of type '(value: number) => IPromise<any>'.
tests/cases/compiler/promisePermutations3.ts(136,11): error TS2346: Supplied parameters do not match any signature of call target.
tests/cases/compiler/promisePermutations3.ts(143,12): error TS2346: Supplied parameters do not match any signature of call target.
tests/cases/compiler/promisePermutations3.ts(151,12): error TS2346: Supplied parameters do not match any signature of call target.
tests/cases/compiler/promisePermutations3.ts(155,21): error TS2345: Argument of type '{ (x: number): IPromise<number>; (x: string): IPromise<string>; }' is not assignable to parameter of type '(value: number) => IPromise<string>'.
tests/cases/compiler/promisePermutations3.ts(157,21): error TS2345: Argument of type '{ (x: number): IPromise<number>; (x: string): IPromise<string>; }' is not assignable to parameter of type '(value: number) => IPromise<string>'.
tests/cases/compiler/promisePermutations3.ts(158,21): error TS2345: Argument of type '{ (x: number): Promise<number>; (x: string): Promise<string>; }' is not assignable to parameter of type '(value: number) => Promise<string>'.
tests/cases/compiler/promisePermutations3.ts(159,21): error TS2345: Argument of type '{ (x: number): Promise<number>; (x: string): Promise<string>; }' is not assignable to parameter of type '(value: number) => IPromise<string>'.
tests/cases/compiler/promisePermutations3.ts(165,21): error TS2345: Argument of type '{ <T>(x: T): IPromise<T>; <T>(x: T, y: T): Promise<T>; }' is not assignable to parameter of type '(value: (x: any) => any) => Promise<any>'.
==== tests/cases/compiler/promisePermutations3.ts (28 errors) ====
==== tests/cases/compiler/promisePermutations3.ts (35 errors) ====
// same as promisePermutations but without the same overloads in IPromise<T>
interface Promise<T> {
@ -104,6 +111,8 @@ tests/cases/compiler/promisePermutations3.ts(165,21): error TS2345: Argument of
var s3b = s3.then(testFunction3P, testFunction3P, testFunction3P);
var s3c = s3.then(testFunction3P, testFunction3, testFunction3);
var s3d = s3.then(testFunction3P, testFunction3, testFunction3).then(testFunction3, testFunction3, testFunction3);
~~~~~~~~~~~~~
!!! error TS2345: Argument of type '(x: number) => IPromise<number>' is not assignable to parameter of type '(value: IPromise<number>) => IPromise<number>'.
var r4: IPromise<string>;
var sIPromise: (x: any) => IPromise<string>;
@ -201,6 +210,8 @@ tests/cases/compiler/promisePermutations3.ts(165,21): error TS2345: Argument of
var r9b = r9.then(sIPromise, sIPromise, sIPromise); // ok
var r9c = r9.then(nIPromise, nIPromise, nIPromise); // ok
var r9d = r9.then(testFunction, sIPromise, nIPromise); // ok
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2346: Supplied parameters do not match any signature of call target.
var r9e = r9.then(testFunction, nIPromise, sIPromise).then(sIPromise, sIPromise, sIPromise); // ok
var s9: Promise<number>;
var s9a = s9.then(testFunction9, testFunction9, testFunction9); // error
@ -215,6 +226,8 @@ tests/cases/compiler/promisePermutations3.ts(165,21): error TS2345: Argument of
var s9d = s9.then(sPromise, sPromise, sPromise); // ok
var s9e = s9.then(nPromise, nPromise, nPromise); // ok
var s9f = s9.then(testFunction, sIPromise, nIPromise); // ok
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2346: Supplied parameters do not match any signature of call target.
var s9g = s9.then(testFunction, nIPromise, sIPromise).then(sIPromise, sIPromise, sIPromise); // ok
var r10 = testFunction10(x => x);
@ -222,6 +235,8 @@ tests/cases/compiler/promisePermutations3.ts(165,21): error TS2345: Argument of
var r10b = r10.then(sIPromise, sIPromise, sIPromise); // ok
var r10c = r10.then(nIPromise, nIPromise, nIPromise); // ok
var r10d = r10.then(testFunction, sIPromise, nIPromise); // ok
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2346: Supplied parameters do not match any signature of call target.
var r10e = r10.then(testFunction, nIPromise, sIPromise).then(sIPromise, sIPromise, sIPromise); // ok
var s10 = testFunction10P(x => x);
var s10a = s10.then(testFunction10, testFunction10, testFunction10); // ok
@ -230,6 +245,8 @@ tests/cases/compiler/promisePermutations3.ts(165,21): error TS2345: Argument of
var s10d = s10.then(sPromise, sPromise, sPromise); // ok
var s10e = s10.then(nIPromise, nPromise, nIPromise); // ok
var s10f = s10.then(testFunctionP, sIPromise, nIPromise); // ok
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2346: Supplied parameters do not match any signature of call target.
var s10g = s10.then(testFunctionP, nIPromise, sIPromise).then(sPromise, sIPromise, sIPromise); // ok
var r11: IPromise<number>;
@ -241,7 +258,11 @@ tests/cases/compiler/promisePermutations3.ts(165,21): error TS2345: Argument of
~~~~~~~~~~~~~~
!!! error TS2345: Argument of type '{ (x: number): IPromise<number>; (x: string): IPromise<string>; }' is not assignable to parameter of type '(value: number) => IPromise<string>'.
var s11b = s11.then(testFunction11P, testFunction11P, testFunction11P); // ok
~~~~~~~~~~~~~~~
!!! error TS2345: Argument of type '{ (x: number): Promise<number>; (x: string): Promise<string>; }' is not assignable to parameter of type '(value: number) => Promise<string>'.
var s11c = s11.then(testFunction11P, testFunction11, testFunction11); // ok
~~~~~~~~~~~~~~~
!!! error TS2345: Argument of type '{ (x: number): Promise<number>; (x: string): Promise<string>; }' is not assignable to parameter of type '(value: number) => IPromise<string>'.
var r12 = testFunction12(x => x);
var r12a = r12.then(testFunction12, testFunction12, testFunction12); // ok

View file

@ -24,9 +24,10 @@ tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerCon
tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerConstrainsPropertyDeclarations.ts(71,5): error TS2411: Property 'foo' of type '() => string' is not assignable to string index type 'string'.
tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerConstrainsPropertyDeclarations.ts(73,5): error TS2411: Property '"4.0"' of type 'number' is not assignable to string index type 'string'.
tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerConstrainsPropertyDeclarations.ts(74,5): error TS2411: Property 'f' of type 'MyString' is not assignable to string index type 'string'.
tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerConstrainsPropertyDeclarations.ts(78,5): error TS2322: Type '{ [x: string]: {}; 1.0: string; 2.0: number; a: string; b: number; c: () => void; "d": string; "e": number; "3.0": string; "4.0": number; f: MyString; X: string; foo: () => string; }' is not assignable to type '{ [x: string]: string; }':
tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerConstrainsPropertyDeclarations.ts(78,5): error TS2322: Type '{ [x: string]: string | number | MyString | { (): void; }; 1.0: string; 2.0: number; a: string; b: number; c: () => void; "d": string; "e": number; "3.0": string; "4.0": number; f: MyString; X: string; foo: () => string; }' is not assignable to type '{ [x: string]: string; }':
Index signatures are incompatible:
Type '{}' is not assignable to type 'string'.
Type 'string | number | MyString | { (): void; }' is not assignable to type 'string':
Type 'number' is not assignable to type 'string'.
==== tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerConstrainsPropertyDeclarations.ts (27 errors) ====
@ -159,9 +160,10 @@ tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerCon
// error
var b: { [x: string]: string; } = {
~
!!! error TS2322: Type '{ [x: string]: {}; 1.0: string; 2.0: number; a: string; b: number; c: () => void; "d": string; "e": number; "3.0": string; "4.0": number; f: MyString; X: string; foo: () => string; }' is not assignable to type '{ [x: string]: string; }':
!!! error TS2322: Type '{ [x: string]: string | number | MyString | { (): void; }; 1.0: string; 2.0: number; a: string; b: number; c: () => void; "d": string; "e": number; "3.0": string; "4.0": number; f: MyString; X: string; foo: () => string; }' is not assignable to type '{ [x: string]: string; }':
!!! error TS2322: Index signatures are incompatible:
!!! error TS2322: Type '{}' is not assignable to type 'string'.
!!! error TS2322: Type 'string | number | MyString | { (): void; }' is not assignable to type 'string':
!!! error TS2322: Type 'number' is not assignable to type 'string'.
a: '',
b: 1,
c: () => { },

View file

@ -1,46 +1,10 @@
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameter.ts(7,7): error TS2416: Class 'D1<T, U>' incorrectly extends base class 'C3<T>':
Types of property 'foo' are incompatible:
Type 'U' is not assignable to type 'T'.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameter.ts(12,13): error TS2367: No best common type exists between 'T' and 'U'.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameter.ts(13,13): error TS2367: No best common type exists between 'U' and 'T'.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameter.ts(38,14): error TS2367: No best common type exists between 'number' and 'T'.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameter.ts(39,14): error TS2367: No best common type exists between 'T' and 'number'.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameter.ts(41,14): error TS2367: No best common type exists between 'string' and 'T'.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameter.ts(42,14): error TS2367: No best common type exists between 'T' and 'string'.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameter.ts(44,14): error TS2367: No best common type exists between 'boolean' and 'T'.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameter.ts(45,14): error TS2367: No best common type exists between 'T' and 'boolean'.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameter.ts(47,14): error TS2367: No best common type exists between 'Date' and 'T'.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameter.ts(48,14): error TS2367: No best common type exists between 'T' and 'Date'.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameter.ts(50,14): error TS2367: No best common type exists between 'RegExp' and 'T'.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameter.ts(51,14): error TS2367: No best common type exists between 'T' and 'RegExp'.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameter.ts(53,14): error TS2367: No best common type exists between '{ foo: number; }' and 'T'.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameter.ts(54,14): error TS2367: No best common type exists between 'T' and '{ foo: number; }'.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameter.ts(56,14): error TS2367: No best common type exists between '() => void' and 'T'.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameter.ts(57,14): error TS2367: No best common type exists between 'T' and '() => void'.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameter.ts(59,14): error TS2367: No best common type exists between '<T>(x: T) => T' and 'T'.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameter.ts(60,15): error TS2367: No best common type exists between 'T' and '<T>(x: T) => T'.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameter.ts(63,14): error TS2367: No best common type exists between 'I1' and 'T'.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameter.ts(64,14): error TS2367: No best common type exists between 'T' and 'I1'.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameter.ts(67,15): error TS2367: No best common type exists between 'C1' and 'T'.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameter.ts(68,15): error TS2367: No best common type exists between 'T' and 'C1'.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameter.ts(72,15): error TS2367: No best common type exists between 'C2<number>' and 'T'.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameter.ts(73,15): error TS2367: No best common type exists between 'T' and 'C2<number>'.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameter.ts(76,15): error TS2367: No best common type exists between 'typeof E' and 'T'.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameter.ts(77,15): error TS2367: No best common type exists between 'T' and 'typeof E'.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameter.ts(79,15): error TS2367: No best common type exists between 'E' and 'T'.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameter.ts(80,15): error TS2367: No best common type exists between 'T' and 'E'.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameter.ts(83,15): error TS2367: No best common type exists between 'typeof f' and 'T'.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameter.ts(84,15): error TS2367: No best common type exists between 'T' and 'typeof f'.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameter.ts(87,15): error TS2367: No best common type exists between 'typeof c' and 'T'.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameter.ts(88,15): error TS2367: No best common type exists between 'T' and 'typeof c'.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameter.ts(91,19): error TS2367: No best common type exists between 'T' and 'T'.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameter.ts(92,19): error TS2367: No best common type exists between 'T' and 'T'.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameter.ts(95,21): error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameter.ts(96,19): error TS2367: No best common type exists between 'T' and 'U'.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameter.ts(97,19): error TS2367: No best common type exists between 'U' and 'T'.
==== tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameter.ts (38 errors) ====
==== tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameter.ts (2 errors) ====
// checking whether other types are subtypes of type parameters
class C3<T> {
@ -57,11 +21,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf
function f1<T, U>(x: T, y: U) {
var r = true ? x : y; // error
~~~~~~~~~~~~
!!! error TS2367: No best common type exists between 'T' and 'U'.
var r = true ? y : x; // error
~~~~~~~~~~~~
!!! error TS2367: No best common type exists between 'U' and 'T'.
}
interface I1 { foo: number; }
@ -87,135 +47,67 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf
var r0b = true ? x : u;
var r1 = true ? 1 : x;
~~~~~~~~~~~~
!!! error TS2367: No best common type exists between 'number' and 'T'.
var r1 = true ? x : 1;
~~~~~~~~~~~~
!!! error TS2367: No best common type exists between 'T' and 'number'.
var r2 = true ? '' : x;
~~~~~~~~~~~~~
!!! error TS2367: No best common type exists between 'string' and 'T'.
var r2 = true ? x : '';
~~~~~~~~~~~~~
!!! error TS2367: No best common type exists between 'T' and 'string'.
var r3 = true ? true : x;
~~~~~~~~~~~~~~~
!!! error TS2367: No best common type exists between 'boolean' and 'T'.
var r3 = true ? x : true;
~~~~~~~~~~~~~~~
!!! error TS2367: No best common type exists between 'T' and 'boolean'.
var r4 = true ? new Date() : x;
~~~~~~~~~~~~~~~~~~~~~
!!! error TS2367: No best common type exists between 'Date' and 'T'.
var r4 = true ? x : new Date();
~~~~~~~~~~~~~~~~~~~~~
!!! error TS2367: No best common type exists between 'T' and 'Date'.
var r5 = true ? /1/ : x;
~~~~~~~~~~~~~~
!!! error TS2367: No best common type exists between 'RegExp' and 'T'.
var r5 = true ? x : /1/;
~~~~~~~~~~~~~~
!!! error TS2367: No best common type exists between 'T' and 'RegExp'.
var r6 = true ? { foo: 1 } : x;
~~~~~~~~~~~~~~~~~~~~~
!!! error TS2367: No best common type exists between '{ foo: number; }' and 'T'.
var r6 = true ? x : { foo: 1 };
~~~~~~~~~~~~~~~~~~~~~
!!! error TS2367: No best common type exists between 'T' and '{ foo: number; }'.
var r7 = true ? () => { } : x;
~~~~~~~~~~~~~~~~~~~~
!!! error TS2367: No best common type exists between '() => void' and 'T'.
var r7 = true ? x : () => { };
~~~~~~~~~~~~~~~~~~~~
!!! error TS2367: No best common type exists between 'T' and '() => void'.
var r8 = true ? <T>(x: T) => { return x } : x;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2367: No best common type exists between '<T>(x: T) => T' and 'T'.
var r8b = true ? x : <T>(x: T) => { return x }; // type parameters not identical across declarations
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2367: No best common type exists between 'T' and '<T>(x: T) => T'.
var i1: I1;
var r9 = true ? i1 : x;
~~~~~~~~~~~~~
!!! error TS2367: No best common type exists between 'I1' and 'T'.
var r9 = true ? x : i1;
~~~~~~~~~~~~~
!!! error TS2367: No best common type exists between 'T' and 'I1'.
var c1: C1;
var r10 = true ? c1 : x;
~~~~~~~~~~~~~
!!! error TS2367: No best common type exists between 'C1' and 'T'.
var r10 = true ? x : c1;
~~~~~~~~~~~~~
!!! error TS2367: No best common type exists between 'T' and 'C1'.
var c2: C2<number>;
var r12 = true ? c2 : x;
~~~~~~~~~~~~~
!!! error TS2367: No best common type exists between 'C2<number>' and 'T'.
var r12 = true ? x : c2;
~~~~~~~~~~~~~
!!! error TS2367: No best common type exists between 'T' and 'C2<number>'.
var r13 = true ? E : x;
~~~~~~~~~~~~
!!! error TS2367: No best common type exists between 'typeof E' and 'T'.
var r13 = true ? x : E;
~~~~~~~~~~~~
!!! error TS2367: No best common type exists between 'T' and 'typeof E'.
var r14 = true ? E.A : x;
~~~~~~~~~~~~~~
!!! error TS2367: No best common type exists between 'E' and 'T'.
var r14 = true ? x : E.A;
~~~~~~~~~~~~~~
!!! error TS2367: No best common type exists between 'T' and 'E'.
var af: typeof f;
var r15 = true ? af : x;
~~~~~~~~~~~~~
!!! error TS2367: No best common type exists between 'typeof f' and 'T'.
var r15 = true ? x : af;
~~~~~~~~~~~~~
!!! error TS2367: No best common type exists between 'T' and 'typeof f'.
var ac: typeof c;
var r16 = true ? ac : x;
~~~~~~~~~~~~~
!!! error TS2367: No best common type exists between 'typeof c' and 'T'.
var r16 = true ? x : ac;
~~~~~~~~~~~~~
!!! error TS2367: No best common type exists between 'T' and 'typeof c'.
function f17<T>(a: T) {
var r17 = true ? x : a;
~~~~~~~~~~~~
!!! error TS2367: No best common type exists between 'T' and 'T'.
var r17 = true ? a : x;
~~~~~~~~~~~~
!!! error TS2367: No best common type exists between 'T' and 'T'.
}
function f18<T, U extends T>(a: U) {
~~~~~~~~~~~
!!! error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list.
var r18 = true ? x : a;
~~~~~~~~~~~~
!!! error TS2367: No best common type exists between 'T' and 'U'.
var r18 = true ? a : x;
~~~~~~~~~~~~
!!! error TS2367: No best common type exists between 'U' and 'T'.
}
var r19 = true ? new Object() : x; // BCT is Object

View file

@ -1,46 +1,20 @@
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints2.ts(3,13): error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints2.ts(4,13): error TS2367: No best common type exists between 'T' and 'U'.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints2.ts(5,13): error TS2367: No best common type exists between 'U' and 'T'.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints2.ts(9,13): error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints2.ts(9,26): error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints2.ts(10,13): error TS2367: No best common type exists between 'T' and 'U'.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints2.ts(11,13): error TS2367: No best common type exists between 'U' and 'T'.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints2.ts(14,14): error TS2367: No best common type exists between 'V' and 'U'.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints2.ts(15,14): error TS2367: No best common type exists between 'U' and 'V'.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints2.ts(18,14): error TS2367: No best common type exists between 'V' and 'T'.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints2.ts(19,14): error TS2367: No best common type exists between 'T' and 'V'.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints2.ts(18,9): error TS2403: Subsequent variable declarations must have the same type. Variable 'r2' must be of type 'U | V', but here has type 'T | V'.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints2.ts(19,9): error TS2403: Subsequent variable declarations must have the same type. Variable 'r2' must be of type 'U | V', but here has type 'T | V'.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints2.ts(23,13): error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints2.ts(24,13): error TS2367: No best common type exists between 'T' and 'U'.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints2.ts(25,13): error TS2367: No best common type exists between 'U' and 'T'.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints2.ts(28,14): error TS2367: No best common type exists between 'T' and 'Date'.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints2.ts(29,14): error TS2367: No best common type exists between 'Date' and 'T'.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints2.ts(60,14): error TS2367: No best common type exists between 'number' and 'T'.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints2.ts(61,14): error TS2367: No best common type exists between 'T' and 'number'.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints2.ts(65,14): error TS2367: No best common type exists between 'string' and 'T'.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints2.ts(66,14): error TS2367: No best common type exists between 'T' and 'string'.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints2.ts(70,14): error TS2367: No best common type exists between 'boolean' and 'T'.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints2.ts(71,14): error TS2367: No best common type exists between 'T' and 'boolean'.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints2.ts(118,15): error TS2367: No best common type exists between 'typeof E' and 'T'.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints2.ts(119,15): error TS2367: No best common type exists between 'T' and 'typeof E'.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints2.ts(121,15): error TS2367: No best common type exists between 'E' and 'T'.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints2.ts(122,15): error TS2367: No best common type exists between 'T' and 'E'.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints2.ts(143,18): error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints2.ts(144,19): error TS2367: No best common type exists between 'T' and 'V'.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints2.ts(145,19): error TS2367: No best common type exists between 'V' and 'T'.
==== tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints2.ts (29 errors) ====
==== tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints2.ts (7 errors) ====
// checking whether other types are subtypes of type parameters with constraints
function f1<T extends U, U>(x: T, y: U) {
~~~~~~~~~~~
!!! error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list.
var r = true ? x : y;
~~~~~~~~~~~~
!!! error TS2367: No best common type exists between 'T' and 'U'.
var r = true ? y : x;
~~~~~~~~~~~~
!!! error TS2367: No best common type exists between 'U' and 'T'.
}
// V > U > T
@ -50,27 +24,19 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf
~~~~~~~~~~~
!!! error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list.
var r = true ? x : y;
~~~~~~~~~~~~
!!! error TS2367: No best common type exists between 'T' and 'U'.
var r = true ? y : x;
~~~~~~~~~~~~
!!! error TS2367: No best common type exists between 'U' and 'T'.
// ok
var r2 = true ? z : y;
~~~~~~~~~~~~
!!! error TS2367: No best common type exists between 'V' and 'U'.
var r2 = true ? y : z;
~~~~~~~~~~~~
!!! error TS2367: No best common type exists between 'U' and 'V'.
// ok
var r2 = true ? z : x;
~~~~~~~~~~~~
!!! error TS2367: No best common type exists between 'V' and 'T'.
~~
!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'r2' must be of type 'U | V', but here has type 'T | V'.
var r2 = true ? x : z;
~~~~~~~~~~~~
!!! error TS2367: No best common type exists between 'T' and 'V'.
~~
!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'r2' must be of type 'U | V', but here has type 'T | V'.
}
// Date > U > T
@ -78,19 +44,11 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf
~~~~~~~~~~~
!!! error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list.
var r = true ? x : y;
~~~~~~~~~~~~
!!! error TS2367: No best common type exists between 'T' and 'U'.
var r = true ? y : x;
~~~~~~~~~~~~
!!! error TS2367: No best common type exists between 'U' and 'T'.
// ok
var r2 = true ? x : new Date();
~~~~~~~~~~~~~~~~~~~~~
!!! error TS2367: No best common type exists between 'T' and 'Date'.
var r2 = true ? new Date() : x;
~~~~~~~~~~~~~~~~~~~~~
!!! error TS2367: No best common type exists between 'Date' and 'T'.
// ok
var r3 = true ? y : new Date();
@ -122,29 +80,17 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf
function f5<T extends Number>(x: T) {
var r1 = true ? 1 : x; // error
~~~~~~~~~~~~
!!! error TS2367: No best common type exists between 'number' and 'T'.
var r1 = true ? x : 1; // error
~~~~~~~~~~~~
!!! error TS2367: No best common type exists between 'T' and 'number'.
}
function f6<T extends String>(x: T) {
var r2 = true ? '' : x; // error
~~~~~~~~~~~~~
!!! error TS2367: No best common type exists between 'string' and 'T'.
var r2 = true ? x : ''; // error
~~~~~~~~~~~~~
!!! error TS2367: No best common type exists between 'T' and 'string'.
}
function f7<T extends Boolean>(x: T) {
var r3 = true ? true : x; // error
~~~~~~~~~~~~~~~
!!! error TS2367: No best common type exists between 'boolean' and 'T'.
var r3 = true ? x : true; // error
~~~~~~~~~~~~~~~
!!! error TS2367: No best common type exists between 'T' and 'boolean'.
}
function f8<T extends Date>(x: T) {
@ -192,18 +138,10 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf
function f16<T extends E>(x: T) {
var r13 = true ? E : x; // BUG 831833
~~~~~~~~~~~~
!!! error TS2367: No best common type exists between 'typeof E' and 'T'.
var r13 = true ? x : E; // BUG 831833
~~~~~~~~~~~~
!!! error TS2367: No best common type exists between 'T' and 'typeof E'.
var r14 = true ? E.A : x; // BUG 831833
~~~~~~~~~~~~~~
!!! error TS2367: No best common type exists between 'E' and 'T'.
var r14 = true ? x : E.A; // BUG 831833
~~~~~~~~~~~~~~
!!! error TS2367: No best common type exists between 'T' and 'E'.
}
function f17<T extends typeof f>(x: T) {
@ -228,11 +166,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf
~~~~~~~~~~~
!!! error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list.
var r18 = true ? x : a; // ok
~~~~~~~~~~~~
!!! error TS2367: No best common type exists between 'T' and 'V'.
var r18 = true ? a : x; // ok
~~~~~~~~~~~~
!!! error TS2367: No best common type exists between 'V' and 'T'.
}
}

View file

@ -1,13 +1,7 @@
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints3.ts(3,12): error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints3.ts(5,13): error TS2367: No best common type exists between 'T' and 'U'.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints3.ts(6,13): error TS2367: No best common type exists between 'U' and 'T'.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints3.ts(9,14): error TS2367: No best common type exists between 'T' and 'V'.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints3.ts(10,14): error TS2367: No best common type exists between 'V' and 'T'.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints3.ts(13,14): error TS2367: No best common type exists between 'V' and 'U'.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints3.ts(14,14): error TS2367: No best common type exists between 'U' and 'V'.
==== tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints3.ts (7 errors) ====
==== tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints3.ts (1 errors) ====
// checking whether other types are subtypes of type parameters with constraints
function f<T extends U, U, V>(t: T, u: U, v: V) {
@ -15,25 +9,13 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf
!!! error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list.
// ok
var r = true ? t : u;
~~~~~~~~~~~~
!!! error TS2367: No best common type exists between 'T' and 'U'.
var r = true ? u : t;
~~~~~~~~~~~~
!!! error TS2367: No best common type exists between 'U' and 'T'.
// error
var r2 = true ? t : v;
~~~~~~~~~~~~
!!! error TS2367: No best common type exists between 'T' and 'V'.
var r2 = true ? v : t;
~~~~~~~~~~~~
!!! error TS2367: No best common type exists between 'V' and 'T'.
// error
var r3 = true ? v : u;
~~~~~~~~~~~~
!!! error TS2367: No best common type exists between 'V' and 'U'.
var r3 = true ? u : v;
~~~~~~~~~~~~
!!! error TS2367: No best common type exists between 'U' and 'V'.
}

View file

@ -1,11 +1,3 @@
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints4.ts(6,13): error TS2367: No best common type exists between 'T' and 'U'.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints4.ts(7,13): error TS2367: No best common type exists between 'U' and 'T'.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints4.ts(10,14): error TS2367: No best common type exists between 'T' and 'V'.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints4.ts(11,14): error TS2367: No best common type exists between 'V' and 'T'.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints4.ts(14,14): error TS2367: No best common type exists between 'V' and 'U'.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints4.ts(15,14): error TS2367: No best common type exists between 'U' and 'V'.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints4.ts(26,14): error TS2367: No best common type exists between 'V' and 'Foo'.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints4.ts(27,14): error TS2367: No best common type exists between 'Foo' and 'V'.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints4.ts(45,7): error TS2416: Class 'D3<T, U, V>' incorrectly extends base class 'B1<Foo>':
Types of property 'foo' are incompatible:
Type 'V' is not assignable to type 'Foo':
@ -29,34 +21,22 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints4.ts(77,5): error TS2411: Property 'foo' of type 'V' is not assignable to string index type 'U'.
==== tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints4.ts (18 errors) ====
==== tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints4.ts (10 errors) ====
// checking whether other types are subtypes of type parameters with constraints
class Foo { foo: number; }
function f<T extends Foo, U extends Foo, V>(t: T, u: U, v: V) {
// error
var r = true ? t : u;
~~~~~~~~~~~~
!!! error TS2367: No best common type exists between 'T' and 'U'.
var r = true ? u : t;
~~~~~~~~~~~~
!!! error TS2367: No best common type exists between 'U' and 'T'.
// error
var r2 = true ? t : v;
~~~~~~~~~~~~
!!! error TS2367: No best common type exists between 'T' and 'V'.
var r2 = true ? v : t;
~~~~~~~~~~~~
!!! error TS2367: No best common type exists between 'V' and 'T'.
// error
var r3 = true ? v : u;
~~~~~~~~~~~~
!!! error TS2367: No best common type exists between 'V' and 'U'.
var r3 = true ? u : v;
~~~~~~~~~~~~
!!! error TS2367: No best common type exists between 'U' and 'V'.
// ok
var r4 = true ? t : new Foo();
@ -68,11 +48,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf
// BUG, should be error
var r6 = true ? v : new Foo();
~~~~~~~~~~~~~~~~~~~~
!!! error TS2367: No best common type exists between 'V' and 'Foo'.
var r6 = true ? new Foo() : v;
~~~~~~~~~~~~~~~~~~~~
!!! error TS2367: No best common type exists between 'Foo' and 'V'.
}

View file

@ -1,30 +1,6 @@
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(4,12): error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(4,30): error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(4,48): error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(6,14): error TS2367: No best common type exists between 'T' and 'U'.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(7,14): error TS2367: No best common type exists between 'U' and 'T'.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(10,14): error TS2367: No best common type exists between 'T' and 'V'.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(11,14): error TS2367: No best common type exists between 'V' and 'T'.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(14,14): error TS2367: No best common type exists between 'V' and 'U'.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(15,14): error TS2367: No best common type exists between 'U' and 'V'.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(18,14): error TS2367: No best common type exists between 'T' and 'Foo<T>'.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(19,14): error TS2367: No best common type exists between 'Foo<T>' and 'T'.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(22,14): error TS2367: No best common type exists between 'U' and 'Foo<T>'.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(23,14): error TS2367: No best common type exists between 'Foo<T>' and 'U'.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(26,14): error TS2367: No best common type exists between 'V' and 'Foo<T>'.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(27,14): error TS2367: No best common type exists between 'Foo<T>' and 'V'.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(31,14): error TS2367: No best common type exists between 'T' and 'Foo<U>'.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(32,14): error TS2367: No best common type exists between 'Foo<U>' and 'T'.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(35,14): error TS2367: No best common type exists between 'U' and 'Foo<U>'.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(36,14): error TS2367: No best common type exists between 'Foo<U>' and 'U'.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(39,14): error TS2367: No best common type exists between 'V' and 'Foo<U>'.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(40,14): error TS2367: No best common type exists between 'Foo<U>' and 'V'.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(44,15): error TS2367: No best common type exists between 'T' and 'Foo<V>'.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(45,15): error TS2367: No best common type exists between 'Foo<V>' and 'T'.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(48,15): error TS2367: No best common type exists between 'U' and 'Foo<V>'.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(49,15): error TS2367: No best common type exists between 'Foo<V>' and 'U'.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(52,15): error TS2367: No best common type exists between 'V' and 'Foo<V>'.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(53,15): error TS2367: No best common type exists between 'Foo<V>' and 'V'.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(61,14): error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(61,32): error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(61,50): error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list.
@ -111,7 +87,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(153,50): error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list.
==== tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts (99 errors) ====
==== tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts (75 errors) ====
// checking whether other types are subtypes of type parameters with constraints
class Foo<T> { foo: T; }
@ -124,101 +100,53 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf
!!! error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list.
// error
var r1 = true ? t : u;
~~~~~~~~~~~~
!!! error TS2367: No best common type exists between 'T' and 'U'.
var r1 = true ? u : t;
~~~~~~~~~~~~
!!! error TS2367: No best common type exists between 'U' and 'T'.
// error
var r2 = true ? t : v;
~~~~~~~~~~~~
!!! error TS2367: No best common type exists between 'T' and 'V'.
var r2 = true ? v : t;
~~~~~~~~~~~~
!!! error TS2367: No best common type exists between 'V' and 'T'.
// error
var r3 = true ? v : u;
~~~~~~~~~~~~
!!! error TS2367: No best common type exists between 'V' and 'U'.
var r3 = true ? u : v;
~~~~~~~~~~~~
!!! error TS2367: No best common type exists between 'U' and 'V'.
// ok?
var r4 = true ? t : new Foo<T>();
~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2367: No best common type exists between 'T' and 'Foo<T>'.
var r4 = true ? new Foo<T>() : t;
~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2367: No best common type exists between 'Foo<T>' and 'T'.
// ok?
var r5 = true ? u : new Foo<T>();
~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2367: No best common type exists between 'U' and 'Foo<T>'.
var r5 = true ? new Foo<T>() : u;
~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2367: No best common type exists between 'Foo<T>' and 'U'.
// ok?
var r6 = true ? v : new Foo<T>();
~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2367: No best common type exists between 'V' and 'Foo<T>'.
var r6 = true ? new Foo<T>() : v;
~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2367: No best common type exists between 'Foo<T>' and 'V'.
// ok?
var r7 = true ? t : new Foo<U>();
~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2367: No best common type exists between 'T' and 'Foo<U>'.
var r7 = true ? new Foo<U>() : t;
~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2367: No best common type exists between 'Foo<U>' and 'T'.
// ok?
var r8 = true ? u : new Foo<U>();
~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2367: No best common type exists between 'U' and 'Foo<U>'.
var r8 = true ? new Foo<U>() : u;
~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2367: No best common type exists between 'Foo<U>' and 'U'.
// ok?
var r9 = true ? v : new Foo<U>();
~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2367: No best common type exists between 'V' and 'Foo<U>'.
var r9 = true ? new Foo<U>() : v;
~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2367: No best common type exists between 'Foo<U>' and 'V'.
// ok?
var r10 = true ? t : new Foo<V>();
~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2367: No best common type exists between 'T' and 'Foo<V>'.
var r10 = true ? new Foo<V>() : t;
~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2367: No best common type exists between 'Foo<V>' and 'T'.
// ok?
var r11 = true ? u : new Foo<V>();
~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2367: No best common type exists between 'U' and 'Foo<V>'.
var r11 = true ? new Foo<V>() : u;
~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2367: No best common type exists between 'Foo<V>' and 'U'.
// ok?
var r12 = true ? v : new Foo<V>();
~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2367: No best common type exists between 'V' and 'Foo<V>'.
var r12 = true ? new Foo<V>() : v;
~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2367: No best common type exists between 'Foo<V>' and 'V'.
}
module M1 {

View file

@ -368,8 +368,8 @@ var r2a = [r2arg1, r2arg2];
>r2arg2 : (x: number) => string[]
var r2b = [r2arg2, r2arg1];
>r2b : { (x: number): string[]; }[]
>[r2arg2, r2arg1] : { (x: number): string[]; }[]
>r2b : { <T>(x: T): string[]; }[]
>[r2arg2, r2arg1] : { <T>(x: T): string[]; }[]
>r2arg2 : (x: number) => string[]
>r2arg1 : <T>(x: T) => string[]
@ -399,8 +399,8 @@ var r3a = [r3arg1, r3arg2];
>r3arg2 : (x: number) => void
var r3b = [r3arg2, r3arg1];
>r3b : { (x: number): void; }[]
>[r3arg2, r3arg1] : { (x: number): void; }[]
>r3b : { <T>(x: T): T; }[]
>[r3arg2, r3arg1] : { <T>(x: T): T; }[]
>r3arg2 : (x: number) => void
>r3arg1 : <T>(x: T) => T
@ -795,8 +795,8 @@ var r12a = [r12arg1, r12arg2];
>r12arg2 : (x: Base[], y: Derived2[]) => Derived[]
var r12b = [r12arg2, r12arg1];
>r12b : { (x: Base[], y: Derived2[]): Derived[]; }[]
>[r12arg2, r12arg1] : { (x: Base[], y: Derived2[]): Derived[]; }[]
>r12b : { <T extends Base[]>(x: Base[], y: T): Derived[]; }[]
>[r12arg2, r12arg1] : { <T extends Base[]>(x: Base[], y: T): Derived[]; }[]
>r12arg2 : (x: Base[], y: Derived2[]) => Derived[]
>r12arg1 : <T extends Base[]>(x: Base[], y: T) => Derived[]

View file

@ -340,14 +340,14 @@ module Errors {
>r3arg : <T extends Base, U extends Derived>(x: (arg: T) => U, y: (arg2: { foo: number; }) => U) => (r: T) => U
var r3a = [r3arg2, r3arg];
>r3a : {}[]
>[r3arg2, r3arg] : {}[]
>r3a : Array<{ <T extends Base, U extends Derived>(x: (arg: T) => U, y: (arg2: { foo: number; }) => U): (r: T) => U; } | { (x: (arg: Base) => Derived, y: (arg2: Base) => Derived): (r: Base) => Derived; }>
>[r3arg2, r3arg] : Array<{ <T extends Base, U extends Derived>(x: (arg: T) => U, y: (arg2: { foo: number; }) => U): (r: T) => U; } | { (x: (arg: Base) => Derived, y: (arg2: Base) => Derived): (r: Base) => Derived; }>
>r3arg2 : (x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived
>r3arg : <T extends Base, U extends Derived>(x: (arg: T) => U, y: (arg2: { foo: number; }) => U) => (r: T) => U
var r3b = [r3arg, r3arg2];
>r3b : {}[]
>[r3arg, r3arg2] : {}[]
>r3b : Array<{ <T extends Base, U extends Derived>(x: (arg: T) => U, y: (arg2: { foo: number; }) => U): (r: T) => U; } | { (x: (arg: Base) => Derived, y: (arg2: Base) => Derived): (r: Base) => Derived; }>
>[r3arg, r3arg2] : Array<{ <T extends Base, U extends Derived>(x: (arg: T) => U, y: (arg2: { foo: number; }) => U): (r: T) => U; } | { (x: (arg: Base) => Derived, y: (arg2: Base) => Derived): (r: Base) => Derived; }>
>r3arg : <T extends Base, U extends Derived>(x: (arg: T) => U, y: (arg2: { foo: number; }) => U) => (r: T) => U
>r3arg2 : (x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived
@ -535,8 +535,8 @@ module Errors {
>r7arg3 : <T extends Base>(x: { a: T; b: T; }) => number
var r7e = [r7arg3, r7arg2];
>r7e : { <T extends Base>(x: { a: T; b: T; }): number; }[]
>[r7arg3, r7arg2] : { <T extends Base>(x: { a: T; b: T; }): number; }[]
>r7e : { (x: { a: string; b: number; }): number; }[]
>[r7arg3, r7arg2] : { (x: { a: string; b: number; }): number; }[]
>r7arg3 : <T extends Base>(x: { a: T; b: T; }) => number
>r7arg2 : (x: { a: string; b: number; }) => number

View file

@ -318,8 +318,8 @@ var r3a = [r3arg, r3arg2];
>r3arg2 : <T>(x: T) => void
var r3b = [r3arg2, r3arg];
>r3b : { <T>(x: T): void; }[]
>[r3arg2, r3arg] : { <T>(x: T): void; }[]
>r3b : { <T>(x: T): T; }[]
>[r3arg2, r3arg] : { <T>(x: T): T; }[]
>r3arg2 : <T>(x: T) => void
>r3arg : <T>(x: T) => T
@ -442,8 +442,8 @@ var r6a = [r6arg, r6arg2];
>r6arg2 : <T extends Base>(x: (arg: T) => Derived) => T
var r6b = [r6arg2, r6arg];
>r6b : { <T extends Base>(x: (arg: T) => Derived): T; }[]
>[r6arg2, r6arg] : { <T extends Base>(x: (arg: T) => Derived): T; }[]
>r6b : { <T extends Base, U extends Derived>(x: (arg: T) => U): T; }[]
>[r6arg2, r6arg] : { <T extends Base, U extends Derived>(x: (arg: T) => U): T; }[]
>r6arg2 : <T extends Base>(x: (arg: T) => Derived) => T
>r6arg : <T extends Base, U extends Derived>(x: (arg: T) => U) => T
@ -491,8 +491,8 @@ var r11a = [r11arg, r11arg2];
>r11arg2 : <T>(x: { foo: T; }, y: { foo: T; bar: T; }) => Base
var r11b = [r11arg2, r11arg];
>r11b : { <T>(x: { foo: T; }, y: { foo: T; bar: T; }): Base; }[]
>[r11arg2, r11arg] : { <T>(x: { foo: T; }, y: { foo: T; bar: T; }): Base; }[]
>r11b : { <T, U>(x: { foo: T; }, y: { foo: U; bar: U; }): Base; }[]
>[r11arg2, r11arg] : { <T, U>(x: { foo: T; }, y: { foo: U; bar: U; }): Base; }[]
>r11arg2 : <T>(x: { foo: T; }, y: { foo: T; bar: T; }) => Base
>r11arg : <T, U>(x: { foo: T; }, y: { foo: U; bar: U; }) => Base
@ -534,8 +534,8 @@ var r15a = [r15arg, r15arg2];
>r15arg2 : <T>(x: { a: T; b: T; }) => T[]
var r15b = [r15arg2, r15arg];
>r15b : { <T>(x: { a: T; b: T; }): T[]; }[]
>[r15arg2, r15arg] : { <T>(x: { a: T; b: T; }): T[]; }[]
>r15b : { <U, V>(x: { a: U; b: V; }): U[]; }[]
>[r15arg2, r15arg] : { <U, V>(x: { a: U; b: V; }): U[]; }[]
>r15arg2 : <T>(x: { a: T; b: T; }) => T[]
>r15arg : <U, V>(x: { a: U; b: V; }) => U[]

View file

@ -360,8 +360,8 @@ var r2a = [r2arg1, r2arg2];
>r2arg2 : new (x: number) => string[]
var r2b = [r2arg2, r2arg1];
>r2b : { new (x: number): string[]; }[]
>[r2arg2, r2arg1] : { new (x: number): string[]; }[]
>r2b : { new <T>(x: T): string[]; }[]
>[r2arg2, r2arg1] : { new <T>(x: T): string[]; }[]
>r2arg2 : new (x: number) => string[]
>r2arg1 : new <T>(x: T) => string[]
@ -389,8 +389,8 @@ var r3a = [r3arg1, r3arg2];
>r3arg2 : new (x: number) => void
var r3b = [r3arg2, r3arg1];
>r3b : { new (x: number): void; }[]
>[r3arg2, r3arg1] : { new (x: number): void; }[]
>r3b : { new <T>(x: T): T; }[]
>[r3arg2, r3arg1] : { new <T>(x: T): T; }[]
>r3arg2 : new (x: number) => void
>r3arg1 : new <T>(x: T) => T
@ -630,14 +630,14 @@ var r9 = foo9(r9arg1); // any
>r9arg1 : new <T extends Base, U extends Derived>(x: new (arg: T) => U, y: (arg2: { foo: string; bing: number; }) => U) => new (r: T) => U
var r9a = [r9arg1, r9arg2];
>r9a : {}[]
>[r9arg1, r9arg2] : {}[]
>r9a : Array<{ new <T extends Base, U extends Derived>(x: new (arg: T) => U, y: (arg2: { foo: string; bing: number; }) => U): new (r: T) => U; } | { new (x: new (arg: Base) => Derived, y: new (arg2: Base) => Derived): new (r: Base) => Derived; }>
>[r9arg1, r9arg2] : Array<{ new <T extends Base, U extends Derived>(x: new (arg: T) => U, y: (arg2: { foo: string; bing: number; }) => U): new (r: T) => U; } | { new (x: new (arg: Base) => Derived, y: new (arg2: Base) => Derived): new (r: Base) => Derived; }>
>r9arg1 : new <T extends Base, U extends Derived>(x: new (arg: T) => U, y: (arg2: { foo: string; bing: number; }) => U) => new (r: T) => U
>r9arg2 : new (x: new (arg: Base) => Derived, y: new (arg2: Base) => Derived) => new (r: Base) => Derived
var r9b = [r9arg2, r9arg1];
>r9b : {}[]
>[r9arg2, r9arg1] : {}[]
>r9b : Array<{ new <T extends Base, U extends Derived>(x: new (arg: T) => U, y: (arg2: { foo: string; bing: number; }) => U): new (r: T) => U; } | { new (x: new (arg: Base) => Derived, y: new (arg2: Base) => Derived): new (r: Base) => Derived; }>
>[r9arg2, r9arg1] : Array<{ new <T extends Base, U extends Derived>(x: new (arg: T) => U, y: (arg2: { foo: string; bing: number; }) => U): new (r: T) => U; } | { new (x: new (arg: Base) => Derived, y: new (arg2: Base) => Derived): new (r: Base) => Derived; }>
>r9arg2 : new (x: new (arg: Base) => Derived, y: new (arg2: Base) => Derived) => new (r: Base) => Derived
>r9arg1 : new <T extends Base, U extends Derived>(x: new (arg: T) => U, y: (arg2: { foo: string; bing: number; }) => U) => new (r: T) => U
@ -747,8 +747,8 @@ var r12a = [r12arg1, r12arg2];
>r12arg2 : new (x: Base[], y: Derived2[]) => Derived[]
var r12b = [r12arg2, r12arg1];
>r12b : { new (x: Base[], y: Derived2[]): Derived[]; }[]
>[r12arg2, r12arg1] : { new (x: Base[], y: Derived2[]): Derived[]; }[]
>r12b : { new <T extends Base[]>(x: Base[], y: T): Derived[]; }[]
>[r12arg2, r12arg1] : { new <T extends Base[]>(x: Base[], y: T): Derived[]; }[]
>r12arg2 : new (x: Base[], y: Derived2[]) => Derived[]
>r12arg1 : new <T extends Base[]>(x: Base[], y: T) => Derived[]

View file

@ -318,14 +318,14 @@ module Errors {
>r3arg1 : new <T extends Base, U extends Derived>(x: new (arg: T) => U, y: (arg2: { foo: number; }) => U) => new (r: T) => U
var r3a = [r3arg2, r3arg1];
>r3a : {}[]
>[r3arg2, r3arg1] : {}[]
>r3a : Array<{ new <T extends Base, U extends Derived>(x: new (arg: T) => U, y: (arg2: { foo: number; }) => U): new (r: T) => U; } | { new (x: (arg: Base) => Derived, y: new (arg2: Base) => Derived): new (r: Base) => Derived; }>
>[r3arg2, r3arg1] : Array<{ new <T extends Base, U extends Derived>(x: new (arg: T) => U, y: (arg2: { foo: number; }) => U): new (r: T) => U; } | { new (x: (arg: Base) => Derived, y: new (arg2: Base) => Derived): new (r: Base) => Derived; }>
>r3arg2 : new (x: (arg: Base) => Derived, y: new (arg2: Base) => Derived) => new (r: Base) => Derived
>r3arg1 : new <T extends Base, U extends Derived>(x: new (arg: T) => U, y: (arg2: { foo: number; }) => U) => new (r: T) => U
var r3b = [r3arg1, r3arg2];
>r3b : {}[]
>[r3arg1, r3arg2] : {}[]
>r3b : Array<{ new <T extends Base, U extends Derived>(x: new (arg: T) => U, y: (arg2: { foo: number; }) => U): new (r: T) => U; } | { new (x: (arg: Base) => Derived, y: new (arg2: Base) => Derived): new (r: Base) => Derived; }>
>[r3arg1, r3arg2] : Array<{ new <T extends Base, U extends Derived>(x: new (arg: T) => U, y: (arg2: { foo: number; }) => U): new (r: T) => U; } | { new (x: (arg: Base) => Derived, y: new (arg2: Base) => Derived): new (r: Base) => Derived; }>
>r3arg1 : new <T extends Base, U extends Derived>(x: new (arg: T) => U, y: (arg2: { foo: number; }) => U) => new (r: T) => U
>r3arg2 : new (x: (arg: Base) => Derived, y: new (arg2: Base) => Derived) => new (r: Base) => Derived
@ -497,8 +497,8 @@ module Errors {
>r7arg3 : new <T extends Base>(x: { a: T; b: T; }) => number
var r7e = [r7arg3, r7arg2];
>r7e : { new <T extends Base>(x: { a: T; b: T; }): number; }[]
>[r7arg3, r7arg2] : { new <T extends Base>(x: { a: T; b: T; }): number; }[]
>r7e : { new (x: { a: string; b: number; }): number; }[]
>[r7arg3, r7arg2] : { new (x: { a: string; b: number; }): number; }[]
>r7arg3 : new <T extends Base>(x: { a: T; b: T; }) => number
>r7arg2 : new (x: { a: string; b: number; }) => number

View file

@ -307,8 +307,8 @@ var r3a = [r3arg, r3arg2];
>r3arg2 : new <T>(x: T) => void
var r3b = [r3arg2, r3arg];
>r3b : { new <T>(x: T): void; }[]
>[r3arg2, r3arg] : { new <T>(x: T): void; }[]
>r3b : { new <T>(x: T): T; }[]
>[r3arg2, r3arg] : { new <T>(x: T): T; }[]
>r3arg2 : new <T>(x: T) => void
>r3arg : new <T>(x: T) => T
@ -421,8 +421,8 @@ var r6a = [r6arg, r6arg2];
>r6arg2 : new <T extends Base>(x: new (arg: T) => Derived) => T
var r6b = [r6arg2, r6arg];
>r6b : { new <T extends Base>(x: new (arg: T) => Derived): T; }[]
>[r6arg2, r6arg] : { new <T extends Base>(x: new (arg: T) => Derived): T; }[]
>r6b : { new <T extends Base, U extends Derived>(x: new (arg: T) => U): T; }[]
>[r6arg2, r6arg] : { new <T extends Base, U extends Derived>(x: new (arg: T) => U): T; }[]
>r6arg2 : new <T extends Base>(x: new (arg: T) => Derived) => T
>r6arg : new <T extends Base, U extends Derived>(x: new (arg: T) => U) => T
@ -466,8 +466,8 @@ var r11a = [r11arg, r11arg2];
>r11arg2 : new <T>(x: { foo: T; }, y: { foo: T; bar: T; }) => Base
var r11b = [r11arg2, r11arg];
>r11b : { new <T>(x: { foo: T; }, y: { foo: T; bar: T; }): Base; }[]
>[r11arg2, r11arg] : { new <T>(x: { foo: T; }, y: { foo: T; bar: T; }): Base; }[]
>r11b : { new <T, U>(x: { foo: T; }, y: { foo: U; bar: U; }): Base; }[]
>[r11arg2, r11arg] : { new <T, U>(x: { foo: T; }, y: { foo: U; bar: U; }): Base; }[]
>r11arg2 : new <T>(x: { foo: T; }, y: { foo: T; bar: T; }) => Base
>r11arg : new <T, U>(x: { foo: T; }, y: { foo: U; bar: U; }) => Base
@ -505,8 +505,8 @@ var r15a = [r15arg, r15arg2];
>r15arg2 : new <T>(x: { a: T; b: T; }) => T[]
var r15b = [r15arg2, r15arg];
>r15b : { new <T>(x: { a: T; b: T; }): T[]; }[]
>[r15arg2, r15arg] : { new <T>(x: { a: T; b: T; }): T[]; }[]
>r15b : { new <U, V>(x: { a: U; b: V; }): U[]; }[]
>[r15arg2, r15arg] : { new <U, V>(x: { a: U; b: V; }): U[]; }[]
>r15arg2 : new <T>(x: { a: T; b: T; }) => T[]
>r15arg : new <U, V>(x: { a: U; b: V; }) => U[]

View file

@ -4,10 +4,9 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW
Property '1' is optional in type 'S2' but required in type 'T2'.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithObjectMembersOptionality2.ts(26,11): error TS2429: Interface 'S3' incorrectly extends interface 'T3':
Property ''1'' is optional in type 'S3' but required in type 'T3'.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithObjectMembersOptionality2.ts(33,9): error TS2367: No best common type exists between '{ Foo: Base; }' and '{ Foo?: Derived; }'.
==== tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithObjectMembersOptionality2.ts (4 errors) ====
==== tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithObjectMembersOptionality2.ts (3 errors) ====
// Derived member is optional but base member is not, should be an error
interface Base { foo: string; }
@ -49,6 +48,4 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW
// object literal case
var a: { Foo: Base; }
var b: { Foo?: Derived; }
var r = true ? a : b; // error
~~~~~~~~~~~~
!!! error TS2367: No best common type exists between '{ Foo: Base; }' and '{ Foo?: Derived; }'.
var r = true ? a : b; // error

View file

@ -1,5 +1,6 @@
tests/cases/compiler/targetTypeTest3.ts(4,5): error TS2322: Type '{}[]' is not assignable to type 'string[]':
Type '{}' is not assignable to type 'string'.
tests/cases/compiler/targetTypeTest3.ts(4,5): error TS2322: Type 'Array<string | number>' is not assignable to type 'string[]':
Type 'string | number' is not assignable to type 'string':
Type 'number' is not assignable to type 'string'.
==== tests/cases/compiler/targetTypeTest3.ts (1 errors) ====
@ -8,8 +9,9 @@ tests/cases/compiler/targetTypeTest3.ts(4,5): error TS2322: Type '{}[]' is not a
var a : string[] = [1,2,"3"]; // should produce an error
~
!!! error TS2322: Type '{}[]' is not assignable to type 'string[]':
!!! error TS2322: Type '{}' is not assignable to type 'string'.
!!! error TS2322: Type 'Array<string | number>' is not assignable to type 'string[]':
!!! error TS2322: Type 'string | number' is not assignable to type 'string':
!!! error TS2322: Type 'number' is not assignable to type 'string'.
function func1(stuff:any[]) { return stuff; }

View file

@ -219,7 +219,7 @@ throw [];
>[] : undefined[]
throw ['a', ['b']];
>['a', ['b']] : {}[]
>['a', ['b']] : Array<string | string[]>
>['b'] : string[]
throw /[a-z]/;

View file

@ -1,7 +1,9 @@
tests/cases/compiler/trailingCommaInHeterogenousArrayLiteral1.ts(5,19): error TS2345: Argument of type '{}[]' is not assignable to parameter of type 'number[]'.
Type '{}' is not assignable to type 'number'.
tests/cases/compiler/trailingCommaInHeterogenousArrayLiteral1.ts(6,19): error TS2345: Argument of type '{}[]' is not assignable to parameter of type 'number[]'.
Type '{}' is not assignable to type 'number'.
tests/cases/compiler/trailingCommaInHeterogenousArrayLiteral1.ts(5,19): error TS2345: Argument of type 'Array<string | number>' is not assignable to parameter of type 'number[]'.
Type 'string | number' is not assignable to type 'number':
Type 'string' is not assignable to type 'number'.
tests/cases/compiler/trailingCommaInHeterogenousArrayLiteral1.ts(6,19): error TS2345: Argument of type 'Array<string | number>' is not assignable to parameter of type 'number[]'.
Type 'string | number' is not assignable to type 'number':
Type 'string' is not assignable to type 'number'.
==== tests/cases/compiler/trailingCommaInHeterogenousArrayLiteral1.ts (2 errors) ====
@ -11,12 +13,14 @@ tests/cases/compiler/trailingCommaInHeterogenousArrayLiteral1.ts(6,19): error TS
// these two should give the same error
this.test([1, 2, "hi", 5, ]);
~~~~~~~~~~~~~~~~~
!!! error TS2345: Argument of type '{}[]' is not assignable to parameter of type 'number[]'.
!!! error TS2345: Type '{}' is not assignable to type 'number'.
!!! error TS2345: Argument of type 'Array<string | number>' is not assignable to parameter of type 'number[]'.
!!! error TS2345: Type 'string | number' is not assignable to type 'number':
!!! error TS2345: Type 'string' is not assignable to type 'number'.
this.test([1, 2, "hi", 5]);
~~~~~~~~~~~~~~~
!!! error TS2345: Argument of type '{}[]' is not assignable to parameter of type 'number[]'.
!!! error TS2345: Type '{}' is not assignable to type 'number'.
!!! error TS2345: Argument of type 'Array<string | number>' is not assignable to parameter of type 'number[]'.
!!! error TS2345: Type 'string | number' is not assignable to type 'number':
!!! error TS2345: Type 'string' is not assignable to type 'number'.
}
}

View file

@ -1,16 +1,19 @@
tests/cases/compiler/tupleTypes.ts(1,9): error TS1122: A tuple type element list cannot be empty.
tests/cases/compiler/tupleTypes.ts(14,1): error TS2322: Type '{}[]' is not assignable to type '[number, string]':
Property '0' is missing in type '{}[]'.
tests/cases/compiler/tupleTypes.ts(12,5): error TS2403: Subsequent variable declarations must have the same type. Variable 't2' must be of type 'string | number', but here has type '{}'.
tests/cases/compiler/tupleTypes.ts(14,1): error TS2322: Type 'Array<string | number>' is not assignable to type '[number, string]':
Property '0' is missing in type 'Array<string | number>'.
tests/cases/compiler/tupleTypes.ts(15,1): error TS2322: Type '[number]' is not assignable to type '[number, string]':
Property '1' is missing in type '[number]'.
tests/cases/compiler/tupleTypes.ts(17,1): error TS2322: Type '[string, number]' is not assignable to type '[number, string]':
Types of property '0' are incompatible:
Type 'string' is not assignable to type 'number'.
tests/cases/compiler/tupleTypes.ts(41,1): error TS2323: Type '{}[]' is not assignable to type '[number, string]'.
tests/cases/compiler/tupleTypes.ts(36,5): error TS2403: Subsequent variable declarations must have the same type. Variable 'tt2' must be of type 'string | number', but here has type '{}'.
tests/cases/compiler/tupleTypes.ts(41,1): error TS2323: Type 'Array<string | number>' is not assignable to type '[number, string]'.
tests/cases/compiler/tupleTypes.ts(47,1): error TS2322: Type '[number, string]' is not assignable to type 'number[]':
Types of property 'pop' are incompatible:
Type '() => {}' is not assignable to type '() => number':
Type '{}' is not assignable to type 'number'.
Type '() => string | number' is not assignable to type '() => number':
Type 'string | number' is not assignable to type 'number':
Type 'string' is not assignable to type 'number'.
tests/cases/compiler/tupleTypes.ts(49,1): error TS2322: Type '[number, {}]' is not assignable to type 'number[]':
Types of property 'pop' are incompatible:
Type '() => {}' is not assignable to type '() => number':
@ -23,7 +26,7 @@ tests/cases/compiler/tupleTypes.ts(51,1): error TS2322: Type '[number, {}]' is n
Type '{}' is not assignable to type 'string'.
==== tests/cases/compiler/tupleTypes.ts (9 errors) ====
==== tests/cases/compiler/tupleTypes.ts (11 errors) ====
var v1: []; // Error
~~
!!! error TS1122: A tuple type element list cannot be empty.
@ -38,11 +41,13 @@ tests/cases/compiler/tupleTypes.ts(51,1): error TS2322: Type '[number, {}]' is n
var t1: string;
var t2 = t[2]; // {}
var t2: {};
~~
!!! error TS2403: Subsequent variable declarations must have the same type. Variable 't2' must be of type 'string | number', but here has type '{}'.
t = []; // Error
~
!!! error TS2322: Type '{}[]' is not assignable to type '[number, string]':
!!! error TS2322: Property '0' is missing in type '{}[]'.
!!! error TS2322: Type 'Array<string | number>' is not assignable to type '[number, string]':
!!! error TS2322: Property '0' is missing in type 'Array<string | number>'.
t = [1]; // Error
~
!!! error TS2322: Type '[number]' is not assignable to type '[number, string]':
@ -72,13 +77,15 @@ tests/cases/compiler/tupleTypes.ts(51,1): error TS2322: Type '[number, {}]' is n
var tt1: string;
var tt2 = tt[2];
var tt2: {};
~~~
!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'tt2' must be of type 'string | number', but here has type '{}'.
tt = tuple2(1, undefined);
tt = [1, undefined];
tt = [undefined, undefined];
tt = []; // Error
~~
!!! error TS2323: Type '{}[]' is not assignable to type '[number, string]'.
!!! error TS2323: Type 'Array<string | number>' is not assignable to type '[number, string]'.
var a: number[];
var a1: [number, string];
@ -88,8 +95,9 @@ tests/cases/compiler/tupleTypes.ts(51,1): error TS2322: Type '[number, {}]' is n
~
!!! error TS2322: Type '[number, string]' is not assignable to type 'number[]':
!!! error TS2322: Types of property 'pop' are incompatible:
!!! error TS2322: Type '() => {}' is not assignable to type '() => number':
!!! error TS2322: Type '{}' is not assignable to type 'number'.
!!! error TS2322: Type '() => string | number' is not assignable to type '() => number':
!!! error TS2322: Type 'string | number' is not assignable to type 'number':
!!! error TS2322: Type 'string' is not assignable to type 'number'.
a = a2;
a = a3; // Error
~

View file

@ -0,0 +1,18 @@
tests/cases/compiler/typeArgInference2.ts(12,10): error TS2346: Supplied parameters do not match any signature of call target.
==== tests/cases/compiler/typeArgInference2.ts (1 errors) ====
interface Item {
name: string;
}
declare function foo<T extends Item>(x?: T, y?: T): T;
var z1 = foo(null); // any
var z2 = foo(); // Item
var z3 = foo({ name: null }); // { name: any }
var z4 = foo({ name: "abc" }); // { name: string }
var z5 = foo({ name: "abc", a: 5 }); // { name: string; a: number }
var z6 = foo({ name: "abc", a: 5 }, { name: "def", b: 5 }); // Item
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2346: Supplied parameters do not match any signature of call target.

View file

@ -1,61 +0,0 @@
=== tests/cases/compiler/typeArgInference2.ts ===
interface Item {
>Item : Item
name: string;
>name : string
}
declare function foo<T extends Item>(x?: T, y?: T): T;
>foo : <T extends Item>(x?: T, y?: T) => T
>T : T
>Item : Item
>x : T
>T : T
>y : T
>T : T
>T : T
var z1 = foo(null); // any
>z1 : any
>foo(null) : any
>foo : <T extends Item>(x?: T, y?: T) => T
var z2 = foo(); // Item
>z2 : Item
>foo() : Item
>foo : <T extends Item>(x?: T, y?: T) => T
var z3 = foo({ name: null }); // { name: any }
>z3 : { name: any; }
>foo({ name: null }) : { name: any; }
>foo : <T extends Item>(x?: T, y?: T) => T
>{ name: null } : { name: null; }
>name : null
var z4 = foo({ name: "abc" }); // { name: string }
>z4 : { name: string; }
>foo({ name: "abc" }) : { name: string; }
>foo : <T extends Item>(x?: T, y?: T) => T
>{ name: "abc" } : { name: string; }
>name : string
var z5 = foo({ name: "abc", a: 5 }); // { name: string; a: number }
>z5 : { name: string; a: number; }
>foo({ name: "abc", a: 5 }) : { name: string; a: number; }
>foo : <T extends Item>(x?: T, y?: T) => T
>{ name: "abc", a: 5 } : { name: string; a: number; }
>name : string
>a : number
var z6 = foo({ name: "abc", a: 5 }, { name: "def", b: 5 }); // Item
>z6 : Item
>foo({ name: "abc", a: 5 }, { name: "def", b: 5 }) : Item
>foo : <T extends Item>(x?: T, y?: T) => T
>{ name: "abc", a: 5 } : { name: string; a: number; }
>name : string
>a : number
>{ name: "def", b: 5 } : { name: string; b: number; }
>name : string
>b : number

View file

@ -1,4 +1,4 @@
tests/cases/compiler/typeArgInference2WithError.ts(7,14): error TS2345: Argument of type 'string' is not assignable to parameter of type 'Item'.
tests/cases/compiler/typeArgInference2WithError.ts(7,10): error TS2346: Supplied parameters do not match any signature of call target.
==== tests/cases/compiler/typeArgInference2WithError.ts (1 errors) ====
@ -9,5 +9,5 @@ tests/cases/compiler/typeArgInference2WithError.ts(7,14): error TS2345: Argument
declare function foo<T extends Item>(x?: T, y?: T): T;
var z7 = foo("abc", 5); // Error
~~~~~
!!! error TS2345: Argument of type 'string' is not assignable to parameter of type 'Item'.
~~~~~~~~~~~~~
!!! error TS2346: Supplied parameters do not match any signature of call target.

View file

@ -0,0 +1,109 @@
tests/cases/conformance/expressions/functionCalls/typeArgumentInference.ts(68,11): error TS2346: Supplied parameters do not match any signature of call target.
tests/cases/conformance/expressions/functionCalls/typeArgumentInference.ts(82,11): error TS2346: Supplied parameters do not match any signature of call target.
==== tests/cases/conformance/expressions/functionCalls/typeArgumentInference.ts (2 errors) ====
// Generic call with no parameters
function noParams<T>() { }
noParams();
noParams<string>();
noParams<{}>();
// Generic call with parameters but none use type parameter type
function noGenericParams<T>(n: string) { }
noGenericParams('');
noGenericParams<number>('');
noGenericParams<{}>('');
// Generic call with multiple type parameters and only one used in parameter type annotation
function someGenerics1<T, U>(n: T, m: number) { }
someGenerics1(3, 4);
someGenerics1<number, {}>(3, 4);
// Generic call with argument of function type whose parameter is of type parameter type
function someGenerics2a<T>(n: (x: T) => void) { }
someGenerics2a((n: string) => n);
someGenerics2a<string>((n: string) => n);
someGenerics2a<string>((n) => n.substr(0));
function someGenerics2b<T, U>(n: (x: T, y: U) => void) { }
someGenerics2b((n: string, x: number) => n);
someGenerics2b<string, number>((n: string, t: number) => n);
someGenerics2b<string, number>((n, t) => n.substr(t * t));
// Generic call with argument of function type whose parameter is not of type parameter type but body/return type uses type parameter
function someGenerics3<T>(producer: () => T) { }
someGenerics3(() => '');
someGenerics3<Date>(() => undefined);
someGenerics3<number>(() => 3);
// 2 parameter generic call with argument 1 of type parameter type and argument 2 of function type whose parameter is of type parameter type
function someGenerics4<T, U>(n: T, f: (x: U) => void) { }
someGenerics4(4, () => null);
someGenerics4<string, number>('', () => 3);
someGenerics4<string, number>(null, null);
// 2 parameter generic call with argument 2 of type parameter type and argument 1 of function type whose parameter is of type parameter type
function someGenerics5<U, T>(n: T, f: (x: U) => void) { }
someGenerics5(4, () => null);
someGenerics5<number, string>('', () => 3);
someGenerics5<string, number>(null, null);
// Generic call with multiple arguments of function types that each have parameters of the same generic type
function someGenerics6<A>(a: (a: A) => A, b: (b: A) => A, c: (c: A) => A) { }
someGenerics6(n => n, n => n, n => n);
someGenerics6<number>(n => n, n => n, n => n);
someGenerics6<number>((n: number) => n, (n: number) => n, (n: number) => n);
// Generic call with multiple arguments of function types that each have parameters of different generic type
function someGenerics7<A, B, C>(a: (a: A) => A, b: (b: B) => B, c: (c: C) => C) { }
someGenerics7(n => n, n => n, n => n);
someGenerics7<number, string, number>(n => n, n => n, n => n);
someGenerics7<number, string, number>((n: number) => n, (n: string) => n, (n: number) => n);
// Generic call with argument of generic function type
function someGenerics8<T>(n: T): T { return n; }
var x = someGenerics8(someGenerics7);
x<string, string, string>(null, null, null);
// Generic call with multiple parameters of generic type passed arguments with no best common type
function someGenerics9<T>(a: T, b: T, c: T): T {
return null;
}
var a9a = someGenerics9('', 0, []);
~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2346: Supplied parameters do not match any signature of call target.
var a9a: {};
var a9b = someGenerics9<{ a?: number; b?: string; }>({ a: 0 }, { b: '' }, null);
var a9b: { a?: number; b?: string; };
// Generic call with multiple parameters of generic type passed arguments with multiple best common types
interface A91 {
x: number;
y?: string;
}
interface A92 {
x: number;
z?: Date;
}
var a9e = someGenerics9(undefined, { x: 6, z: new Date() }, { x: 6, y: '' });
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2346: Supplied parameters do not match any signature of call target.
var a9e: {};
var a9f = someGenerics9<A92>(undefined, { x: 6, z: new Date() }, { x: 6, y: '' });
var a9f: A92;
// Generic call with multiple parameters of generic type passed arguments with a single best common type
var a9d = someGenerics9({ x: 3 }, { x: 6 }, { x: 6 });
var a9d: { x: number; };
// Generic call with multiple parameters of generic type where one argument is of type 'any'
var anyVar: any;
var a = someGenerics9(7, anyVar, 4);
var a: any;
// Generic call with multiple parameters of generic type where one argument is [] and the other is not 'any'
var arr = someGenerics9([], null, undefined);
var arr: any[];

View file

@ -1,468 +0,0 @@
=== tests/cases/conformance/expressions/functionCalls/typeArgumentInference.ts ===
// Generic call with no parameters
function noParams<T>() { }
>noParams : <T>() => void
>T : T
noParams();
>noParams() : void
>noParams : <T>() => void
noParams<string>();
>noParams<string>() : void
>noParams : <T>() => void
noParams<{}>();
>noParams<{}>() : void
>noParams : <T>() => void
// Generic call with parameters but none use type parameter type
function noGenericParams<T>(n: string) { }
>noGenericParams : <T>(n: string) => void
>T : T
>n : string
noGenericParams('');
>noGenericParams('') : void
>noGenericParams : <T>(n: string) => void
noGenericParams<number>('');
>noGenericParams<number>('') : void
>noGenericParams : <T>(n: string) => void
noGenericParams<{}>('');
>noGenericParams<{}>('') : void
>noGenericParams : <T>(n: string) => void
// Generic call with multiple type parameters and only one used in parameter type annotation
function someGenerics1<T, U>(n: T, m: number) { }
>someGenerics1 : <T, U>(n: T, m: number) => void
>T : T
>U : U
>n : T
>T : T
>m : number
someGenerics1(3, 4);
>someGenerics1(3, 4) : void
>someGenerics1 : <T, U>(n: T, m: number) => void
someGenerics1<number, {}>(3, 4);
>someGenerics1<number, {}>(3, 4) : void
>someGenerics1 : <T, U>(n: T, m: number) => void
// Generic call with argument of function type whose parameter is of type parameter type
function someGenerics2a<T>(n: (x: T) => void) { }
>someGenerics2a : <T>(n: (x: T) => void) => void
>T : T
>n : (x: T) => void
>x : T
>T : T
someGenerics2a((n: string) => n);
>someGenerics2a((n: string) => n) : void
>someGenerics2a : <T>(n: (x: T) => void) => void
>(n: string) => n : (n: string) => string
>n : string
>n : string
someGenerics2a<string>((n: string) => n);
>someGenerics2a<string>((n: string) => n) : void
>someGenerics2a : <T>(n: (x: T) => void) => void
>(n: string) => n : (n: string) => string
>n : string
>n : string
someGenerics2a<string>((n) => n.substr(0));
>someGenerics2a<string>((n) => n.substr(0)) : void
>someGenerics2a : <T>(n: (x: T) => void) => void
>(n) => n.substr(0) : (n: string) => string
>n : string
>n.substr(0) : string
>n.substr : (from: number, length?: number) => string
>n : string
>substr : (from: number, length?: number) => string
function someGenerics2b<T, U>(n: (x: T, y: U) => void) { }
>someGenerics2b : <T, U>(n: (x: T, y: U) => void) => void
>T : T
>U : U
>n : (x: T, y: U) => void
>x : T
>T : T
>y : U
>U : U
someGenerics2b((n: string, x: number) => n);
>someGenerics2b((n: string, x: number) => n) : void
>someGenerics2b : <T, U>(n: (x: T, y: U) => void) => void
>(n: string, x: number) => n : (n: string, x: number) => string
>n : string
>x : number
>n : string
someGenerics2b<string, number>((n: string, t: number) => n);
>someGenerics2b<string, number>((n: string, t: number) => n) : void
>someGenerics2b : <T, U>(n: (x: T, y: U) => void) => void
>(n: string, t: number) => n : (n: string, t: number) => string
>n : string
>t : number
>n : string
someGenerics2b<string, number>((n, t) => n.substr(t * t));
>someGenerics2b<string, number>((n, t) => n.substr(t * t)) : void
>someGenerics2b : <T, U>(n: (x: T, y: U) => void) => void
>(n, t) => n.substr(t * t) : (n: string, t: number) => string
>n : string
>t : number
>n.substr(t * t) : string
>n.substr : (from: number, length?: number) => string
>n : string
>substr : (from: number, length?: number) => string
>t * t : number
>t : number
>t : number
// Generic call with argument of function type whose parameter is not of type parameter type but body/return type uses type parameter
function someGenerics3<T>(producer: () => T) { }
>someGenerics3 : <T>(producer: () => T) => void
>T : T
>producer : () => T
>T : T
someGenerics3(() => '');
>someGenerics3(() => '') : void
>someGenerics3 : <T>(producer: () => T) => void
>() => '' : () => string
someGenerics3<Date>(() => undefined);
>someGenerics3<Date>(() => undefined) : void
>someGenerics3 : <T>(producer: () => T) => void
>Date : Date
>() => undefined : () => any
>undefined : undefined
someGenerics3<number>(() => 3);
>someGenerics3<number>(() => 3) : void
>someGenerics3 : <T>(producer: () => T) => void
>() => 3 : () => number
// 2 parameter generic call with argument 1 of type parameter type and argument 2 of function type whose parameter is of type parameter type
function someGenerics4<T, U>(n: T, f: (x: U) => void) { }
>someGenerics4 : <T, U>(n: T, f: (x: U) => void) => void
>T : T
>U : U
>n : T
>T : T
>f : (x: U) => void
>x : U
>U : U
someGenerics4(4, () => null);
>someGenerics4(4, () => null) : void
>someGenerics4 : <T, U>(n: T, f: (x: U) => void) => void
>() => null : () => any
someGenerics4<string, number>('', () => 3);
>someGenerics4<string, number>('', () => 3) : void
>someGenerics4 : <T, U>(n: T, f: (x: U) => void) => void
>() => 3 : () => number
someGenerics4<string, number>(null, null);
>someGenerics4<string, number>(null, null) : void
>someGenerics4 : <T, U>(n: T, f: (x: U) => void) => void
// 2 parameter generic call with argument 2 of type parameter type and argument 1 of function type whose parameter is of type parameter type
function someGenerics5<U, T>(n: T, f: (x: U) => void) { }
>someGenerics5 : <U, T>(n: T, f: (x: U) => void) => void
>U : U
>T : T
>n : T
>T : T
>f : (x: U) => void
>x : U
>U : U
someGenerics5(4, () => null);
>someGenerics5(4, () => null) : void
>someGenerics5 : <U, T>(n: T, f: (x: U) => void) => void
>() => null : () => any
someGenerics5<number, string>('', () => 3);
>someGenerics5<number, string>('', () => 3) : void
>someGenerics5 : <U, T>(n: T, f: (x: U) => void) => void
>() => 3 : () => number
someGenerics5<string, number>(null, null);
>someGenerics5<string, number>(null, null) : void
>someGenerics5 : <U, T>(n: T, f: (x: U) => void) => void
// Generic call with multiple arguments of function types that each have parameters of the same generic type
function someGenerics6<A>(a: (a: A) => A, b: (b: A) => A, c: (c: A) => A) { }
>someGenerics6 : <A>(a: (a: A) => A, b: (b: A) => A, c: (c: A) => A) => void
>A : A
>a : (a: A) => A
>a : A
>A : A
>A : A
>b : (b: A) => A
>b : A
>A : A
>A : A
>c : (c: A) => A
>c : A
>A : A
>A : A
someGenerics6(n => n, n => n, n => n);
>someGenerics6(n => n, n => n, n => n) : void
>someGenerics6 : <A>(a: (a: A) => A, b: (b: A) => A, c: (c: A) => A) => void
>n => n : (n: {}) => {}
>n : {}
>n : {}
>n => n : (n: {}) => {}
>n : {}
>n : {}
>n => n : (n: {}) => {}
>n : {}
>n : {}
someGenerics6<number>(n => n, n => n, n => n);
>someGenerics6<number>(n => n, n => n, n => n) : void
>someGenerics6 : <A>(a: (a: A) => A, b: (b: A) => A, c: (c: A) => A) => void
>n => n : (n: number) => number
>n : number
>n : number
>n => n : (n: number) => number
>n : number
>n : number
>n => n : (n: number) => number
>n : number
>n : number
someGenerics6<number>((n: number) => n, (n: number) => n, (n: number) => n);
>someGenerics6<number>((n: number) => n, (n: number) => n, (n: number) => n) : void
>someGenerics6 : <A>(a: (a: A) => A, b: (b: A) => A, c: (c: A) => A) => void
>(n: number) => n : (n: number) => number
>n : number
>n : number
>(n: number) => n : (n: number) => number
>n : number
>n : number
>(n: number) => n : (n: number) => number
>n : number
>n : number
// Generic call with multiple arguments of function types that each have parameters of different generic type
function someGenerics7<A, B, C>(a: (a: A) => A, b: (b: B) => B, c: (c: C) => C) { }
>someGenerics7 : <A, B, C>(a: (a: A) => A, b: (b: B) => B, c: (c: C) => C) => void
>A : A
>B : B
>C : C
>a : (a: A) => A
>a : A
>A : A
>A : A
>b : (b: B) => B
>b : B
>B : B
>B : B
>c : (c: C) => C
>c : C
>C : C
>C : C
someGenerics7(n => n, n => n, n => n);
>someGenerics7(n => n, n => n, n => n) : void
>someGenerics7 : <A, B, C>(a: (a: A) => A, b: (b: B) => B, c: (c: C) => C) => void
>n => n : (n: {}) => {}
>n : {}
>n : {}
>n => n : (n: {}) => {}
>n : {}
>n : {}
>n => n : (n: {}) => {}
>n : {}
>n : {}
someGenerics7<number, string, number>(n => n, n => n, n => n);
>someGenerics7<number, string, number>(n => n, n => n, n => n) : void
>someGenerics7 : <A, B, C>(a: (a: A) => A, b: (b: B) => B, c: (c: C) => C) => void
>n => n : (n: number) => number
>n : number
>n : number
>n => n : (n: string) => string
>n : string
>n : string
>n => n : (n: number) => number
>n : number
>n : number
someGenerics7<number, string, number>((n: number) => n, (n: string) => n, (n: number) => n);
>someGenerics7<number, string, number>((n: number) => n, (n: string) => n, (n: number) => n) : void
>someGenerics7 : <A, B, C>(a: (a: A) => A, b: (b: B) => B, c: (c: C) => C) => void
>(n: number) => n : (n: number) => number
>n : number
>n : number
>(n: string) => n : (n: string) => string
>n : string
>n : string
>(n: number) => n : (n: number) => number
>n : number
>n : number
// Generic call with argument of generic function type
function someGenerics8<T>(n: T): T { return n; }
>someGenerics8 : <T>(n: T) => T
>T : T
>n : T
>T : T
>T : T
>n : T
var x = someGenerics8(someGenerics7);
>x : <A, B, C>(a: (a: A) => A, b: (b: B) => B, c: (c: C) => C) => void
>someGenerics8(someGenerics7) : <A, B, C>(a: (a: A) => A, b: (b: B) => B, c: (c: C) => C) => void
>someGenerics8 : <T>(n: T) => T
>someGenerics7 : <A, B, C>(a: (a: A) => A, b: (b: B) => B, c: (c: C) => C) => void
x<string, string, string>(null, null, null);
>x<string, string, string>(null, null, null) : void
>x : <A, B, C>(a: (a: A) => A, b: (b: B) => B, c: (c: C) => C) => void
// Generic call with multiple parameters of generic type passed arguments with no best common type
function someGenerics9<T>(a: T, b: T, c: T): T {
>someGenerics9 : <T>(a: T, b: T, c: T) => T
>T : T
>a : T
>T : T
>b : T
>T : T
>c : T
>T : T
>T : T
return null;
}
var a9a = someGenerics9('', 0, []);
>a9a : {}
>someGenerics9('', 0, []) : {}
>someGenerics9 : <T>(a: T, b: T, c: T) => T
>[] : undefined[]
var a9a: {};
>a9a : {}
var a9b = someGenerics9<{ a?: number; b?: string; }>({ a: 0 }, { b: '' }, null);
>a9b : { a?: number; b?: string; }
>someGenerics9<{ a?: number; b?: string; }>({ a: 0 }, { b: '' }, null) : { a?: number; b?: string; }
>someGenerics9 : <T>(a: T, b: T, c: T) => T
>a : number
>b : string
>{ a: 0 } : { a: number; }
>a : number
>{ b: '' } : { b: string; }
>b : string
var a9b: { a?: number; b?: string; };
>a9b : { a?: number; b?: string; }
>a : number
>b : string
// Generic call with multiple parameters of generic type passed arguments with multiple best common types
interface A91 {
>A91 : A91
x: number;
>x : number
y?: string;
>y : string
}
interface A92 {
>A92 : A92
x: number;
>x : number
z?: Date;
>z : Date
>Date : Date
}
var a9e = someGenerics9(undefined, { x: 6, z: new Date() }, { x: 6, y: '' });
>a9e : {}
>someGenerics9(undefined, { x: 6, z: new Date() }, { x: 6, y: '' }) : {}
>someGenerics9 : <T>(a: T, b: T, c: T) => T
>undefined : undefined
>{ x: 6, z: new Date() } : { x: number; z: Date; }
>x : number
>z : Date
>new Date() : Date
>Date : { (): string; new (): Date; new (value: number): Date; new (value: string): Date; new (year: number, month: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): Date; prototype: Date; parse(s: string): number; UTC(year: number, month: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): number; now(): number; }
>{ x: 6, y: '' } : { x: number; y: string; }
>x : number
>y : string
var a9e: {};
>a9e : {}
var a9f = someGenerics9<A92>(undefined, { x: 6, z: new Date() }, { x: 6, y: '' });
>a9f : A92
>someGenerics9<A92>(undefined, { x: 6, z: new Date() }, { x: 6, y: '' }) : A92
>someGenerics9 : <T>(a: T, b: T, c: T) => T
>A92 : A92
>undefined : undefined
>{ x: 6, z: new Date() } : { x: number; z: Date; }
>x : number
>z : Date
>new Date() : Date
>Date : { (): string; new (): Date; new (value: number): Date; new (value: string): Date; new (year: number, month: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): Date; prototype: Date; parse(s: string): number; UTC(year: number, month: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): number; now(): number; }
>{ x: 6, y: '' } : { x: number; y: string; }
>x : number
>y : string
var a9f: A92;
>a9f : A92
>A92 : A92
// Generic call with multiple parameters of generic type passed arguments with a single best common type
var a9d = someGenerics9({ x: 3 }, { x: 6 }, { x: 6 });
>a9d : { x: number; }
>someGenerics9({ x: 3 }, { x: 6 }, { x: 6 }) : { x: number; }
>someGenerics9 : <T>(a: T, b: T, c: T) => T
>{ x: 3 } : { x: number; }
>x : number
>{ x: 6 } : { x: number; }
>x : number
>{ x: 6 } : { x: number; }
>x : number
var a9d: { x: number; };
>a9d : { x: number; }
>x : number
// Generic call with multiple parameters of generic type where one argument is of type 'any'
var anyVar: any;
>anyVar : any
var a = someGenerics9(7, anyVar, 4);
>a : any
>someGenerics9(7, anyVar, 4) : any
>someGenerics9 : <T>(a: T, b: T, c: T) => T
>anyVar : any
var a: any;
>a : any
// Generic call with multiple parameters of generic type where one argument is [] and the other is not 'any'
var arr = someGenerics9([], null, undefined);
>arr : any[]
>someGenerics9([], null, undefined) : any[]
>someGenerics9 : <T>(a: T, b: T, c: T) => T
>[] : any[]
>undefined : undefined
var arr: any[];
>arr : any[]

View file

@ -3,12 +3,14 @@ tests/cases/conformance/expressions/functionCalls/typeArgumentInferenceConstruct
tests/cases/conformance/expressions/functionCalls/typeArgumentInferenceConstructSignatures.ts(61,39): error TS2345: Argument of type '(x: string) => string' is not assignable to parameter of type '(x: number) => void'.
tests/cases/conformance/expressions/functionCalls/typeArgumentInferenceConstructSignatures.ts(71,39): error TS2345: Argument of type '(x: string) => string' is not assignable to parameter of type '(x: number) => void'.
tests/cases/conformance/expressions/functionCalls/typeArgumentInferenceConstructSignatures.ts(81,45): error TS2345: Argument of type '(n: string) => string' is not assignable to parameter of type '(b: number) => number'.
tests/cases/conformance/expressions/functionCalls/typeArgumentInferenceConstructSignatures.ts(106,11): error TS2346: Supplied parameters do not match any signature of call target.
tests/cases/conformance/expressions/functionCalls/typeArgumentInferenceConstructSignatures.ts(118,9): error TS2304: Cannot find name 'Window'.
tests/cases/conformance/expressions/functionCalls/typeArgumentInferenceConstructSignatures.ts(120,11): error TS2346: Supplied parameters do not match any signature of call target.
tests/cases/conformance/expressions/functionCalls/typeArgumentInferenceConstructSignatures.ts(120,51): error TS2304: Cannot find name 'window'.
tests/cases/conformance/expressions/functionCalls/typeArgumentInferenceConstructSignatures.ts(122,56): error TS2304: Cannot find name 'window'.
==== tests/cases/conformance/expressions/functionCalls/typeArgumentInferenceConstructSignatures.ts (8 errors) ====
==== tests/cases/conformance/expressions/functionCalls/typeArgumentInferenceConstructSignatures.ts (10 errors) ====
// Generic call with no parameters
interface NoParams {
new <T>();
@ -125,6 +127,8 @@ tests/cases/conformance/expressions/functionCalls/typeArgumentInferenceConstruct
}
var someGenerics9: someGenerics9;
var a9a = new someGenerics9('', 0, []);
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2346: Supplied parameters do not match any signature of call target.
var a9a: {};
var a9b = new someGenerics9<{ a?: number; b?: string; }>({ a: 0 }, { b: '' }, null);
var a9b: { a?: number; b?: string; };
@ -141,6 +145,8 @@ tests/cases/conformance/expressions/functionCalls/typeArgumentInferenceConstruct
!!! error TS2304: Cannot find name 'Window'.
}
var a9e = new someGenerics9(undefined, { x: 6, z: window }, { x: 6, y: '' });
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2346: Supplied parameters do not match any signature of call target.
~~~~~~
!!! error TS2304: Cannot find name 'window'.
var a9e: {};

View file

@ -1,9 +1,8 @@
tests/cases/conformance/expressions/functionCalls/typeArgumentInferenceTransitiveConstraints.ts(2,29): error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list.
tests/cases/conformance/expressions/functionCalls/typeArgumentInferenceTransitiveConstraints.ts(2,42): error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list.
tests/cases/conformance/expressions/functionCalls/typeArgumentInferenceTransitiveConstraints.ts(7,5): error TS2403: Subsequent variable declarations must have the same type. Variable 'd' must be of type '{}[]', but here has type 'Date[]'.
==== tests/cases/conformance/expressions/functionCalls/typeArgumentInferenceTransitiveConstraints.ts (3 errors) ====
==== tests/cases/conformance/expressions/functionCalls/typeArgumentInferenceTransitiveConstraints.ts (2 errors) ====
function fn<A extends Date, B extends A, C extends B>(a: A, b: B, c: C) {
~~~~~~~~~~~
@ -15,6 +14,4 @@ tests/cases/conformance/expressions/functionCalls/typeArgumentInferenceTransitiv
var d = fn(new Date(), new Date(), new Date());
var d: Date[]; // Should be OK (d should be Date[])
~
!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'd' must be of type '{}[]', but here has type 'Date[]'.

View file

@ -0,0 +1,13 @@
tests/cases/compiler/typeArgumentInferenceWithConstraintAsCommonRoot.ts(7,1): error TS2346: Supplied parameters do not match any signature of call target.
==== tests/cases/compiler/typeArgumentInferenceWithConstraintAsCommonRoot.ts (1 errors) ====
interface Animal { x }
interface Giraffe extends Animal { y }
interface Elephant extends Animal { z }
function f<T extends Animal>(x: T, y: T): T { return undefined; }
var g: Giraffe;
var e: Elephant;
f(g, e); // valid because both Giraffe and Elephant satisfy the constraint. T is Animal
~~~~~~~
!!! error TS2346: Supplied parameters do not match any signature of call target.

View file

@ -1,40 +0,0 @@
=== tests/cases/compiler/typeArgumentInferenceWithConstraintAsCommonRoot.ts ===
interface Animal { x }
>Animal : Animal
>x : any
interface Giraffe extends Animal { y }
>Giraffe : Giraffe
>Animal : Animal
>y : any
interface Elephant extends Animal { z }
>Elephant : Elephant
>Animal : Animal
>z : any
function f<T extends Animal>(x: T, y: T): T { return undefined; }
>f : <T extends Animal>(x: T, y: T) => T
>T : T
>Animal : Animal
>x : T
>T : T
>y : T
>T : T
>T : T
>undefined : undefined
var g: Giraffe;
>g : Giraffe
>Giraffe : Giraffe
var e: Elephant;
>e : Elephant
>Elephant : Elephant
f(g, e); // valid because both Giraffe and Elephant satisfy the constraint. T is Animal
>f(g, e) : Animal
>f : <T extends Animal>(x: T, y: T) => T
>g : Giraffe
>e : Elephant

View file

@ -8,12 +8,14 @@ tests/cases/conformance/expressions/functionCalls/typeArgumentInferenceWithConst
tests/cases/conformance/expressions/functionCalls/typeArgumentInferenceWithConstraints.ts(49,15): error TS2344: Type 'string' does not satisfy the constraint 'number'.
tests/cases/conformance/expressions/functionCalls/typeArgumentInferenceWithConstraints.ts(55,41): error TS2345: Argument of type '(n: string) => string' is not assignable to parameter of type '(b: number) => number'.
tests/cases/conformance/expressions/functionCalls/typeArgumentInferenceWithConstraints.ts(66,31): error TS2345: Argument of type '<A, B extends string, C>(a: (a: A) => A, b: (b: B) => B, c: (c: C) => C) => void' is not assignable to parameter of type 'string'.
tests/cases/conformance/expressions/functionCalls/typeArgumentInferenceWithConstraints.ts(73,11): error TS2346: Supplied parameters do not match any signature of call target.
tests/cases/conformance/expressions/functionCalls/typeArgumentInferenceWithConstraints.ts(85,9): error TS2304: Cannot find name 'Window'.
tests/cases/conformance/expressions/functionCalls/typeArgumentInferenceWithConstraints.ts(87,11): error TS2346: Supplied parameters do not match any signature of call target.
tests/cases/conformance/expressions/functionCalls/typeArgumentInferenceWithConstraints.ts(87,47): error TS2304: Cannot find name 'window'.
tests/cases/conformance/expressions/functionCalls/typeArgumentInferenceWithConstraints.ts(89,52): error TS2304: Cannot find name 'window'.
==== tests/cases/conformance/expressions/functionCalls/typeArgumentInferenceWithConstraints.ts (13 errors) ====
==== tests/cases/conformance/expressions/functionCalls/typeArgumentInferenceWithConstraints.ts (15 errors) ====
// Generic call with no parameters
function noParams<T extends {}>() { }
noParams();
@ -107,6 +109,8 @@ tests/cases/conformance/expressions/functionCalls/typeArgumentInferenceWithConst
return null;
}
var a9a = someGenerics9('', 0, []);
~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2346: Supplied parameters do not match any signature of call target.
var a9a: {};
var a9b = someGenerics9<{ a?: number; b?: string; }>({ a: 0 }, { b: '' }, null);
var a9b: { a?: number; b?: string; };
@ -123,6 +127,8 @@ tests/cases/conformance/expressions/functionCalls/typeArgumentInferenceWithConst
!!! error TS2304: Cannot find name 'Window'.
}
var a9e = someGenerics9(undefined, { x: 6, z: window }, { x: 6, y: '' });
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2346: Supplied parameters do not match any signature of call target.
~~~~~~
!!! error TS2304: Cannot find name 'window'.
var a9e: {};

View file

@ -0,0 +1,9 @@
tests/cases/compiler/typeInferenceConflictingCandidates.ts(3,1): error TS2346: Supplied parameters do not match any signature of call target.
==== tests/cases/compiler/typeInferenceConflictingCandidates.ts (1 errors) ====
declare function g<T>(a: T, b: T, c: (t: T) => T): T;
g("", 3, a => a);
~~~~~~~~~~~~~~~~
!!! error TS2346: Supplied parameters do not match any signature of call target.

View file

@ -1,21 +0,0 @@
=== tests/cases/compiler/typeInferenceConflictingCandidates.ts ===
declare function g<T>(a: T, b: T, c: (t: T) => T): T;
>g : <T>(a: T, b: T, c: (t: T) => T) => T
>T : T
>a : T
>T : T
>b : T
>T : T
>c : (t: T) => T
>t : T
>T : T
>T : T
>T : T
g("", 3, a => a);
>g("", 3, a => a) : {}
>g : <T>(a: T, b: T, c: (t: T) => T) => T
>a => a : (a: {}) => {}
>a : {}
>a : {}

View file

@ -8,7 +8,7 @@ function fee<T>() {
>T : T
var arr = [t, ""];
>arr : {}[]
>[t, ""] : {}[]
>arr : Array<string | T>
>[t, ""] : Array<string | T>
>t : T
}

View file

@ -176,7 +176,7 @@ _.all([true, 1, null, 'yes'], _.identity);
>_.all : { <T>(list: T[], iterator?: Iterator<T, boolean>, context?: any): boolean; <T>(list: Dictionary<T>, iterator?: Iterator<T, boolean>, context?: any): boolean; }
>_ : Underscore.Static
>all : { <T>(list: T[], iterator?: Iterator<T, boolean>, context?: any): boolean; <T>(list: Dictionary<T>, iterator?: Iterator<T, boolean>, context?: any): boolean; }
>[true, 1, null, 'yes'] : {}[]
>[true, 1, null, 'yes'] : Array<string | number | boolean>
>_.identity : <T>(value: T) => T
>_ : Underscore.Static
>identity : <T>(value: T) => T
@ -186,7 +186,7 @@ _.any([null, 0, 'yes', false]);
>_.any : { <T>(list: T[], iterator?: Iterator<T, boolean>, context?: any): boolean; <T>(list: Dictionary<T>, iterator?: Iterator<T, boolean>, context?: any): boolean; }
>_ : Underscore.Static
>any : { <T>(list: T[], iterator?: Iterator<T, boolean>, context?: any): boolean; <T>(list: Dictionary<T>, iterator?: Iterator<T, boolean>, context?: any): boolean; }
>[null, 0, 'yes', false] : {}[]
>[null, 0, 'yes', false] : Array<string | number | boolean>
_.contains([1, 2, 3], 3);
>_.contains([1, 2, 3], 3) : boolean
@ -364,11 +364,11 @@ _.rest([5, 4, 3, 2, 1]);
>[5, 4, 3, 2, 1] : number[]
_.compact([0, 1, false, 2, '', 3]);
>_.compact([0, 1, false, 2, '', 3]) : {}[]
>_.compact([0, 1, false, 2, '', 3]) : Array<string | number | boolean>
>_.compact : <T>(list: T[]) => T[]
>_ : Underscore.Static
>compact : <T>(list: T[]) => T[]
>[0, 1, false, 2, '', 3] : {}[]
>[0, 1, false, 2, '', 3] : Array<string | number | boolean>
_.flatten([1, 2, 3, 4]);
>_.flatten([1, 2, 3, 4]) : {}[]
@ -393,7 +393,7 @@ _.flatten([1, [2], [3, [[4]]]]);
>flatten : { <T>(list: T[][]): T[]; <T>(array: any[], shallow?: boolean): T[]; }
>[1, [2], [3, [[4]]]] : any[]
>[2] : number[]
>[3, [[4]]] : {}[]
>[3, [[4]]] : Array<number | number[][]>
>[[4]] : number[][]
>[4] : number[]
@ -404,7 +404,7 @@ _.flatten([1, [2], [3, [[4]]]], true);
>flatten : { <T>(list: T[][]): T[]; <T>(array: any[], shallow?: boolean): T[]; }
>[1, [2], [3, [[4]]]] : any[]
>[2] : number[]
>[3, [[4]]] : {}[]
>[3, [[4]]] : Array<number | number[][]>
>[[4]] : number[][]
>[4] : number[]