TypeScript/tests/cases/compiler/arrayCast.ts
2014-07-12 17:30:19 -07:00

6 lines
325 B
TypeScript

// 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" }, {}];