|
| 1 | +tests/cases/compiler/objectLiteralExcessProperties.ts(9,18): error TS2322: Type '{ forword: string; }' is not assignable to type 'Book'. |
| 2 | + Object literal may only specify known properties, and 'forword' does not exist in type 'Book'. |
| 3 | +tests/cases/compiler/objectLiteralExcessProperties.ts(11,27): error TS2322: Type '{ foreward: string; }' is not assignable to type 'Book | string'. |
| 4 | + Object literal may only specify known properties, and 'foreward' does not exist in type 'Book | string'. |
| 5 | +tests/cases/compiler/objectLiteralExcessProperties.ts(13,53): error TS2322: Type '({ foreword: string; } | { forwards: string; })[]' is not assignable to type 'Book | Book[]'. |
| 6 | + Type '({ foreword: string; } | { forwards: string; })[]' is not assignable to type 'Book[]'. |
| 7 | + Type '{ foreword: string; } | { forwards: string; }' is not assignable to type 'Book'. |
| 8 | + Type '{ forwards: string; }' is not assignable to type 'Book'. |
| 9 | + Object literal may only specify known properties, and 'forwards' does not exist in type 'Book'. |
| 10 | +tests/cases/compiler/objectLiteralExcessProperties.ts(15,42): error TS2322: Type '{ foreword: string; colour: string; }' is not assignable to type 'Book & Cover'. |
| 11 | + Object literal may only specify known properties, and 'colour' does not exist in type 'Book & Cover'. |
| 12 | +tests/cases/compiler/objectLiteralExcessProperties.ts(17,26): error TS2322: Type '{ foreward: string; color: string; }' is not assignable to type 'Book & Cover'. |
| 13 | + Object literal may only specify known properties, and 'foreward' does not exist in type 'Book & Cover'. |
| 14 | +tests/cases/compiler/objectLiteralExcessProperties.ts(19,57): error TS2322: Type '{ foreword: string; color: string; price: number; }' is not assignable to type 'Book & Cover'. |
| 15 | + Object literal may only specify known properties, and 'price' does not exist in type 'Book & Cover'. |
| 16 | +tests/cases/compiler/objectLiteralExcessProperties.ts(21,43): error TS2322: Type '{ foreword: string; price: number; }' is not assignable to type 'Book & number'. |
| 17 | + Object literal may only specify known properties, and 'price' does not exist in type 'Book & number'. |
| 18 | + |
| 19 | + |
| 20 | +==== tests/cases/compiler/objectLiteralExcessProperties.ts (7 errors) ==== |
| 21 | + interface Book { |
| 22 | + foreword: string; |
| 23 | + } |
| 24 | + |
| 25 | + interface Cover { |
| 26 | + color?: string; |
| 27 | + } |
| 28 | + |
| 29 | + var b1: Book = { forword: "oops" }; |
| 30 | + ~~~~~~~~~~~~~~~ |
| 31 | +!!! error TS2322: Type '{ forword: string; }' is not assignable to type 'Book'. |
| 32 | +!!! error TS2322: Object literal may only specify known properties, and 'forword' does not exist in type 'Book'. |
| 33 | + |
| 34 | + var b2: Book | string = { foreward: "nope" }; |
| 35 | + ~~~~~~~~~~~~~~~~ |
| 36 | +!!! error TS2322: Type '{ foreward: string; }' is not assignable to type 'Book | string'. |
| 37 | +!!! error TS2322: Object literal may only specify known properties, and 'foreward' does not exist in type 'Book | string'. |
| 38 | + |
| 39 | + var b3: Book | (Book[]) = [{ foreword: "hello" }, { forwards: "back" }]; |
| 40 | + ~~~~~~~~~~~~~~~~ |
| 41 | +!!! error TS2322: Type '({ foreword: string; } | { forwards: string; })[]' is not assignable to type 'Book | Book[]'. |
| 42 | +!!! error TS2322: Type '({ foreword: string; } | { forwards: string; })[]' is not assignable to type 'Book[]'. |
| 43 | +!!! error TS2322: Type '{ foreword: string; } | { forwards: string; }' is not assignable to type 'Book'. |
| 44 | +!!! error TS2322: Type '{ forwards: string; }' is not assignable to type 'Book'. |
| 45 | +!!! error TS2322: Object literal may only specify known properties, and 'forwards' does not exist in type 'Book'. |
| 46 | + |
| 47 | + var b4: Book & Cover = { foreword: "hi", colour: "blue" }; |
| 48 | + ~~~~~~~~~~~~~~ |
| 49 | +!!! error TS2322: Type '{ foreword: string; colour: string; }' is not assignable to type 'Book & Cover'. |
| 50 | +!!! error TS2322: Object literal may only specify known properties, and 'colour' does not exist in type 'Book & Cover'. |
| 51 | + |
| 52 | + var b5: Book & Cover = { foreward: "hi", color: "blue" }; |
| 53 | + ~~~~~~~~~~~~~~ |
| 54 | +!!! error TS2322: Type '{ foreward: string; color: string; }' is not assignable to type 'Book & Cover'. |
| 55 | +!!! error TS2322: Object literal may only specify known properties, and 'foreward' does not exist in type 'Book & Cover'. |
| 56 | + |
| 57 | + var b6: Book & Cover = { foreword: "hi", color: "blue", price: 10.99 }; |
| 58 | + ~~~~~~~~~~~~ |
| 59 | +!!! error TS2322: Type '{ foreword: string; color: string; price: number; }' is not assignable to type 'Book & Cover'. |
| 60 | +!!! error TS2322: Object literal may only specify known properties, and 'price' does not exist in type 'Book & Cover'. |
| 61 | + |
| 62 | + var b7: Book & number = { foreword: "hi", price: 10.99 }; |
| 63 | + ~~~~~~~~~~~~ |
| 64 | +!!! error TS2322: Type '{ foreword: string; price: number; }' is not assignable to type 'Book & number'. |
| 65 | +!!! error TS2322: Object literal may only specify known properties, and 'price' does not exist in type 'Book & number'. |
| 66 | + |
0 commit comments