diff --git a/tests/baselines/reference/arrayBestCommonTypes.types b/tests/baselines/reference/arrayBestCommonTypes.types index a0f407358c..6495b7df6a 100644 --- a/tests/baselines/reference/arrayBestCommonTypes.types +++ b/tests/baselines/reference/arrayBestCommonTypes.types @@ -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 diff --git a/tests/baselines/reference/arrayLiteralContextualType.errors.txt b/tests/baselines/reference/arrayLiteralContextualType.errors.txt deleted file mode 100644 index 5f661647d9..0000000000 --- a/tests/baselines/reference/arrayLiteralContextualType.errors.txt +++ /dev/null @@ -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; }'. \ No newline at end of file diff --git a/tests/baselines/reference/arrayLiteralContextualType.types b/tests/baselines/reference/arrayLiteralContextualType.types new file mode 100644 index 0000000000..3d5330d00c --- /dev/null +++ b/tests/baselines/reference/arrayLiteralContextualType.types @@ -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 +>[new Giraffe(), new Elephant()] : Array +>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 + +bar(arr); // Error because of no contextual type +>bar(arr) : void +>bar : (animals: { [x: number]: IAnimal; }) => void +>arr : Array + diff --git a/tests/baselines/reference/arrayLiteralWithMultipleBestCommonTypes.types b/tests/baselines/reference/arrayLiteralWithMultipleBestCommonTypes.types index 7729b28016..49b65a86aa 100644 --- a/tests/baselines/reference/arrayLiteralWithMultipleBestCommonTypes.types +++ b/tests/baselines/reference/arrayLiteralWithMultipleBestCommonTypes.types @@ -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; } diff --git a/tests/baselines/reference/arrayLiterals.errors.txt b/tests/baselines/reference/arrayLiterals.errors.txt new file mode 100644 index 0000000000..65666a50ce --- /dev/null +++ b/tests/baselines/reference/arrayLiterals.errors.txt @@ -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', 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', 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', 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', 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; // 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()]; + + \ No newline at end of file diff --git a/tests/baselines/reference/arrayLiterals.types b/tests/baselines/reference/arrayLiterals.types deleted file mode 100644 index 29dd1b1997..0000000000 --- a/tests/baselines/reference/arrayLiterals.types +++ /dev/null @@ -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; // 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 - - diff --git a/tests/baselines/reference/arrayLiteralsWithRecursiveGenerics.types b/tests/baselines/reference/arrayLiteralsWithRecursiveGenerics.types index becff7617b..e99ca18673 100644 --- a/tests/baselines/reference/arrayLiteralsWithRecursiveGenerics.types +++ b/tests/baselines/reference/arrayLiteralsWithRecursiveGenerics.types @@ -61,8 +61,8 @@ var xs = [list, myList]; // {}[] >myList : MyList var ys = [list, list2]; // {}[] ->ys : {}[] ->[list, list2] : {}[] +>ys : Array | List> +>[list, list2] : Array | List> >list : List >list2 : List diff --git a/tests/baselines/reference/bestCommonTypeOfConditionalExpressions.types b/tests/baselines/reference/bestCommonTypeOfConditionalExpressions.types index 3deeae69bb..18fe6efb8c 100644 --- a/tests/baselines/reference/bestCommonTypeOfConditionalExpressions.types +++ b/tests/baselines/reference/bestCommonTypeOfConditionalExpressions.types @@ -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; } diff --git a/tests/baselines/reference/bestCommonTypeOfConditionalExpressions2.errors.txt b/tests/baselines/reference/bestCommonTypeOfConditionalExpressions2.errors.txt index 532a40becd..83f4678c8f 100644 --- a/tests/baselines/reference/bestCommonTypeOfConditionalExpressions2.errors.txt +++ b/tests/baselines/reference/bestCommonTypeOfConditionalExpressions2.errors.txt @@ -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: T, u: U) { return true ? t : u; - ~~~~~~~~~~~~ -!!! error TS2367: No best common type exists between 'T' and 'U'. } function foo2(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: 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'. } \ No newline at end of file diff --git a/tests/baselines/reference/conditionalExpression1.errors.txt b/tests/baselines/reference/conditionalExpression1.errors.txt index 542b660ba4..30703c7169 100644 --- a/tests/baselines/reference/conditionalExpression1.errors.txt +++ b/tests/baselines/reference/conditionalExpression1.errors.txt @@ -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'. \ No newline at end of file +!!! error TS2322: Type 'string | number' is not assignable to type 'boolean': +!!! error TS2322: Type 'string' is not assignable to type 'boolean'. \ No newline at end of file diff --git a/tests/baselines/reference/conditionalOperatorWithoutIdenticalBCT.errors.txt b/tests/baselines/reference/conditionalOperatorWithoutIdenticalBCT.errors.txt index 7db921cbe1..33905a2cda 100644 --- a/tests/baselines/reference/conditionalOperatorWithoutIdenticalBCT.errors.txt +++ b/tests/baselines/reference/conditionalOperatorWithoutIdenticalBCT.errors.txt @@ -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'. \ No newline at end of file +!!! 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'. \ No newline at end of file diff --git a/tests/baselines/reference/contextualTyping21.errors.txt b/tests/baselines/reference/contextualTyping21.errors.txt index 999cfcbd76..620b0635d1 100644 --- a/tests/baselines/reference/contextualTyping21.errors.txt +++ b/tests/baselines/reference/contextualTyping21.errors.txt @@ -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' 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 '{}'. \ No newline at end of file +!!! error TS2322: Type 'Array' 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'. \ No newline at end of file diff --git a/tests/baselines/reference/contextualTyping30.errors.txt b/tests/baselines/reference/contextualTyping30.errors.txt index 3b2fbc8aac..4c8d87d41b 100644 --- a/tests/baselines/reference/contextualTyping30.errors.txt +++ b/tests/baselines/reference/contextualTyping30.errors.txt @@ -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' 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'. \ No newline at end of file +!!! error TS2345: Argument of type 'Array' 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'. \ No newline at end of file diff --git a/tests/baselines/reference/contextualTyping33.errors.txt b/tests/baselines/reference/contextualTyping33.errors.txt index 8f83fc37ab..82799037ec 100644 --- a/tests/baselines/reference/contextualTyping33.errors.txt +++ b/tests/baselines/reference/contextualTyping33.errors.txt @@ -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; }'. \ No newline at end of file +!!! 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; }'. \ No newline at end of file diff --git a/tests/baselines/reference/contextualTypingOfArrayLiterals1.errors.txt b/tests/baselines/reference/contextualTypingOfArrayLiterals1.errors.txt index 0f9fc64536..cb3b439681 100644 --- a/tests/baselines/reference/contextualTypingOfArrayLiterals1.errors.txt +++ b/tests/baselines/reference/contextualTypingOfArrayLiterals1.errors.txt @@ -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' 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' 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(); \ No newline at end of file diff --git a/tests/baselines/reference/contextualTypingOfConditionalExpression2.errors.txt b/tests/baselines/reference/contextualTypingOfConditionalExpression2.errors.txt index c433bd1d8c..574e25c6f4 100644 --- a/tests/baselines/reference/contextualTypingOfConditionalExpression2.errors.txt +++ b/tests/baselines/reference/contextualTypingOfConditionalExpression2.errors.txt @@ -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'. \ No newline at end of file diff --git a/tests/baselines/reference/contextualTypingWithFixedTypeParameters1.errors.txt b/tests/baselines/reference/contextualTypingWithFixedTypeParameters1.errors.txt index e4d8a82c47..b8cd56acad 100644 --- a/tests/baselines/reference/contextualTypingWithFixedTypeParameters1.errors.txt +++ b/tests/baselines/reference/contextualTypingWithFixedTypeParameters1.errors.txt @@ -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: (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 \ No newline at end of file + var r9 = f10('', () => (a => a.foo), 1); // now a should be any + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2346: Supplied parameters do not match any signature of call target. \ No newline at end of file diff --git a/tests/baselines/reference/contextuallyTypingOrOperator.types b/tests/baselines/reference/contextuallyTypingOrOperator.types index ee1ac4b0bb..5a20b2b921 100644 --- a/tests/baselines/reference/contextuallyTypingOrOperator.types +++ b/tests/baselines/reference/contextuallyTypingOrOperator.types @@ -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 diff --git a/tests/baselines/reference/contextuallyTypingOrOperator2.types b/tests/baselines/reference/contextuallyTypingOrOperator2.types index 57c9992436..b46d0c0aed 100644 --- a/tests/baselines/reference/contextuallyTypingOrOperator2.types +++ b/tests/baselines/reference/contextuallyTypingOrOperator2.types @@ -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 diff --git a/tests/baselines/reference/defaultBestCommonTypesHaveDecls.errors.txt b/tests/baselines/reference/defaultBestCommonTypesHaveDecls.errors.txt index ada7f83af3..c03b31e9e2 100644 --- a/tests/baselines/reference/defaultBestCommonTypesHaveDecls.errors.txt +++ b/tests/baselines/reference/defaultBestCommonTypesHaveDecls.errors.txt @@ -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(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 '{}'. \ No newline at end of file diff --git a/tests/baselines/reference/enumBasics.types b/tests/baselines/reference/enumBasics.types index f775295891..696e68eded 100644 --- a/tests/baselines/reference/enumBasics.types +++ b/tests/baselines/reference/enumBasics.types @@ -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 +>[ E8.B, E7.A, E4.Z, E3.X, E3.Y, E3.Z] : Array 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 +>[ E9.A, E9.B, E6.B, E6.C, E6.A, E5.A, E5.B, E5.C] : Array E9.A, E9.B, E6.B, E6.C, E6.A, E5.A, E5.B, E5.C >E9.A : E9 diff --git a/tests/baselines/reference/fixTypeParameterInSignatureWithRestParameters.errors.txt b/tests/baselines/reference/fixTypeParameterInSignatureWithRestParameters.errors.txt new file mode 100644 index 0000000000..d9416eb4c2 --- /dev/null +++ b/tests/baselines/reference/fixTypeParameterInSignatureWithRestParameters.errors.txt @@ -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(item1: T, item2: T) { } + bar(1, ""); // Should be ok + ~~~~~~~~~~ +!!! error TS2346: Supplied parameters do not match any signature of call target. \ No newline at end of file diff --git a/tests/baselines/reference/fixTypeParameterInSignatureWithRestParameters.types b/tests/baselines/reference/fixTypeParameterInSignatureWithRestParameters.types deleted file mode 100644 index 95214571df..0000000000 --- a/tests/baselines/reference/fixTypeParameterInSignatureWithRestParameters.types +++ /dev/null @@ -1,13 +0,0 @@ -=== tests/cases/compiler/fixTypeParameterInSignatureWithRestParameters.ts === -function bar(item1: T, item2: T) { } ->bar : (item1: T, item2: T) => void ->T : T ->item1 : T ->T : T ->item2 : T ->T : T - -bar(1, ""); // Should be ok ->bar(1, "") : void ->bar : (item1: T, item2: T) => void - diff --git a/tests/baselines/reference/forStatementsMultipleInvalidDecl.errors.txt b/tests/baselines/reference/forStatementsMultipleInvalidDecl.errors.txt index b653bc01f5..66e8a2a66d 100644 --- a/tests/baselines/reference/forStatementsMultipleInvalidDecl.errors.txt +++ b/tests/baselines/reference/forStatementsMultipleInvalidDecl.errors.txt @@ -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>'. 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[]', but here has type 'D[]'. 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()];;){} ~~~ -!!! 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>'. for(var arr2 = [new D()];;){} for( var arr2 = new Array>();;){} diff --git a/tests/baselines/reference/generatedContextualTyping.types b/tests/baselines/reference/generatedContextualTyping.types index 57b5408eab..c609c6aec9 100644 --- a/tests/baselines/reference/generatedContextualTyping.types +++ b/tests/baselines/reference/generatedContextualTyping.types @@ -127,11 +127,11 @@ var x12: Genric = { func: n => { return [d1, d2]; } }; >x12 : Genric >Genric : Genric >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; } +>func : (n: Base[]) => Array +>n => { return [d1, d2]; } : (n: Base[]) => Array >n : Base[] ->[d1, d2] : {}[] +>[d1, d2] : Array >d1 : Derived1 >d2 : Derived2 @@ -243,11 +243,11 @@ class x24 { member: Genric = { func: n => { return [d1, d2]; } } } >member : Genric >Genric : Genric >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; } +>func : (n: Base[]) => Array +>n => { return [d1, d2]; } : (n: Base[]) => Array >n : Base[] ->[d1, d2] : {}[] +>[d1, d2] : Array >d1 : Derived1 >d2 : Derived2 @@ -359,11 +359,11 @@ class x36 { private member: Genric = { func: n => { return [d1, d2]; } } } >member : Genric >Genric : Genric >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; } +>func : (n: Base[]) => Array +>n => { return [d1, d2]; } : (n: Base[]) => Array >n : Base[] ->[d1, d2] : {}[] +>[d1, d2] : Array >d1 : Derived1 >d2 : Derived2 @@ -475,11 +475,11 @@ class x48 { public member: Genric = { func: n => { return [d1, d2]; } } } >member : Genric >Genric : Genric >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; } +>func : (n: Base[]) => Array +>n => { return [d1, d2]; } : (n: Base[]) => Array >n : Base[] ->[d1, d2] : {}[] +>[d1, d2] : Array >d1 : Derived1 >d2 : Derived2 @@ -591,11 +591,11 @@ class x60 { static member: Genric = { func: n => { return [d1, d2]; } } } >member : Genric >Genric : Genric >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; } +>func : (n: Base[]) => Array +>n => { return [d1, d2]; } : (n: Base[]) => Array >n : Base[] ->[d1, d2] : {}[] +>[d1, d2] : Array >d1 : Derived1 >d2 : Derived2 @@ -707,11 +707,11 @@ class x72 { private static member: Genric = { func: n => { return [d1, d2] >member : Genric >Genric : Genric >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; } +>func : (n: Base[]) => Array +>n => { return [d1, d2]; } : (n: Base[]) => Array >n : Base[] ->[d1, d2] : {}[] +>[d1, d2] : Array >d1 : Derived1 >d2 : Derived2 @@ -823,11 +823,11 @@ class x84 { public static member: Genric = { func: n => { return [d1, d2]; >member : Genric >Genric : Genric >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; } +>func : (n: Base[]) => Array +>n => { return [d1, d2]; } : (n: Base[]) => Array >n : Base[] ->[d1, d2] : {}[] +>[d1, d2] : Array >d1 : Derived1 >d2 : Derived2 @@ -939,11 +939,11 @@ class x96 { constructor(parm: Genric = { func: n => { return [d1, d2]; } } >parm : Genric >Genric : Genric >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; } +>func : (n: Base[]) => Array +>n => { return [d1, d2]; } : (n: Base[]) => Array >n : Base[] ->[d1, d2] : {}[] +>[d1, d2] : Array >d1 : Derived1 >d2 : Derived2 @@ -1055,11 +1055,11 @@ class x108 { constructor(public parm: Genric = { func: n => { return [d1, >parm : Genric >Genric : Genric >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; } +>func : (n: Base[]) => Array +>n => { return [d1, d2]; } : (n: Base[]) => Array >n : Base[] ->[d1, d2] : {}[] +>[d1, d2] : Array >d1 : Derived1 >d2 : Derived2 @@ -1171,11 +1171,11 @@ class x120 { constructor(private parm: Genric = { func: n => { return [d1, >parm : Genric >Genric : Genric >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; } +>func : (n: Base[]) => Array +>n => { return [d1, d2]; } : (n: Base[]) => Array >n : Base[] ->[d1, d2] : {}[] +>[d1, d2] : Array >d1 : Derived1 >d2 : Derived2 @@ -1287,11 +1287,11 @@ function x132(parm: Genric = { func: n => { return [d1, d2]; } }) { } >parm : Genric >Genric : Genric >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; } +>func : (n: Base[]) => Array +>n => { return [d1, d2]; } : (n: Base[]) => Array >n : Base[] ->[d1, d2] : {}[] +>[d1, d2] : Array >d1 : Derived1 >d2 : Derived2 @@ -1391,11 +1391,11 @@ function x144(): Genric { return { func: n => { return [d1, d2]; } }; } >x144 : () => Genric >Genric : Genric >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; } +>func : (n: Base[]) => Array +>n => { return [d1, d2]; } : (n: Base[]) => Array >n : Base[] ->[d1, d2] : {}[] +>[d1, d2] : Array >d1 : Derived1 >d2 : Derived2 @@ -1539,18 +1539,18 @@ function x156(): Genric { return { func: n => { return [d1, d2]; } }; retu >x156 : () => Genric >Genric : Genric >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; } +>func : (n: Base[]) => Array +>n => { return [d1, d2]; } : (n: Base[]) => Array >n : Base[] ->[d1, d2] : {}[] +>[d1, d2] : Array >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; } +>func : (n: Base[]) => Array +>n => { return [d1, d2]; } : (n: Base[]) => Array >n : Base[] ->[d1, d2] : {}[] +>[d1, d2] : Array >d1 : Derived1 >d2 : Derived2 @@ -1661,12 +1661,12 @@ var x168: () => Genric = () => { return { func: n => { return [d1, d2]; } >x168 : () => Genric >Genric : Genric >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; } +>{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => Array; } +>func : (n: Base[]) => Array +>n => { return [d1, d2]; } : (n: Base[]) => Array >n : Base[] ->[d1, d2] : {}[] +>[d1, d2] : Array >d1 : Derived1 >d2 : Derived2 @@ -1777,12 +1777,12 @@ var x180: () => Genric = function() { return { func: n => { return [d1, d2 >x180 : () => Genric >Genric : Genric >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; } +>{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => Array; } +>func : (n: Base[]) => Array +>n => { return [d1, d2]; } : (n: Base[]) => Array >n : Base[] ->[d1, d2] : {}[] +>[d1, d2] : Array >d1 : Derived1 >d2 : Derived2 @@ -1894,11 +1894,11 @@ module x192 { var t: Genric = { func: n => { return [d1, d2]; } }; } >t : Genric >Genric : Genric >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; } +>func : (n: Base[]) => Array +>n => { return [d1, d2]; } : (n: Base[]) => Array >n : Base[] ->[d1, d2] : {}[] +>[d1, d2] : Array >d1 : Derived1 >d2 : Derived2 @@ -2010,11 +2010,11 @@ module x204 { export var t: Genric = { func: n => { return [d1, d2]; } }; >t : Genric >Genric : Genric >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; } +>func : (n: Base[]) => Array +>n => { return [d1, d2]; } : (n: Base[]) => Array >n : Base[] ->[d1, d2] : {}[] +>[d1, d2] : Array >d1 : Derived1 >d2 : Derived2 @@ -2098,11 +2098,11 @@ var x216 = >{ func: n => { return [d1, d2]; } }; >>{ func: n => { return [d1, d2]; } } : Genric >Genric : Genric >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; } +>func : (n: Base[]) => Array +>n => { return [d1, d2]; } : (n: Base[]) => Array >n : Base[] ->[d1, d2] : {}[] +>[d1, d2] : Array >d1 : Derived1 >d2 : Derived2 @@ -2323,13 +2323,13 @@ var x236: Genric; x236 = { func: n => { return [d1, d2]; } }; >x236 : Genric >Genric : Genric >Base : Base ->x236 = { func: n => { return [d1, d2]; } } : { func: (n: Base[]) => {}[]; } +>x236 = { func: n => { return [d1, d2]; } } : { func: (n: Base[]) => Array; } >x236 : Genric ->{ 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; } +>func : (n: Base[]) => Array +>n => { return [d1, d2]; } : (n: Base[]) => Array >n : Base[] ->[d1, d2] : {}[] +>[d1, d2] : Array >d1 : Derived1 >d2 : Derived2 @@ -2463,13 +2463,13 @@ var x248: { n: Genric; } = { n: { func: n => { return [d1, d2]; } } }; >n : Genric >Genric : Genric >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; }; } +>n : { func: (n: Base[]) => Array; } +>{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => Array; } +>func : (n: Base[]) => Array +>n => { return [d1, d2]; } : (n: Base[]) => Array >n : Base[] ->[d1, d2] : {}[] +>[d1, d2] : Array >d1 : Derived1 >d2 : Derived2 @@ -2543,11 +2543,11 @@ var x260: Genric[] = [{ func: n => { return [d1, d2]; } }]; >Genric : Genric >Base : Base >[{ func: n => { return [d1, d2]; } }] : Genric[] ->{ 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; } +>func : (n: Base[]) => Array +>n => { return [d1, d2]; } : (n: Base[]) => Array >n : Base[] ->[d1, d2] : {}[] +>[d1, d2] : Array >d1 : Derived1 >d2 : Derived2 @@ -2976,18 +2976,18 @@ var x296: Genric = true ? { func: n => { return [d1, d2]; } } : { func: n >Genric : Genric >Base : Base >true ? { func: n => { return [d1, d2]; } } : { func: n => { return [d1, d2]; } } : Genric ->{ 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; } +>func : (n: Base[]) => Array +>n => { return [d1, d2]; } : (n: Base[]) => Array >n : Base[] ->[d1, d2] : {}[] +>[d1, d2] : Array >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; } +>func : (n: Base[]) => Array +>n => { return [d1, d2]; } : (n: Base[]) => Array >n : Base[] ->[d1, d2] : {}[] +>[d1, d2] : Array >d1 : Derived1 >d2 : Derived2 @@ -3111,11 +3111,11 @@ var x308: Genric = true ? undefined : { func: n => { return [d1, d2]; } }; >Base : Base >true ? undefined : { func: n => { return [d1, d2]; } } : Genric >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; } +>func : (n: Base[]) => Array +>n => { return [d1, d2]; } : (n: Base[]) => Array >n : Base[] ->[d1, d2] : {}[] +>[d1, d2] : Array >d1 : Derived1 >d2 : Derived2 @@ -3238,11 +3238,11 @@ var x320: Genric = true ? { func: n => { return [d1, d2]; } } : undefined; >Genric : Genric >Base : Base >true ? { func: n => { return [d1, d2]; } } : undefined : Genric ->{ 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; } +>func : (n: Base[]) => Array +>n => { return [d1, d2]; } : (n: Base[]) => Array >n : Base[] ->[d1, d2] : {}[] +>[d1, d2] : Array >d1 : Derived1 >d2 : Derived2 >undefined : undefined @@ -3379,11 +3379,11 @@ function x332(n: Genric) { }; x332({ func: n => { return [d1, d2]; } }); >Base : Base >x332({ func: n => { return [d1, d2]; } }) : void >x332 : (n: Genric) => 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; } +>func : (n: Base[]) => Array +>n => { return [d1, d2]; } : (n: Base[]) => Array >n : Base[] ->[d1, d2] : {}[] +>[d1, d2] : Array >d1 : Derived1 >d2 : Derived2 @@ -3543,11 +3543,11 @@ var x344 = (n: Genric) => n; x344({ func: n => { return [d1, d2]; } }); >n : Genric >x344({ func: n => { return [d1, d2]; } }) : Genric >x344 : (n: Genric) => Genric ->{ 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; } +>func : (n: Base[]) => Array +>n => { return [d1, d2]; } : (n: Base[]) => Array >n : Base[] ->[d1, d2] : {}[] +>[d1, d2] : Array >d1 : Derived1 >d2 : Derived2 @@ -3695,11 +3695,11 @@ var x356 = function(n: Genric) { }; x356({ func: n => { return [d1, d2]; } >Base : Base >x356({ func: n => { return [d1, d2]; } }) : void >x356 : (n: Genric) => 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; } +>func : (n: Base[]) => Array +>n => { return [d1, d2]; } : (n: Base[]) => Array >n : Base[] ->[d1, d2] : {}[] +>[d1, d2] : Array >d1 : Derived1 >d2 : Derived2 diff --git a/tests/baselines/reference/genericArgumentCallSigAssignmentCompat.types b/tests/baselines/reference/genericArgumentCallSigAssignmentCompat.types index 2ac2483c40..f16e747d41 100644 --- a/tests/baselines/reference/genericArgumentCallSigAssignmentCompat.types +++ b/tests/baselines/reference/genericArgumentCallSigAssignmentCompat.types @@ -49,7 +49,7 @@ _.all([true, 1, null, 'yes'], _.identity); >_.all : (list: T[], iterator?: Underscore.Iterator, context?: any) => boolean >_ : Underscore.Static >all : (list: T[], iterator?: Underscore.Iterator, context?: any) => boolean ->[true, 1, null, 'yes'] : {}[] +>[true, 1, null, 'yes'] : Array >_.identity : (value: T) => T >_ : Underscore.Static >identity : (value: T) => T diff --git a/tests/baselines/reference/genericCallWithArrayLiteralArgs.types b/tests/baselines/reference/genericCallWithArrayLiteralArgs.types index c79efb0792..a6a75f9bd1 100644 --- a/tests/baselines/reference/genericCallWithArrayLiteralArgs.types +++ b/tests/baselines/reference/genericCallWithArrayLiteralArgs.types @@ -40,10 +40,10 @@ var r3 = foo([]); // number[] >[] : number[] var r4 = foo([1, '']); // {}[] ->r4 : {}[] ->foo([1, '']) : {}[] +>r4 : Array +>foo([1, '']) : Array >foo : (t: T) => T ->[1, ''] : {}[] +>[1, ''] : Array var r5 = foo([1, '']); // any[] >r5 : any[] diff --git a/tests/baselines/reference/genericCallWithFunctionTypedArguments.errors.txt b/tests/baselines/reference/genericCallWithFunctionTypedArguments.errors.txt new file mode 100644 index 0000000000..1a84c08dc3 --- /dev/null +++ b/tests/baselines/reference/genericCallWithFunctionTypedArguments.errors.txt @@ -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(x: (a: T) => T) { + return x(null); + } + + var r = foo((x: U) => ''); // {} + var r2 = foo((x: U) => ''); // string + var r3 = foo(x => ''); // {} + + function foo2(x: T, cb: (a: T) => U) { + return cb(x); + } + + var r4 = foo2(1, function (a: Z) { return '' }); // string, contextual signature instantiation is applied to generic functions + var r5 = foo2(1, (a) => ''); // string + var r6 = foo2('', (a: Z) => 1); + + function foo3(x: T, cb: (a: T) => U, y: U) { + return cb(x); + } + + var r7 = foo3(1, (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(1, (a) => '', ''); // string + + function other(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'. + } \ No newline at end of file diff --git a/tests/baselines/reference/genericCallWithFunctionTypedArguments.types b/tests/baselines/reference/genericCallWithFunctionTypedArguments.types deleted file mode 100644 index 2d3b234d0e..0000000000 --- a/tests/baselines/reference/genericCallWithFunctionTypedArguments.types +++ /dev/null @@ -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(x: (a: T) => T) { ->foo : (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((x: U) => ''); // {} ->r : {} ->foo((x: U) => '') : {} ->foo : (x: (a: T) => T) => T ->(x: U) => '' : (x: U) => string ->U : U ->x : U ->U : U - -var r2 = foo((x: U) => ''); // string ->r2 : string ->foo((x: U) => '') : string ->foo : (x: (a: T) => T) => T ->(x: U) => '' : (x: U) => string ->U : U ->x : U ->U : U - -var r3 = foo(x => ''); // {} ->r3 : {} ->foo(x => '') : {} ->foo : (x: (a: T) => T) => T ->x => '' : (x: {}) => string ->x : {} - -function foo2(x: T, cb: (a: T) => U) { ->foo2 : (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 (a: Z) { return '' }); // string, contextual signature instantiation is applied to generic functions ->r4 : string ->foo2(1, function (a: Z) { return '' }) : string ->foo2 : (x: T, cb: (a: T) => U) => U ->function (a: Z) { return '' } : (a: Z) => string ->Z : Z ->a : Z ->Z : Z - -var r5 = foo2(1, (a) => ''); // string ->r5 : string ->foo2(1, (a) => '') : string ->foo2 : (x: T, cb: (a: T) => U) => U ->(a) => '' : (a: number) => string ->a : number - -var r6 = foo2('', (a: Z) => 1); ->r6 : number ->foo2('', (a: Z) => 1) : number ->foo2 : (x: T, cb: (a: T) => U) => U ->(a: Z) => 1 : (a: Z) => number ->Z : Z ->a : Z ->Z : Z - -function foo3(x: T, cb: (a: T) => U, y: U) { ->foo3 : (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, (a: Z) => '', ''); // string ->r7 : string ->foo3(1, (a: Z) => '', '') : string ->foo3 : (x: T, cb: (a: T) => U, y: U) => U ->(a: 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 : (x: T, cb: (a: T) => U, y: U) => U ->function (a) { return '' } : (a: number) => string ->a : number - -var r9 = foo3(1, (a) => '', ''); // string ->r9 : string ->foo3(1, (a) => '', '') : string ->foo3 : (x: T, cb: (a: T) => U, y: U) => U ->(a) => '' : (a: number) => string ->a : number - -function other(t: T, u: U) { ->other : (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 : (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 : (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 : (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 : (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 : (x: T, cb: (a: T) => U, y: U) => U ->function (a) { return '' } : (a: number) => string ->a : number -} diff --git a/tests/baselines/reference/genericCallWithFunctionTypedArguments2.errors.txt b/tests/baselines/reference/genericCallWithFunctionTypedArguments2.errors.txt new file mode 100644 index 0000000000..6caeb1cd6d --- /dev/null +++ b/tests/baselines/reference/genericCallWithFunctionTypedArguments2.errors.txt @@ -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(x: new(a: T) => T) { + return new x(null); + } + + interface I { + new (x: T): T; + } + interface I2 { + new (x: T): T; + } + var i: I; + var i2: I2; + var a: { + new (x: T): T; + } + + var r = foo(i); // any + var r2 = foo(i); // string + var r3 = foo(i2); // string + var r3b = foo(a); // any + + function foo2(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('', i2); // string + + function foo3(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('', i2, ''); // string \ No newline at end of file diff --git a/tests/baselines/reference/genericCallWithFunctionTypedArguments2.types b/tests/baselines/reference/genericCallWithFunctionTypedArguments2.types deleted file mode 100644 index 89d7afd94e..0000000000 --- a/tests/baselines/reference/genericCallWithFunctionTypedArguments2.types +++ /dev/null @@ -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(x: new(a: T) => T) { ->foo : (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 (x: T): T; ->T : T ->x : T ->T : T ->T : T -} -interface I2 { ->I2 : I2 ->T : T - - new (x: T): T; ->x : T ->T : T ->T : T -} -var i: I; ->i : I ->I : I - -var i2: I2; ->i2 : I2 ->I2 : I2 - -var a: { ->a : new (x: T) => T - - new (x: T): T; ->T : T ->x : T ->T : T ->T : T -} - -var r = foo(i); // any ->r : any ->foo(i) : any ->foo : (x: new (a: T) => T) => T ->i : I - -var r2 = foo(i); // string ->r2 : string ->foo(i) : string ->foo : (x: new (a: T) => T) => T ->i : I - -var r3 = foo(i2); // string ->r3 : string ->foo(i2) : string ->foo : (x: new (a: T) => T) => T ->i2 : I2 - -var r3b = foo(a); // any ->r3b : any ->foo(a) : any ->foo : (x: new (a: T) => T) => T ->a : new (x: T) => T - -function foo2(x: T, cb: new(a: T) => U) { ->foo2 : (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 : (x: T, cb: new (a: T) => U) => U ->i2 : I2 - -var r4b = foo2(1, a); // any ->r4b : any ->foo2(1, a) : any ->foo2 : (x: T, cb: new (a: T) => U) => U ->a : new (x: T) => T - -var r5 = foo2(1, i); // any ->r5 : any ->foo2(1, i) : any ->foo2 : (x: T, cb: new (a: T) => U) => U ->i : I - -var r6 = foo2('', i2); // string ->r6 : string ->foo2('', i2) : string ->foo2 : (x: T, cb: new (a: T) => U) => U ->i2 : I2 - -function foo3(x: T, cb: new(a: T) => U, y: U) { ->foo3 : (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 : (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 : (x: T, cb: new (a: T) => U, y: U) => U ->a : new (x: T) => T - -var r8 = foo3(1, i2, 1); // {} ->r8 : {} ->foo3(1, i2, 1) : {} ->foo3 : (x: T, cb: new (a: T) => U, y: U) => U ->i2 : I2 - -var r9 = foo3('', i2, ''); // string ->r9 : string ->foo3('', i2, '') : string ->foo3 : (x: T, cb: new (a: T) => U, y: U) => U ->i2 : I2 - diff --git a/tests/baselines/reference/genericCallWithGenericSignatureArguments2.errors.txt b/tests/baselines/reference/genericCallWithGenericSignatureArguments2.errors.txt index 7f4fa26aad..1a4ad29fce 100644 --- a/tests/baselines/reference/genericCallWithGenericSignatureArguments2.errors.txt +++ b/tests/baselines/reference/genericCallWithGenericSignatureArguments2.errors.txt @@ -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(x: T) { var r7 = foo((a: T) => a, (b: T) => b); // T => T diff --git a/tests/baselines/reference/genericCallWithGenericSignatureArguments3.errors.txt b/tests/baselines/reference/genericCallWithGenericSignatureArguments3.errors.txt new file mode 100644 index 0000000000..691a3f1192 --- /dev/null +++ b/tests/baselines/reference/genericCallWithGenericSignatureArguments3.errors.txt @@ -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(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(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. \ No newline at end of file diff --git a/tests/baselines/reference/genericCallWithGenericSignatureArguments3.types b/tests/baselines/reference/genericCallWithGenericSignatureArguments3.types deleted file mode 100644 index 2c0d21a5a0..0000000000 --- a/tests/baselines/reference/genericCallWithGenericSignatureArguments3.types +++ /dev/null @@ -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(x: T, a: (x: T) => T, b: (x: T) => T) { ->foo : (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 : (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 : (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 : (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 : (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 : (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 : (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 : (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(x: T, a: (x: T) => U, b: (x: T) => U) { ->foo2 : (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 : (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 : (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 : (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 : (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 : (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 - diff --git a/tests/baselines/reference/genericCallWithObjectLiteralArgs.errors.txt b/tests/baselines/reference/genericCallWithObjectLiteralArgs.errors.txt new file mode 100644 index 0000000000..092540b499 --- /dev/null +++ b/tests/baselines/reference/genericCallWithObjectLiteralArgs.errors.txt @@ -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(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({ bar: 1, baz: '' }); // T = Object \ No newline at end of file diff --git a/tests/baselines/reference/genericCallWithObjectLiteralArgs.types b/tests/baselines/reference/genericCallWithObjectLiteralArgs.types deleted file mode 100644 index d23445ecbc..0000000000 --- a/tests/baselines/reference/genericCallWithObjectLiteralArgs.types +++ /dev/null @@ -1,49 +0,0 @@ -=== tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithObjectLiteralArgs.ts === -function foo(x: { bar: T; baz: T }) { ->foo : (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 : (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 : (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: (x: { bar: T; baz: T; }) => { bar: T; baz: T; }; baz: (x: { bar: T; baz: T; }) => { bar: T; baz: T; }; } ->foo({ bar: foo, baz: foo }) : { bar: (x: { bar: T; baz: T; }) => { bar: T; baz: T; }; baz: (x: { bar: T; baz: T; }) => { bar: T; baz: T; }; } ->foo : (x: { bar: T; baz: T; }) => { bar: T; baz: T; } ->{ bar: foo, baz: foo } : { bar: (x: { bar: T; baz: T; }) => { bar: T; baz: T; }; baz: (x: { bar: T; baz: T; }) => { bar: T; baz: T; }; } ->bar : (x: { bar: T; baz: T; }) => { bar: T; baz: T; } ->foo : (x: { bar: T; baz: T; }) => { bar: T; baz: T; } ->baz : (x: { bar: T; baz: T; }) => { bar: T; baz: T; } ->foo : (x: { bar: T; baz: T; }) => { bar: T; baz: T; } - -var r4 = foo({ bar: 1, baz: '' }); // T = Object ->r4 : { bar: Object; baz: Object; } ->foo({ bar: 1, baz: '' }) : { bar: Object; baz: Object; } ->foo : (x: { bar: T; baz: T; }) => { bar: T; baz: T; } ->Object : Object ->{ bar: 1, baz: '' } : { bar: number; baz: string; } ->bar : number ->baz : string - diff --git a/tests/baselines/reference/genericCallWithObjectLiteralArguments1.errors.txt b/tests/baselines/reference/genericCallWithObjectLiteralArguments1.errors.txt index 3b3f8d43ff..4ac64500bd 100644 --- a/tests/baselines/reference/genericCallWithObjectLiteralArguments1.errors.txt +++ b/tests/baselines/reference/genericCallWithObjectLiteralArguments1.errors.txt @@ -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(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({ x: 3, y: "" }, 4); ~~~~~~~~~~~~~~~ diff --git a/tests/baselines/reference/genericCallWithObjectTypeArgs.errors.txt b/tests/baselines/reference/genericCallWithObjectTypeArgs.errors.txt new file mode 100644 index 0000000000..dce9562a8f --- /dev/null +++ b/tests/baselines/reference/genericCallWithObjectTypeArgs.errors.txt @@ -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 { + x: T; + } + + function foo(t: X, t2: X) { + var x: T; + return x; + } + + var c1 = new X(); + var d1 = new X(); + var r = foo(c1, d1); // error + ~~~~~~~~~~~ +!!! error TS2346: Supplied parameters do not match any signature of call target. + var r2 = foo(c1, c1); // ok \ No newline at end of file diff --git a/tests/baselines/reference/genericCallWithObjectTypeArgs.types b/tests/baselines/reference/genericCallWithObjectTypeArgs.types deleted file mode 100644 index ddbd7d8305..0000000000 --- a/tests/baselines/reference/genericCallWithObjectTypeArgs.types +++ /dev/null @@ -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 { ->X : X ->T : T - - x: T; ->x : T ->T : T -} - -function foo(t: X, t2: X) { ->foo : (t: X, t2: X) => T ->T : T ->t : X ->X : X ->T : T ->t2 : X ->X : X ->T : T - - var x: T; ->x : T ->T : T - - return x; ->x : T -} - -var c1 = new X(); ->c1 : X ->new X() : X ->X : typeof X ->C : C - -var d1 = new X(); ->d1 : X ->new X() : X ->X : typeof X ->D : D - -var r = foo(c1, d1); // error ->r : {} ->foo(c1, d1) : {} ->foo : (t: X, t2: X) => T ->c1 : X ->d1 : X - -var r2 = foo(c1, c1); // ok ->r2 : C ->foo(c1, c1) : C ->foo : (t: X, t2: X) => T ->c1 : X ->c1 : X - diff --git a/tests/baselines/reference/genericCallWithObjectTypeArgs2.types b/tests/baselines/reference/genericCallWithObjectTypeArgs2.types index 0065811fdc..6c8ed4e468 100644 --- a/tests/baselines/reference/genericCallWithObjectTypeArgs2.types +++ b/tests/baselines/reference/genericCallWithObjectTypeArgs2.types @@ -22,7 +22,7 @@ class Derived2 extends Base { // returns {}[] function f(a: { x: T; y: U }) { ->f : (a: { x: T; y: U; }) => {}[] +>f : (a: { x: T; y: U; }) => Array >T : T >Base : Base >U : U @@ -34,7 +34,7 @@ function f(a: { x: T; y: U }) { >U : U return [a.x, a.y]; ->[a.x, a.y] : {}[] +>[a.x, a.y] : Array >a.x : T >a : { x: T; y: U; } >x : T @@ -44,9 +44,9 @@ function f(a: { x: T; y: U }) { } var r = f({ x: new Derived(), y: new Derived2() }); // {}[] ->r : {}[] ->f({ x: new Derived(), y: new Derived2() }) : {}[] ->f : (a: { x: T; y: U; }) => {}[] +>r : Array +>f({ x: new Derived(), y: new Derived2() }) : Array +>f : (a: { x: T; y: U; }) => Array >{ 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 : (a: { x: T; y: U; }) => {}[] +>r2 : Base[] +>f({ x: new Base(), y: new Derived2() }) : Base[] +>f : (a: { x: T; y: U; }) => Array >{ x: new Base(), y: new Derived2() } : { x: Base; y: Derived2; } >x : Base >new Base() : Base diff --git a/tests/baselines/reference/genericCallWithObjectTypeArgsAndConstraints3.errors.txt b/tests/baselines/reference/genericCallWithObjectTypeArgsAndConstraints3.errors.txt index c41ca0e887..9cb190ddec 100644 --- a/tests/baselines/reference/genericCallWithObjectTypeArgsAndConstraints3.errors.txt +++ b/tests/baselines/reference/genericCallWithObjectTypeArgsAndConstraints3.errors.txt @@ -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(a: U) { ~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/tests/baselines/reference/genericCallWithOverloadedConstructorTypedArguments.errors.txt b/tests/baselines/reference/genericCallWithOverloadedConstructorTypedArguments.errors.txt new file mode 100644 index 0000000000..b5a423ac07 --- /dev/null +++ b/tests/baselines/reference/genericCallWithOverloadedConstructorTypedArguments.errors.txt @@ -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 (x: T): T }; + var r2 = foo4(b); + } + + module GenericParameter { + function foo5(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(x: T): string; new(x: number): T; } + var r7 = foo5(b); // new any => string; new(x:number) => any + + function foo6(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(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 (x: T): string; (x: number): T; } + var c2: { new (x: T): string; new(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 + } \ No newline at end of file diff --git a/tests/baselines/reference/genericCallWithOverloadedConstructorTypedArguments.types b/tests/baselines/reference/genericCallWithOverloadedConstructorTypedArguments.types deleted file mode 100644 index 6c16ad0259..0000000000 --- a/tests/baselines/reference/genericCallWithOverloadedConstructorTypedArguments.types +++ /dev/null @@ -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 (x: T): T }; ->b : new (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 (x: T) => T -} - -module GenericParameter { ->GenericParameter : typeof GenericParameter - - function foo5(cb: { new(x: T): string; new(x: number): T }) { ->foo5 : (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 : (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(x: T): string; new(x: number): T; } ->b : { new (x: T): string; new (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 : (cb: { new (x: T): string; new (x: number): T; }) => { new (x: T): string; new (x: number): T; } ->b : { new (x: T): string; new (x: number): T; } - - function foo6(cb: { new(x: T): string; new(x: T, y?: T): string }) { ->foo6 : (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 : (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 : (cb: { new (x: T): string; new (x: T, y?: T): string; }) => { new (x: T): string; new (x: T, y?: T): string; } ->b : { new (x: T): string; new (x: number): T; } - - function foo7(x:T, cb: { new(x: T): string; new(x: T, y?: T): string }) { ->foo7 : (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 : (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 (x: T): string; new (x: number): T; } - - var c: { new (x: T): string; (x: number): T; } ->c : { (x: number): T; new (x: T): string; } ->T : T ->x : T ->T : T ->T : T ->x : number ->T : T - - var c2: { new (x: T): string; new(x: number): T; } ->c2 : { new (x: T): string; new (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 : (x: T, cb: { new (x: T): string; new (x: T, y?: T): string; }) => { new (x: T): string; new (x: T, y?: T): string; } ->c : { (x: number): T; new (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 : (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 (x: T): string; new (x: number): T; } -} diff --git a/tests/baselines/reference/genericClassWithFunctionTypedMemberArguments.errors.txt b/tests/baselines/reference/genericClassWithFunctionTypedMemberArguments.errors.txt new file mode 100644 index 0000000000..63ac5002f8 --- /dev/null +++ b/tests/baselines/reference/genericClassWithFunctionTypedMemberArguments.errors.txt @@ -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 { + foo(x: (a: T) => T) { + return x(null); + } + } + + var c = new C(); + var r = c.foo((x: U) => ''); // {} + var r2 = c.foo((x: U) => ''); // string + var r3 = c.foo(x => ''); // {} + + class C2 { + foo(x: (a: T) => T) { + return x(null); + } + } + + var c2 = new C2(); + var ra = c2.foo((x: U) => 1); // number + var r3a = c2.foo(x => 1); // number + } + + module WithCandidates { + class C { + foo2(x: T, cb: (a: T) => U) { + return cb(x); + } + } + + var c: C; + var r4 = c.foo2(1, function (a: Z) { return '' }); // string, contextual signature instantiation is applied to generic functions + var r5 = c.foo2(1, (a) => ''); // string + var r6 = c.foo2('', (a: Z) => 1); // number + + class C2 { + foo3(x: T, cb: (a: T) => U, y: U) { + return cb(x); + } + } + + var c2: C2; + var r7 = c2.foo3(1, (a: Z) => '', ''); // string + var r8 = c2.foo3(1, function (a) { return '' }, ''); // string + + class C3 { + foo3(x: T, cb: (a: T) => U, y: U) { + return cb(x); + } + } + var c3: C3; + + function other(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'. + } + } \ No newline at end of file diff --git a/tests/baselines/reference/genericClassWithFunctionTypedMemberArguments.types b/tests/baselines/reference/genericClassWithFunctionTypedMemberArguments.types deleted file mode 100644 index 68b94d81d0..0000000000 --- a/tests/baselines/reference/genericClassWithFunctionTypedMemberArguments.types +++ /dev/null @@ -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 { ->C : C ->T : T - - foo(x: (a: T) => T) { ->foo : (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(); ->c : C ->new C() : C ->C : typeof C - - var r = c.foo((x: U) => ''); // {} ->r : {} ->c.foo((x: U) => '') : {} ->c.foo : (x: (a: T) => T) => T ->c : C ->foo : (x: (a: T) => T) => T ->(x: U) => '' : (x: U) => string ->U : U ->x : U ->U : U - - var r2 = c.foo((x: U) => ''); // string ->r2 : string ->c.foo((x: U) => '') : string ->c.foo : (x: (a: T) => T) => T ->c : C ->foo : (x: (a: T) => T) => T ->(x: U) => '' : (x: U) => string ->U : U ->x : U ->U : U - - var r3 = c.foo(x => ''); // {} ->r3 : {} ->c.foo(x => '') : {} ->c.foo : (x: (a: T) => T) => T ->c : C ->foo : (x: (a: T) => T) => T ->x => '' : (x: {}) => string ->x : {} - - class C2 { ->C2 : C2 ->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(); ->c2 : C2 ->new C2() : C2 ->C2 : typeof C2 - - var ra = c2.foo((x: U) => 1); // number ->ra : number ->c2.foo((x: U) => 1) : number ->c2.foo : (x: (a: number) => number) => number ->c2 : C2 ->foo : (x: (a: number) => number) => number ->(x: U) => 1 : (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 ->foo : (x: (a: number) => number) => number ->x => 1 : (x: number) => number ->x : number -} - -module WithCandidates { ->WithCandidates : typeof WithCandidates - - class C { ->C : C ->T : T - - foo2(x: T, cb: (a: T) => U) { ->foo2 : (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; ->c : C ->C : C - - var r4 = c.foo2(1, function (a: Z) { return '' }); // string, contextual signature instantiation is applied to generic functions ->r4 : string ->c.foo2(1, function (a: Z) { return '' }) : string ->c.foo2 : (x: T, cb: (a: T) => U) => U ->c : C ->foo2 : (x: T, cb: (a: T) => U) => U ->function (a: Z) { return '' } : (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 : (x: T, cb: (a: T) => U) => U ->c : C ->foo2 : (x: T, cb: (a: T) => U) => U ->(a) => '' : (a: number) => string ->a : number - - var r6 = c.foo2('', (a: Z) => 1); // number ->r6 : number ->c.foo2('', (a: Z) => 1) : number ->c.foo2 : (x: T, cb: (a: T) => U) => U ->c : C ->foo2 : (x: T, cb: (a: T) => U) => U ->(a: Z) => 1 : (a: Z) => number ->Z : Z ->a : Z ->Z : Z - - class C2 { ->C2 : C2 ->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; ->c2 : C2 ->C2 : C2 - - var r7 = c2.foo3(1, (a: Z) => '', ''); // string ->r7 : string ->c2.foo3(1, (a: Z) => '', '') : string ->c2.foo3 : (x: number, cb: (a: number) => string, y: string) => string ->c2 : C2 ->foo3 : (x: number, cb: (a: number) => string, y: string) => string ->(a: 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 ->foo3 : (x: number, cb: (a: number) => string, y: string) => string ->function (a) { return '' } : (a: number) => string ->a : number - - class C3 { ->C3 : C3 ->T : T ->U : U - - foo3(x: T, cb: (a: T) => U, y: U) { ->foo3 : (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; ->c3 : C3 ->C3 : C3 - - function other(t: T, u: U) { ->other : (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 : (x: T, cb: (a: T) => U) => U ->c : C ->foo2 : (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 : (x: T, cb: (a: T) => U) => U ->c : C ->foo2 : (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 : (x: T, cb: (a: T) => U, y: U) => U ->c3 : C3 ->foo3 : (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 : (x: T, cb: (a: T) => U, y: U) => U ->c3 : C3 ->foo3 : (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 : (x: T, cb: (a: T) => U, y: U) => U ->c3 : C3 ->foo3 : (x: T, cb: (a: T) => U, y: U) => U ->function (a) { return '' } : (a: number) => string ->a : number - } -} diff --git a/tests/baselines/reference/genericRestArgs.errors.txt b/tests/baselines/reference/genericRestArgs.errors.txt index db36a9a016..49f61de325 100644 --- a/tests/baselines/reference/genericRestArgs.errors.txt +++ b/tests/baselines/reference/genericRestArgs.errors.txt @@ -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(...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(1, ""); var a1Gc = makeArrayG(1, ""); var a1Gd = makeArrayG(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(1, ""); var a2Gc = makeArrayG(1, ""); // error ~ diff --git a/tests/baselines/reference/genericTypeArgumentInference1.types b/tests/baselines/reference/genericTypeArgumentInference1.types index 20a9a0ca8f..c7d932befb 100644 --- a/tests/baselines/reference/genericTypeArgumentInference1.types +++ b/tests/baselines/reference/genericTypeArgumentInference1.types @@ -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 : (list: T[], iterator?: Underscore.Iterator, context?: any) => T >_ : Underscore.Static >all : (list: T[], iterator?: Underscore.Iterator, context?: any) => T ->[true, 1, null, 'yes'] : {}[] +>[true, 1, null, 'yes'] : Array >_.identity : (value: T) => T >_ : Underscore.Static >identity : (value: T) => T diff --git a/tests/baselines/reference/genericsManyTypeParameters.types b/tests/baselines/reference/genericsManyTypeParameters.types index 65f9a7c115..df2144de86 100644 --- a/tests/baselines/reference/genericsManyTypeParameters.types +++ b/tests/baselines/reference/genericsManyTypeParameters.types @@ -1,6 +1,6 @@ === tests/cases/compiler/genericsManyTypeParameters.ts === function Foo< ->Foo : (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 : (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, >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 >x1 : a1 >y1 : a21 >z1 : a31 diff --git a/tests/baselines/reference/heterogeneousArrayAndOverloads.errors.txt b/tests/baselines/reference/heterogeneousArrayAndOverloads.errors.txt index 072d06e868..985aaa7948 100644 --- a/tests/baselines/reference/heterogeneousArrayAndOverloads.errors.txt +++ b/tests/baselines/reference/heterogeneousArrayAndOverloads.errors.txt @@ -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' 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' 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'. } } \ No newline at end of file diff --git a/tests/baselines/reference/heterogeneousArrayLiterals.types b/tests/baselines/reference/heterogeneousArrayLiterals.types index 8177073163..882fe1e829 100644 --- a/tests/baselines/reference/heterogeneousArrayLiterals.types +++ b/tests/baselines/reference/heterogeneousArrayLiterals.types @@ -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 +>[1, ''] : Array var b = [1, null]; // number[] >b : number[] >[1, null] : number[] var c = [1, '', null]; // {}[] ->c : {}[] ->[1, '', null] : {}[] +>c : Array +>[1, '', null] : Array var d = [{}, 1]; // {}[] >d : {}[] @@ -31,8 +31,8 @@ var f = [[], [1]]; // number[][] >[1] : number[] var g = [[1], ['']]; // {}[] ->g : {}[] ->[[1], ['']] : {}[] +>g : Array +>[[1], ['']] : Array >[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] : Array >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: T, u: U) { >t : T var c = [t, u]; // {}[] ->c : {}[] ->[t, u] : {}[] +>c : Array +>[t, u] : Array >t : T >u : U var d = [t, 1]; // {}[] ->d : {}[] ->[t, 1] : {}[] +>d : Array +>[t, 1] : Array >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: T, u: U) { >t : T var c = [t, u]; // {}[] ->c : {}[] ->[t, u] : {}[] +>c : Array +>[t, u] : Array >t : T >u : U var d = [t, 1]; // {}[] ->d : {}[] ->[t, 1] : {}[] +>d : Array +>[t, 1] : Array >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: T, u: U) { >base : Base var h = [t, derived]; // Derived[] ->h : {}[] ->[t, derived] : {}[] +>h : Array +>[t, derived] : Array >t : T >derived : Derived @@ -383,19 +383,19 @@ function foo3(t: T, u: U) { >t : T var c = [t, u]; // {}[] ->c : {}[] ->[t, u] : {}[] +>c : Array +>[t, u] : Array >t : T >u : U var d = [t, 1]; // {}[] ->d : {}[] ->[t, 1] : {}[] +>d : Array +>[t, 1] : Array >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: T, u: U) { >t : T var c = [t, u]; // BUG 821629 ->c : {}[] ->[t, u] : {}[] +>c : Array +>[t, u] : Array >t : T >u : U var d = [t, 1]; // {}[] ->d : {}[] ->[t, 1] : {}[] +>d : Array +>[t, 1] : Array >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: T, u: U) { >base : Base var h = [t, derived]; // Derived[] ->h : {}[] ->[t, derived] : {}[] +>h : Array +>[t, derived] : Array >t : T >derived : Derived @@ -504,8 +504,8 @@ function foo4(t: T, u: U) { >base : Base var j = [u, derived]; // Derived[] ->j : {}[] ->[u, derived] : {}[] +>j : Array +>[u, derived] : Array >u : U >derived : Derived diff --git a/tests/baselines/reference/invalidMultipleVariableDeclarations.errors.txt b/tests/baselines/reference/invalidMultipleVariableDeclarations.errors.txt index 0a4761994d..b82c82b9eb 100644 --- a/tests/baselines/reference/invalidMultipleVariableDeclarations.errors.txt +++ b/tests/baselines/reference/invalidMultipleVariableDeclarations.errors.txt @@ -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>'. 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[]', but here has type 'D[]'. 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()]; ~~~ -!!! 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>'. var arr2 = [new D()]; var arr2 = new Array>(); diff --git a/tests/baselines/reference/logicalOrOperatorWithEveryType.types b/tests/baselines/reference/logicalOrOperatorWithEveryType.types index 3cf0399f43..3e3b0dcf37 100644 --- a/tests/baselines/reference/logicalOrOperatorWithEveryType.types +++ b/tests/baselines/reference/logicalOrOperatorWithEveryType.types @@ -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[] diff --git a/tests/baselines/reference/logicalOrOperatorWithTypeParameters.types b/tests/baselines/reference/logicalOrOperatorWithTypeParameters.types index ff0e0ce568..9a450b8778 100644 --- a/tests/baselines/reference/logicalOrOperatorWithTypeParameters.types +++ b/tests/baselines/reference/logicalOrOperatorWithTypeParameters.types @@ -22,8 +22,8 @@ function fn1(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: 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: 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 fn3U : U var r1 = t || u; ->r1 : {} ->t || u : {} +>r1 : T | U +>t || u : T | U >t : T >u : U diff --git a/tests/baselines/reference/mismatchedExplicitTypeParameterAndArgumentType.errors.txt b/tests/baselines/reference/mismatchedExplicitTypeParameterAndArgumentType.errors.txt index 557f60967a..ed4f45ec1d 100644 --- a/tests/baselines/reference/mismatchedExplicitTypeParameterAndArgumentType.errors.txt +++ b/tests/baselines/reference/mismatchedExplicitTypeParameterAndArgumentType.errors.txt @@ -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' 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([1, ""], (x) => x.toString()); var r7 = map([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' 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([1, ""], (x) => x.toString()); // error ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS2346: Supplied parameters do not match any signature of call target. diff --git a/tests/baselines/reference/nonContextuallyTypedLogicalOr.errors.txt b/tests/baselines/reference/nonContextuallyTypedLogicalOr.errors.txt deleted file mode 100644 index ca4dc9f67e..0000000000 --- a/tests/baselines/reference/nonContextuallyTypedLogicalOr.errors.txt +++ /dev/null @@ -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 '{}'. \ No newline at end of file diff --git a/tests/baselines/reference/nonContextuallyTypedLogicalOr.types b/tests/baselines/reference/nonContextuallyTypedLogicalOr.types new file mode 100644 index 0000000000..4d15083c3b --- /dev/null +++ b/tests/baselines/reference/nonContextuallyTypedLogicalOr.types @@ -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 + diff --git a/tests/baselines/reference/numericIndexerConstrainsPropertyDeclarations.errors.txt b/tests/baselines/reference/numericIndexerConstrainsPropertyDeclarations.errors.txt index fd23cab995..7fb3d450f0 100644 --- a/tests/baselines/reference/numericIndexerConstrainsPropertyDeclarations.errors.txt +++ b/tests/baselines/reference/numericIndexerConstrainsPropertyDeclarations.errors.txt @@ -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: () => { }, diff --git a/tests/baselines/reference/numericIndexerConstrainsPropertyDeclarations2.errors.txt b/tests/baselines/reference/numericIndexerConstrainsPropertyDeclarations2.errors.txt index 0e9cff1556..4d0488ec80 100644 --- a/tests/baselines/reference/numericIndexerConstrainsPropertyDeclarations2.errors.txt +++ b/tests/baselines/reference/numericIndexerConstrainsPropertyDeclarations2.errors.txt @@ -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(), diff --git a/tests/baselines/reference/parser15.4.4.14-9-2.errors.txt b/tests/baselines/reference/parser15.4.4.14-9-2.errors.txt index ab9bab7890..237541b40f 100644 --- a/tests/baselines/reference/parser15.4.4.14-9-2.errors.txt +++ b/tests/baselines/reference/parser15.4.4.14-9-2.errors.txt @@ -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 diff --git a/tests/baselines/reference/promisePermutations.errors.txt b/tests/baselines/reference/promisePermutations.errors.txt index ee723821cc..4ee3ea31de 100644 --- a/tests/baselines/reference/promisePermutations.errors.txt +++ b/tests/baselines/reference/promisePermutations.errors.txt @@ -1,3 +1,4 @@ +tests/cases/compiler/promisePermutations.ts(74,70): error TS2345: Argument of type '(x: number) => IPromise' is not assignable to parameter of type '(value: IPromise) => IPromise'. tests/cases/compiler/promisePermutations.ts(79,19): error TS2345: Argument of type '(x: number, y?: string) => IPromise' is not assignable to parameter of type '(value: string) => IPromise'. tests/cases/compiler/promisePermutations.ts(82,19): error TS2345: Argument of type '(x: number, y?: string) => IPromise' is not assignable to parameter of type '(value: string) => IPromise'. tests/cases/compiler/promisePermutations.ts(83,19): error TS2345: Argument of type '(x: number, y?: string) => Promise' is not assignable to parameter of type '(value: string) => Promise'. @@ -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 '(x: T, cb: (a: T) => T) => Promise' is not assignable to parameter of type '(value: number) => Promise'. tests/cases/compiler/promisePermutations.ts(122,19): error TS2345: Argument of type '(x: T, cb: (a: T) => T) => Promise' is not assignable to parameter of type '(value: number) => IPromise'. tests/cases/compiler/promisePermutations.ts(126,19): error TS2345: Argument of type '(x: T, cb: (a: U) => U) => IPromise' is not assignable to parameter of type '(value: number) => IPromise'. +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 '(x: T, cb: (a: U) => U) => IPromise' is not assignable to parameter of type '(value: number) => IPromise'. tests/cases/compiler/promisePermutations.ts(133,19): error TS2345: Argument of type '(x: T, cb: (a: U) => U) => Promise' is not assignable to parameter of type '(value: number) => Promise'. tests/cases/compiler/promisePermutations.ts(134,19): error TS2345: Argument of type '(x: T, cb: (a: U) => U) => Promise' is not assignable to parameter of type '(value: number) => IPromise'. +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; (x: string): IPromise; }' is not assignable to parameter of type '(value: number) => IPromise'. tests/cases/compiler/promisePermutations.ts(158,21): error TS2345: Argument of type '{ (x: number): IPromise; (x: string): IPromise; }' is not assignable to parameter of type '(value: number) => IPromise'. +tests/cases/compiler/promisePermutations.ts(159,21): error TS2345: Argument of type '{ (x: number): Promise; (x: string): Promise; }' is not assignable to parameter of type '(value: number) => Promise'. +tests/cases/compiler/promisePermutations.ts(160,21): error TS2345: Argument of type '{ (x: number): Promise; (x: string): Promise; }' is not assignable to parameter of type '(value: number) => IPromise'. -==== tests/cases/compiler/promisePermutations.ts (25 errors) ==== +==== tests/cases/compiler/promisePermutations.ts (33 errors) ==== interface Promise { then(success?: (value: T) => Promise, error?: (error: any) => Promise, progress?: (progress: any) => void): Promise; then(success?: (value: T) => Promise, error?: (error: any) => U, progress?: (progress: any) => void): Promise; @@ -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' is not assignable to parameter of type '(value: IPromise) => IPromise'. var r4: IPromise; var sIPromise: (x: any) => IPromise; @@ -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; 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; var r11a = r11.then(testFunction11, testFunction11, testFunction11); // ok + ~~~~~~~~~~~~~~ +!!! error TS2345: Argument of type '{ (x: number): IPromise; (x: string): IPromise; }' is not assignable to parameter of type '(value: number) => IPromise'. var s11: Promise; var s11a = s11.then(testFunction11, testFunction11, testFunction11); // ok ~~~~~~~~~~~~~~ !!! error TS2345: Argument of type '{ (x: number): IPromise; (x: string): IPromise; }' is not assignable to parameter of type '(value: number) => IPromise'. var s11b = s11.then(testFunction11P, testFunction11P, testFunction11P); // ok + ~~~~~~~~~~~~~~~ +!!! error TS2345: Argument of type '{ (x: number): Promise; (x: string): Promise; }' is not assignable to parameter of type '(value: number) => Promise'. var s11c = s11.then(testFunction11P, testFunction11, testFunction11); // ok + ~~~~~~~~~~~~~~~ +!!! error TS2345: Argument of type '{ (x: number): Promise; (x: string): Promise; }' is not assignable to parameter of type '(value: number) => IPromise'. var r12 = testFunction12(x => x); var r12a = r12.then(testFunction12, testFunction12, testFunction12); // ok diff --git a/tests/baselines/reference/promisePermutations2.errors.txt b/tests/baselines/reference/promisePermutations2.errors.txt index f85a3eb925..6c127f85f0 100644 --- a/tests/baselines/reference/promisePermutations2.errors.txt +++ b/tests/baselines/reference/promisePermutations2.errors.txt @@ -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 '(x: T, cb: (a: T) => T) => Promise' is not assignable to parameter of type '(value: number) => Promise'. tests/cases/compiler/promisePermutations2.ts(121,19): error TS2345: Argument of type '(x: T, cb: (a: T) => T) => Promise' is not assignable to parameter of type '(value: number) => IPromise'. tests/cases/compiler/promisePermutations2.ts(125,19): error TS2345: Argument of type '(x: T, cb: (a: U) => U) => IPromise' is not assignable to parameter of type '(value: number) => IPromise'. +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 '(x: T, cb: (a: U) => U) => IPromise' is not assignable to parameter of type '(value: number) => IPromise'. tests/cases/compiler/promisePermutations2.ts(132,19): error TS2345: Argument of type '(x: T, cb: (a: U) => U) => Promise' is not assignable to parameter of type '(value: number) => Promise'. tests/cases/compiler/promisePermutations2.ts(133,19): error TS2345: Argument of type '(x: T, cb: (a: U) => U) => Promise' is not assignable to parameter of type '(value: number) => IPromise'. +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; (x: string): IPromise; }' is not assignable to parameter of type '(value: number) => IPromise'. tests/cases/compiler/promisePermutations2.ts(157,21): error TS2345: Argument of type '{ (x: number): IPromise; (x: string): IPromise; }' is not assignable to parameter of type '(value: number) => IPromise'. tests/cases/compiler/promisePermutations2.ts(158,21): error TS2345: Argument of type '{ (x: number): Promise; (x: string): Promise; }' is not assignable to parameter of type '(value: number) => Promise'. tests/cases/compiler/promisePermutations2.ts(159,21): error TS2345: Argument of type '{ (x: number): Promise; (x: string): Promise; }' is not assignable to parameter of type '(value: number) => IPromise'. -==== tests/cases/compiler/promisePermutations2.ts (28 errors) ==== +==== tests/cases/compiler/promisePermutations2.ts (33 errors) ==== // same as promisePermutations but without the same overloads in Promise interface Promise { @@ -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; 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; var r11a = r11.then(testFunction11, testFunction11, testFunction11); // ok + ~~~~~~~~~~~~~~ +!!! error TS2345: Argument of type '{ (x: number): IPromise; (x: string): IPromise; }' is not assignable to parameter of type '(value: number) => IPromise'. var s11: Promise; var s11a = s11.then(testFunction11, testFunction11, testFunction11); // ok ~~~~~~~~~~~~~~ diff --git a/tests/baselines/reference/promisePermutations3.errors.txt b/tests/baselines/reference/promisePermutations3.errors.txt index edd5f87904..636e89645b 100644 --- a/tests/baselines/reference/promisePermutations3.errors.txt +++ b/tests/baselines/reference/promisePermutations3.errors.txt @@ -1,4 +1,5 @@ tests/cases/compiler/promisePermutations3.ts(68,69): error TS2345: Argument of type '(x: number) => IPromise' is not assignable to parameter of type '(value: IPromise) => IPromise'. +tests/cases/compiler/promisePermutations3.ts(73,70): error TS2345: Argument of type '(x: number) => IPromise' is not assignable to parameter of type '(value: IPromise) => IPromise'. tests/cases/compiler/promisePermutations3.ts(78,19): error TS2345: Argument of type '(x: number, y?: string) => IPromise' is not assignable to parameter of type '(value: string) => IPromise'. tests/cases/compiler/promisePermutations3.ts(81,19): error TS2345: Argument of type '(x: number, y?: string) => IPromise' is not assignable to parameter of type '(value: string) => IPromise'. tests/cases/compiler/promisePermutations3.ts(82,19): error TS2345: Argument of type '(x: number, y?: string) => Promise' is not assignable to parameter of type '(value: string) => Promise'. @@ -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 '(x: T, cb: (a: T) => T) => Promise' is not assignable to parameter of type '(value: number) => Promise'. tests/cases/compiler/promisePermutations3.ts(121,19): error TS2345: Argument of type '(x: T, cb: (a: T) => T) => Promise' is not assignable to parameter of type '(value: number) => IPromise'. tests/cases/compiler/promisePermutations3.ts(125,19): error TS2345: Argument of type '(x: T, cb: (a: U) => U) => IPromise' is not assignable to parameter of type '(value: number) => IPromise'. +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 '(x: T, cb: (a: U) => U) => IPromise' is not assignable to parameter of type '(value: number) => IPromise'. tests/cases/compiler/promisePermutations3.ts(132,19): error TS2345: Argument of type '(x: T, cb: (a: U) => U) => Promise' is not assignable to parameter of type '(value: number) => Promise'. tests/cases/compiler/promisePermutations3.ts(133,19): error TS2345: Argument of type '(x: T, cb: (a: U) => U) => Promise' is not assignable to parameter of type '(value: number) => IPromise'. +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; (x: string): IPromise; }' is not assignable to parameter of type '(value: number) => IPromise'. tests/cases/compiler/promisePermutations3.ts(157,21): error TS2345: Argument of type '{ (x: number): IPromise; (x: string): IPromise; }' is not assignable to parameter of type '(value: number) => IPromise'. +tests/cases/compiler/promisePermutations3.ts(158,21): error TS2345: Argument of type '{ (x: number): Promise; (x: string): Promise; }' is not assignable to parameter of type '(value: number) => Promise'. +tests/cases/compiler/promisePermutations3.ts(159,21): error TS2345: Argument of type '{ (x: number): Promise; (x: string): Promise; }' is not assignable to parameter of type '(value: number) => IPromise'. tests/cases/compiler/promisePermutations3.ts(165,21): error TS2345: Argument of type '{ (x: T): IPromise; (x: T, y: T): Promise; }' is not assignable to parameter of type '(value: (x: any) => any) => Promise'. -==== tests/cases/compiler/promisePermutations3.ts (28 errors) ==== +==== tests/cases/compiler/promisePermutations3.ts (35 errors) ==== // same as promisePermutations but without the same overloads in IPromise interface Promise { @@ -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' is not assignable to parameter of type '(value: IPromise) => IPromise'. var r4: IPromise; var sIPromise: (x: any) => IPromise; @@ -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; 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; @@ -241,7 +258,11 @@ tests/cases/compiler/promisePermutations3.ts(165,21): error TS2345: Argument of ~~~~~~~~~~~~~~ !!! error TS2345: Argument of type '{ (x: number): IPromise; (x: string): IPromise; }' is not assignable to parameter of type '(value: number) => IPromise'. var s11b = s11.then(testFunction11P, testFunction11P, testFunction11P); // ok + ~~~~~~~~~~~~~~~ +!!! error TS2345: Argument of type '{ (x: number): Promise; (x: string): Promise; }' is not assignable to parameter of type '(value: number) => Promise'. var s11c = s11.then(testFunction11P, testFunction11, testFunction11); // ok + ~~~~~~~~~~~~~~~ +!!! error TS2345: Argument of type '{ (x: number): Promise; (x: string): Promise; }' is not assignable to parameter of type '(value: number) => IPromise'. var r12 = testFunction12(x => x); var r12a = r12.then(testFunction12, testFunction12, testFunction12); // ok diff --git a/tests/baselines/reference/stringIndexerConstrainsPropertyDeclarations.errors.txt b/tests/baselines/reference/stringIndexerConstrainsPropertyDeclarations.errors.txt index a731dcca18..b71b04263b 100644 --- a/tests/baselines/reference/stringIndexerConstrainsPropertyDeclarations.errors.txt +++ b/tests/baselines/reference/stringIndexerConstrainsPropertyDeclarations.errors.txt @@ -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: () => { }, diff --git a/tests/baselines/reference/subtypesOfTypeParameter.errors.txt b/tests/baselines/reference/subtypesOfTypeParameter.errors.txt index a986258bf1..bdb3c9a056 100644 --- a/tests/baselines/reference/subtypesOfTypeParameter.errors.txt +++ b/tests/baselines/reference/subtypesOfTypeParameter.errors.txt @@ -1,46 +1,10 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameter.ts(7,7): error TS2416: Class 'D1' incorrectly extends base class 'C3': 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 '(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 '(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' and 'T'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameter.ts(73,15): error TS2367: No best common type exists between 'T' and 'C2'. -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 { @@ -57,11 +21,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf function f1(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 ? (x: T) => { return x } : x; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2367: No best common type exists between '(x: T) => T' and 'T'. var r8b = true ? x : (x: T) => { return x }; // type parameters not identical across declarations - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2367: No best common type exists between 'T' and '(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; var r12 = true ? c2 : x; - ~~~~~~~~~~~~~ -!!! error TS2367: No best common type exists between 'C2' and 'T'. var r12 = true ? x : c2; - ~~~~~~~~~~~~~ -!!! error TS2367: No best common type exists between 'T' and 'C2'. 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(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(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 diff --git a/tests/baselines/reference/subtypesOfTypeParameterWithConstraints2.errors.txt b/tests/baselines/reference/subtypesOfTypeParameterWithConstraints2.errors.txt index c2b429c08b..7f23cb39c8 100644 --- a/tests/baselines/reference/subtypesOfTypeParameterWithConstraints2.errors.txt +++ b/tests/baselines/reference/subtypesOfTypeParameterWithConstraints2.errors.txt @@ -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(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(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(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(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(x: T) { @@ -192,18 +138,10 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf function f16(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(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'. } } diff --git a/tests/baselines/reference/subtypesOfTypeParameterWithConstraints3.errors.txt b/tests/baselines/reference/subtypesOfTypeParameterWithConstraints3.errors.txt index f26389bb2a..edb09275be 100644 --- a/tests/baselines/reference/subtypesOfTypeParameterWithConstraints3.errors.txt +++ b/tests/baselines/reference/subtypesOfTypeParameterWithConstraints3.errors.txt @@ -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: 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'. } \ No newline at end of file diff --git a/tests/baselines/reference/subtypesOfTypeParameterWithConstraints4.errors.txt b/tests/baselines/reference/subtypesOfTypeParameterWithConstraints4.errors.txt index 082d78d43d..480090391e 100644 --- a/tests/baselines/reference/subtypesOfTypeParameterWithConstraints4.errors.txt +++ b/tests/baselines/reference/subtypesOfTypeParameterWithConstraints4.errors.txt @@ -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' incorrectly extends base class 'B1': 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: 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'. } diff --git a/tests/baselines/reference/subtypesOfTypeParameterWithRecursiveConstraints.errors.txt b/tests/baselines/reference/subtypesOfTypeParameterWithRecursiveConstraints.errors.txt index bf7cbbcae0..4f11fc6e1b 100644 --- a/tests/baselines/reference/subtypesOfTypeParameterWithRecursiveConstraints.errors.txt +++ b/tests/baselines/reference/subtypesOfTypeParameterWithRecursiveConstraints.errors.txt @@ -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'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(19,14): error TS2367: No best common type exists between 'Foo' and 'T'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(22,14): error TS2367: No best common type exists between 'U' and 'Foo'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(23,14): error TS2367: No best common type exists between 'Foo' and 'U'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(26,14): error TS2367: No best common type exists between 'V' and 'Foo'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(27,14): error TS2367: No best common type exists between 'Foo' and 'V'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(31,14): error TS2367: No best common type exists between 'T' and 'Foo'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(32,14): error TS2367: No best common type exists between 'Foo' and 'T'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(35,14): error TS2367: No best common type exists between 'U' and 'Foo'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(36,14): error TS2367: No best common type exists between 'Foo' and 'U'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(39,14): error TS2367: No best common type exists between 'V' and 'Foo'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(40,14): error TS2367: No best common type exists between 'Foo' and 'V'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(44,15): error TS2367: No best common type exists between 'T' and 'Foo'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(45,15): error TS2367: No best common type exists between 'Foo' and 'T'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(48,15): error TS2367: No best common type exists between 'U' and 'Foo'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(49,15): error TS2367: No best common type exists between 'Foo' and 'U'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(52,15): error TS2367: No best common type exists between 'V' and 'Foo'. -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(53,15): error TS2367: No best common type exists between 'Foo' 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 { 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(); - ~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2367: No best common type exists between 'T' and 'Foo'. var r4 = true ? new Foo() : t; - ~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2367: No best common type exists between 'Foo' and 'T'. // ok? var r5 = true ? u : new Foo(); - ~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2367: No best common type exists between 'U' and 'Foo'. var r5 = true ? new Foo() : u; - ~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2367: No best common type exists between 'Foo' and 'U'. // ok? 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'. // ok? var r7 = true ? t : new Foo(); - ~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2367: No best common type exists between 'T' and 'Foo'. var r7 = true ? new Foo() : t; - ~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2367: No best common type exists between 'Foo' and 'T'. // ok? var r8 = true ? u : new Foo(); - ~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2367: No best common type exists between 'U' and 'Foo'. var r8 = true ? new Foo() : u; - ~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2367: No best common type exists between 'Foo' and 'U'. // ok? var r9 = true ? v : new Foo(); - ~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2367: No best common type exists between 'V' and 'Foo'. var r9 = true ? new Foo() : v; - ~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2367: No best common type exists between 'Foo' and 'V'. // ok? var r10 = true ? t : new Foo(); - ~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2367: No best common type exists between 'T' and 'Foo'. var r10 = true ? new Foo() : t; - ~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2367: No best common type exists between 'Foo' and 'T'. // ok? var r11 = true ? u : new Foo(); - ~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2367: No best common type exists between 'U' and 'Foo'. var r11 = true ? new Foo() : u; - ~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2367: No best common type exists between 'Foo' and 'U'. // ok? var r12 = true ? v : new Foo(); - ~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2367: No best common type exists between 'V' and 'Foo'. var r12 = true ? new Foo() : v; - ~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2367: No best common type exists between 'Foo' and 'V'. } module M1 { diff --git a/tests/baselines/reference/subtypingWithCallSignatures2.types b/tests/baselines/reference/subtypingWithCallSignatures2.types index 5006e00d52..12344a46f3 100644 --- a/tests/baselines/reference/subtypingWithCallSignatures2.types +++ b/tests/baselines/reference/subtypingWithCallSignatures2.types @@ -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 : { (x: T): string[]; }[] +>[r2arg2, r2arg1] : { (x: T): string[]; }[] >r2arg2 : (x: number) => string[] >r2arg1 : (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 : { (x: T): T; }[] +>[r3arg2, r3arg1] : { (x: T): T; }[] >r3arg2 : (x: number) => void >r3arg1 : (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 : { (x: Base[], y: T): Derived[]; }[] +>[r12arg2, r12arg1] : { (x: Base[], y: T): Derived[]; }[] >r12arg2 : (x: Base[], y: Derived2[]) => Derived[] >r12arg1 : (x: Base[], y: T) => Derived[] diff --git a/tests/baselines/reference/subtypingWithCallSignatures3.types b/tests/baselines/reference/subtypingWithCallSignatures3.types index 8c13611346..be5fb44c9c 100644 --- a/tests/baselines/reference/subtypingWithCallSignatures3.types +++ b/tests/baselines/reference/subtypingWithCallSignatures3.types @@ -340,14 +340,14 @@ module Errors { >r3arg : (x: (arg: T) => U, y: (arg2: { foo: number; }) => U) => (r: T) => U var r3a = [r3arg2, r3arg]; ->r3a : {}[] ->[r3arg2, r3arg] : {}[] +>r3a : Array<{ (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<{ (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 : (x: (arg: T) => U, y: (arg2: { foo: number; }) => U) => (r: T) => U var r3b = [r3arg, r3arg2]; ->r3b : {}[] ->[r3arg, r3arg2] : {}[] +>r3b : Array<{ (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<{ (x: (arg: T) => U, y: (arg2: { foo: number; }) => U): (r: T) => U; } | { (x: (arg: Base) => Derived, y: (arg2: Base) => Derived): (r: Base) => Derived; }> >r3arg : (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 : (x: { a: T; b: T; }) => number var r7e = [r7arg3, r7arg2]; ->r7e : { (x: { a: T; b: T; }): number; }[] ->[r7arg3, r7arg2] : { (x: { a: T; b: T; }): number; }[] +>r7e : { (x: { a: string; b: number; }): number; }[] +>[r7arg3, r7arg2] : { (x: { a: string; b: number; }): number; }[] >r7arg3 : (x: { a: T; b: T; }) => number >r7arg2 : (x: { a: string; b: number; }) => number diff --git a/tests/baselines/reference/subtypingWithCallSignatures4.types b/tests/baselines/reference/subtypingWithCallSignatures4.types index 07b3af3e54..f31a4fa928 100644 --- a/tests/baselines/reference/subtypingWithCallSignatures4.types +++ b/tests/baselines/reference/subtypingWithCallSignatures4.types @@ -318,8 +318,8 @@ var r3a = [r3arg, r3arg2]; >r3arg2 : (x: T) => void var r3b = [r3arg2, r3arg]; ->r3b : { (x: T): void; }[] ->[r3arg2, r3arg] : { (x: T): void; }[] +>r3b : { (x: T): T; }[] +>[r3arg2, r3arg] : { (x: T): T; }[] >r3arg2 : (x: T) => void >r3arg : (x: T) => T @@ -442,8 +442,8 @@ var r6a = [r6arg, r6arg2]; >r6arg2 : (x: (arg: T) => Derived) => T var r6b = [r6arg2, r6arg]; ->r6b : { (x: (arg: T) => Derived): T; }[] ->[r6arg2, r6arg] : { (x: (arg: T) => Derived): T; }[] +>r6b : { (x: (arg: T) => U): T; }[] +>[r6arg2, r6arg] : { (x: (arg: T) => U): T; }[] >r6arg2 : (x: (arg: T) => Derived) => T >r6arg : (x: (arg: T) => U) => T @@ -491,8 +491,8 @@ var r11a = [r11arg, r11arg2]; >r11arg2 : (x: { foo: T; }, y: { foo: T; bar: T; }) => Base var r11b = [r11arg2, r11arg]; ->r11b : { (x: { foo: T; }, y: { foo: T; bar: T; }): Base; }[] ->[r11arg2, r11arg] : { (x: { foo: T; }, y: { foo: T; bar: T; }): Base; }[] +>r11b : { (x: { foo: T; }, y: { foo: U; bar: U; }): Base; }[] +>[r11arg2, r11arg] : { (x: { foo: T; }, y: { foo: U; bar: U; }): Base; }[] >r11arg2 : (x: { foo: T; }, y: { foo: T; bar: T; }) => Base >r11arg : (x: { foo: T; }, y: { foo: U; bar: U; }) => Base @@ -534,8 +534,8 @@ var r15a = [r15arg, r15arg2]; >r15arg2 : (x: { a: T; b: T; }) => T[] var r15b = [r15arg2, r15arg]; ->r15b : { (x: { a: T; b: T; }): T[]; }[] ->[r15arg2, r15arg] : { (x: { a: T; b: T; }): T[]; }[] +>r15b : { (x: { a: U; b: V; }): U[]; }[] +>[r15arg2, r15arg] : { (x: { a: U; b: V; }): U[]; }[] >r15arg2 : (x: { a: T; b: T; }) => T[] >r15arg : (x: { a: U; b: V; }) => U[] diff --git a/tests/baselines/reference/subtypingWithConstructSignatures2.types b/tests/baselines/reference/subtypingWithConstructSignatures2.types index fdba601475..3832697d04 100644 --- a/tests/baselines/reference/subtypingWithConstructSignatures2.types +++ b/tests/baselines/reference/subtypingWithConstructSignatures2.types @@ -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 (x: T): string[]; }[] +>[r2arg2, r2arg1] : { new (x: T): string[]; }[] >r2arg2 : new (x: number) => string[] >r2arg1 : new (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 (x: T): T; }[] +>[r3arg2, r3arg1] : { new (x: T): T; }[] >r3arg2 : new (x: number) => void >r3arg1 : new (x: T) => T @@ -630,14 +630,14 @@ var r9 = foo9(r9arg1); // any >r9arg1 : new (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 (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 (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 (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 (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 (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 (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 (x: Base[], y: T): Derived[]; }[] +>[r12arg2, r12arg1] : { new (x: Base[], y: T): Derived[]; }[] >r12arg2 : new (x: Base[], y: Derived2[]) => Derived[] >r12arg1 : new (x: Base[], y: T) => Derived[] diff --git a/tests/baselines/reference/subtypingWithConstructSignatures3.types b/tests/baselines/reference/subtypingWithConstructSignatures3.types index cf4db8939f..ff6b9adef0 100644 --- a/tests/baselines/reference/subtypingWithConstructSignatures3.types +++ b/tests/baselines/reference/subtypingWithConstructSignatures3.types @@ -318,14 +318,14 @@ module Errors { >r3arg1 : new (x: new (arg: T) => U, y: (arg2: { foo: number; }) => U) => new (r: T) => U var r3a = [r3arg2, r3arg1]; ->r3a : {}[] ->[r3arg2, r3arg1] : {}[] +>r3a : Array<{ new (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 (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 (x: new (arg: T) => U, y: (arg2: { foo: number; }) => U) => new (r: T) => U var r3b = [r3arg1, r3arg2]; ->r3b : {}[] ->[r3arg1, r3arg2] : {}[] +>r3b : Array<{ new (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 (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 (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 (x: { a: T; b: T; }) => number var r7e = [r7arg3, r7arg2]; ->r7e : { new (x: { a: T; b: T; }): number; }[] ->[r7arg3, r7arg2] : { new (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 (x: { a: T; b: T; }) => number >r7arg2 : new (x: { a: string; b: number; }) => number diff --git a/tests/baselines/reference/subtypingWithConstructSignatures4.types b/tests/baselines/reference/subtypingWithConstructSignatures4.types index a9116880df..473bbe9a20 100644 --- a/tests/baselines/reference/subtypingWithConstructSignatures4.types +++ b/tests/baselines/reference/subtypingWithConstructSignatures4.types @@ -307,8 +307,8 @@ var r3a = [r3arg, r3arg2]; >r3arg2 : new (x: T) => void var r3b = [r3arg2, r3arg]; ->r3b : { new (x: T): void; }[] ->[r3arg2, r3arg] : { new (x: T): void; }[] +>r3b : { new (x: T): T; }[] +>[r3arg2, r3arg] : { new (x: T): T; }[] >r3arg2 : new (x: T) => void >r3arg : new (x: T) => T @@ -421,8 +421,8 @@ var r6a = [r6arg, r6arg2]; >r6arg2 : new (x: new (arg: T) => Derived) => T var r6b = [r6arg2, r6arg]; ->r6b : { new (x: new (arg: T) => Derived): T; }[] ->[r6arg2, r6arg] : { new (x: new (arg: T) => Derived): T; }[] +>r6b : { new (x: new (arg: T) => U): T; }[] +>[r6arg2, r6arg] : { new (x: new (arg: T) => U): T; }[] >r6arg2 : new (x: new (arg: T) => Derived) => T >r6arg : new (x: new (arg: T) => U) => T @@ -466,8 +466,8 @@ var r11a = [r11arg, r11arg2]; >r11arg2 : new (x: { foo: T; }, y: { foo: T; bar: T; }) => Base var r11b = [r11arg2, r11arg]; ->r11b : { new (x: { foo: T; }, y: { foo: T; bar: T; }): Base; }[] ->[r11arg2, r11arg] : { new (x: { foo: T; }, y: { foo: T; bar: T; }): Base; }[] +>r11b : { new (x: { foo: T; }, y: { foo: U; bar: U; }): Base; }[] +>[r11arg2, r11arg] : { new (x: { foo: T; }, y: { foo: U; bar: U; }): Base; }[] >r11arg2 : new (x: { foo: T; }, y: { foo: T; bar: T; }) => Base >r11arg : new (x: { foo: T; }, y: { foo: U; bar: U; }) => Base @@ -505,8 +505,8 @@ var r15a = [r15arg, r15arg2]; >r15arg2 : new (x: { a: T; b: T; }) => T[] var r15b = [r15arg2, r15arg]; ->r15b : { new (x: { a: T; b: T; }): T[]; }[] ->[r15arg2, r15arg] : { new (x: { a: T; b: T; }): T[]; }[] +>r15b : { new (x: { a: U; b: V; }): U[]; }[] +>[r15arg2, r15arg] : { new (x: { a: U; b: V; }): U[]; }[] >r15arg2 : new (x: { a: T; b: T; }) => T[] >r15arg : new (x: { a: U; b: V; }) => U[] diff --git a/tests/baselines/reference/subtypingWithObjectMembersOptionality2.errors.txt b/tests/baselines/reference/subtypingWithObjectMembersOptionality2.errors.txt index 74d47f1256..b3eae74f56 100644 --- a/tests/baselines/reference/subtypingWithObjectMembersOptionality2.errors.txt +++ b/tests/baselines/reference/subtypingWithObjectMembersOptionality2.errors.txt @@ -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; }'. \ No newline at end of file + var r = true ? a : b; // error \ No newline at end of file diff --git a/tests/baselines/reference/targetTypeTest3.errors.txt b/tests/baselines/reference/targetTypeTest3.errors.txt index e81cba71a4..d9dbec4115 100644 --- a/tests/baselines/reference/targetTypeTest3.errors.txt +++ b/tests/baselines/reference/targetTypeTest3.errors.txt @@ -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' 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' 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; } diff --git a/tests/baselines/reference/throwStatements.types b/tests/baselines/reference/throwStatements.types index efc2ff2412..7f106daced 100644 --- a/tests/baselines/reference/throwStatements.types +++ b/tests/baselines/reference/throwStatements.types @@ -219,7 +219,7 @@ throw []; >[] : undefined[] throw ['a', ['b']]; ->['a', ['b']] : {}[] +>['a', ['b']] : Array >['b'] : string[] throw /[a-z]/; diff --git a/tests/baselines/reference/trailingCommaInHeterogenousArrayLiteral1.errors.txt b/tests/baselines/reference/trailingCommaInHeterogenousArrayLiteral1.errors.txt index e1681f5cc2..823bf93e53 100644 --- a/tests/baselines/reference/trailingCommaInHeterogenousArrayLiteral1.errors.txt +++ b/tests/baselines/reference/trailingCommaInHeterogenousArrayLiteral1.errors.txt @@ -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' 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' 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' 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' 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'. } } \ No newline at end of file diff --git a/tests/baselines/reference/tupleTypes.errors.txt b/tests/baselines/reference/tupleTypes.errors.txt index fcc65ff5c2..2ce9b044f4 100644 --- a/tests/baselines/reference/tupleTypes.errors.txt +++ b/tests/baselines/reference/tupleTypes.errors.txt @@ -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' is not assignable to type '[number, string]': + Property '0' is missing in type 'Array'. 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' 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' is not assignable to type '[number, string]': +!!! error TS2322: Property '0' is missing in type 'Array'. 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' 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 ~ diff --git a/tests/baselines/reference/typeArgInference2.errors.txt b/tests/baselines/reference/typeArgInference2.errors.txt new file mode 100644 index 0000000000..3e148ca1da --- /dev/null +++ b/tests/baselines/reference/typeArgInference2.errors.txt @@ -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(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. \ No newline at end of file diff --git a/tests/baselines/reference/typeArgInference2.types b/tests/baselines/reference/typeArgInference2.types deleted file mode 100644 index 1b94a0638b..0000000000 --- a/tests/baselines/reference/typeArgInference2.types +++ /dev/null @@ -1,61 +0,0 @@ -=== tests/cases/compiler/typeArgInference2.ts === -interface Item { ->Item : Item - - name: string; ->name : string -} - -declare function foo(x?: T, y?: T): T; ->foo : (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 : (x?: T, y?: T) => T - -var z2 = foo(); // Item ->z2 : Item ->foo() : Item ->foo : (x?: T, y?: T) => T - -var z3 = foo({ name: null }); // { name: any } ->z3 : { name: any; } ->foo({ name: null }) : { name: any; } ->foo : (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 : (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 : (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 : (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 - diff --git a/tests/baselines/reference/typeArgInference2WithError.errors.txt b/tests/baselines/reference/typeArgInference2WithError.errors.txt index 26259abf37..83fa81b552 100644 --- a/tests/baselines/reference/typeArgInference2WithError.errors.txt +++ b/tests/baselines/reference/typeArgInference2WithError.errors.txt @@ -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(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'. \ No newline at end of file + ~~~~~~~~~~~~~ +!!! error TS2346: Supplied parameters do not match any signature of call target. \ No newline at end of file diff --git a/tests/baselines/reference/typeArgumentInference.errors.txt b/tests/baselines/reference/typeArgumentInference.errors.txt new file mode 100644 index 0000000000..dbff8b8385 --- /dev/null +++ b/tests/baselines/reference/typeArgumentInference.errors.txt @@ -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() { } + noParams(); + noParams(); + noParams<{}>(); + + // Generic call with parameters but none use type parameter type + function noGenericParams(n: string) { } + noGenericParams(''); + noGenericParams(''); + noGenericParams<{}>(''); + + // Generic call with multiple type parameters and only one used in parameter type annotation + function someGenerics1(n: T, m: number) { } + someGenerics1(3, 4); + someGenerics1(3, 4); + + // Generic call with argument of function type whose parameter is of type parameter type + function someGenerics2a(n: (x: T) => void) { } + someGenerics2a((n: string) => n); + someGenerics2a((n: string) => n); + someGenerics2a((n) => n.substr(0)); + + function someGenerics2b(n: (x: T, y: U) => void) { } + someGenerics2b((n: string, x: number) => n); + someGenerics2b((n: string, t: number) => n); + someGenerics2b((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(producer: () => T) { } + someGenerics3(() => ''); + someGenerics3(() => undefined); + someGenerics3(() => 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(n: T, f: (x: U) => void) { } + someGenerics4(4, () => null); + someGenerics4('', () => 3); + someGenerics4(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(n: T, f: (x: U) => void) { } + someGenerics5(4, () => null); + someGenerics5('', () => 3); + someGenerics5(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, b: (b: A) => A, c: (c: A) => A) { } + someGenerics6(n => n, n => n, n => n); + someGenerics6(n => n, n => n, n => n); + someGenerics6((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: (a: A) => A, b: (b: B) => B, c: (c: C) => C) { } + someGenerics7(n => n, n => n, n => n); + someGenerics7(n => n, n => n, n => n); + someGenerics7((n: number) => n, (n: string) => n, (n: number) => n); + + // Generic call with argument of generic function type + function someGenerics8(n: T): T { return n; } + var x = someGenerics8(someGenerics7); + x(null, null, null); + + // Generic call with multiple parameters of generic type passed arguments with no best common type + function someGenerics9(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(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[]; + + \ No newline at end of file diff --git a/tests/baselines/reference/typeArgumentInference.types b/tests/baselines/reference/typeArgumentInference.types deleted file mode 100644 index 40136bd10c..0000000000 --- a/tests/baselines/reference/typeArgumentInference.types +++ /dev/null @@ -1,468 +0,0 @@ -=== tests/cases/conformance/expressions/functionCalls/typeArgumentInference.ts === -// Generic call with no parameters -function noParams() { } ->noParams : () => void ->T : T - -noParams(); ->noParams() : void ->noParams : () => void - -noParams(); ->noParams() : void ->noParams : () => void - -noParams<{}>(); ->noParams<{}>() : void ->noParams : () => void - -// Generic call with parameters but none use type parameter type -function noGenericParams(n: string) { } ->noGenericParams : (n: string) => void ->T : T ->n : string - -noGenericParams(''); ->noGenericParams('') : void ->noGenericParams : (n: string) => void - -noGenericParams(''); ->noGenericParams('') : void ->noGenericParams : (n: string) => void - -noGenericParams<{}>(''); ->noGenericParams<{}>('') : void ->noGenericParams : (n: string) => void - -// Generic call with multiple type parameters and only one used in parameter type annotation -function someGenerics1(n: T, m: number) { } ->someGenerics1 : (n: T, m: number) => void ->T : T ->U : U ->n : T ->T : T ->m : number - -someGenerics1(3, 4); ->someGenerics1(3, 4) : void ->someGenerics1 : (n: T, m: number) => void - -someGenerics1(3, 4); ->someGenerics1(3, 4) : void ->someGenerics1 : (n: T, m: number) => void - -// Generic call with argument of function type whose parameter is of type parameter type -function someGenerics2a(n: (x: T) => void) { } ->someGenerics2a : (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 : (n: (x: T) => void) => void ->(n: string) => n : (n: string) => string ->n : string ->n : string - -someGenerics2a((n: string) => n); ->someGenerics2a((n: string) => n) : void ->someGenerics2a : (n: (x: T) => void) => void ->(n: string) => n : (n: string) => string ->n : string ->n : string - -someGenerics2a((n) => n.substr(0)); ->someGenerics2a((n) => n.substr(0)) : void ->someGenerics2a : (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(n: (x: T, y: U) => void) { } ->someGenerics2b : (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 : (n: (x: T, y: U) => void) => void ->(n: string, x: number) => n : (n: string, x: number) => string ->n : string ->x : number ->n : string - -someGenerics2b((n: string, t: number) => n); ->someGenerics2b((n: string, t: number) => n) : void ->someGenerics2b : (n: (x: T, y: U) => void) => void ->(n: string, t: number) => n : (n: string, t: number) => string ->n : string ->t : number ->n : string - -someGenerics2b((n, t) => n.substr(t * t)); ->someGenerics2b((n, t) => n.substr(t * t)) : void ->someGenerics2b : (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(producer: () => T) { } ->someGenerics3 : (producer: () => T) => void ->T : T ->producer : () => T ->T : T - -someGenerics3(() => ''); ->someGenerics3(() => '') : void ->someGenerics3 : (producer: () => T) => void ->() => '' : () => string - -someGenerics3(() => undefined); ->someGenerics3(() => undefined) : void ->someGenerics3 : (producer: () => T) => void ->Date : Date ->() => undefined : () => any ->undefined : undefined - -someGenerics3(() => 3); ->someGenerics3(() => 3) : void ->someGenerics3 : (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(n: T, f: (x: U) => void) { } ->someGenerics4 : (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 : (n: T, f: (x: U) => void) => void ->() => null : () => any - -someGenerics4('', () => 3); ->someGenerics4('', () => 3) : void ->someGenerics4 : (n: T, f: (x: U) => void) => void ->() => 3 : () => number - -someGenerics4(null, null); ->someGenerics4(null, null) : void ->someGenerics4 : (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(n: T, f: (x: U) => void) { } ->someGenerics5 : (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 : (n: T, f: (x: U) => void) => void ->() => null : () => any - -someGenerics5('', () => 3); ->someGenerics5('', () => 3) : void ->someGenerics5 : (n: T, f: (x: U) => void) => void ->() => 3 : () => number - -someGenerics5(null, null); ->someGenerics5(null, null) : void ->someGenerics5 : (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, b: (b: A) => A, c: (c: A) => A) { } ->someGenerics6 : (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, 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(n => n, n => n, n => n); ->someGenerics6(n => n, n => n, n => n) : void ->someGenerics6 : (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((n: number) => n, (n: number) => n, (n: number) => n); ->someGenerics6((n: number) => n, (n: number) => n, (n: number) => n) : void ->someGenerics6 : (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: (a: A) => A, b: (b: B) => B, c: (c: C) => C) { } ->someGenerics7 : (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: (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(n => n, n => n, n => n); ->someGenerics7(n => n, n => n, n => n) : void ->someGenerics7 : (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((n: number) => n, (n: string) => n, (n: number) => n); ->someGenerics7((n: number) => n, (n: string) => n, (n: number) => n) : void ->someGenerics7 : (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(n: T): T { return n; } ->someGenerics8 : (n: T) => T ->T : T ->n : T ->T : T ->T : T ->n : T - -var x = someGenerics8(someGenerics7); ->x : (a: (a: A) => A, b: (b: B) => B, c: (c: C) => C) => void ->someGenerics8(someGenerics7) : (a: (a: A) => A, b: (b: B) => B, c: (c: C) => C) => void ->someGenerics8 : (n: T) => T ->someGenerics7 : (a: (a: A) => A, b: (b: B) => B, c: (c: C) => C) => void - -x(null, null, null); ->x(null, null, null) : void ->x : (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(a: T, b: T, c: T): T { ->someGenerics9 : (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 : (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 : (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 : (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(undefined, { x: 6, z: new Date() }, { x: 6, y: '' }); ->a9f : A92 ->someGenerics9(undefined, { x: 6, z: new Date() }, { x: 6, y: '' }) : A92 ->someGenerics9 : (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 : (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 : (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 : (a: T, b: T, c: T) => T ->[] : any[] ->undefined : undefined - -var arr: any[]; ->arr : any[] - - diff --git a/tests/baselines/reference/typeArgumentInferenceConstructSignatures.errors.txt b/tests/baselines/reference/typeArgumentInferenceConstructSignatures.errors.txt index a9de02d422..4f11cb6135 100644 --- a/tests/baselines/reference/typeArgumentInferenceConstructSignatures.errors.txt +++ b/tests/baselines/reference/typeArgumentInferenceConstructSignatures.errors.txt @@ -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 (); @@ -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: {}; diff --git a/tests/baselines/reference/typeArgumentInferenceTransitiveConstraints.errors.txt b/tests/baselines/reference/typeArgumentInferenceTransitiveConstraints.errors.txt index e6e59308dd..08cb5348c2 100644 --- a/tests/baselines/reference/typeArgumentInferenceTransitiveConstraints.errors.txt +++ b/tests/baselines/reference/typeArgumentInferenceTransitiveConstraints.errors.txt @@ -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: 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[]'. \ No newline at end of file diff --git a/tests/baselines/reference/typeArgumentInferenceWithConstraintAsCommonRoot.errors.txt b/tests/baselines/reference/typeArgumentInferenceWithConstraintAsCommonRoot.errors.txt new file mode 100644 index 0000000000..c0ee4329c8 --- /dev/null +++ b/tests/baselines/reference/typeArgumentInferenceWithConstraintAsCommonRoot.errors.txt @@ -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(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. \ No newline at end of file diff --git a/tests/baselines/reference/typeArgumentInferenceWithConstraintAsCommonRoot.types b/tests/baselines/reference/typeArgumentInferenceWithConstraintAsCommonRoot.types deleted file mode 100644 index 35328f7280..0000000000 --- a/tests/baselines/reference/typeArgumentInferenceWithConstraintAsCommonRoot.types +++ /dev/null @@ -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(x: T, y: T): T { return undefined; } ->f : (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 : (x: T, y: T) => T ->g : Giraffe ->e : Elephant - diff --git a/tests/baselines/reference/typeArgumentInferenceWithConstraints.errors.txt b/tests/baselines/reference/typeArgumentInferenceWithConstraints.errors.txt index 8cf2a2d350..c0dbf74f66 100644 --- a/tests/baselines/reference/typeArgumentInferenceWithConstraints.errors.txt +++ b/tests/baselines/reference/typeArgumentInferenceWithConstraints.errors.txt @@ -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: (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() { } 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: {}; diff --git a/tests/baselines/reference/typeInferenceConflictingCandidates.errors.txt b/tests/baselines/reference/typeInferenceConflictingCandidates.errors.txt new file mode 100644 index 0000000000..5f9f980e73 --- /dev/null +++ b/tests/baselines/reference/typeInferenceConflictingCandidates.errors.txt @@ -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(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. \ No newline at end of file diff --git a/tests/baselines/reference/typeInferenceConflictingCandidates.types b/tests/baselines/reference/typeInferenceConflictingCandidates.types deleted file mode 100644 index 7a77daf409..0000000000 --- a/tests/baselines/reference/typeInferenceConflictingCandidates.types +++ /dev/null @@ -1,21 +0,0 @@ -=== tests/cases/compiler/typeInferenceConflictingCandidates.ts === -declare function g(a: T, b: T, c: (t: T) => T): T; ->g : (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 : (a: T, b: T, c: (t: T) => T) => T ->a => a : (a: {}) => {} ->a : {} ->a : {} - diff --git a/tests/baselines/reference/typeParameterAsElementType.types b/tests/baselines/reference/typeParameterAsElementType.types index 0dbbbf5ac7..828c7034a5 100644 --- a/tests/baselines/reference/typeParameterAsElementType.types +++ b/tests/baselines/reference/typeParameterAsElementType.types @@ -8,7 +8,7 @@ function fee() { >T : T var arr = [t, ""]; ->arr : {}[] ->[t, ""] : {}[] +>arr : Array +>[t, ""] : Array >t : T } diff --git a/tests/baselines/reference/underscoreTest1.types b/tests/baselines/reference/underscoreTest1.types index 115bc09195..a23eff1f8e 100644 --- a/tests/baselines/reference/underscoreTest1.types +++ b/tests/baselines/reference/underscoreTest1.types @@ -176,7 +176,7 @@ _.all([true, 1, null, 'yes'], _.identity); >_.all : { (list: T[], iterator?: Iterator, context?: any): boolean; (list: Dictionary, iterator?: Iterator, context?: any): boolean; } >_ : Underscore.Static >all : { (list: T[], iterator?: Iterator, context?: any): boolean; (list: Dictionary, iterator?: Iterator, context?: any): boolean; } ->[true, 1, null, 'yes'] : {}[] +>[true, 1, null, 'yes'] : Array >_.identity : (value: T) => T >_ : Underscore.Static >identity : (value: T) => T @@ -186,7 +186,7 @@ _.any([null, 0, 'yes', false]); >_.any : { (list: T[], iterator?: Iterator, context?: any): boolean; (list: Dictionary, iterator?: Iterator, context?: any): boolean; } >_ : Underscore.Static >any : { (list: T[], iterator?: Iterator, context?: any): boolean; (list: Dictionary, iterator?: Iterator, context?: any): boolean; } ->[null, 0, 'yes', false] : {}[] +>[null, 0, 'yes', false] : Array _.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 >_.compact : (list: T[]) => T[] >_ : Underscore.Static >compact : (list: T[]) => T[] ->[0, 1, false, 2, '', 3] : {}[] +>[0, 1, false, 2, '', 3] : Array _.flatten([1, 2, 3, 4]); >_.flatten([1, 2, 3, 4]) : {}[] @@ -393,7 +393,7 @@ _.flatten([1, [2], [3, [[4]]]]); >flatten : { (list: T[][]): T[]; (array: any[], shallow?: boolean): T[]; } >[1, [2], [3, [[4]]]] : any[] >[2] : number[] ->[3, [[4]]] : {}[] +>[3, [[4]]] : Array >[[4]] : number[][] >[4] : number[] @@ -404,7 +404,7 @@ _.flatten([1, [2], [3, [[4]]]], true); >flatten : { (list: T[][]): T[]; (array: any[], shallow?: boolean): T[]; } >[1, [2], [3, [[4]]]] : any[] >[2] : number[] ->[3, [[4]]] : {}[] +>[3, [[4]]] : Array >[[4]] : number[][] >[4] : number[]