|
| 1 | +tests/cases/conformance/es6/destructuring/missingAndExcessProperties.ts(3,11): error TS2459: Type '{}' has no property 'x' and no string index signature. |
| 2 | +tests/cases/conformance/es6/destructuring/missingAndExcessProperties.ts(3,14): error TS2459: Type '{}' has no property 'y' and no string index signature. |
| 3 | +tests/cases/conformance/es6/destructuring/missingAndExcessProperties.ts(4,18): error TS2459: Type '{ x?: number; }' has no property 'y' and no string index signature. |
| 4 | +tests/cases/conformance/es6/destructuring/missingAndExcessProperties.ts(5,11): error TS2459: Type '{ y?: number; }' has no property 'x' and no string index signature. |
| 5 | +tests/cases/conformance/es6/destructuring/missingAndExcessProperties.ts(12,8): error TS2459: Type '{}' has no property 'x' and no string index signature. |
| 6 | +tests/cases/conformance/es6/destructuring/missingAndExcessProperties.ts(12,11): error TS2459: Type '{}' has no property 'y' and no string index signature. |
| 7 | +tests/cases/conformance/es6/destructuring/missingAndExcessProperties.ts(13,18): error TS2459: Type '{ x?: number; }' has no property 'y' and no string index signature. |
| 8 | +tests/cases/conformance/es6/destructuring/missingAndExcessProperties.ts(14,8): error TS2459: Type '{ y?: number; }' has no property 'x' and no string index signature. |
| 9 | +tests/cases/conformance/es6/destructuring/missingAndExcessProperties.ts(20,17): error TS2353: Object literal may only specify known properties, and 'x' does not exist in type '{}'. |
| 10 | +tests/cases/conformance/es6/destructuring/missingAndExcessProperties.ts(20,23): error TS2353: Object literal may only specify known properties, and 'y' does not exist in type '{}'. |
| 11 | +tests/cases/conformance/es6/destructuring/missingAndExcessProperties.ts(21,25): error TS2353: Object literal may only specify known properties, and 'y' does not exist in type '{ x: any; }'. |
| 12 | +tests/cases/conformance/es6/destructuring/missingAndExcessProperties.ts(22,19): error TS2353: Object literal may only specify known properties, and 'x' does not exist in type '{ y: any; }'. |
| 13 | +tests/cases/conformance/es6/destructuring/missingAndExcessProperties.ts(29,14): error TS2353: Object literal may only specify known properties, and 'x' does not exist in type '{}'. |
| 14 | +tests/cases/conformance/es6/destructuring/missingAndExcessProperties.ts(29,20): error TS2353: Object literal may only specify known properties, and 'y' does not exist in type '{}'. |
| 15 | +tests/cases/conformance/es6/destructuring/missingAndExcessProperties.ts(30,22): error TS2353: Object literal may only specify known properties, and 'y' does not exist in type '{ x: number; }'. |
| 16 | +tests/cases/conformance/es6/destructuring/missingAndExcessProperties.ts(31,16): error TS2353: Object literal may only specify known properties, and 'x' does not exist in type '{ y: number; }'. |
| 17 | + |
| 18 | + |
| 19 | +==== tests/cases/conformance/es6/destructuring/missingAndExcessProperties.ts (16 errors) ==== |
| 20 | + // Missing properties |
| 21 | + function f1() { |
| 22 | + var { x, y } = {}; |
| 23 | + ~ |
| 24 | +!!! error TS2459: Type '{}' has no property 'x' and no string index signature. |
| 25 | + ~ |
| 26 | +!!! error TS2459: Type '{}' has no property 'y' and no string index signature. |
| 27 | + var { x = 1, y } = {}; |
| 28 | + ~ |
| 29 | +!!! error TS2459: Type '{ x?: number; }' has no property 'y' and no string index signature. |
| 30 | + var { x, y = 1 } = {}; |
| 31 | + ~ |
| 32 | +!!! error TS2459: Type '{ y?: number; }' has no property 'x' and no string index signature. |
| 33 | + var { x = 1, y = 1 } = {}; |
| 34 | + } |
| 35 | + |
| 36 | + // Missing properties |
| 37 | + function f2() { |
| 38 | + var x: number, y: number; |
| 39 | + ({ x, y } = {}); |
| 40 | + ~ |
| 41 | +!!! error TS2459: Type '{}' has no property 'x' and no string index signature. |
| 42 | + ~ |
| 43 | +!!! error TS2459: Type '{}' has no property 'y' and no string index signature. |
| 44 | + ({ x: x = 1, y } = {}); |
| 45 | + ~ |
| 46 | +!!! error TS2459: Type '{ x?: number; }' has no property 'y' and no string index signature. |
| 47 | + ({ x, y: y = 1 } = {}); |
| 48 | + ~ |
| 49 | +!!! error TS2459: Type '{ y?: number; }' has no property 'x' and no string index signature. |
| 50 | + ({ x: x = 1, y: y = 1 } = {}); |
| 51 | + } |
| 52 | + |
| 53 | + // Excess properties |
| 54 | + function f3() { |
| 55 | + var { } = { x: 0, y: 0 }; |
| 56 | + ~ |
| 57 | +!!! error TS2353: Object literal may only specify known properties, and 'x' does not exist in type '{}'. |
| 58 | + ~ |
| 59 | +!!! error TS2353: Object literal may only specify known properties, and 'y' does not exist in type '{}'. |
| 60 | + var { x } = { x: 0, y: 0 }; |
| 61 | + ~ |
| 62 | +!!! error TS2353: Object literal may only specify known properties, and 'y' does not exist in type '{ x: any; }'. |
| 63 | + var { y } = { x: 0, y: 0 }; |
| 64 | + ~ |
| 65 | +!!! error TS2353: Object literal may only specify known properties, and 'x' does not exist in type '{ y: any; }'. |
| 66 | + var { x, y } = { x: 0, y: 0 }; |
| 67 | + } |
| 68 | + |
| 69 | + // Excess properties |
| 70 | + function f4() { |
| 71 | + var x: number, y: number; |
| 72 | + ({ } = { x: 0, y: 0 }); |
| 73 | + ~ |
| 74 | +!!! error TS2353: Object literal may only specify known properties, and 'x' does not exist in type '{}'. |
| 75 | + ~ |
| 76 | +!!! error TS2353: Object literal may only specify known properties, and 'y' does not exist in type '{}'. |
| 77 | + ({ x } = { x: 0, y: 0 }); |
| 78 | + ~ |
| 79 | +!!! error TS2353: Object literal may only specify known properties, and 'y' does not exist in type '{ x: number; }'. |
| 80 | + ({ y } = { x: 0, y: 0 }); |
| 81 | + ~ |
| 82 | +!!! error TS2353: Object literal may only specify known properties, and 'x' does not exist in type '{ y: number; }'. |
| 83 | + ({ x, y } = { x: 0, y: 0 }); |
| 84 | + } |
| 85 | + |
0 commit comments