mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Adding test for excess/missing properties
This commit is contained in:
@@ -0,0 +1,85 @@
|
||||
tests/cases/conformance/es6/destructuring/missingAndExcessProperties.ts(3,11): error TS2459: Type '{}' has no property 'x' and no string index signature.
|
||||
tests/cases/conformance/es6/destructuring/missingAndExcessProperties.ts(3,14): error TS2459: Type '{}' has no property 'y' and no string index signature.
|
||||
tests/cases/conformance/es6/destructuring/missingAndExcessProperties.ts(4,18): error TS2459: Type '{ x?: number; }' has no property 'y' and no string index signature.
|
||||
tests/cases/conformance/es6/destructuring/missingAndExcessProperties.ts(5,11): error TS2459: Type '{ y?: number; }' has no property 'x' and no string index signature.
|
||||
tests/cases/conformance/es6/destructuring/missingAndExcessProperties.ts(12,8): error TS2459: Type '{}' has no property 'x' and no string index signature.
|
||||
tests/cases/conformance/es6/destructuring/missingAndExcessProperties.ts(12,11): error TS2459: Type '{}' has no property 'y' and no string index signature.
|
||||
tests/cases/conformance/es6/destructuring/missingAndExcessProperties.ts(13,18): error TS2459: Type '{ x?: number; }' has no property 'y' and no string index signature.
|
||||
tests/cases/conformance/es6/destructuring/missingAndExcessProperties.ts(14,8): error TS2459: Type '{ y?: number; }' has no property 'x' and no string index signature.
|
||||
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 '{}'.
|
||||
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 '{}'.
|
||||
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; }'.
|
||||
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; }'.
|
||||
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 '{}'.
|
||||
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 '{}'.
|
||||
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; }'.
|
||||
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; }'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/destructuring/missingAndExcessProperties.ts (16 errors) ====
|
||||
// Missing properties
|
||||
function f1() {
|
||||
var { x, y } = {};
|
||||
~
|
||||
!!! error TS2459: Type '{}' has no property 'x' and no string index signature.
|
||||
~
|
||||
!!! error TS2459: Type '{}' has no property 'y' and no string index signature.
|
||||
var { x = 1, y } = {};
|
||||
~
|
||||
!!! error TS2459: Type '{ x?: number; }' has no property 'y' and no string index signature.
|
||||
var { x, y = 1 } = {};
|
||||
~
|
||||
!!! error TS2459: Type '{ y?: number; }' has no property 'x' and no string index signature.
|
||||
var { x = 1, y = 1 } = {};
|
||||
}
|
||||
|
||||
// Missing properties
|
||||
function f2() {
|
||||
var x: number, y: number;
|
||||
({ x, y } = {});
|
||||
~
|
||||
!!! error TS2459: Type '{}' has no property 'x' and no string index signature.
|
||||
~
|
||||
!!! error TS2459: Type '{}' has no property 'y' and no string index signature.
|
||||
({ x: x = 1, y } = {});
|
||||
~
|
||||
!!! error TS2459: Type '{ x?: number; }' has no property 'y' and no string index signature.
|
||||
({ x, y: y = 1 } = {});
|
||||
~
|
||||
!!! error TS2459: Type '{ y?: number; }' has no property 'x' and no string index signature.
|
||||
({ x: x = 1, y: y = 1 } = {});
|
||||
}
|
||||
|
||||
// Excess properties
|
||||
function f3() {
|
||||
var { } = { x: 0, y: 0 };
|
||||
~
|
||||
!!! error TS2353: Object literal may only specify known properties, and 'x' does not exist in type '{}'.
|
||||
~
|
||||
!!! error TS2353: Object literal may only specify known properties, and 'y' does not exist in type '{}'.
|
||||
var { x } = { x: 0, y: 0 };
|
||||
~
|
||||
!!! error TS2353: Object literal may only specify known properties, and 'y' does not exist in type '{ x: any; }'.
|
||||
var { y } = { x: 0, y: 0 };
|
||||
~
|
||||
!!! error TS2353: Object literal may only specify known properties, and 'x' does not exist in type '{ y: any; }'.
|
||||
var { x, y } = { x: 0, y: 0 };
|
||||
}
|
||||
|
||||
// Excess properties
|
||||
function f4() {
|
||||
var x: number, y: number;
|
||||
({ } = { x: 0, y: 0 });
|
||||
~
|
||||
!!! error TS2353: Object literal may only specify known properties, and 'x' does not exist in type '{}'.
|
||||
~
|
||||
!!! error TS2353: Object literal may only specify known properties, and 'y' does not exist in type '{}'.
|
||||
({ x } = { x: 0, y: 0 });
|
||||
~
|
||||
!!! error TS2353: Object literal may only specify known properties, and 'y' does not exist in type '{ x: number; }'.
|
||||
({ y } = { x: 0, y: 0 });
|
||||
~
|
||||
!!! error TS2353: Object literal may only specify known properties, and 'x' does not exist in type '{ y: number; }'.
|
||||
({ x, y } = { x: 0, y: 0 });
|
||||
}
|
||||
|
||||
@@ -0,0 +1,69 @@
|
||||
//// [missingAndExcessProperties.ts]
|
||||
// Missing properties
|
||||
function f1() {
|
||||
var { x, y } = {};
|
||||
var { x = 1, y } = {};
|
||||
var { x, y = 1 } = {};
|
||||
var { x = 1, y = 1 } = {};
|
||||
}
|
||||
|
||||
// Missing properties
|
||||
function f2() {
|
||||
var x: number, y: number;
|
||||
({ x, y } = {});
|
||||
({ x: x = 1, y } = {});
|
||||
({ x, y: y = 1 } = {});
|
||||
({ x: x = 1, y: y = 1 } = {});
|
||||
}
|
||||
|
||||
// Excess properties
|
||||
function f3() {
|
||||
var { } = { x: 0, y: 0 };
|
||||
var { x } = { x: 0, y: 0 };
|
||||
var { y } = { x: 0, y: 0 };
|
||||
var { x, y } = { x: 0, y: 0 };
|
||||
}
|
||||
|
||||
// Excess properties
|
||||
function f4() {
|
||||
var x: number, y: number;
|
||||
({ } = { x: 0, y: 0 });
|
||||
({ x } = { x: 0, y: 0 });
|
||||
({ y } = { x: 0, y: 0 });
|
||||
({ x, y } = { x: 0, y: 0 });
|
||||
}
|
||||
|
||||
|
||||
//// [missingAndExcessProperties.js]
|
||||
// Missing properties
|
||||
function f1() {
|
||||
var _a = {}, x = _a.x, y = _a.y;
|
||||
var _b = {}, _c = _b.x, x = _c === void 0 ? 1 : _c, y = _b.y;
|
||||
var _d = {}, x = _d.x, _e = _d.y, y = _e === void 0 ? 1 : _e;
|
||||
var _f = {}, _g = _f.x, x = _g === void 0 ? 1 : _g, _h = _f.y, y = _h === void 0 ? 1 : _h;
|
||||
}
|
||||
// Missing properties
|
||||
function f2() {
|
||||
var x, y;
|
||||
(_a = {}, x = _a.x, y = _a.y, _a);
|
||||
(_b = {}, _c = _b.x, x = _c === void 0 ? 1 : _c, y = _b.y, _b);
|
||||
(_d = {}, x = _d.x, _e = _d.y, y = _e === void 0 ? 1 : _e, _d);
|
||||
(_f = {}, _g = _f.x, x = _g === void 0 ? 1 : _g, _h = _f.y, y = _h === void 0 ? 1 : _h, _f);
|
||||
var _a, _b, _c, _d, _e, _f, _g, _h;
|
||||
}
|
||||
// Excess properties
|
||||
function f3() {
|
||||
var _a = { x: 0, y: 0 };
|
||||
var x = { x: 0, y: 0 }.x;
|
||||
var y = { x: 0, y: 0 }.y;
|
||||
var _b = { x: 0, y: 0 }, x = _b.x, y = _b.y;
|
||||
}
|
||||
// Excess properties
|
||||
function f4() {
|
||||
var x, y;
|
||||
({ x: 0, y: 0 });
|
||||
(_a = { x: 0, y: 0 }, x = _a.x, _a);
|
||||
(_b = { x: 0, y: 0 }, y = _b.y, _b);
|
||||
(_c = { x: 0, y: 0 }, x = _c.x, y = _c.y, _c);
|
||||
var _a, _b, _c;
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
// Missing properties
|
||||
function f1() {
|
||||
var { x, y } = {};
|
||||
var { x = 1, y } = {};
|
||||
var { x, y = 1 } = {};
|
||||
var { x = 1, y = 1 } = {};
|
||||
}
|
||||
|
||||
// Missing properties
|
||||
function f2() {
|
||||
var x: number, y: number;
|
||||
({ x, y } = {});
|
||||
({ x: x = 1, y } = {});
|
||||
({ x, y: y = 1 } = {});
|
||||
({ x: x = 1, y: y = 1 } = {});
|
||||
}
|
||||
|
||||
// Excess properties
|
||||
function f3() {
|
||||
var { } = { x: 0, y: 0 };
|
||||
var { x } = { x: 0, y: 0 };
|
||||
var { y } = { x: 0, y: 0 };
|
||||
var { x, y } = { x: 0, y: 0 };
|
||||
}
|
||||
|
||||
// Excess properties
|
||||
function f4() {
|
||||
var x: number, y: number;
|
||||
({ } = { x: 0, y: 0 });
|
||||
({ x } = { x: 0, y: 0 });
|
||||
({ y } = { x: 0, y: 0 });
|
||||
({ x, y } = { x: 0, y: 0 });
|
||||
}
|
||||
Reference in New Issue
Block a user