2014-10-28 08:28:59 +01:00
|
|
|
tests/cases/compiler/arrayCast.ts(3,1): error TS2352: Neither type '{ foo: string; }[]' nor type '{ id: number; }[]' is assignable to the other.
|
|
|
|
Type '{ foo: string; }' is not assignable to type '{ id: number; }'.
|
2015-01-24 17:04:23 +01:00
|
|
|
Property 'id' is missing in type '{ foo: string; }'.
|
2014-09-12 22:35:07 +02:00
|
|
|
|
|
|
|
|
2014-07-13 01:04:16 +02:00
|
|
|
==== tests/cases/compiler/arrayCast.ts (1 errors) ====
|
|
|
|
// Should fail. Even though the array is contextually typed with { id: number }[], it still
|
|
|
|
// has type { foo: string }[], which is not assignable to { id: number }[].
|
|
|
|
<{ id: number; }[]>[{ foo: "s" }];
|
|
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
2014-10-28 08:28:59 +01:00
|
|
|
!!! error TS2352: Neither type '{ foo: string; }[]' nor type '{ id: number; }[]' is assignable to the other.
|
|
|
|
!!! error TS2352: Type '{ foo: string; }' is not assignable to type '{ id: number; }'.
|
2015-01-24 17:04:23 +01:00
|
|
|
!!! error TS2352: Property 'id' is missing in type '{ foo: string; }'.
|
2014-07-13 01:04:16 +02:00
|
|
|
|
|
|
|
// Should succeed, as the {} element causes the type of the array to be {}[]
|
|
|
|
<{ id: number; }[]>[{ foo: "s" }, {}];
|