2014-07-13 01:04:16 +02:00
|
|
|
//// [arrayCast.ts]
|
|
|
|
// 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" }];
|
|
|
|
|
|
|
|
// Should succeed, as the {} element causes the type of the array to be {}[]
|
|
|
|
<{ id: number; }[]>[{ foo: "s" }, {}];
|
|
|
|
|
|
|
|
//// [arrayCast.js]
|
2014-08-16 00:49:09 +02:00
|
|
|
// 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 }[].
|
2014-07-13 01:04:16 +02:00
|
|
|
[{ foo: "s" }];
|
2014-08-16 00:49:09 +02:00
|
|
|
// Should succeed, as the {} element causes the type of the array to be {}[]
|
2014-07-13 01:04:16 +02:00
|
|
|
[{ foo: "s" }, {}];
|