|
| 1 | +tests/cases/compiler/arrayLiteralTypeInference.ts(13,5): error TS2322: Type '({ id: number; trueness: boolean; } | { id: number; name: string; })[]' is not assignable to type 'Action[]'. |
| 2 | + Type '{ id: number; trueness: boolean; } | { id: number; name: string; }' is not assignable to type 'Action'. |
| 3 | + Type '{ id: number; trueness: boolean; }' is not assignable to type 'Action'. |
| 4 | + Property 'trueness' does not exist on type 'Action'. |
| 5 | +tests/cases/compiler/arrayLiteralTypeInference.ts(29,5): error TS2322: Type '({ id: number; trueness: boolean; } | { id: number; name: string; })[]' is not assignable to type '{ id: number; }[]'. |
| 6 | + Type '{ id: number; trueness: boolean; } | { id: number; name: string; }' is not assignable to type '{ id: number; }'. |
| 7 | + Type '{ id: number; trueness: boolean; }' is not assignable to type '{ id: number; }'. |
| 8 | + Property 'trueness' does not exist on type '{ id: number; }'. |
| 9 | + |
| 10 | + |
| 11 | +==== tests/cases/compiler/arrayLiteralTypeInference.ts (2 errors) ==== |
| 12 | + class Action { |
| 13 | + id: number; |
| 14 | + } |
| 15 | + |
| 16 | + class ActionA extends Action { |
| 17 | + value: string; |
| 18 | + } |
| 19 | + |
| 20 | + class ActionB extends Action { |
| 21 | + trueNess: boolean; |
| 22 | + } |
| 23 | + |
| 24 | + var x1: Action[] = [ |
| 25 | + ~~ |
| 26 | +!!! error TS2322: Type '({ id: number; trueness: boolean; } | { id: number; name: string; })[]' is not assignable to type 'Action[]'. |
| 27 | +!!! error TS2322: Type '{ id: number; trueness: boolean; } | { id: number; name: string; }' is not assignable to type 'Action'. |
| 28 | +!!! error TS2322: Type '{ id: number; trueness: boolean; }' is not assignable to type 'Action'. |
| 29 | +!!! error TS2322: Property 'trueness' does not exist on type 'Action'. |
| 30 | + { id: 2, trueness: false }, |
| 31 | + { id: 3, name: "three" } |
| 32 | + ] |
| 33 | + |
| 34 | + var x2: Action[] = [ |
| 35 | + new ActionA(), |
| 36 | + new ActionB() |
| 37 | + ] |
| 38 | + |
| 39 | + var x3: Action[] = [ |
| 40 | + new Action(), |
| 41 | + new ActionA(), |
| 42 | + new ActionB() |
| 43 | + ] |
| 44 | + |
| 45 | + var z1: { id: number }[] = |
| 46 | + ~~ |
| 47 | +!!! error TS2322: Type '({ id: number; trueness: boolean; } | { id: number; name: string; })[]' is not assignable to type '{ id: number; }[]'. |
| 48 | +!!! error TS2322: Type '{ id: number; trueness: boolean; } | { id: number; name: string; }' is not assignable to type '{ id: number; }'. |
| 49 | +!!! error TS2322: Type '{ id: number; trueness: boolean; }' is not assignable to type '{ id: number; }'. |
| 50 | +!!! error TS2322: Property 'trueness' does not exist on type '{ id: number; }'. |
| 51 | + [ |
| 52 | + { id: 2, trueness: false }, |
| 53 | + { id: 3, name: "three" } |
| 54 | + ] |
| 55 | + |
| 56 | + var z2: { id: number }[] = |
| 57 | + [ |
| 58 | + new ActionA(), |
| 59 | + new ActionB() |
| 60 | + ] |
| 61 | + |
| 62 | + var z3: { id: number }[] = |
| 63 | + [ |
| 64 | + new Action(), |
| 65 | + new ActionA(), |
| 66 | + new ActionB() |
| 67 | + ] |
| 68 | + |
| 69 | + |
| 70 | + |
| 71 | + |
| 72 | + |
0 commit comments