-
Notifications
You must be signed in to change notification settings - Fork 12.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add errors for invalid assignments and a trailing '?.'
- Loading branch information
Showing
13 changed files
with
988 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
tests/cases/conformance/expressions/optionalChaining/elementAccessChain/elementAccessChain.3.ts(3,1): error TS2774: The operand of an increment or decrement operator may not be an optional property access. | ||
tests/cases/conformance/expressions/optionalChaining/elementAccessChain/elementAccessChain.3.ts(4,1): error TS2774: The operand of an increment or decrement operator may not be an optional property access. | ||
tests/cases/conformance/expressions/optionalChaining/elementAccessChain/elementAccessChain.3.ts(5,1): error TS2774: The operand of an increment or decrement operator may not be an optional property access. | ||
tests/cases/conformance/expressions/optionalChaining/elementAccessChain/elementAccessChain.3.ts(6,1): error TS2774: The operand of an increment or decrement operator may not be an optional property access. | ||
tests/cases/conformance/expressions/optionalChaining/elementAccessChain/elementAccessChain.3.ts(8,3): error TS2774: The operand of an increment or decrement operator may not be an optional property access. | ||
tests/cases/conformance/expressions/optionalChaining/elementAccessChain/elementAccessChain.3.ts(9,3): error TS2774: The operand of an increment or decrement operator may not be an optional property access. | ||
tests/cases/conformance/expressions/optionalChaining/elementAccessChain/elementAccessChain.3.ts(10,3): error TS2774: The operand of an increment or decrement operator may not be an optional property access. | ||
tests/cases/conformance/expressions/optionalChaining/elementAccessChain/elementAccessChain.3.ts(11,3): error TS2774: The operand of an increment or decrement operator may not be an optional property access. | ||
tests/cases/conformance/expressions/optionalChaining/elementAccessChain/elementAccessChain.3.ts(13,1): error TS2776: The left-hand side of an assignment expression may not be an optional property access. | ||
tests/cases/conformance/expressions/optionalChaining/elementAccessChain/elementAccessChain.3.ts(14,1): error TS2776: The left-hand side of an assignment expression may not be an optional property access. | ||
tests/cases/conformance/expressions/optionalChaining/elementAccessChain/elementAccessChain.3.ts(15,1): error TS2776: The left-hand side of an assignment expression may not be an optional property access. | ||
tests/cases/conformance/expressions/optionalChaining/elementAccessChain/elementAccessChain.3.ts(16,1): error TS2776: The left-hand side of an assignment expression may not be an optional property access. | ||
tests/cases/conformance/expressions/optionalChaining/elementAccessChain/elementAccessChain.3.ts(18,6): error TS2777: The left-hand side of a 'for...in' statement may not be an optional property access. | ||
tests/cases/conformance/expressions/optionalChaining/elementAccessChain/elementAccessChain.3.ts(19,6): error TS2777: The left-hand side of a 'for...in' statement may not be an optional property access. | ||
tests/cases/conformance/expressions/optionalChaining/elementAccessChain/elementAccessChain.3.ts(20,6): error TS2778: The left-hand side of a 'for...of' statement may not be an optional property access. | ||
tests/cases/conformance/expressions/optionalChaining/elementAccessChain/elementAccessChain.3.ts(21,6): error TS2778: The left-hand side of a 'for...of' statement may not be an optional property access. | ||
tests/cases/conformance/expressions/optionalChaining/elementAccessChain/elementAccessChain.3.ts(23,7): error TS2776: The left-hand side of an assignment expression may not be an optional property access. | ||
tests/cases/conformance/expressions/optionalChaining/elementAccessChain/elementAccessChain.3.ts(24,7): error TS2776: The left-hand side of an assignment expression may not be an optional property access. | ||
tests/cases/conformance/expressions/optionalChaining/elementAccessChain/elementAccessChain.3.ts(25,7): error TS2775: The target of an object rest assignment may not be an optional property access. | ||
tests/cases/conformance/expressions/optionalChaining/elementAccessChain/elementAccessChain.3.ts(26,7): error TS2775: The target of an object rest assignment may not be an optional property access. | ||
tests/cases/conformance/expressions/optionalChaining/elementAccessChain/elementAccessChain.3.ts(27,5): error TS2776: The left-hand side of an assignment expression may not be an optional property access. | ||
tests/cases/conformance/expressions/optionalChaining/elementAccessChain/elementAccessChain.3.ts(28,5): error TS2776: The left-hand side of an assignment expression may not be an optional property access. | ||
|
||
|
||
==== tests/cases/conformance/expressions/optionalChaining/elementAccessChain/elementAccessChain.3.ts (22 errors) ==== | ||
declare const obj: any; | ||
|
||
obj?.["a"]++; | ||
~~~~~~~~~~ | ||
!!! error TS2774: The operand of an increment or decrement operator may not be an optional property access. | ||
obj?.a["b"]++; | ||
~~~~~~~~~~~ | ||
!!! error TS2774: The operand of an increment or decrement operator may not be an optional property access. | ||
obj?.["a"]--; | ||
~~~~~~~~~~ | ||
!!! error TS2774: The operand of an increment or decrement operator may not be an optional property access. | ||
obj?.a["b"]--; | ||
~~~~~~~~~~~ | ||
!!! error TS2774: The operand of an increment or decrement operator may not be an optional property access. | ||
|
||
++obj?.["a"]; | ||
~~~~~~~~~~ | ||
!!! error TS2774: The operand of an increment or decrement operator may not be an optional property access. | ||
++obj?.a["b"]; | ||
~~~~~~~~~~~ | ||
!!! error TS2774: The operand of an increment or decrement operator may not be an optional property access. | ||
--obj?.["a"]; | ||
~~~~~~~~~~ | ||
!!! error TS2774: The operand of an increment or decrement operator may not be an optional property access. | ||
--obj?.a["b"]; | ||
~~~~~~~~~~~ | ||
!!! error TS2774: The operand of an increment or decrement operator may not be an optional property access. | ||
|
||
obj?.["a"] = 1; | ||
~~~~~~~~~~ | ||
!!! error TS2776: The left-hand side of an assignment expression may not be an optional property access. | ||
obj?.a["b"] = 1; | ||
~~~~~~~~~~~ | ||
!!! error TS2776: The left-hand side of an assignment expression may not be an optional property access. | ||
obj?.["a"] += 1; | ||
~~~~~~~~~~ | ||
!!! error TS2776: The left-hand side of an assignment expression may not be an optional property access. | ||
obj?.a["b"] += 1; | ||
~~~~~~~~~~~ | ||
!!! error TS2776: The left-hand side of an assignment expression may not be an optional property access. | ||
|
||
for (obj?.["a"] in {}); | ||
~~~~~~~~~~ | ||
!!! error TS2777: The left-hand side of a 'for...in' statement may not be an optional property access. | ||
for (obj?.a["b"] in {}); | ||
~~~~~~~~~~~ | ||
!!! error TS2777: The left-hand side of a 'for...in' statement may not be an optional property access. | ||
for (obj?.["a"] of []); | ||
~~~~~~~~~~ | ||
!!! error TS2778: The left-hand side of a 'for...of' statement may not be an optional property access. | ||
for (obj?.a["b"] of []); | ||
~~~~~~~~~~~ | ||
!!! error TS2778: The left-hand side of a 'for...of' statement may not be an optional property access. | ||
|
||
({ a: obj?.["a"] } = { a: 1 }); | ||
~~~~~~~~~~ | ||
!!! error TS2776: The left-hand side of an assignment expression may not be an optional property access. | ||
({ a: obj?.a["b"] } = { a: 1 }); | ||
~~~~~~~~~~~ | ||
!!! error TS2776: The left-hand side of an assignment expression may not be an optional property access. | ||
({ ...obj?.["a"] } = { a: 1 }); | ||
~~~~~~~~~~ | ||
!!! error TS2775: The target of an object rest assignment may not be an optional property access. | ||
({ ...obj?.a["b"] } = { a: 1 }); | ||
~~~~~~~~~~~ | ||
!!! error TS2775: The target of an object rest assignment may not be an optional property access. | ||
[...obj?.["a"]] = []; | ||
~~~~~~~~~~ | ||
!!! error TS2776: The left-hand side of an assignment expression may not be an optional property access. | ||
[...obj?.a["b"]] = []; | ||
~~~~~~~~~~~ | ||
!!! error TS2776: The left-hand side of an assignment expression may not be an optional property access. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
//// [elementAccessChain.3.ts] | ||
declare const obj: any; | ||
|
||
obj?.["a"]++; | ||
obj?.a["b"]++; | ||
obj?.["a"]--; | ||
obj?.a["b"]--; | ||
|
||
++obj?.["a"]; | ||
++obj?.a["b"]; | ||
--obj?.["a"]; | ||
--obj?.a["b"]; | ||
|
||
obj?.["a"] = 1; | ||
obj?.a["b"] = 1; | ||
obj?.["a"] += 1; | ||
obj?.a["b"] += 1; | ||
|
||
for (obj?.["a"] in {}); | ||
for (obj?.a["b"] in {}); | ||
for (obj?.["a"] of []); | ||
for (obj?.a["b"] of []); | ||
|
||
({ a: obj?.["a"] } = { a: 1 }); | ||
({ a: obj?.a["b"] } = { a: 1 }); | ||
({ ...obj?.["a"] } = { a: 1 }); | ||
({ ...obj?.a["b"] } = { a: 1 }); | ||
[...obj?.["a"]] = []; | ||
[...obj?.a["b"]] = []; | ||
|
||
|
||
//// [elementAccessChain.3.js] | ||
"use strict"; | ||
var __rest = (this && this.__rest) || function (s, e) { | ||
var t = {}; | ||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) | ||
t[p] = s[p]; | ||
if (s != null && typeof Object.getOwnPropertySymbols === "function") | ||
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) { | ||
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) | ||
t[p[i]] = s[p[i]]; | ||
} | ||
return t; | ||
}; | ||
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x; | ||
((_a = obj) === null || _a === void 0 ? void 0 : _a["a"])++; | ||
((_b = obj) === null || _b === void 0 ? void 0 : _b.a["b"])++; | ||
((_c = obj) === null || _c === void 0 ? void 0 : _c["a"])--; | ||
((_d = obj) === null || _d === void 0 ? void 0 : _d.a["b"])--; | ||
++((_e = obj) === null || _e === void 0 ? void 0 : _e["a"]); | ||
++((_f = obj) === null || _f === void 0 ? void 0 : _f.a["b"]); | ||
--((_g = obj) === null || _g === void 0 ? void 0 : _g["a"]); | ||
--((_h = obj) === null || _h === void 0 ? void 0 : _h.a["b"]); | ||
(_j = obj) === null || _j === void 0 ? void 0 : _j["a"] = 1; | ||
(_k = obj) === null || _k === void 0 ? void 0 : _k.a["b"] = 1; | ||
(_l = obj) === null || _l === void 0 ? void 0 : _l["a"] += 1; | ||
(_m = obj) === null || _m === void 0 ? void 0 : _m.a["b"] += 1; | ||
for ((_o = obj) === null || _o === void 0 ? void 0 : _o["a"] in {}) | ||
; | ||
for ((_p = obj) === null || _p === void 0 ? void 0 : _p.a["b"] in {}) | ||
; | ||
for (var _i = 0, _y = []; _i < _y.length; _i++) { | ||
(_q = obj) === null || _q === void 0 ? void 0 : _q["a"] = _y[_i]; | ||
; | ||
} | ||
for (var _z = 0, _0 = []; _z < _0.length; _z++) { | ||
(_r = obj) === null || _r === void 0 ? void 0 : _r.a["b"] = _0[_z]; | ||
; | ||
} | ||
((_s = obj) === null || _s === void 0 ? void 0 : _s["a"] = { a: 1 }.a); | ||
((_t = obj) === null || _t === void 0 ? void 0 : _t.a["b"] = { a: 1 }.a); | ||
((_u = obj) === null || _u === void 0 ? void 0 : _u["a"] = __rest({ a: 1 }, [])); | ||
((_v = obj) === null || _v === void 0 ? void 0 : _v.a["b"] = __rest({ a: 1 }, [])); | ||
(_w = obj) === null || _w === void 0 ? void 0 : _w["a"] = [].slice(0); | ||
(_x = obj) === null || _x === void 0 ? void 0 : _x.a["b"] = [].slice(0); |
Oops, something went wrong.