mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-15 12:51:30 -05:00
Make finer-grained errors get reported on function arguments (#26784)
This commit is contained in:
@@ -10528,9 +10528,13 @@ namespace ts {
|
||||
* attempt to issue more specific errors on, for example, specific object literal properties or tuple members.
|
||||
*/
|
||||
function checkTypeAssignableToAndOptionallyElaborate(source: Type, target: Type, errorNode: Node | undefined, expr: Expression | undefined, headMessage?: DiagnosticMessage, containingMessageChain?: () => DiagnosticMessageChain | undefined): boolean {
|
||||
if (isTypeAssignableTo(source, target)) return true;
|
||||
if (!elaborateError(expr, source, target)) {
|
||||
return checkTypeRelatedTo(source, target, assignableRelation, errorNode, headMessage, containingMessageChain);
|
||||
return checkTypeRelatedToAndOptionallyElaborate(source, target, assignableRelation, errorNode, expr, headMessage, containingMessageChain);
|
||||
}
|
||||
|
||||
function checkTypeRelatedToAndOptionallyElaborate(source: Type, target: Type, relation: Map<RelationComparisonResult>, errorNode: Node | undefined, expr: Expression | undefined, headMessage?: DiagnosticMessage, containingMessageChain?: () => DiagnosticMessageChain | undefined): boolean {
|
||||
if (isTypeRelatedTo(source, target, relation)) return true;
|
||||
if (!errorNode || !elaborateError(expr, source, target)) {
|
||||
return checkTypeRelatedTo(source, target, relation, errorNode, headMessage, containingMessageChain);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -18869,7 +18873,7 @@ namespace ts {
|
||||
// we obtain the regular type of any object literal arguments because we may not have inferred complete
|
||||
// parameter types yet and therefore excess property checks may yield false positives (see #17041).
|
||||
const checkArgType = excludeArgument ? getRegularTypeOfObjectLiteral(argType) : argType;
|
||||
if (!checkTypeRelatedTo(checkArgType, paramType, relation, reportErrors ? arg : undefined, headMessage)) {
|
||||
if (!checkTypeRelatedToAndOptionallyElaborate(checkArgType, paramType, relation, reportErrors ? arg : undefined, arg, headMessage)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
tests/cases/compiler/assignmentCompatFunctionsWithOptionalArgs.ts(1,10): error TS2391: Function implementation is missing or not immediately following the declaration.
|
||||
tests/cases/compiler/assignmentCompatFunctionsWithOptionalArgs.ts(4,5): error TS2345: Argument of type '{ id: number; name: boolean; }' is not assignable to parameter of type '{ id: number; name?: string; }'.
|
||||
Types of property 'name' are incompatible.
|
||||
Type 'boolean' is not assignable to type 'string'.
|
||||
tests/cases/compiler/assignmentCompatFunctionsWithOptionalArgs.ts(4,17): error TS2322: Type 'false' is not assignable to type 'string'.
|
||||
tests/cases/compiler/assignmentCompatFunctionsWithOptionalArgs.ts(5,5): error TS2345: Argument of type '{ name: string; }' is not assignable to parameter of type '{ id: number; name?: string; }'.
|
||||
Property 'id' is missing in type '{ name: string; }'.
|
||||
|
||||
@@ -13,10 +11,9 @@ tests/cases/compiler/assignmentCompatFunctionsWithOptionalArgs.ts(5,5): error TS
|
||||
foo({ id: 1234 }); // Ok
|
||||
foo({ id: 1234, name: "hello" }); // Ok
|
||||
foo({ id: 1234, name: false }); // Error, name of wrong type
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2345: Argument of type '{ id: number; name: boolean; }' is not assignable to parameter of type '{ id: number; name?: string; }'.
|
||||
!!! error TS2345: Types of property 'name' are incompatible.
|
||||
!!! error TS2345: Type 'boolean' is not assignable to type 'string'.
|
||||
~~~~
|
||||
!!! error TS2322: Type 'false' is not assignable to type 'string'.
|
||||
!!! related TS6500 tests/cases/compiler/assignmentCompatFunctionsWithOptionalArgs.ts:1:31: The expected type comes from property 'name' which is declared here on type '{ id: number; name?: string; }'
|
||||
foo({ name: "hello" }); // Error, id required but missing
|
||||
~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2345: Argument of type '{ name: string; }' is not assignable to parameter of type '{ id: number; name?: string; }'.
|
||||
|
||||
@@ -17,10 +17,8 @@ tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(73,11):
|
||||
tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(73,14): error TS2525: Initializer provides no value for this binding element and the binding element has no default value.
|
||||
tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(74,11): error TS2459: Type 'undefined[]' has no property 'a' and no string index signature.
|
||||
tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(74,14): error TS2459: Type 'undefined[]' has no property 'b' and no string index signature.
|
||||
tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(106,5): error TS2345: Argument of type '[number, [string, { y: false; }]]' is not assignable to parameter of type '[number, [string, { x: any; y?: boolean; }]]'.
|
||||
Type '[string, { y: false; }]' is not assignable to type '[string, { x: any; y?: boolean; }]'.
|
||||
Type '{ y: false; }' is not assignable to type '{ x: any; y?: boolean; }'.
|
||||
Property 'x' is missing in type '{ y: false; }'.
|
||||
tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(106,17): error TS2322: Type '{ y: boolean; }' is not assignable to type '{ x: any; y?: boolean; }'.
|
||||
Property 'x' is missing in type '{ y: boolean; }'.
|
||||
tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(138,6): error TS2322: Type 'string' is not assignable to type 'number'.
|
||||
tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(138,9): error TS2322: Type 'number' is not assignable to type 'string'.
|
||||
|
||||
@@ -170,11 +168,9 @@ tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(138,9):
|
||||
f14([2, ["abc", { x: 0, y: true }]]);
|
||||
f14([2, ["abc", { x: 0 }]]);
|
||||
f14([2, ["abc", { y: false }]]); // Error, no x
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2345: Argument of type '[number, [string, { y: false; }]]' is not assignable to parameter of type '[number, [string, { x: any; y?: boolean; }]]'.
|
||||
!!! error TS2345: Type '[string, { y: false; }]' is not assignable to type '[string, { x: any; y?: boolean; }]'.
|
||||
!!! error TS2345: Type '{ y: false; }' is not assignable to type '{ x: any; y?: boolean; }'.
|
||||
!!! error TS2345: Property 'x' is missing in type '{ y: false; }'.
|
||||
~~~~~~~~~~~~
|
||||
!!! error TS2322: Type '{ y: boolean; }' is not assignable to type '{ x: any; y?: boolean; }'.
|
||||
!!! error TS2322: Property 'x' is missing in type '{ y: boolean; }'.
|
||||
|
||||
module M {
|
||||
export var [a, b] = [1, 2];
|
||||
|
||||
@@ -1,38 +1,21 @@
|
||||
tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts(7,4): error TS2345: Argument of type '[number, string, string[][]]' is not assignable to parameter of type '[number, number, string[][]]'.
|
||||
Type 'string' is not assignable to type 'number'.
|
||||
tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts(7,8): error TS2322: Type 'string' is not assignable to type 'number'.
|
||||
tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts(7,29): error TS1005: ',' expected.
|
||||
tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts(8,4): error TS2345: Argument of type '[number, number, string[][], string]' is not assignable to parameter of type '[number, number, string[][]]'.
|
||||
Types of property 'length' are incompatible.
|
||||
Type '4' is not assignable to type '3'.
|
||||
tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts(16,8): error TS2371: A parameter initializer is only allowed in a function or constructor implementation.
|
||||
tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts(16,16): error TS2371: A parameter initializer is only allowed in a function or constructor implementation.
|
||||
tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts(23,14): error TS2345: Argument of type '{ x: string; y: boolean; }' is not assignable to parameter of type '{ x: number; y: any; }'.
|
||||
Types of property 'x' are incompatible.
|
||||
Type 'string' is not assignable to type 'number'.
|
||||
tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts(23,16): error TS2322: Type 'string' is not assignable to type 'number'.
|
||||
tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts(30,14): error TS2300: Duplicate identifier 'z'.
|
||||
tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts(30,18): error TS2300: Duplicate identifier 'z'.
|
||||
tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts(34,4): error TS2345: Argument of type '{ z: number; }' is not assignable to parameter of type '{ z: { x: any; y: { j: any; }; }; }'.
|
||||
Types of property 'z' are incompatible.
|
||||
Type 'number' is not assignable to type '{ x: any; y: { j: any; }; }'.
|
||||
tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts(34,6): error TS2322: Type 'number' is not assignable to type '{ x: any; y: { j: any; }; }'.
|
||||
tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts(35,4): error TS2345: Argument of type '{}' is not assignable to parameter of type '{ z: number; }'.
|
||||
Property 'z' is missing in type '{}'.
|
||||
tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts(36,4): error TS2345: Argument of type '{ z: boolean; }' is not assignable to parameter of type '{ z: number; }'.
|
||||
Types of property 'z' are incompatible.
|
||||
Type 'boolean' is not assignable to type 'number'.
|
||||
tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts(37,4): error TS2345: Argument of type '{ z: boolean; }' is not assignable to parameter of type '{ z?: number; }'.
|
||||
Types of property 'z' are incompatible.
|
||||
Type 'boolean' is not assignable to type 'number'.
|
||||
tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts(38,4): error TS2345: Argument of type '{ b: boolean; }' is not assignable to parameter of type '{ b: string | number; }'.
|
||||
Types of property 'b' are incompatible.
|
||||
Type 'boolean' is not assignable to type 'string | number'.
|
||||
tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts(39,4): error TS2345: Argument of type '[number, number, boolean, boolean]' is not assignable to parameter of type '[any, any, [[any]]]'.
|
||||
Types of property '2' are incompatible.
|
||||
Type 'boolean' is not assignable to type '[[any]]'.
|
||||
tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts(40,4): error TS2345: Argument of type '[number, number, [[string]]]' is not assignable to parameter of type '[any, any, [[number?]]]'.
|
||||
Type '[[string]]' is not assignable to type '[[number?]]'.
|
||||
Type '[string]' is not assignable to type '[number?]'.
|
||||
Types of property '0' are incompatible.
|
||||
Type 'string' is not assignable to type 'number'.
|
||||
tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts(36,6): error TS2322: Type 'true' is not assignable to type 'number'.
|
||||
tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts(37,6): error TS2322: Type 'false' is not assignable to type 'number'.
|
||||
tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts(38,6): error TS2322: Type 'true' is not assignable to type 'string | number'.
|
||||
tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts(39,11): error TS2322: Type 'false' is not assignable to type '[[any]]'.
|
||||
tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts(40,13): error TS2322: Type 'string' is not assignable to type 'number'.
|
||||
tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts(46,13): error TS2463: A binding pattern parameter cannot be optional in an implementation signature.
|
||||
tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts(47,13): error TS2463: A binding pattern parameter cannot be optional in an implementation signature.
|
||||
tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts(56,8): error TS2463: A binding pattern parameter cannot be optional in an implementation signature.
|
||||
@@ -54,9 +37,8 @@ tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts(
|
||||
// If the declaration includes a type annotation, the parameter is of that type
|
||||
function a0([a, b, [[c]]]: [number, number, string[][]]) { }
|
||||
a0([1, "string", [["world"]]); // Error
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2345: Argument of type '[number, string, string[][]]' is not assignable to parameter of type '[number, number, string[][]]'.
|
||||
!!! error TS2345: Type 'string' is not assignable to type 'number'.
|
||||
~~~~~~~~
|
||||
!!! error TS2322: Type 'string' is not assignable to type 'number'.
|
||||
~
|
||||
!!! error TS1005: ',' expected.
|
||||
a0([1, 2, [["world"]], "string"]); // Error
|
||||
@@ -83,10 +65,9 @@ tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts(
|
||||
function b3([[a], b, [[c, d]]] = [[undefined], undefined, [[undefined, undefined]]]) { }
|
||||
|
||||
b1("string", { x: "string", y: true }); // Error
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2345: Argument of type '{ x: string; y: boolean; }' is not assignable to parameter of type '{ x: number; y: any; }'.
|
||||
!!! error TS2345: Types of property 'x' are incompatible.
|
||||
!!! error TS2345: Type 'string' is not assignable to type 'number'.
|
||||
~
|
||||
!!! error TS2322: Type 'string' is not assignable to type 'number'.
|
||||
!!! related TS6500 tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts:19:29: The expected type comes from property 'x' which is declared here on type '{ x: number; y: any; }'
|
||||
|
||||
// If the declaration specifies a binding pattern, the parameter type is the implied type of that binding pattern (section 5.1.3)
|
||||
function c0({z: {x, y: {j}}}) { }
|
||||
@@ -102,41 +83,29 @@ tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts(
|
||||
function c6([a, b, [[c = 1]]]) { }
|
||||
|
||||
c0({ z: 1 }); // Error, implied type is { z: {x: any, y: {j: any}} }
|
||||
~~~~~~~~
|
||||
!!! error TS2345: Argument of type '{ z: number; }' is not assignable to parameter of type '{ z: { x: any; y: { j: any; }; }; }'.
|
||||
!!! error TS2345: Types of property 'z' are incompatible.
|
||||
!!! error TS2345: Type 'number' is not assignable to type '{ x: any; y: { j: any; }; }'.
|
||||
~
|
||||
!!! error TS2322: Type 'number' is not assignable to type '{ x: any; y: { j: any; }; }'.
|
||||
c1({}); // Error, implied type is {z:number}?
|
||||
~~
|
||||
!!! error TS2345: Argument of type '{}' is not assignable to parameter of type '{ z: number; }'.
|
||||
!!! error TS2345: Property 'z' is missing in type '{}'.
|
||||
c1({ z: true }); // Error, implied type is {z:number}?
|
||||
~~~~~~~~~~~
|
||||
!!! error TS2345: Argument of type '{ z: boolean; }' is not assignable to parameter of type '{ z: number; }'.
|
||||
!!! error TS2345: Types of property 'z' are incompatible.
|
||||
!!! error TS2345: Type 'boolean' is not assignable to type 'number'.
|
||||
~
|
||||
!!! error TS2322: Type 'true' is not assignable to type 'number'.
|
||||
!!! related TS6500 tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts:27:21: The expected type comes from property 'z' which is declared here on type '{ z: number; }'
|
||||
c2({ z: false }); // Error, implied type is {z?: number}
|
||||
~~~~~~~~~~~~
|
||||
!!! error TS2345: Argument of type '{ z: boolean; }' is not assignable to parameter of type '{ z?: number; }'.
|
||||
!!! error TS2345: Types of property 'z' are incompatible.
|
||||
!!! error TS2345: Type 'boolean' is not assignable to type 'number'.
|
||||
~
|
||||
!!! error TS2322: Type 'false' is not assignable to type 'number'.
|
||||
c3({ b: true }); // Error, implied type is { b: number|string }.
|
||||
~~~~~~~~~~~
|
||||
!!! error TS2345: Argument of type '{ b: boolean; }' is not assignable to parameter of type '{ b: string | number; }'.
|
||||
!!! error TS2345: Types of property 'b' are incompatible.
|
||||
!!! error TS2345: Type 'boolean' is not assignable to type 'string | number'.
|
||||
~
|
||||
!!! error TS2322: Type 'true' is not assignable to type 'string | number'.
|
||||
!!! related TS6500 tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts:29:20: The expected type comes from property 'b' which is declared here on type '{ b: string | number; }'
|
||||
c5([1, 2, false, true]); // Error, implied type is [any, any, [[any]]]
|
||||
~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2345: Argument of type '[number, number, boolean, boolean]' is not assignable to parameter of type '[any, any, [[any]]]'.
|
||||
!!! error TS2345: Types of property '2' are incompatible.
|
||||
!!! error TS2345: Type 'boolean' is not assignable to type '[[any]]'.
|
||||
~~~~~
|
||||
!!! error TS2322: Type 'false' is not assignable to type '[[any]]'.
|
||||
c6([1, 2, [["string"]]]); // Error, implied type is [any, any, [[number]]] // Use initializer
|
||||
~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2345: Argument of type '[number, number, [[string]]]' is not assignable to parameter of type '[any, any, [[number?]]]'.
|
||||
!!! error TS2345: Type '[[string]]' is not assignable to type '[[number?]]'.
|
||||
!!! error TS2345: Type '[string]' is not assignable to type '[number?]'.
|
||||
!!! error TS2345: Types of property '0' are incompatible.
|
||||
!!! error TS2345: Type 'string' is not assignable to type 'number'.
|
||||
~~~~~~~~
|
||||
!!! error TS2322: Type 'string' is not assignable to type 'number'.
|
||||
|
||||
// A parameter can be marked optional by following its name or binding pattern with a question mark (?)
|
||||
// or by including an initializer. Initializers (including binding property or element initializers) are
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration3ES5.ts(26,4): error TS2345: Argument of type '[number, number, [[string]], boolean, boolean]' is not assignable to parameter of type '[any, any, [[any]]]'.
|
||||
Types of property 'length' are incompatible.
|
||||
Type '5' is not assignable to type '3'.
|
||||
tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration3ES5.ts(29,5): error TS2345: Argument of type '[number, number, number, boolean, boolean]' is not assignable to parameter of type '[any, any, [[any]], ...any[]]'.
|
||||
Types of property '2' are incompatible.
|
||||
Type 'number' is not assignable to type '[[any]]'.
|
||||
tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration3ES5.ts(29,12): error TS2322: Type 'number' is not assignable to type '[[any]]'.
|
||||
tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration3ES5.ts(30,5): error TS2345: Argument of type '[number, number]' is not assignable to parameter of type '[any, any, [[any]], ...any[]]'.
|
||||
Property '2' is missing in type '[number, number]'.
|
||||
|
||||
@@ -42,10 +40,8 @@ tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration3ES5.
|
||||
|
||||
a10([1, 2, [["string"]], false, true]); // Parameter type is any[]
|
||||
a10([1, 2, 3, false, true]); // Parameter type is any[]
|
||||
~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2345: Argument of type '[number, number, number, boolean, boolean]' is not assignable to parameter of type '[any, any, [[any]], ...any[]]'.
|
||||
!!! error TS2345: Types of property '2' are incompatible.
|
||||
!!! error TS2345: Type 'number' is not assignable to type '[[any]]'.
|
||||
~
|
||||
!!! error TS2322: Type 'number' is not assignable to type '[[any]]'.
|
||||
a10([1, 2]); // Parameter type is any[]
|
||||
~~~~~~
|
||||
!!! error TS2345: Argument of type '[number, number]' is not assignable to parameter of type '[any, any, [[any]], ...any[]]'.
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration3ES5iterable.ts(26,4): error TS2345: Argument of type '[number, number, [[string]], boolean, boolean]' is not assignable to parameter of type '[any, any, [[any]]]'.
|
||||
Types of property 'length' are incompatible.
|
||||
Type '5' is not assignable to type '3'.
|
||||
tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration3ES5iterable.ts(29,5): error TS2345: Argument of type '[number, number, number, boolean, boolean]' is not assignable to parameter of type '[any, any, [[any]], ...any[]]'.
|
||||
Types of property '2' are incompatible.
|
||||
Type 'number' is not assignable to type '[[any]]'.
|
||||
tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration3ES5iterable.ts(29,12): error TS2322: Type 'number' is not assignable to type '[[any]]'.
|
||||
tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration3ES5iterable.ts(30,5): error TS2345: Argument of type '[number, number]' is not assignable to parameter of type '[any, any, [[any]], ...any[]]'.
|
||||
Property '2' is missing in type '[number, number]'.
|
||||
|
||||
@@ -42,10 +40,8 @@ tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration3ES5i
|
||||
|
||||
a10([1, 2, [["string"]], false, true]); // Parameter type is any[]
|
||||
a10([1, 2, 3, false, true]); // Parameter type is any[]
|
||||
~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2345: Argument of type '[number, number, number, boolean, boolean]' is not assignable to parameter of type '[any, any, [[any]], ...any[]]'.
|
||||
!!! error TS2345: Types of property '2' are incompatible.
|
||||
!!! error TS2345: Type 'number' is not assignable to type '[[any]]'.
|
||||
~
|
||||
!!! error TS2322: Type 'number' is not assignable to type '[[any]]'.
|
||||
a10([1, 2]); // Parameter type is any[]
|
||||
~~~~~~
|
||||
!!! error TS2345: Argument of type '[number, number]' is not assignable to parameter of type '[any, any, [[any]], ...any[]]'.
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration3ES6.ts(26,4): error TS2345: Argument of type '[number, number, [[string]], boolean, boolean]' is not assignable to parameter of type '[any, any, [[any]]]'.
|
||||
Types of property 'length' are incompatible.
|
||||
Type '5' is not assignable to type '3'.
|
||||
tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration3ES6.ts(29,5): error TS2345: Argument of type '[number, number, number, boolean, boolean]' is not assignable to parameter of type '[any, any, [[any]], ...any[]]'.
|
||||
Types of property '2' are incompatible.
|
||||
Type 'number' is not assignable to type '[[any]]'.
|
||||
tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration3ES6.ts(29,12): error TS2322: Type 'number' is not assignable to type '[[any]]'.
|
||||
tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration3ES6.ts(30,5): error TS2345: Argument of type '[number, number]' is not assignable to parameter of type '[any, any, [[any]], ...any[]]'.
|
||||
Property '2' is missing in type '[number, number]'.
|
||||
|
||||
@@ -42,10 +40,8 @@ tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration3ES6.
|
||||
|
||||
a10([1, 2, [["string"]], false, true]); // Parameter type is any[]
|
||||
a10([1, 2, 3, false, true]); // Parameter type is any[]
|
||||
~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2345: Argument of type '[number, number, number, boolean, boolean]' is not assignable to parameter of type '[any, any, [[any]], ...any[]]'.
|
||||
!!! error TS2345: Types of property '2' are incompatible.
|
||||
!!! error TS2345: Type 'number' is not assignable to type '[[any]]'.
|
||||
~
|
||||
!!! error TS2322: Type 'number' is not assignable to type '[[any]]'.
|
||||
a10([1, 2]); // Parameter type is any[]
|
||||
~~~~~~
|
||||
!!! error TS2345: Argument of type '[number, number]' is not assignable to parameter of type '[any, any, [[any]], ...any[]]'.
|
||||
|
||||
@@ -2,9 +2,7 @@ tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration4.ts(
|
||||
tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration4.ts(15,16): error TS1048: A rest parameter cannot have an initializer.
|
||||
tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration4.ts(20,19): error TS2345: Argument of type 'true' is not assignable to parameter of type 'string | number'.
|
||||
tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration4.ts(21,7): error TS2552: Cannot find name 'array2'. Did you mean 'Array'?
|
||||
tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration4.ts(22,4): error TS2345: Argument of type '[number, number, string, boolean, boolean]' is not assignable to parameter of type '[any, any, [[any]]]'.
|
||||
Types of property '2' are incompatible.
|
||||
Type 'string' is not assignable to type '[[any]]'.
|
||||
tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration4.ts(22,11): error TS2322: Type 'string' is not assignable to type '[[any]]'.
|
||||
tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration4.ts(23,4): error TS2345: Argument of type '[number, number]' is not assignable to parameter of type '[any, any, [[any]]]'.
|
||||
Property '2' is missing in type '[number, number]'.
|
||||
tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration4.ts(24,4): error TS2345: Argument of type '(string | number)[]' is not assignable to parameter of type 'number[]'.
|
||||
@@ -47,10 +45,8 @@ tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration4.ts(
|
||||
!!! error TS2552: Cannot find name 'array2'. Did you mean 'Array'?
|
||||
!!! related TS2728 /.ts/lib.es5.d.ts:1298:15: 'Array' is declared here.
|
||||
a5([1, 2, "string", false, true]); // Error, parameter type is [any, any, [[any]]]
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2345: Argument of type '[number, number, string, boolean, boolean]' is not assignable to parameter of type '[any, any, [[any]]]'.
|
||||
!!! error TS2345: Types of property '2' are incompatible.
|
||||
!!! error TS2345: Type 'string' is not assignable to type '[[any]]'.
|
||||
~~~~~~~~
|
||||
!!! error TS2322: Type 'string' is not assignable to type '[[any]]'.
|
||||
a5([1, 2]); // Error, parameter type is [any, any, [[any]]]
|
||||
~~~~~~
|
||||
!!! error TS2345: Argument of type '[number, number]' is not assignable to parameter of type '[any, any, [[any]]]'.
|
||||
|
||||
@@ -1,15 +1,9 @@
|
||||
tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration5.ts(47,4): error TS2345: Argument of type '{ y: Class; }' is not assignable to parameter of type '{ y: D; }'.
|
||||
Types of property 'y' are incompatible.
|
||||
Type 'Class' is not assignable to type 'D'.
|
||||
Property 'foo' is missing in type 'Class'.
|
||||
tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration5.ts(47,6): error TS2322: Type 'Class' is not assignable to type 'D'.
|
||||
Property 'foo' is missing in type 'Class'.
|
||||
tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration5.ts(48,4): error TS2345: Argument of type '{}' is not assignable to parameter of type '{ y: D; }'.
|
||||
Property 'y' is missing in type '{}'.
|
||||
tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration5.ts(49,4): error TS2345: Argument of type '{ y: number; }' is not assignable to parameter of type '{ y: D; }'.
|
||||
Types of property 'y' are incompatible.
|
||||
Type 'number' is not assignable to type 'D'.
|
||||
tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration5.ts(50,4): error TS2345: Argument of type '{ y: string; }' is not assignable to parameter of type '{ y: D; }'.
|
||||
Types of property 'y' are incompatible.
|
||||
Type 'string' is not assignable to type 'D'.
|
||||
tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration5.ts(49,6): error TS2322: Type 'number' is not assignable to type 'D'.
|
||||
tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration5.ts(50,6): error TS2322: Type 'string' is not assignable to type 'D'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration5.ts (4 errors) ====
|
||||
@@ -60,22 +54,19 @@ tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration5.ts(
|
||||
d3({ y: new SubClass() });
|
||||
// Error
|
||||
d3({ y: new Class() });
|
||||
~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2345: Argument of type '{ y: Class; }' is not assignable to parameter of type '{ y: D; }'.
|
||||
!!! error TS2345: Types of property 'y' are incompatible.
|
||||
!!! error TS2345: Type 'Class' is not assignable to type 'D'.
|
||||
!!! error TS2345: Property 'foo' is missing in type 'Class'.
|
||||
~
|
||||
!!! error TS2322: Type 'Class' is not assignable to type 'D'.
|
||||
!!! error TS2322: Property 'foo' is missing in type 'Class'.
|
||||
!!! related TS6500 tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration5.ts:29:33: The expected type comes from property 'y' which is declared here on type '{ y: D; }'
|
||||
d3({});
|
||||
~~
|
||||
!!! error TS2345: Argument of type '{}' is not assignable to parameter of type '{ y: D; }'.
|
||||
!!! error TS2345: Property 'y' is missing in type '{}'.
|
||||
d3({ y: 1 });
|
||||
~~~~~~~~
|
||||
!!! error TS2345: Argument of type '{ y: number; }' is not assignable to parameter of type '{ y: D; }'.
|
||||
!!! error TS2345: Types of property 'y' are incompatible.
|
||||
!!! error TS2345: Type 'number' is not assignable to type 'D'.
|
||||
~
|
||||
!!! error TS2322: Type 'number' is not assignable to type 'D'.
|
||||
!!! related TS6500 tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration5.ts:29:33: The expected type comes from property 'y' which is declared here on type '{ y: D; }'
|
||||
d3({ y: "world" });
|
||||
~~~~~~~~~~~~~~
|
||||
!!! error TS2345: Argument of type '{ y: string; }' is not assignable to parameter of type '{ y: D; }'.
|
||||
!!! error TS2345: Types of property 'y' are incompatible.
|
||||
!!! error TS2345: Type 'string' is not assignable to type 'D'.
|
||||
~
|
||||
!!! error TS2322: Type 'string' is not assignable to type 'D'.
|
||||
!!! related TS6500 tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration5.ts:29:33: The expected type comes from property 'y' which is declared here on type '{ y: D; }'
|
||||
@@ -1,11 +1,7 @@
|
||||
tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration8.ts(4,5): error TS2322: Type '"z"' is not assignable to type '"x" | "y"'.
|
||||
tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration8.ts(5,15): error TS2322: Type '"c"' is not assignable to type '"a" | "b"'.
|
||||
tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration8.ts(17,6): error TS2345: Argument of type '{ method: "z"; nested: { p: "b"; }; }' is not assignable to parameter of type '{ method?: "x" | "y"; nested?: { p: "a" | "b"; }; }'.
|
||||
Types of property 'method' are incompatible.
|
||||
Type '"z"' is not assignable to type '"x" | "y"'.
|
||||
tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration8.ts(18,6): error TS2345: Argument of type '{ method: "one"; nested: { p: "a"; }; }' is not assignable to parameter of type '{ method?: "x" | "y"; nested?: { p: "a" | "b"; }; }'.
|
||||
Types of property 'method' are incompatible.
|
||||
Type '"one"' is not assignable to type '"x" | "y"'.
|
||||
tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration8.ts(17,8): error TS2322: Type '"z"' is not assignable to type '"x" | "y"'.
|
||||
tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration8.ts(18,8): error TS2322: Type '"one"' is not assignable to type '"x" | "y"'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration8.ts (4 errors) ====
|
||||
@@ -30,13 +26,11 @@ tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration8.ts(
|
||||
test({});
|
||||
test({ method: 'x', nested: { p: 'a' } })
|
||||
test({ method: 'z', nested: { p: 'b' } })
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2345: Argument of type '{ method: "z"; nested: { p: "b"; }; }' is not assignable to parameter of type '{ method?: "x" | "y"; nested?: { p: "a" | "b"; }; }'.
|
||||
!!! error TS2345: Types of property 'method' are incompatible.
|
||||
!!! error TS2345: Type '"z"' is not assignable to type '"x" | "y"'.
|
||||
~~~~~~
|
||||
!!! error TS2322: Type '"z"' is not assignable to type '"x" | "y"'.
|
||||
!!! related TS6500 tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration8.ts:7:5: The expected type comes from property 'method' which is declared here on type '{ method?: "x" | "y"; nested?: { p: "a" | "b"; }; }'
|
||||
test({ method: 'one', nested: { p: 'a' } })
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2345: Argument of type '{ method: "one"; nested: { p: "a"; }; }' is not assignable to parameter of type '{ method?: "x" | "y"; nested?: { p: "a" | "b"; }; }'.
|
||||
!!! error TS2345: Types of property 'method' are incompatible.
|
||||
!!! error TS2345: Type '"one"' is not assignable to type '"x" | "y"'.
|
||||
~~~~~~
|
||||
!!! error TS2322: Type '"one"' is not assignable to type '"x" | "y"'.
|
||||
!!! related TS6500 tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration8.ts:7:5: The expected type comes from property 'method' which is declared here on type '{ method?: "x" | "y"; nested?: { p: "a" | "b"; }; }'
|
||||
|
||||
@@ -5,8 +5,7 @@ tests/cases/conformance/es6/destructuring/destructuringParameterProperties2.ts(4
|
||||
tests/cases/conformance/es6/destructuring/destructuringParameterProperties2.ts(9,21): error TS2339: Property 'a' does not exist on type 'C1'.
|
||||
tests/cases/conformance/es6/destructuring/destructuringParameterProperties2.ts(13,21): error TS2339: Property 'b' does not exist on type 'C1'.
|
||||
tests/cases/conformance/es6/destructuring/destructuringParameterProperties2.ts(17,21): error TS2339: Property 'c' does not exist on type 'C1'.
|
||||
tests/cases/conformance/es6/destructuring/destructuringParameterProperties2.ts(21,27): error TS2345: Argument of type '[number, undefined, string]' is not assignable to parameter of type '[number, string, boolean]'.
|
||||
Type 'string' is not assignable to type 'boolean'.
|
||||
tests/cases/conformance/es6/destructuring/destructuringParameterProperties2.ts(21,42): error TS2322: Type 'string' is not assignable to type 'boolean'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/destructuring/destructuringParameterProperties2.ts (8 errors) ====
|
||||
@@ -45,9 +44,8 @@ tests/cases/conformance/es6/destructuring/destructuringParameterProperties2.ts(2
|
||||
}
|
||||
|
||||
var x = new C1(undefined, [0, undefined, ""]);
|
||||
~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2345: Argument of type '[number, undefined, string]' is not assignable to parameter of type '[number, string, boolean]'.
|
||||
!!! error TS2345: Type 'string' is not assignable to type 'boolean'.
|
||||
~~
|
||||
!!! error TS2322: Type 'string' is not assignable to type 'boolean'.
|
||||
var [x_a, x_b, x_c] = [x.getA(), x.getB(), x.getC()];
|
||||
|
||||
var y = new C1(10, [0, "", true]);
|
||||
|
||||
@@ -7,12 +7,13 @@ tests/cases/conformance/es6/destructuring/destructuringParameterProperties5.ts(7
|
||||
tests/cases/conformance/es6/destructuring/destructuringParameterProperties5.ts(7,51): error TS2339: Property 'x3' does not exist on type 'C1'.
|
||||
tests/cases/conformance/es6/destructuring/destructuringParameterProperties5.ts(7,62): error TS2339: Property 'y' does not exist on type 'C1'.
|
||||
tests/cases/conformance/es6/destructuring/destructuringParameterProperties5.ts(7,72): error TS2339: Property 'z' does not exist on type 'C1'.
|
||||
tests/cases/conformance/es6/destructuring/destructuringParameterProperties5.ts(11,19): error TS2345: Argument of type '[{ x1: number; x2: string; x3: boolean; }, string, boolean]' is not assignable to parameter of type '[ObjType1, number, string]'.
|
||||
Type '{ x1: number; x2: string; x3: boolean; }' is not assignable to type 'ObjType1'.
|
||||
Object literal may only specify known properties, and 'x1' does not exist in type 'ObjType1'.
|
||||
tests/cases/conformance/es6/destructuring/destructuringParameterProperties5.ts(11,19): error TS2322: Type '{ x1: number; x2: string; x3: boolean; }' is not assignable to type 'ObjType1'.
|
||||
Object literal may only specify known properties, and 'x1' does not exist in type 'ObjType1'.
|
||||
tests/cases/conformance/es6/destructuring/destructuringParameterProperties5.ts(11,47): error TS2322: Type 'string' is not assignable to type 'number'.
|
||||
tests/cases/conformance/es6/destructuring/destructuringParameterProperties5.ts(11,51): error TS2322: Type 'false' is not assignable to type 'string'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/destructuring/destructuringParameterProperties5.ts (10 errors) ====
|
||||
==== tests/cases/conformance/es6/destructuring/destructuringParameterProperties5.ts (12 errors) ====
|
||||
type ObjType1 = { x: number; y: string; z: boolean }
|
||||
type TupleType1 = [ObjType1, number, string]
|
||||
|
||||
@@ -43,7 +44,10 @@ tests/cases/conformance/es6/destructuring/destructuringParameterProperties5.ts(1
|
||||
|
||||
var a = new C1([{ x1: 10, x2: "", x3: true }, "", false]);
|
||||
~~~~~~
|
||||
!!! error TS2345: Argument of type '[{ x1: number; x2: string; x3: boolean; }, string, boolean]' is not assignable to parameter of type '[ObjType1, number, string]'.
|
||||
!!! error TS2345: Type '{ x1: number; x2: string; x3: boolean; }' is not assignable to type 'ObjType1'.
|
||||
!!! error TS2345: Object literal may only specify known properties, and 'x1' does not exist in type 'ObjType1'.
|
||||
!!! error TS2322: Type '{ x1: number; x2: string; x3: boolean; }' is not assignable to type 'ObjType1'.
|
||||
!!! error TS2322: Object literal may only specify known properties, and 'x1' does not exist in type 'ObjType1'.
|
||||
~~
|
||||
!!! error TS2322: Type 'string' is not assignable to type 'number'.
|
||||
~~~~~
|
||||
!!! error TS2322: Type 'false' is not assignable to type 'string'.
|
||||
var [a_x1, a_x2, a_x3, a_y, a_z] = [a.x1, a.x2, a.x3, a.y, a.z];
|
||||
@@ -1,9 +1,5 @@
|
||||
tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithFunctionTypedArguments5.ts(10,14): error TS2345: Argument of type '{ cb: <T>(x: T, y: T) => string; }' is not assignable to parameter of type '{ cb: (t: {}) => string; }'.
|
||||
Types of property 'cb' are incompatible.
|
||||
Type '<T>(x: T, y: T) => string' is not assignable to type '(t: {}) => string'.
|
||||
tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithFunctionTypedArguments5.ts(11,14): error TS2345: Argument of type '{ cb: (x: string, y: number) => string; }' is not assignable to parameter of type '{ cb: (t: string) => string; }'.
|
||||
Types of property 'cb' are incompatible.
|
||||
Type '(x: string, y: number) => string' is not assignable to type '(t: string) => string'.
|
||||
tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithFunctionTypedArguments5.ts(10,16): error TS2322: Type '<T>(x: T, y: T) => string' is not assignable to type '(t: {}) => string'.
|
||||
tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithFunctionTypedArguments5.ts(11,16): error TS2322: Type '(x: string, y: number) => string' is not assignable to type '(t: string) => string'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithFunctionTypedArguments5.ts (2 errors) ====
|
||||
@@ -17,15 +13,13 @@ tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithFun
|
||||
var r = foo(arg); // {}
|
||||
// more args not allowed
|
||||
var r2 = foo({ cb: <T>(x: T, y: T) => '' }); // error
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2345: Argument of type '{ cb: <T>(x: T, y: T) => string; }' is not assignable to parameter of type '{ cb: (t: {}) => string; }'.
|
||||
!!! error TS2345: Types of property 'cb' are incompatible.
|
||||
!!! error TS2345: Type '<T>(x: T, y: T) => string' is not assignable to type '(t: {}) => string'.
|
||||
~~
|
||||
!!! error TS2322: Type '<T>(x: T, y: T) => string' is not assignable to type '(t: {}) => string'.
|
||||
!!! related TS6500 tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithFunctionTypedArguments5.ts:3:27: The expected type comes from property 'cb' which is declared here on type '{ cb: (t: {}) => string; }'
|
||||
var r3 = foo({ cb: (x: string, y: number) => '' }); // error
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2345: Argument of type '{ cb: (x: string, y: number) => string; }' is not assignable to parameter of type '{ cb: (t: string) => string; }'.
|
||||
!!! error TS2345: Types of property 'cb' are incompatible.
|
||||
!!! error TS2345: Type '(x: string, y: number) => string' is not assignable to type '(t: string) => string'.
|
||||
~~
|
||||
!!! error TS2322: Type '(x: string, y: number) => string' is not assignable to type '(t: string) => string'.
|
||||
!!! related TS6500 tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithFunctionTypedArguments5.ts:3:27: The expected type comes from property 'cb' which is declared here on type '{ cb: (t: string) => string; }'
|
||||
|
||||
function foo2<T, U>(arg: { cb: (t: T, t2: T) => U }) {
|
||||
return arg.cb(null, null);
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithObjectLiteralArgs.ts(5,13): error TS2345: Argument of type '{ bar: number; baz: string; }' is not assignable to parameter of type '{ bar: number; baz: number; }'.
|
||||
Types of property 'baz' are incompatible.
|
||||
Type 'string' is not assignable to type 'number'.
|
||||
tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithObjectLiteralArgs.ts(5,23): error TS2322: Type 'string' is not assignable to type 'number'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithObjectLiteralArgs.ts (1 errors) ====
|
||||
@@ -9,10 +7,9 @@ tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithObj
|
||||
}
|
||||
|
||||
var r = foo({ bar: 1, baz: '' }); // error
|
||||
~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2345: Argument of type '{ bar: number; baz: string; }' is not assignable to parameter of type '{ bar: number; baz: number; }'.
|
||||
!!! error TS2345: Types of property 'baz' are incompatible.
|
||||
!!! error TS2345: Type 'string' is not assignable to type 'number'.
|
||||
~~~
|
||||
!!! error TS2322: Type 'string' is not assignable to type 'number'.
|
||||
!!! related TS6500 tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithObjectLiteralArgs.ts:1:30: The expected type comes from property 'baz' which is declared here on type '{ bar: number; baz: number; }'
|
||||
var r2 = foo({ bar: 1, baz: 1 }); // T = number
|
||||
var r3 = foo({ bar: foo, baz: foo }); // T = typeof foo
|
||||
var r4 = foo<Object>({ bar: 1, baz: '' }); // T = Object
|
||||
@@ -1,45 +1,30 @@
|
||||
tests/cases/compiler/genericCallWithObjectLiteralArguments1.ts(3,13): 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'.
|
||||
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'.
|
||||
tests/cases/compiler/genericCallWithObjectLiteralArguments1.ts(5,22): error TS2345: Argument of type '{ x: number; y: string; }' is not assignable to parameter of type '{ x: string; y: string; }'.
|
||||
Types of property 'x' are incompatible.
|
||||
Type 'number' is not assignable to type 'string'.
|
||||
tests/cases/compiler/genericCallWithObjectLiteralArguments1.ts(6,22): error TS2345: Argument of type '{ x: string; y: number; }' is not assignable to parameter of type '{ x: number; y: number; }'.
|
||||
Types of property 'x' are incompatible.
|
||||
Type 'string' is not assignable to type 'number'.
|
||||
tests/cases/compiler/genericCallWithObjectLiteralArguments1.ts(7,22): error TS2345: Argument of type '{ x: string; y: number; }' is not assignable to parameter of type '{ x: string; y: string; }'.
|
||||
Types of property 'y' are incompatible.
|
||||
Type 'number' is not assignable to type 'string'.
|
||||
tests/cases/compiler/genericCallWithObjectLiteralArguments1.ts(3,21): error TS2322: Type 'string' is not assignable to type 'number'.
|
||||
tests/cases/compiler/genericCallWithObjectLiteralArguments1.ts(4,30): error TS2322: Type 'string' is not assignable to type 'number'.
|
||||
tests/cases/compiler/genericCallWithObjectLiteralArguments1.ts(5,24): error TS2322: Type 'number' is not assignable to type 'string'.
|
||||
tests/cases/compiler/genericCallWithObjectLiteralArguments1.ts(6,24): error TS2322: Type 'string' is not assignable to type 'number'.
|
||||
tests/cases/compiler/genericCallWithObjectLiteralArguments1.ts(7,31): error TS2322: Type 'number' is not assignable to type 'string'.
|
||||
|
||||
|
||||
==== tests/cases/compiler/genericCallWithObjectLiteralArguments1.ts (5 errors) ====
|
||||
function foo<T>(n: { x: T; y: T }, m: T) { return m; }
|
||||
// these are all errors
|
||||
var x = foo({ x: 3, y: "" }, 4);
|
||||
~~~~~~~~~~~~~~~
|
||||
!!! error TS2345: Argument of type '{ x: number; y: string; }' is not assignable to parameter of type '{ x: number; y: number; }'.
|
||||
!!! error TS2345: Types of property 'y' are incompatible.
|
||||
!!! error TS2345: Type 'string' is not assignable to type 'number'.
|
||||
~
|
||||
!!! error TS2322: Type 'string' is not assignable to type 'number'.
|
||||
!!! related TS6500 tests/cases/compiler/genericCallWithObjectLiteralArguments1.ts:1:28: The expected type comes from property 'y' which is declared here on type '{ x: number; y: number; }'
|
||||
var x2 = foo<number>({ x: 3, y: "" }, 4);
|
||||
~~~~~~~~~~~~~~~
|
||||
!!! error TS2345: Argument of type '{ x: number; y: string; }' is not assignable to parameter of type '{ x: number; y: number; }'.
|
||||
!!! error TS2345: Types of property 'y' are incompatible.
|
||||
!!! error TS2345: Type 'string' is not assignable to type 'number'.
|
||||
~
|
||||
!!! error TS2322: Type 'string' is not assignable to type 'number'.
|
||||
!!! related TS6500 tests/cases/compiler/genericCallWithObjectLiteralArguments1.ts:1:28: The expected type comes from property 'y' which is declared here on type '{ x: number; y: number; }'
|
||||
var x3 = foo<string>({ x: 3, y: "" }, 4);
|
||||
~~~~~~~~~~~~~~~
|
||||
!!! error TS2345: Argument of type '{ x: number; y: string; }' is not assignable to parameter of type '{ x: string; y: string; }'.
|
||||
!!! error TS2345: Types of property 'x' are incompatible.
|
||||
!!! error TS2345: Type 'number' is not assignable to type 'string'.
|
||||
~
|
||||
!!! error TS2322: Type 'number' is not assignable to type 'string'.
|
||||
!!! related TS6500 tests/cases/compiler/genericCallWithObjectLiteralArguments1.ts:1:22: The expected type comes from property 'x' which is declared here on type '{ x: string; y: string; }'
|
||||
var x4 = foo<number>({ x: "", y: 4 }, "");
|
||||
~~~~~~~~~~~~~~~
|
||||
!!! error TS2345: Argument of type '{ x: string; y: number; }' is not assignable to parameter of type '{ x: number; y: number; }'.
|
||||
!!! error TS2345: Types of property 'x' are incompatible.
|
||||
!!! error TS2345: Type 'string' is not assignable to type 'number'.
|
||||
~
|
||||
!!! error TS2322: Type 'string' is not assignable to type 'number'.
|
||||
!!! related TS6500 tests/cases/compiler/genericCallWithObjectLiteralArguments1.ts:1:22: The expected type comes from property 'x' which is declared here on type '{ x: number; y: number; }'
|
||||
var x5 = foo<string>({ x: "", y: 4 }, "");
|
||||
~~~~~~~~~~~~~~~
|
||||
!!! error TS2345: Argument of type '{ x: string; y: number; }' is not assignable to parameter of type '{ x: string; y: string; }'.
|
||||
!!! error TS2345: Types of property 'y' are incompatible.
|
||||
!!! error TS2345: Type 'number' is not assignable to type 'string'.
|
||||
~
|
||||
!!! error TS2322: Type 'number' is not assignable to type 'string'.
|
||||
!!! related TS6500 tests/cases/compiler/genericCallWithObjectLiteralArguments1.ts:1:28: The expected type comes from property 'y' which is declared here on type '{ x: string; y: string; }'
|
||||
@@ -1,7 +1,5 @@
|
||||
tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithObjectTypeArgsAndConstraints3.ts(18,12): error TS2345: Argument of type '{ x: Derived; y: Derived2; }' is not assignable to parameter of type '{ x: Derived; y: Derived; }'.
|
||||
Types of property 'y' are incompatible.
|
||||
Type 'Derived2' is not assignable to type 'Derived'.
|
||||
Property 'y' is missing in type 'Derived2'.
|
||||
tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithObjectTypeArgsAndConstraints3.ts(18,32): error TS2322: Type 'Derived2' is not assignable to type 'Derived'.
|
||||
Property 'y' is missing in type 'Derived2'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithObjectTypeArgsAndConstraints3.ts (1 errors) ====
|
||||
@@ -23,11 +21,10 @@ tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithObj
|
||||
}
|
||||
|
||||
var r1 = f({ x: new Derived(), y: new Derived2() }); // error because neither is supertype of the other
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2345: Argument of type '{ x: Derived; y: Derived2; }' is not assignable to parameter of type '{ x: Derived; y: Derived; }'.
|
||||
!!! error TS2345: Types of property 'y' are incompatible.
|
||||
!!! error TS2345: Type 'Derived2' is not assignable to type 'Derived'.
|
||||
!!! error TS2345: Property 'y' is missing in type 'Derived2'.
|
||||
~
|
||||
!!! error TS2322: Type 'Derived2' is not assignable to type 'Derived'.
|
||||
!!! error TS2322: Property 'y' is missing in type 'Derived2'.
|
||||
!!! related TS6500 tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithObjectTypeArgsAndConstraints3.ts:13:39: The expected type comes from property 'y' which is declared here on type '{ x: Derived; y: Derived; }'
|
||||
|
||||
function f2<T extends Base, U extends { x: T; y: T }>(a: U) {
|
||||
var r: T;
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
tests/cases/compiler/genericConstraintSatisfaction1.ts(6,5): error TS2345: Argument of type '{ s: number; }' is not assignable to parameter of type '{ s: string; }'.
|
||||
Types of property 's' are incompatible.
|
||||
Type 'number' is not assignable to type 'string'.
|
||||
tests/cases/compiler/genericConstraintSatisfaction1.ts(6,6): error TS2322: Type 'number' is not assignable to type 'string'.
|
||||
|
||||
|
||||
==== tests/cases/compiler/genericConstraintSatisfaction1.ts (1 errors) ====
|
||||
@@ -10,8 +8,7 @@ tests/cases/compiler/genericConstraintSatisfaction1.ts(6,5): error TS2345: Argum
|
||||
|
||||
var x: I<{s: string}>
|
||||
x.f({s: 1})
|
||||
~~~~~~
|
||||
!!! error TS2345: Argument of type '{ s: number; }' is not assignable to parameter of type '{ s: string; }'.
|
||||
!!! error TS2345: Types of property 's' are incompatible.
|
||||
!!! error TS2345: Type 'number' is not assignable to type 'string'.
|
||||
~
|
||||
!!! error TS2322: Type 'number' is not assignable to type 'string'.
|
||||
!!! related TS6500 tests/cases/compiler/genericConstraintSatisfaction1.ts:5:11: The expected type comes from property 's' which is declared here on type '{ s: string; }'
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
tests/cases/compiler/indexedAccessRelation.ts(16,23): error TS2345: Argument of type '{ a: T; }' is not assignable to parameter of type 'Pick<S & State<T>, "a">'.
|
||||
Types of property 'a' are incompatible.
|
||||
Type 'T' is not assignable to type 'S["a"] & T'.
|
||||
Type 'Foo' is not assignable to type 'S["a"] & T'.
|
||||
tests/cases/compiler/indexedAccessRelation.ts(16,25): error TS2322: Type 'T' is not assignable to type 'S["a"] & T'.
|
||||
Type 'Foo' is not assignable to type 'S["a"] & T'.
|
||||
Type 'Foo' is not assignable to type 'S["a"]'.
|
||||
Type 'T' is not assignable to type 'S["a"]'.
|
||||
Type 'Foo' is not assignable to type 'S["a"]'.
|
||||
Type 'T' is not assignable to type 'S["a"]'.
|
||||
Type 'Foo' is not assignable to type 'S["a"]'.
|
||||
|
||||
|
||||
==== tests/cases/compiler/indexedAccessRelation.ts (1 errors) ====
|
||||
@@ -24,14 +22,13 @@ tests/cases/compiler/indexedAccessRelation.ts(16,23): error TS2345: Argument of
|
||||
{
|
||||
foo(a: T) {
|
||||
this.setState({ a: a });
|
||||
~~~~~~~~
|
||||
!!! error TS2345: Argument of type '{ a: T; }' is not assignable to parameter of type 'Pick<S & State<T>, "a">'.
|
||||
!!! error TS2345: Types of property 'a' are incompatible.
|
||||
!!! error TS2345: Type 'T' is not assignable to type 'S["a"] & T'.
|
||||
!!! error TS2345: Type 'Foo' is not assignable to type 'S["a"] & T'.
|
||||
!!! error TS2345: Type 'Foo' is not assignable to type 'S["a"]'.
|
||||
!!! error TS2345: Type 'T' is not assignable to type 'S["a"]'.
|
||||
!!! error TS2345: Type 'Foo' is not assignable to type 'S["a"]'.
|
||||
~
|
||||
!!! error TS2322: Type 'T' is not assignable to type 'S["a"] & T'.
|
||||
!!! error TS2322: Type 'Foo' is not assignable to type 'S["a"] & T'.
|
||||
!!! error TS2322: Type 'Foo' is not assignable to type 'S["a"]'.
|
||||
!!! error TS2322: Type 'T' is not assignable to type 'S["a"]'.
|
||||
!!! error TS2322: Type 'Foo' is not assignable to type 'S["a"]'.
|
||||
!!! related TS6500 tests/cases/compiler/indexedAccessRelation.ts:8:5: The expected type comes from property 'a' which is declared here on type 'Pick<S & State<T>, "a">'
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
tests/cases/compiler/infiniteConstraints.ts(4,37): error TS2536: Type '"val"' cannot be used to index type 'B[Exclude<keyof B, K>]'.
|
||||
tests/cases/compiler/infiniteConstraints.ts(31,42): error TS2345: Argument of type '{ main: Record<"val", "dup">; alternate: Record<"val", "dup">; }' is not assignable to parameter of type '{ main: never; alternate: never; }'.
|
||||
Types of property 'main' are incompatible.
|
||||
Type 'Record<"val", "dup">' is not assignable to type 'never'.
|
||||
tests/cases/compiler/infiniteConstraints.ts(31,43): error TS2322: Type 'Record<"val", "dup">' is not assignable to type 'never'.
|
||||
tests/cases/compiler/infiniteConstraints.ts(31,63): error TS2322: Type 'Record<"val", "dup">' is not assignable to type 'never'.
|
||||
tests/cases/compiler/infiniteConstraints.ts(36,71): error TS2536: Type '"foo"' cannot be used to index type 'T[keyof T]'.
|
||||
|
||||
|
||||
==== tests/cases/compiler/infiniteConstraints.ts (3 errors) ====
|
||||
==== tests/cases/compiler/infiniteConstraints.ts (4 errors) ====
|
||||
// Both of the following types trigger the recursion limiter in getImmediateBaseConstraint
|
||||
|
||||
type T1<B extends { [K in keyof B]: Extract<B[Exclude<keyof B, K>], { val: string }>["val"] }> = B;
|
||||
@@ -39,10 +38,12 @@ tests/cases/compiler/infiniteConstraints.ts(36,71): error TS2536: Type '"foo"' c
|
||||
const shouldBeNoError = ensureNoDuplicates({main: value("test")});
|
||||
|
||||
const shouldBeError = ensureNoDuplicates({main: value("dup"), alternate: value("dup")});
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2345: Argument of type '{ main: Record<"val", "dup">; alternate: Record<"val", "dup">; }' is not assignable to parameter of type '{ main: never; alternate: never; }'.
|
||||
!!! error TS2345: Types of property 'main' are incompatible.
|
||||
!!! error TS2345: Type 'Record<"val", "dup">' is not assignable to type 'never'.
|
||||
~~~~
|
||||
!!! error TS2322: Type 'Record<"val", "dup">' is not assignable to type 'never'.
|
||||
!!! related TS6500 tests/cases/compiler/infiniteConstraints.ts:31:43: The expected type comes from property 'main' which is declared here on type '{ main: never; alternate: never; }'
|
||||
~~~~~~~~~
|
||||
!!! error TS2322: Type 'Record<"val", "dup">' is not assignable to type 'never'.
|
||||
!!! related TS6500 tests/cases/compiler/infiniteConstraints.ts:31:63: The expected type comes from property 'alternate' which is declared here on type '{ main: never; alternate: never; }'
|
||||
|
||||
// Repro from #26448
|
||||
|
||||
|
||||
@@ -8,9 +8,7 @@ tests/cases/compiler/invariantGenericErrorElaboration.ts(3,7): error TS2322: Typ
|
||||
Type 'Constraint<Constraint<Runtype<any>>>' is not assignable to type 'Constraint<Constraint<Num>>'.
|
||||
Types of property 'underlying' are incompatible.
|
||||
Type 'Constraint<Runtype<any>>' is not assignable to type 'Constraint<Num>'.
|
||||
tests/cases/compiler/invariantGenericErrorElaboration.ts(4,17): error TS2345: Argument of type '{ foo: Num; }' is not assignable to parameter of type '{ [_: string]: Runtype<any>; }'.
|
||||
Property 'foo' is incompatible with index signature.
|
||||
Type 'Num' is not assignable to type 'Runtype<any>'.
|
||||
tests/cases/compiler/invariantGenericErrorElaboration.ts(4,19): error TS2322: Type 'Num' is not assignable to type 'Runtype<any>'.
|
||||
|
||||
|
||||
==== tests/cases/compiler/invariantGenericErrorElaboration.ts (2 errors) ====
|
||||
@@ -29,10 +27,9 @@ tests/cases/compiler/invariantGenericErrorElaboration.ts(4,17): error TS2345: Ar
|
||||
!!! error TS2322: Types of property 'underlying' are incompatible.
|
||||
!!! error TS2322: Type 'Constraint<Runtype<any>>' is not assignable to type 'Constraint<Num>'.
|
||||
const Foo = Obj({ foo: Num })
|
||||
~~~~~~~~~~~~
|
||||
!!! error TS2345: Argument of type '{ foo: Num; }' is not assignable to parameter of type '{ [_: string]: Runtype<any>; }'.
|
||||
!!! error TS2345: Property 'foo' is incompatible with index signature.
|
||||
!!! error TS2345: Type 'Num' is not assignable to type 'Runtype<any>'.
|
||||
~~~
|
||||
!!! error TS2322: Type 'Num' is not assignable to type 'Runtype<any>'.
|
||||
!!! related TS6501 tests/cases/compiler/invariantGenericErrorElaboration.ts:17:34: The expected type comes from this index signature.
|
||||
|
||||
interface Runtype<A> {
|
||||
constraint: Constraint<this>
|
||||
|
||||
@@ -1,13 +1,12 @@
|
||||
tests/cases/compiler/lastPropertyInLiteralWins.ts(7,6): error TS2345: Argument of type '{ thunk: (num: number) => void; }' is not assignable to parameter of type 'Thing'.
|
||||
Types of property 'thunk' are incompatible.
|
||||
Type '(num: number) => void' is not assignable to type '(str: string) => void'.
|
||||
Types of parameters 'num' and 'str' are incompatible.
|
||||
Type 'string' is not assignable to type 'number'.
|
||||
tests/cases/compiler/lastPropertyInLiteralWins.ts(8,5): error TS2322: Type '(num: number) => void' is not assignable to type '(str: string) => void'.
|
||||
Types of parameters 'num' and 'str' are incompatible.
|
||||
Type 'string' is not assignable to type 'number'.
|
||||
tests/cases/compiler/lastPropertyInLiteralWins.ts(9,5): error TS2300: Duplicate identifier 'thunk'.
|
||||
tests/cases/compiler/lastPropertyInLiteralWins.ts(9,5): error TS2322: Type '(num: number) => void' is not assignable to type '(str: string) => void'.
|
||||
tests/cases/compiler/lastPropertyInLiteralWins.ts(14,5): error TS2300: Duplicate identifier 'thunk'.
|
||||
|
||||
|
||||
==== tests/cases/compiler/lastPropertyInLiteralWins.ts (3 errors) ====
|
||||
==== tests/cases/compiler/lastPropertyInLiteralWins.ts (4 errors) ====
|
||||
interface Thing {
|
||||
thunk: (str: string) => void;
|
||||
}
|
||||
@@ -15,20 +14,19 @@ tests/cases/compiler/lastPropertyInLiteralWins.ts(14,5): error TS2300: Duplicate
|
||||
thing.thunk("str");
|
||||
}
|
||||
test({ // Should error, as last one wins, and is wrong type
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
thunk: (str: string) => {},
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
~~~~~
|
||||
!!! error TS2322: Type '(num: number) => void' is not assignable to type '(str: string) => void'.
|
||||
!!! error TS2322: Types of parameters 'num' and 'str' are incompatible.
|
||||
!!! error TS2322: Type 'string' is not assignable to type 'number'.
|
||||
!!! related TS6500 tests/cases/compiler/lastPropertyInLiteralWins.ts:2:5: The expected type comes from property 'thunk' which is declared here on type 'Thing'
|
||||
thunk: (num: number) => {}
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
~~~~~
|
||||
!!! error TS2300: Duplicate identifier 'thunk'.
|
||||
~~~~~
|
||||
!!! error TS2322: Type '(num: number) => void' is not assignable to type '(str: string) => void'.
|
||||
!!! related TS6500 tests/cases/compiler/lastPropertyInLiteralWins.ts:2:5: The expected type comes from property 'thunk' which is declared here on type 'Thing'
|
||||
});
|
||||
~
|
||||
!!! error TS2345: Argument of type '{ thunk: (num: number) => void; }' is not assignable to parameter of type 'Thing'.
|
||||
!!! error TS2345: Types of property 'thunk' are incompatible.
|
||||
!!! error TS2345: Type '(num: number) => void' is not assignable to type '(str: string) => void'.
|
||||
!!! error TS2345: Types of parameters 'num' and 'str' are incompatible.
|
||||
!!! error TS2345: Type 'string' is not assignable to type 'number'.
|
||||
|
||||
test({ // Should be OK. Last 'thunk' is of correct type
|
||||
thunk: (num: number) => {},
|
||||
|
||||
@@ -27,14 +27,10 @@ tests/cases/conformance/types/mapped/mappedTypeErrors.ts(77,59): error TS2345: A
|
||||
Object literal may only specify known properties, and 'z' does not exist in type 'Readonly<{ x: number; y: number; }>'.
|
||||
tests/cases/conformance/types/mapped/mappedTypeErrors.ts(83,58): error TS2345: Argument of type '{ x: number; y: number; z: number; }' is not assignable to parameter of type 'Partial<{ x: number; y: number; }>'.
|
||||
Object literal may only specify known properties, and 'z' does not exist in type 'Partial<{ x: number; y: number; }>'.
|
||||
tests/cases/conformance/types/mapped/mappedTypeErrors.ts(105,15): error TS2345: Argument of type '{ a: undefined; }' is not assignable to parameter of type 'Pick<Foo, "a">'.
|
||||
Types of property 'a' are incompatible.
|
||||
Type 'undefined' is not assignable to type 'string'.
|
||||
tests/cases/conformance/types/mapped/mappedTypeErrors.ts(105,17): error TS2322: Type 'undefined' is not assignable to type 'string'.
|
||||
tests/cases/conformance/types/mapped/mappedTypeErrors.ts(106,17): error TS2345: Argument of type '{ c: boolean; }' is not assignable to parameter of type 'Pick<Foo, "a" | "b">'.
|
||||
Object literal may only specify known properties, and 'c' does not exist in type 'Pick<Foo, "a" | "b">'.
|
||||
tests/cases/conformance/types/mapped/mappedTypeErrors.ts(123,12): error TS2345: Argument of type '{ a: undefined; }' is not assignable to parameter of type 'Pick<Foo, "a">'.
|
||||
Types of property 'a' are incompatible.
|
||||
Type 'undefined' is not assignable to type 'string'.
|
||||
tests/cases/conformance/types/mapped/mappedTypeErrors.ts(123,14): error TS2322: Type 'undefined' is not assignable to type 'string'.
|
||||
tests/cases/conformance/types/mapped/mappedTypeErrors.ts(124,14): error TS2345: Argument of type '{ c: boolean; }' is not assignable to parameter of type 'Pick<Foo, "a" | "b">'.
|
||||
Object literal may only specify known properties, and 'c' does not exist in type 'Pick<Foo, "a" | "b">'.
|
||||
tests/cases/conformance/types/mapped/mappedTypeErrors.ts(128,16): error TS2322: Type 'string' is not assignable to type 'number | undefined'.
|
||||
@@ -196,10 +192,9 @@ tests/cases/conformance/types/mapped/mappedTypeErrors.ts(136,21): error TS2536:
|
||||
setState(foo, { });
|
||||
setState(foo, foo);
|
||||
setState(foo, { a: undefined }); // Error
|
||||
~~~~~~~~~~~~~~~~
|
||||
!!! error TS2345: Argument of type '{ a: undefined; }' is not assignable to parameter of type 'Pick<Foo, "a">'.
|
||||
!!! error TS2345: Types of property 'a' are incompatible.
|
||||
!!! error TS2345: Type 'undefined' is not assignable to type 'string'.
|
||||
~
|
||||
!!! error TS2322: Type 'undefined' is not assignable to type 'string'.
|
||||
!!! related TS6500 tests/cases/conformance/types/mapped/mappedTypeErrors.ts:89:5: The expected type comes from property 'a' which is declared here on type 'Pick<Foo, "a">'
|
||||
setState(foo, { c: true }); // Error
|
||||
~~~~~~~
|
||||
!!! error TS2345: Argument of type '{ c: boolean; }' is not assignable to parameter of type 'Pick<Foo, "a" | "b">'.
|
||||
@@ -221,10 +216,9 @@ tests/cases/conformance/types/mapped/mappedTypeErrors.ts(136,21): error TS2536:
|
||||
c.setState({ });
|
||||
c.setState(foo);
|
||||
c.setState({ a: undefined }); // Error
|
||||
~~~~~~~~~~~~~~~~
|
||||
!!! error TS2345: Argument of type '{ a: undefined; }' is not assignable to parameter of type 'Pick<Foo, "a">'.
|
||||
!!! error TS2345: Types of property 'a' are incompatible.
|
||||
!!! error TS2345: Type 'undefined' is not assignable to type 'string'.
|
||||
~
|
||||
!!! error TS2322: Type 'undefined' is not assignable to type 'string'.
|
||||
!!! related TS6500 tests/cases/conformance/types/mapped/mappedTypeErrors.ts:89:5: The expected type comes from property 'a' which is declared here on type 'Pick<Foo, "a">'
|
||||
c.setState({ c: true }); // Error
|
||||
~~~~~~~
|
||||
!!! error TS2345: Argument of type '{ c: boolean; }' is not assignable to parameter of type 'Pick<Foo, "a" | "b">'.
|
||||
|
||||
@@ -1,9 +1,4 @@
|
||||
tests/cases/conformance/types/mapped/mappedTypeInferenceErrors.ts(9,5): error TS2345: Argument of type '{ props: { x: number; y: number; }; computed: { bar(): number; baz: number; }; }' is not assignable to parameter of type '{ props: { x: number; y: number; }; computed: ComputedOf<{ bar: number; baz: {}; }>; } & ThisType<{ x: number; y: number; } & { bar: number; baz: {}; }>'.
|
||||
Type '{ props: { x: number; y: number; }; computed: { bar(): number; baz: number; }; }' is not assignable to type '{ props: { x: number; y: number; }; computed: ComputedOf<{ bar: number; baz: {}; }>; }'.
|
||||
Types of property 'computed' are incompatible.
|
||||
Type '{ bar(): number; baz: number; }' is not assignable to type 'ComputedOf<{ bar: number; baz: {}; }>'.
|
||||
Types of property 'baz' are incompatible.
|
||||
Type 'number' is not assignable to type '() => {}'.
|
||||
tests/cases/conformance/types/mapped/mappedTypeInferenceErrors.ts(16,9): error TS2322: Type 'number' is not assignable to type '() => {}'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/types/mapped/mappedTypeInferenceErrors.ts (1 errors) ====
|
||||
@@ -16,29 +11,16 @@ tests/cases/conformance/types/mapped/mappedTypeInferenceErrors.ts(9,5): error TS
|
||||
declare function foo<P, C>(options: { props: P, computed: ComputedOf<C> } & ThisType<P & C>): void;
|
||||
|
||||
foo({
|
||||
~
|
||||
props: { x: 10, y: 20 },
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
computed: {
|
||||
~~~~~~~~~~~~~~~
|
||||
bar(): number {
|
||||
~~~~~~~~~~~~~~~~~~~~~~~
|
||||
let z = this.bar;
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
return 42;
|
||||
~~~~~~~~~~~~~~~~~~~~~~
|
||||
},
|
||||
~~~~~~~~~~
|
||||
baz: 42
|
||||
~~~~~~~~~~~~~~~
|
||||
~~~
|
||||
!!! error TS2322: Type 'number' is not assignable to type '() => {}'.
|
||||
!!! related TS6500 tests/cases/conformance/types/mapped/mappedTypeInferenceErrors.ts:16:9: The expected type comes from property 'baz' which is declared here on type 'ComputedOf<{ bar: number; baz: {}; }>'
|
||||
}
|
||||
~~~~~
|
||||
});
|
||||
~
|
||||
!!! error TS2345: Argument of type '{ props: { x: number; y: number; }; computed: { bar(): number; baz: number; }; }' is not assignable to parameter of type '{ props: { x: number; y: number; }; computed: ComputedOf<{ bar: number; baz: {}; }>; } & ThisType<{ x: number; y: number; } & { bar: number; baz: {}; }>'.
|
||||
!!! error TS2345: Type '{ props: { x: number; y: number; }; computed: { bar(): number; baz: number; }; }' is not assignable to type '{ props: { x: number; y: number; }; computed: ComputedOf<{ bar: number; baz: {}; }>; }'.
|
||||
!!! error TS2345: Types of property 'computed' are incompatible.
|
||||
!!! error TS2345: Type '{ bar(): number; baz: number; }' is not assignable to type 'ComputedOf<{ bar: number; baz: {}; }>'.
|
||||
!!! error TS2345: Types of property 'baz' are incompatible.
|
||||
!!! error TS2345: Type 'number' is not assignable to type '() => {}'.
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
tests/cases/compiler/objectLitTargetTypeCallSite.ts(5,9): error TS2345: Argument of type '{ a: boolean; b: string; }' is not assignable to parameter of type '{ a: number; b: string; }'.
|
||||
Types of property 'a' are incompatible.
|
||||
Type 'boolean' is not assignable to type 'number'.
|
||||
tests/cases/compiler/objectLitTargetTypeCallSite.ts(5,10): error TS2322: Type 'true' is not assignable to type 'number'.
|
||||
|
||||
|
||||
==== tests/cases/compiler/objectLitTargetTypeCallSite.ts (1 errors) ====
|
||||
@@ -9,7 +7,6 @@ tests/cases/compiler/objectLitTargetTypeCallSite.ts(5,9): error TS2345: Argument
|
||||
}
|
||||
|
||||
process({a:true,b:"y"});
|
||||
~~~~~~~~~~~~~~
|
||||
!!! error TS2345: Argument of type '{ a: boolean; b: string; }' is not assignable to parameter of type '{ a: number; b: string; }'.
|
||||
!!! error TS2345: Types of property 'a' are incompatible.
|
||||
!!! error TS2345: Type 'boolean' is not assignable to type 'number'.
|
||||
~
|
||||
!!! error TS2322: Type 'true' is not assignable to type 'number'.
|
||||
!!! related TS6500 tests/cases/compiler/objectLitTargetTypeCallSite.ts:1:23: The expected type comes from property 'a' which is declared here on type '{ a: number; b: string; }'
|
||||
@@ -4,12 +4,9 @@ tests/cases/compiler/objectLiteralFunctionArgContextualTyping2.ts(9,4): error TS
|
||||
Property 'doStuff' is missing in type '{ value: string; }'.
|
||||
tests/cases/compiler/objectLiteralFunctionArgContextualTyping2.ts(10,17): error TS2345: Argument of type '{ value: string; what: number; }' is not assignable to parameter of type 'I2'.
|
||||
Object literal may only specify known properties, and 'what' does not exist in type 'I2'.
|
||||
tests/cases/compiler/objectLiteralFunctionArgContextualTyping2.ts(11,6): error TS2345: Argument of type '{ toString: (s: any) => any; }' is not assignable to parameter of type 'I2'.
|
||||
Object literal may only specify known properties, and 'toString' does not exist in type 'I2'.
|
||||
tests/cases/compiler/objectLiteralFunctionArgContextualTyping2.ts(12,6): error TS2345: Argument of type '{ toString: (s: string) => string; }' is not assignable to parameter of type 'I2'.
|
||||
Object literal may only specify known properties, and 'toString' does not exist in type 'I2'.
|
||||
tests/cases/compiler/objectLiteralFunctionArgContextualTyping2.ts(13,17): error TS2345: Argument of type '{ value: string; toString: (s: any) => any; }' is not assignable to parameter of type 'I2'.
|
||||
Object literal may only specify known properties, and 'toString' does not exist in type 'I2'.
|
||||
tests/cases/compiler/objectLiteralFunctionArgContextualTyping2.ts(11,6): error TS2322: Type '(s: any) => any' is not assignable to type '() => string'.
|
||||
tests/cases/compiler/objectLiteralFunctionArgContextualTyping2.ts(12,6): error TS2322: Type '(s: string) => string' is not assignable to type '() => string'.
|
||||
tests/cases/compiler/objectLiteralFunctionArgContextualTyping2.ts(13,17): error TS2322: Type '(s: any) => any' is not assignable to type '() => string'.
|
||||
|
||||
|
||||
==== tests/cases/compiler/objectLiteralFunctionArgContextualTyping2.ts (6 errors) ====
|
||||
@@ -33,14 +30,14 @@ tests/cases/compiler/objectLiteralFunctionArgContextualTyping2.ts(13,17): error
|
||||
!!! error TS2345: Argument of type '{ value: string; what: number; }' is not assignable to parameter of type 'I2'.
|
||||
!!! error TS2345: Object literal may only specify known properties, and 'what' does not exist in type 'I2'.
|
||||
f2({ toString: (s) => s })
|
||||
~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2345: Argument of type '{ toString: (s: any) => any; }' is not assignable to parameter of type 'I2'.
|
||||
!!! error TS2345: Object literal may only specify known properties, and 'toString' does not exist in type 'I2'.
|
||||
~~~~~~~~
|
||||
!!! error TS2322: Type '(s: any) => any' is not assignable to type '() => string'.
|
||||
!!! related TS6500 /.ts/lib.es5.d.ts:125:5: The expected type comes from property 'toString' which is declared here on type 'I2'
|
||||
f2({ toString: (s: string) => s })
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2345: Argument of type '{ toString: (s: string) => string; }' is not assignable to parameter of type 'I2'.
|
||||
!!! error TS2345: Object literal may only specify known properties, and 'toString' does not exist in type 'I2'.
|
||||
~~~~~~~~
|
||||
!!! error TS2322: Type '(s: string) => string' is not assignable to type '() => string'.
|
||||
!!! related TS6500 /.ts/lib.es5.d.ts:125:5: The expected type comes from property 'toString' which is declared here on type 'I2'
|
||||
f2({ value: '', toString: (s) => s.uhhh })
|
||||
~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2345: Argument of type '{ value: string; toString: (s: any) => any; }' is not assignable to parameter of type 'I2'.
|
||||
!!! error TS2345: Object literal may only specify known properties, and 'toString' does not exist in type 'I2'.
|
||||
~~~~~~~~
|
||||
!!! error TS2322: Type '(s: any) => any' is not assignable to type '() => string'.
|
||||
!!! related TS6500 /.ts/lib.es5.d.ts:125:5: The expected type comes from property 'toString' which is declared here on type 'I2'
|
||||
@@ -2,9 +2,7 @@ tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPr
|
||||
Object literal may only specify known properties, and 'name' does not exist in type '{ b: string; id: number; }'.
|
||||
tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesAssignmentError.ts(6,81): error TS2322: Type 'string' is not assignable to type 'number'.
|
||||
tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesAssignmentError.ts(6,87): error TS2322: Type 'number' is not assignable to type 'string'.
|
||||
tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesAssignmentError.ts(8,5): error TS2345: Argument of type '{ name: string; id: number; }' is not assignable to parameter of type '{ name: string; id: boolean; }'.
|
||||
Types of property 'id' are incompatible.
|
||||
Type 'number' is not assignable to type 'boolean'.
|
||||
tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesAssignmentError.ts(8,13): error TS2322: Type 'number' is not assignable to type 'boolean'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesAssignmentError.ts (4 errors) ====
|
||||
@@ -25,9 +23,8 @@ tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPr
|
||||
!!! related TS6500 tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesAssignmentError.ts:6:43: The expected type comes from property 'id' which is declared here on type '{ id: string; name: number; }'
|
||||
function bar(obj: { name: string; id: boolean }) { }
|
||||
bar({ name, id }); // error
|
||||
~~~~~~~~~~~~
|
||||
!!! error TS2345: Argument of type '{ name: string; id: number; }' is not assignable to parameter of type '{ name: string; id: boolean; }'.
|
||||
!!! error TS2345: Types of property 'id' are incompatible.
|
||||
!!! error TS2345: Type 'number' is not assignable to type 'boolean'.
|
||||
~~
|
||||
!!! error TS2322: Type 'number' is not assignable to type 'boolean'.
|
||||
!!! related TS6500 tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesAssignmentError.ts:7:35: The expected type comes from property 'id' which is declared here on type '{ name: string; id: boolean; }'
|
||||
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
tests/cases/conformance/es6/destructuring/optionalBindingParameters1.ts(1,14): error TS2463: A binding pattern parameter cannot be optional in an implementation signature.
|
||||
tests/cases/conformance/es6/destructuring/optionalBindingParameters1.ts(7,5): error TS2345: Argument of type '[boolean, number, string]' is not assignable to parameter of type '[string, number, boolean]'.
|
||||
Type 'boolean' is not assignable to type 'string'.
|
||||
tests/cases/conformance/es6/destructuring/optionalBindingParameters1.ts(7,6): error TS2322: Type 'false' is not assignable to type 'string'.
|
||||
tests/cases/conformance/es6/destructuring/optionalBindingParameters1.ts(7,16): error TS2322: Type 'string' is not assignable to type 'boolean'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/destructuring/optionalBindingParameters1.ts (2 errors) ====
|
||||
==== tests/cases/conformance/es6/destructuring/optionalBindingParameters1.ts (3 errors) ====
|
||||
function foo([x,y,z]?: [string, number, boolean]) {
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2463: A binding pattern parameter cannot be optional in an implementation signature.
|
||||
@@ -13,6 +13,7 @@ tests/cases/conformance/es6/destructuring/optionalBindingParameters1.ts(7,5): er
|
||||
foo(["", 0, false]);
|
||||
|
||||
foo([false, 0, ""]);
|
||||
~~~~~~~~~~~~~~
|
||||
!!! error TS2345: Argument of type '[boolean, number, string]' is not assignable to parameter of type '[string, number, boolean]'.
|
||||
!!! error TS2345: Type 'boolean' is not assignable to type 'string'.
|
||||
~~~~~
|
||||
!!! error TS2322: Type 'false' is not assignable to type 'string'.
|
||||
~~
|
||||
!!! error TS2322: Type 'string' is not assignable to type 'boolean'.
|
||||
@@ -1,10 +1,9 @@
|
||||
tests/cases/conformance/es6/destructuring/optionalBindingParameters2.ts(1,14): error TS2463: A binding pattern parameter cannot be optional in an implementation signature.
|
||||
tests/cases/conformance/es6/destructuring/optionalBindingParameters2.ts(7,5): error TS2345: Argument of type '{ x: boolean; y: number; z: string; }' is not assignable to parameter of type '{ x: string; y: number; z: boolean; }'.
|
||||
Types of property 'x' are incompatible.
|
||||
Type 'boolean' is not assignable to type 'string'.
|
||||
tests/cases/conformance/es6/destructuring/optionalBindingParameters2.ts(7,7): error TS2322: Type 'false' is not assignable to type 'string'.
|
||||
tests/cases/conformance/es6/destructuring/optionalBindingParameters2.ts(7,23): error TS2322: Type 'string' is not assignable to type 'boolean'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/destructuring/optionalBindingParameters2.ts (2 errors) ====
|
||||
==== tests/cases/conformance/es6/destructuring/optionalBindingParameters2.ts (3 errors) ====
|
||||
function foo({ x, y, z }?: { x: string; y: number; z: boolean }) {
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2463: A binding pattern parameter cannot be optional in an implementation signature.
|
||||
@@ -14,7 +13,9 @@ tests/cases/conformance/es6/destructuring/optionalBindingParameters2.ts(7,5): er
|
||||
foo({ x: "", y: 0, z: false });
|
||||
|
||||
foo({ x: false, y: 0, z: "" });
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2345: Argument of type '{ x: boolean; y: number; z: string; }' is not assignable to parameter of type '{ x: string; y: number; z: boolean; }'.
|
||||
!!! error TS2345: Types of property 'x' are incompatible.
|
||||
!!! error TS2345: Type 'boolean' is not assignable to type 'string'.
|
||||
~
|
||||
!!! error TS2322: Type 'false' is not assignable to type 'string'.
|
||||
!!! related TS6500 tests/cases/conformance/es6/destructuring/optionalBindingParameters2.ts:1:30: The expected type comes from property 'x' which is declared here on type '{ x: string; y: number; z: boolean; }'
|
||||
~
|
||||
!!! error TS2322: Type 'string' is not assignable to type 'boolean'.
|
||||
!!! related TS6500 tests/cases/conformance/es6/destructuring/optionalBindingParameters2.ts:1:52: The expected type comes from property 'z' which is declared here on type '{ x: string; y: number; z: boolean; }'
|
||||
@@ -1,8 +1,8 @@
|
||||
tests/cases/conformance/es6/destructuring/optionalBindingParametersInOverloads1.ts(8,5): error TS2345: Argument of type '[boolean, number, string]' is not assignable to parameter of type '[string, number, boolean]'.
|
||||
Type 'boolean' is not assignable to type 'string'.
|
||||
tests/cases/conformance/es6/destructuring/optionalBindingParametersInOverloads1.ts(8,6): error TS2322: Type 'false' is not assignable to type 'string'.
|
||||
tests/cases/conformance/es6/destructuring/optionalBindingParametersInOverloads1.ts(8,16): error TS2322: Type 'string' is not assignable to type 'boolean'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/destructuring/optionalBindingParametersInOverloads1.ts (1 errors) ====
|
||||
==== tests/cases/conformance/es6/destructuring/optionalBindingParametersInOverloads1.ts (2 errors) ====
|
||||
function foo([x, y, z] ?: [string, number, boolean]);
|
||||
function foo(...rest: any[]) {
|
||||
|
||||
@@ -11,6 +11,7 @@ tests/cases/conformance/es6/destructuring/optionalBindingParametersInOverloads1.
|
||||
foo(["", 0, false]);
|
||||
|
||||
foo([false, 0, ""]);
|
||||
~~~~~~~~~~~~~~
|
||||
!!! error TS2345: Argument of type '[boolean, number, string]' is not assignable to parameter of type '[string, number, boolean]'.
|
||||
!!! error TS2345: Type 'boolean' is not assignable to type 'string'.
|
||||
~~~~~
|
||||
!!! error TS2322: Type 'false' is not assignable to type 'string'.
|
||||
~~
|
||||
!!! error TS2322: Type 'string' is not assignable to type 'boolean'.
|
||||
@@ -1,9 +1,8 @@
|
||||
tests/cases/conformance/es6/destructuring/optionalBindingParametersInOverloads2.ts(8,5): error TS2345: Argument of type '{ x: boolean; y: number; z: string; }' is not assignable to parameter of type '{ x: string; y: number; z: boolean; }'.
|
||||
Types of property 'x' are incompatible.
|
||||
Type 'boolean' is not assignable to type 'string'.
|
||||
tests/cases/conformance/es6/destructuring/optionalBindingParametersInOverloads2.ts(8,7): error TS2322: Type 'false' is not assignable to type 'string'.
|
||||
tests/cases/conformance/es6/destructuring/optionalBindingParametersInOverloads2.ts(8,23): error TS2322: Type 'string' is not assignable to type 'boolean'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/destructuring/optionalBindingParametersInOverloads2.ts (1 errors) ====
|
||||
==== tests/cases/conformance/es6/destructuring/optionalBindingParametersInOverloads2.ts (2 errors) ====
|
||||
function foo({ x, y, z }?: { x: string; y: number; z: boolean });
|
||||
function foo(...rest: any[]) {
|
||||
|
||||
@@ -12,7 +11,9 @@ tests/cases/conformance/es6/destructuring/optionalBindingParametersInOverloads2.
|
||||
foo({ x: "", y: 0, z: false });
|
||||
|
||||
foo({ x: false, y: 0, z: "" });
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2345: Argument of type '{ x: boolean; y: number; z: string; }' is not assignable to parameter of type '{ x: string; y: number; z: boolean; }'.
|
||||
!!! error TS2345: Types of property 'x' are incompatible.
|
||||
!!! error TS2345: Type 'boolean' is not assignable to type 'string'.
|
||||
~
|
||||
!!! error TS2322: Type 'false' is not assignable to type 'string'.
|
||||
!!! related TS6500 tests/cases/conformance/es6/destructuring/optionalBindingParametersInOverloads2.ts:1:30: The expected type comes from property 'x' which is declared here on type '{ x: string; y: number; z: boolean; }'
|
||||
~
|
||||
!!! error TS2322: Type 'string' is not assignable to type 'boolean'.
|
||||
!!! related TS6500 tests/cases/conformance/es6/destructuring/optionalBindingParametersInOverloads2.ts:1:52: The expected type comes from property 'z' which is declared here on type '{ x: string; y: number; z: boolean; }'
|
||||
@@ -2,12 +2,8 @@ tests/cases/compiler/overloadResolutionTest1.ts(7,16): error TS2345: Argument of
|
||||
Type '{ a: string; }' is not assignable to type '{ a: boolean; }'.
|
||||
Types of property 'a' are incompatible.
|
||||
Type 'string' is not assignable to type 'boolean'.
|
||||
tests/cases/compiler/overloadResolutionTest1.ts(18,15): error TS2345: Argument of type '{ a: string; }' is not assignable to parameter of type '{ a: boolean; }'.
|
||||
Types of property 'a' are incompatible.
|
||||
Type 'string' is not assignable to type 'boolean'.
|
||||
tests/cases/compiler/overloadResolutionTest1.ts(24,14): error TS2345: Argument of type '{ a: boolean; }' is not assignable to parameter of type '{ a: string; }'.
|
||||
Types of property 'a' are incompatible.
|
||||
Type 'boolean' is not assignable to type 'string'.
|
||||
tests/cases/compiler/overloadResolutionTest1.ts(18,16): error TS2322: Type 'string' is not assignable to type 'boolean'.
|
||||
tests/cases/compiler/overloadResolutionTest1.ts(24,15): error TS2322: Type 'true' is not assignable to type 'string'.
|
||||
|
||||
|
||||
==== tests/cases/compiler/overloadResolutionTest1.ts (3 errors) ====
|
||||
@@ -34,17 +30,15 @@ tests/cases/compiler/overloadResolutionTest1.ts(24,14): error TS2345: Argument o
|
||||
var x2 = foo2({a:0}); // works
|
||||
var x3 = foo2({a:true}); // works
|
||||
var x4 = foo2({a:"s"}); // error
|
||||
~~~~~~~
|
||||
!!! error TS2345: Argument of type '{ a: string; }' is not assignable to parameter of type '{ a: boolean; }'.
|
||||
!!! error TS2345: Types of property 'a' are incompatible.
|
||||
!!! error TS2345: Type 'string' is not assignable to type 'boolean'.
|
||||
~
|
||||
!!! error TS2322: Type 'string' is not assignable to type 'boolean'.
|
||||
!!! related TS6500 tests/cases/compiler/overloadResolutionTest1.ts:13:20: The expected type comes from property 'a' which is declared here on type '{ a: boolean; }'
|
||||
|
||||
|
||||
function foo4(bar:{a:number;}):number;
|
||||
function foo4(bar:{a:string;}):string;
|
||||
function foo4(bar:{a:any;}):any{ return bar };
|
||||
var x = foo4({a:true}); // error
|
||||
~~~~~~~~
|
||||
!!! error TS2345: Argument of type '{ a: boolean; }' is not assignable to parameter of type '{ a: string; }'.
|
||||
!!! error TS2345: Types of property 'a' are incompatible.
|
||||
!!! error TS2345: Type 'boolean' is not assignable to type 'string'.
|
||||
~
|
||||
!!! error TS2322: Type 'true' is not assignable to type 'string'.
|
||||
!!! related TS6500 tests/cases/compiler/overloadResolutionTest1.ts:22:20: The expected type comes from property 'a' which is declared here on type '{ a: string; }'
|
||||
@@ -1,12 +1,8 @@
|
||||
tests/cases/conformance/types/typeParameters/typeArgumentLists/typeParameterAsTypeParameterConstraint2.ts(6,8): error TS2345: Argument of type '""' is not assignable to parameter of type 'number'.
|
||||
tests/cases/conformance/types/typeParameters/typeArgumentLists/typeParameterAsTypeParameterConstraint2.ts(7,8): error TS2345: Argument of type '{}' is not assignable to parameter of type 'number'.
|
||||
tests/cases/conformance/types/typeParameters/typeArgumentLists/typeParameterAsTypeParameterConstraint2.ts(13,17): error TS2345: Argument of type 'NumberVariant' is not assignable to parameter of type 'number'.
|
||||
tests/cases/conformance/types/typeParameters/typeArgumentLists/typeParameterAsTypeParameterConstraint2.ts(16,9): error TS2345: Argument of type '{ length: string; }' is not assignable to parameter of type '{ length: number; }'.
|
||||
Types of property 'length' are incompatible.
|
||||
Type 'string' is not assignable to type 'number'.
|
||||
tests/cases/conformance/types/typeParameters/typeArgumentLists/typeParameterAsTypeParameterConstraint2.ts(17,9): error TS2345: Argument of type '{ length: {}; }' is not assignable to parameter of type '{ length: number; }'.
|
||||
Types of property 'length' are incompatible.
|
||||
Type '{}' is not assignable to type 'number'.
|
||||
tests/cases/conformance/types/typeParameters/typeArgumentLists/typeParameterAsTypeParameterConstraint2.ts(16,11): error TS2322: Type 'string' is not assignable to type 'number'.
|
||||
tests/cases/conformance/types/typeParameters/typeArgumentLists/typeParameterAsTypeParameterConstraint2.ts(17,11): error TS2322: Type '{}' is not assignable to type 'number'.
|
||||
tests/cases/conformance/types/typeParameters/typeArgumentLists/typeParameterAsTypeParameterConstraint2.ts(18,10): error TS2345: Argument of type 'string[]' is not assignable to parameter of type '{ length: any[]; }'.
|
||||
Types of property 'length' are incompatible.
|
||||
Type 'number' is not assignable to type 'any[]'.
|
||||
@@ -35,15 +31,13 @@ tests/cases/conformance/types/typeParameters/typeArgumentLists/typeParameterAsTy
|
||||
|
||||
function foo2<T, U extends { length: T }>(x: T, y: U) { return y; } // this is now an error
|
||||
foo2(1, { length: '' });
|
||||
~~~~~~~~~~~~~~
|
||||
!!! error TS2345: Argument of type '{ length: string; }' is not assignable to parameter of type '{ length: number; }'.
|
||||
!!! error TS2345: Types of property 'length' are incompatible.
|
||||
!!! error TS2345: Type 'string' is not assignable to type 'number'.
|
||||
~~~~~~
|
||||
!!! error TS2322: Type 'string' is not assignable to type 'number'.
|
||||
!!! related TS6500 tests/cases/conformance/types/typeParameters/typeArgumentLists/typeParameterAsTypeParameterConstraint2.ts:15:30: The expected type comes from property 'length' which is declared here on type '{ length: number; }'
|
||||
foo2(1, { length: {} });
|
||||
~~~~~~~~~~~~~~
|
||||
!!! error TS2345: Argument of type '{ length: {}; }' is not assignable to parameter of type '{ length: number; }'.
|
||||
!!! error TS2345: Types of property 'length' are incompatible.
|
||||
!!! error TS2345: Type '{}' is not assignable to type 'number'.
|
||||
~~~~~~
|
||||
!!! error TS2322: Type '{}' is not assignable to type 'number'.
|
||||
!!! related TS6500 tests/cases/conformance/types/typeParameters/typeArgumentLists/typeParameterAsTypeParameterConstraint2.ts:15:30: The expected type comes from property 'length' which is declared here on type '{ length: number; }'
|
||||
foo2([], ['']);
|
||||
~~~~
|
||||
!!! error TS2345: Argument of type 'string[]' is not assignable to parameter of type '{ length: any[]; }'.
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
tests/cases/conformance/types/typeParameters/typeArgumentLists/wrappedAndRecursiveConstraints4.ts(13,12): error TS2345: Argument of type '{ length: number; charAt: (x: number) => void; }' is not assignable to parameter of type 'string'.
|
||||
tests/cases/conformance/types/typeParameters/typeArgumentLists/wrappedAndRecursiveConstraints4.ts(13,25): error TS2322: Type '(x: number) => void' is not assignable to type '(pos: number) => string'.
|
||||
Type 'void' is not assignable to type 'string'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/types/typeParameters/typeArgumentLists/wrappedAndRecursiveConstraints4.ts (1 errors) ====
|
||||
@@ -15,5 +16,7 @@ tests/cases/conformance/types/typeParameters/typeArgumentLists/wrappedAndRecursi
|
||||
var c = new C({ length: 2 });
|
||||
var r = c.foo('');
|
||||
var r2 = r({ length: 3, charAt: (x: number) => { '' } }); // error
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2345: Argument of type '{ length: number; charAt: (x: number) => void; }' is not assignable to parameter of type 'string'.
|
||||
~~~~~~
|
||||
!!! error TS2322: Type '(x: number) => void' is not assignable to type '(pos: number) => string'.
|
||||
!!! error TS2322: Type 'void' is not assignable to type 'string'.
|
||||
!!! related TS6500 /.ts/lib.es5.d.ts:332:5: The expected type comes from property 'charAt' which is declared here on type 'string'
|
||||
Reference in New Issue
Block a user