TypeScript/tests/baselines/reference/contextualTypeWithTuple.errors.txt
2014-10-03 17:37:29 -07:00

40 lines
No EOL
2.3 KiB
Text

tests/cases/conformance/types/tuple/contextualTypeWithTuple.ts(11,1): error TS2322: Type '[{}, number]' is not assignable to type '[{ a: string; }, number]':
Types of property '0' are incompatible:
Type '{}' is not assignable to type '{ a: string; }':
Property 'a' is missing in type '{}'.
tests/cases/conformance/types/tuple/contextualTypeWithTuple.ts(12,1): error TS2322: Type '[number, string]' is not assignable to type '[number, string, boolean]':
Property '2' is missing in type '[number, string]'.
tests/cases/conformance/types/tuple/contextualTypeWithTuple.ts(13,5): error TS2322: Type '[string, string, number]' is not assignable to type '[string, string]':
Types of property 'pop' are incompatible:
Type '() => {}' is not assignable to type '() => string':
Type '{}' is not assignable to type 'string'.
==== tests/cases/conformance/types/tuple/contextualTypeWithTuple.ts (3 errors) ====
// no error
var numStrTuple: [number, string] = [5, "hello"];
var numStrTuple2: [number, string] = [5, "foo", true];
var numStrBoolTuple: [number, string, boolean] = [5, "foo", true];
var objNumTuple: [{ a: string }, number] = [{ a: "world" }, 5];
var strTupleTuple: [string, [number, {}]] = ["bar", [5, { x: 1, y: 1 }]];
numStrTuple = numStrTuple2;
numStrTuple = numStrBoolTuple;
// error
objNumTuple = [ {}, 5];
~~~~~~~~~~~
!!! error TS2322: Type '[{}, number]' is not assignable to type '[{ a: string; }, number]':
!!! error TS2322: Types of property '0' are incompatible:
!!! error TS2322: Type '{}' is not assignable to type '{ a: string; }':
!!! error TS2322: Property 'a' is missing in type '{}'.
numStrBoolTuple = numStrTuple;
~~~~~~~~~~~~~~~
!!! error TS2322: Type '[number, string]' is not assignable to type '[number, string, boolean]':
!!! error TS2322: Property '2' is missing in type '[number, string]'.
var strStrTuple: [string, string] = ["foo", "bar", 5];
~~~~~~~~~~~
!!! error TS2322: Type '[string, string, number]' is not assignable to type '[string, string]':
!!! error TS2322: Types of property 'pop' are incompatible:
!!! error TS2322: Type '() => {}' is not assignable to type '() => string':
!!! error TS2322: Type '{}' is not assignable to type 'string'.