From 2e8bbf0c9660330c42a2df41dd1fee7d403cfe52 Mon Sep 17 00:00:00 2001 From: Herrington Darkholme Date: Wed, 2 Nov 2016 20:27:53 +0800 Subject: [PATCH 1/4] fix #11480, disallow delete operator on readonly property or index signature --- src/compiler/checker.ts | 3 +++ src/compiler/diagnosticMessages.json | 8 ++++++++ 2 files changed, 11 insertions(+) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 006b87cb542ee..7b4fd5803e321 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -13550,6 +13550,9 @@ namespace ts { function checkDeleteExpression(node: DeleteExpression): Type { checkExpression(node.expression); + checkReferenceExpression(node.expression, + Diagnostics.The_operand_of_a_delete_operator_must_be_a_property_reference, + Diagnostics.The_operand_of_a_delete_operator_cannot_be_a_read_only_property); return booleanType; } diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 5290782c156a2..187a3a60d1670 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -1983,6 +1983,14 @@ "category": "Error", "code": 2697 }, + "The operand of a delete operator must be a property reference": { + "category": "Error", + "code": 2698 + }, + "The operand of a delete operator cannot be a read-only property": { + "category": "Error", + "code": 2699 + }, "Import declaration '{0}' is using private name '{1}'.": { "category": "Error", From 8ea8044f80f18417a9c1f09c0268ee0ecf7cd115 Mon Sep 17 00:00:00 2001 From: Herrington Darkholme Date: Wed, 2 Nov 2016 20:47:46 +0800 Subject: [PATCH 2/4] add new tests and accept baselines --- .../await_unaryExpression_es2017_1.errors.txt | 29 +++++++ .../await_unaryExpression_es2017_2.errors.txt | 21 +++++ .../await_unaryExpression_es6_1.errors.txt | 29 +++++++ .../await_unaryExpression_es6_2.errors.txt | 21 +++++ .../deleteOperatorWithAnyOtherType.errors.txt | 44 +++++++++- .../deleteOperatorWithBooleanType.errors.txt | 65 ++++++++++++++ .../deleteOperatorWithEnumType.errors.txt | 64 ++++++++++++++ .../deleteOperatorWithNumberType.errors.txt | 84 ++++++++++++++++++ .../deleteOperatorWithStringType.errors.txt | 86 +++++++++++++++++++ .../reference/deleteReadonly.errors.txt | 28 ++++++ tests/baselines/reference/deleteReadonly.js | 30 +++++++ ...onentiationOperatorSyntaxError2.errors.txt | 26 +++++- ...idSimpleUnaryExpressionOperands.errors.txt | 28 +++++- .../reference/parserStrictMode16.errors.txt | 20 +++++ .../reference/symbolType3.errors.txt | 5 +- ...emplateStringInDeleteExpression.errors.txt | 7 ++ ...lateStringInDeleteExpressionES6.errors.txt | 7 ++ tests/cases/compiler/deleteReadonly.ts | 18 ++++ 18 files changed, 607 insertions(+), 5 deletions(-) create mode 100644 tests/baselines/reference/await_unaryExpression_es2017_1.errors.txt create mode 100644 tests/baselines/reference/await_unaryExpression_es2017_2.errors.txt create mode 100644 tests/baselines/reference/await_unaryExpression_es6_1.errors.txt create mode 100644 tests/baselines/reference/await_unaryExpression_es6_2.errors.txt create mode 100644 tests/baselines/reference/deleteOperatorWithBooleanType.errors.txt create mode 100644 tests/baselines/reference/deleteOperatorWithEnumType.errors.txt create mode 100644 tests/baselines/reference/deleteOperatorWithNumberType.errors.txt create mode 100644 tests/baselines/reference/deleteOperatorWithStringType.errors.txt create mode 100644 tests/baselines/reference/deleteReadonly.errors.txt create mode 100644 tests/baselines/reference/deleteReadonly.js create mode 100644 tests/baselines/reference/parserStrictMode16.errors.txt create mode 100644 tests/baselines/reference/templateStringInDeleteExpression.errors.txt create mode 100644 tests/baselines/reference/templateStringInDeleteExpressionES6.errors.txt create mode 100644 tests/cases/compiler/deleteReadonly.ts diff --git a/tests/baselines/reference/await_unaryExpression_es2017_1.errors.txt b/tests/baselines/reference/await_unaryExpression_es2017_1.errors.txt new file mode 100644 index 0000000000000..60e786cbad10f --- /dev/null +++ b/tests/baselines/reference/await_unaryExpression_es2017_1.errors.txt @@ -0,0 +1,29 @@ +tests/cases/conformance/async/es2017/await_unaryExpression_es2017_1.ts(7,12): error TS2698: The operand of a delete operator must be a property reference +tests/cases/conformance/async/es2017/await_unaryExpression_es2017_1.ts(11,12): error TS2698: The operand of a delete operator must be a property reference + + +==== tests/cases/conformance/async/es2017/await_unaryExpression_es2017_1.ts (2 errors) ==== + + async function bar() { + !await 42; // OK + } + + async function bar1() { + delete await 42; // OK + ~~~~~~~~ +!!! error TS2698: The operand of a delete operator must be a property reference + } + + async function bar2() { + delete await 42; // OK + ~~~~~~~~ +!!! error TS2698: The operand of a delete operator must be a property reference + } + + async function bar3() { + void await 42; + } + + async function bar4() { + +await 42; + } \ No newline at end of file diff --git a/tests/baselines/reference/await_unaryExpression_es2017_2.errors.txt b/tests/baselines/reference/await_unaryExpression_es2017_2.errors.txt new file mode 100644 index 0000000000000..1c1072fd86ceb --- /dev/null +++ b/tests/baselines/reference/await_unaryExpression_es2017_2.errors.txt @@ -0,0 +1,21 @@ +tests/cases/conformance/async/es2017/await_unaryExpression_es2017_2.ts(3,12): error TS2698: The operand of a delete operator must be a property reference +tests/cases/conformance/async/es2017/await_unaryExpression_es2017_2.ts(7,12): error TS2698: The operand of a delete operator must be a property reference + + +==== tests/cases/conformance/async/es2017/await_unaryExpression_es2017_2.ts (2 errors) ==== + + async function bar1() { + delete await 42; + ~~~~~~~~ +!!! error TS2698: The operand of a delete operator must be a property reference + } + + async function bar2() { + delete await 42; + ~~~~~~~~ +!!! error TS2698: The operand of a delete operator must be a property reference + } + + async function bar3() { + void await 42; + } \ No newline at end of file diff --git a/tests/baselines/reference/await_unaryExpression_es6_1.errors.txt b/tests/baselines/reference/await_unaryExpression_es6_1.errors.txt new file mode 100644 index 0000000000000..90bd23b759702 --- /dev/null +++ b/tests/baselines/reference/await_unaryExpression_es6_1.errors.txt @@ -0,0 +1,29 @@ +tests/cases/conformance/async/es6/await_unaryExpression_es6_1.ts(7,12): error TS2698: The operand of a delete operator must be a property reference +tests/cases/conformance/async/es6/await_unaryExpression_es6_1.ts(11,12): error TS2698: The operand of a delete operator must be a property reference + + +==== tests/cases/conformance/async/es6/await_unaryExpression_es6_1.ts (2 errors) ==== + + async function bar() { + !await 42; // OK + } + + async function bar1() { + delete await 42; // OK + ~~~~~~~~ +!!! error TS2698: The operand of a delete operator must be a property reference + } + + async function bar2() { + delete await 42; // OK + ~~~~~~~~ +!!! error TS2698: The operand of a delete operator must be a property reference + } + + async function bar3() { + void await 42; + } + + async function bar4() { + +await 42; + } \ No newline at end of file diff --git a/tests/baselines/reference/await_unaryExpression_es6_2.errors.txt b/tests/baselines/reference/await_unaryExpression_es6_2.errors.txt new file mode 100644 index 0000000000000..9386d206eee72 --- /dev/null +++ b/tests/baselines/reference/await_unaryExpression_es6_2.errors.txt @@ -0,0 +1,21 @@ +tests/cases/conformance/async/es6/await_unaryExpression_es6_2.ts(3,12): error TS2698: The operand of a delete operator must be a property reference +tests/cases/conformance/async/es6/await_unaryExpression_es6_2.ts(7,12): error TS2698: The operand of a delete operator must be a property reference + + +==== tests/cases/conformance/async/es6/await_unaryExpression_es6_2.ts (2 errors) ==== + + async function bar1() { + delete await 42; + ~~~~~~~~ +!!! error TS2698: The operand of a delete operator must be a property reference + } + + async function bar2() { + delete await 42; + ~~~~~~~~ +!!! error TS2698: The operand of a delete operator must be a property reference + } + + async function bar3() { + void await 42; + } \ No newline at end of file diff --git a/tests/baselines/reference/deleteOperatorWithAnyOtherType.errors.txt b/tests/baselines/reference/deleteOperatorWithAnyOtherType.errors.txt index 73ddab1a33c67..d92f1ffb1e763 100644 --- a/tests/baselines/reference/deleteOperatorWithAnyOtherType.errors.txt +++ b/tests/baselines/reference/deleteOperatorWithAnyOtherType.errors.txt @@ -1,9 +1,23 @@ +tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithAnyOtherType.ts(27,31): error TS2698: The operand of a delete operator must be a property reference +tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithAnyOtherType.ts(28,31): error TS2698: The operand of a delete operator must be a property reference +tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithAnyOtherType.ts(33,31): error TS2698: The operand of a delete operator must be a property reference +tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithAnyOtherType.ts(34,31): error TS2698: The operand of a delete operator must be a property reference +tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithAnyOtherType.ts(42,32): error TS2698: The operand of a delete operator must be a property reference +tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithAnyOtherType.ts(43,32): error TS2698: The operand of a delete operator must be a property reference +tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithAnyOtherType.ts(44,32): error TS2698: The operand of a delete operator must be a property reference +tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithAnyOtherType.ts(45,32): error TS2698: The operand of a delete operator must be a property reference tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithAnyOtherType.ts(45,33): error TS2365: Operator '+' cannot be applied to types 'undefined' and 'undefined'. +tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithAnyOtherType.ts(46,32): error TS2698: The operand of a delete operator must be a property reference tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithAnyOtherType.ts(46,33): error TS2365: Operator '+' cannot be applied to types 'null' and 'null'. +tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithAnyOtherType.ts(47,32): error TS2698: The operand of a delete operator must be a property reference tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithAnyOtherType.ts(47,33): error TS2365: Operator '+' cannot be applied to types 'undefined' and 'undefined'. +tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithAnyOtherType.ts(50,32): error TS2698: The operand of a delete operator must be a property reference +tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithAnyOtherType.ts(51,32): error TS2698: The operand of a delete operator must be a property reference +tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithAnyOtherType.ts(51,39): error TS2698: The operand of a delete operator must be a property reference +tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithAnyOtherType.ts(51,46): error TS2698: The operand of a delete operator must be a property reference -==== tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithAnyOtherType.ts (3 errors) ==== +==== tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithAnyOtherType.ts (17 errors) ==== // delete operator on any type var ANY: any; @@ -31,13 +45,21 @@ tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperator var ResultIsBoolean1 = delete ANY1; var ResultIsBoolean2 = delete ANY2; var ResultIsBoolean3 = delete A; + ~ +!!! error TS2698: The operand of a delete operator must be a property reference var ResultIsBoolean4 = delete M; + ~ +!!! error TS2698: The operand of a delete operator must be a property reference var ResultIsBoolean5 = delete obj; var ResultIsBoolean6 = delete obj1; // any type literal var ResultIsBoolean7 = delete undefined; + ~~~~~~~~~ +!!! error TS2698: The operand of a delete operator must be a property reference var ResultIsBoolean8 = delete null; + ~~~~ +!!! error TS2698: The operand of a delete operator must be a property reference // any type expressions var ResultIsBoolean9 = delete ANY2[0]; @@ -46,21 +68,41 @@ tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperator var ResultIsBoolean12 = delete objA.a; var ResultIsBoolean13 = delete M.n; var ResultIsBoolean14 = delete foo(); + ~~~~~ +!!! error TS2698: The operand of a delete operator must be a property reference var ResultIsBoolean15 = delete A.foo(); + ~~~~~~~ +!!! error TS2698: The operand of a delete operator must be a property reference var ResultIsBoolean16 = delete (ANY + ANY1); + ~~~~~~~~~~~~ +!!! error TS2698: The operand of a delete operator must be a property reference var ResultIsBoolean17 = delete (null + undefined); + ~~~~~~~~~~~~~~~~~~ +!!! error TS2698: The operand of a delete operator must be a property reference ~~~~~~~~~~~~~~~~ !!! error TS2365: Operator '+' cannot be applied to types 'undefined' and 'undefined'. var ResultIsBoolean18 = delete (null + null); + ~~~~~~~~~~~~~ +!!! error TS2698: The operand of a delete operator must be a property reference ~~~~~~~~~~~ !!! error TS2365: Operator '+' cannot be applied to types 'null' and 'null'. var ResultIsBoolean19 = delete (undefined + undefined); + ~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2698: The operand of a delete operator must be a property reference ~~~~~~~~~~~~~~~~~~~~~ !!! error TS2365: Operator '+' cannot be applied to types 'undefined' and 'undefined'. // multiple delete operators var ResultIsBoolean20 = delete delete ANY; + ~~~~~~~~~~ +!!! error TS2698: The operand of a delete operator must be a property reference var ResultIsBoolean21 = delete delete delete (ANY + ANY1); + ~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2698: The operand of a delete operator must be a property reference + ~~~~~~~~~~~~~~~~~~~ +!!! error TS2698: The operand of a delete operator must be a property reference + ~~~~~~~~~~~~ +!!! error TS2698: The operand of a delete operator must be a property reference // miss assignment operators delete ANY; diff --git a/tests/baselines/reference/deleteOperatorWithBooleanType.errors.txt b/tests/baselines/reference/deleteOperatorWithBooleanType.errors.txt new file mode 100644 index 0000000000000..3f653671e2ec8 --- /dev/null +++ b/tests/baselines/reference/deleteOperatorWithBooleanType.errors.txt @@ -0,0 +1,65 @@ +tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithBooleanType.ts(20,31): error TS2698: The operand of a delete operator must be a property reference +tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithBooleanType.ts(21,31): error TS2698: The operand of a delete operator must be a property reference +tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithBooleanType.ts(26,31): error TS2698: The operand of a delete operator must be a property reference +tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithBooleanType.ts(27,31): error TS2698: The operand of a delete operator must be a property reference +tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithBooleanType.ts(30,31): error TS2698: The operand of a delete operator must be a property reference +tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithBooleanType.ts(33,8): error TS2698: The operand of a delete operator must be a property reference +tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithBooleanType.ts(35,8): error TS2698: The operand of a delete operator must be a property reference +tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithBooleanType.ts(36,8): error TS2698: The operand of a delete operator must be a property reference + + +==== tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithBooleanType.ts (8 errors) ==== + // delete operator on boolean type + var BOOLEAN: boolean; + + function foo(): boolean { return true; } + + class A { + public a: boolean; + static foo() { return false; } + } + module M { + export var n: boolean; + } + + var objA = new A(); + + // boolean type var + var ResultIsBoolean1 = delete BOOLEAN; + + // boolean type literal + var ResultIsBoolean2 = delete true; + ~~~~ +!!! error TS2698: The operand of a delete operator must be a property reference + var ResultIsBoolean3 = delete { x: true, y: false }; + ~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2698: The operand of a delete operator must be a property reference + + // boolean type expressions + var ResultIsBoolean4 = delete objA.a; + var ResultIsBoolean5 = delete M.n; + var ResultIsBoolean6 = delete foo(); + ~~~~~ +!!! error TS2698: The operand of a delete operator must be a property reference + var ResultIsBoolean7 = delete A.foo(); + ~~~~~~~ +!!! error TS2698: The operand of a delete operator must be a property reference + + // multiple delete operator + var ResultIsBoolean8 = delete delete BOOLEAN; + ~~~~~~~~~~~~~~ +!!! error TS2698: The operand of a delete operator must be a property reference + + // miss assignment operators + delete true; + ~~~~ +!!! error TS2698: The operand of a delete operator must be a property reference + delete BOOLEAN; + delete foo(); + ~~~~~ +!!! error TS2698: The operand of a delete operator must be a property reference + delete true, false; + ~~~~ +!!! error TS2698: The operand of a delete operator must be a property reference + delete objA.a; + delete M.n; \ No newline at end of file diff --git a/tests/baselines/reference/deleteOperatorWithEnumType.errors.txt b/tests/baselines/reference/deleteOperatorWithEnumType.errors.txt new file mode 100644 index 0000000000000..103070d15dc8e --- /dev/null +++ b/tests/baselines/reference/deleteOperatorWithEnumType.errors.txt @@ -0,0 +1,64 @@ +tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithEnumType.ts(7,31): error TS2698: The operand of a delete operator must be a property reference +tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithEnumType.ts(8,31): error TS2698: The operand of a delete operator must be a property reference +tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithEnumType.ts(11,31): error TS2699: The operand of a delete operator cannot be a read-only property +tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithEnumType.ts(12,31): error TS2698: The operand of a delete operator must be a property reference +tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithEnumType.ts(15,31): error TS2698: The operand of a delete operator must be a property reference +tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithEnumType.ts(15,38): error TS2698: The operand of a delete operator must be a property reference +tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithEnumType.ts(16,31): error TS2698: The operand of a delete operator must be a property reference +tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithEnumType.ts(16,38): error TS2698: The operand of a delete operator must be a property reference +tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithEnumType.ts(16,45): error TS2698: The operand of a delete operator must be a property reference +tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithEnumType.ts(19,8): error TS2698: The operand of a delete operator must be a property reference +tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithEnumType.ts(20,8): error TS2698: The operand of a delete operator must be a property reference +tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithEnumType.ts(21,8): error TS2699: The operand of a delete operator cannot be a read-only property +tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithEnumType.ts(22,8): error TS2698: The operand of a delete operator must be a property reference + + +==== tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithEnumType.ts (13 errors) ==== + // delete operator on enum type + + enum ENUM { }; + enum ENUM1 { A, B, "" }; + + // enum type var + var ResultIsBoolean1 = delete ENUM; + ~~~~ +!!! error TS2698: The operand of a delete operator must be a property reference + var ResultIsBoolean2 = delete ENUM1; + ~~~~~ +!!! error TS2698: The operand of a delete operator must be a property reference + + // enum type expressions + var ResultIsBoolean3 = delete ENUM1["A"]; + ~~~~~~~~~~ +!!! error TS2699: The operand of a delete operator cannot be a read-only property + var ResultIsBoolean4 = delete (ENUM[0] + ENUM1["B"]); + ~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2698: The operand of a delete operator must be a property reference + + // multiple delete operators + var ResultIsBoolean5 = delete delete ENUM; + ~~~~~~~~~~~ +!!! error TS2698: The operand of a delete operator must be a property reference + ~~~~ +!!! error TS2698: The operand of a delete operator must be a property reference + var ResultIsBoolean6 = delete delete delete (ENUM[0] + ENUM1["B"]); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2698: The operand of a delete operator must be a property reference + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2698: The operand of a delete operator must be a property reference + ~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2698: The operand of a delete operator must be a property reference + + // miss assignment operators + delete ENUM; + ~~~~ +!!! error TS2698: The operand of a delete operator must be a property reference + delete ENUM1; + ~~~~~ +!!! error TS2698: The operand of a delete operator must be a property reference + delete ENUM1.B; + ~~~~~~~ +!!! error TS2699: The operand of a delete operator cannot be a read-only property + delete ENUM, ENUM1; + ~~~~ +!!! error TS2698: The operand of a delete operator must be a property reference \ No newline at end of file diff --git a/tests/baselines/reference/deleteOperatorWithNumberType.errors.txt b/tests/baselines/reference/deleteOperatorWithNumberType.errors.txt new file mode 100644 index 0000000000000..bb35f3338b932 --- /dev/null +++ b/tests/baselines/reference/deleteOperatorWithNumberType.errors.txt @@ -0,0 +1,84 @@ +tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithNumberType.ts(22,31): error TS2698: The operand of a delete operator must be a property reference +tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithNumberType.ts(23,31): error TS2698: The operand of a delete operator must be a property reference +tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithNumberType.ts(24,31): error TS2698: The operand of a delete operator must be a property reference +tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithNumberType.ts(30,31): error TS2698: The operand of a delete operator must be a property reference +tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithNumberType.ts(31,32): error TS2698: The operand of a delete operator must be a property reference +tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithNumberType.ts(32,32): error TS2698: The operand of a delete operator must be a property reference +tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithNumberType.ts(35,32): error TS2698: The operand of a delete operator must be a property reference +tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithNumberType.ts(36,32): error TS2698: The operand of a delete operator must be a property reference +tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithNumberType.ts(36,39): error TS2698: The operand of a delete operator must be a property reference +tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithNumberType.ts(36,46): error TS2698: The operand of a delete operator must be a property reference +tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithNumberType.ts(39,8): error TS2698: The operand of a delete operator must be a property reference +tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithNumberType.ts(42,8): error TS2698: The operand of a delete operator must be a property reference + + +==== tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithNumberType.ts (12 errors) ==== + // delete operator on number type + var NUMBER: number; + var NUMBER1: number[] = [1, 2]; + + function foo(): number { return 1; } + + class A { + public a: number; + static foo() { return 1; } + } + module M { + export var n: number; + } + + var objA = new A(); + + // number type var + var ResultIsBoolean1 = delete NUMBER; + var ResultIsBoolean2 = delete NUMBER1; + + // number type literal + var ResultIsBoolean3 = delete 1; + ~ +!!! error TS2698: The operand of a delete operator must be a property reference + var ResultIsBoolean4 = delete { x: 1, y: 2}; + ~~~~~~~~~~~~~ +!!! error TS2698: The operand of a delete operator must be a property reference + var ResultIsBoolean5 = delete { x: 1, y: (n: number) => { return n; } }; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2698: The operand of a delete operator must be a property reference + + // number type expressions + var ResultIsBoolean6 = delete objA.a; + var ResultIsBoolean7 = delete M.n; + var ResultIsBoolean8 = delete NUMBER1[0]; + var ResultIsBoolean9 = delete foo(); + ~~~~~ +!!! error TS2698: The operand of a delete operator must be a property reference + var ResultIsBoolean10 = delete A.foo(); + ~~~~~~~ +!!! error TS2698: The operand of a delete operator must be a property reference + var ResultIsBoolean11 = delete (NUMBER + NUMBER); + ~~~~~~~~~~~~~~~~~ +!!! error TS2698: The operand of a delete operator must be a property reference + + // multiple delete operator + var ResultIsBoolean12 = delete delete NUMBER; + ~~~~~~~~~~~~~ +!!! error TS2698: The operand of a delete operator must be a property reference + var ResultIsBoolean13 = delete delete delete (NUMBER + NUMBER); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2698: The operand of a delete operator must be a property reference + ~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2698: The operand of a delete operator must be a property reference + ~~~~~~~~~~~~~~~~~ +!!! error TS2698: The operand of a delete operator must be a property reference + + // miss assignment operators + delete 1; + ~ +!!! error TS2698: The operand of a delete operator must be a property reference + delete NUMBER; + delete NUMBER1; + delete foo(); + ~~~~~ +!!! error TS2698: The operand of a delete operator must be a property reference + delete objA.a; + delete M.n; + delete objA.a, M.n; \ No newline at end of file diff --git a/tests/baselines/reference/deleteOperatorWithStringType.errors.txt b/tests/baselines/reference/deleteOperatorWithStringType.errors.txt new file mode 100644 index 0000000000000..9ffde0a8f97cb --- /dev/null +++ b/tests/baselines/reference/deleteOperatorWithStringType.errors.txt @@ -0,0 +1,86 @@ +tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithStringType.ts(22,31): error TS2698: The operand of a delete operator must be a property reference +tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithStringType.ts(23,31): error TS2698: The operand of a delete operator must be a property reference +tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithStringType.ts(24,31): error TS2698: The operand of a delete operator must be a property reference +tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithStringType.ts(30,31): error TS2698: The operand of a delete operator must be a property reference +tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithStringType.ts(31,32): error TS2698: The operand of a delete operator must be a property reference +tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithStringType.ts(32,32): error TS2698: The operand of a delete operator must be a property reference +tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithStringType.ts(33,32): error TS2698: The operand of a delete operator must be a property reference +tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithStringType.ts(36,32): error TS2698: The operand of a delete operator must be a property reference +tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithStringType.ts(37,32): error TS2698: The operand of a delete operator must be a property reference +tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithStringType.ts(37,39): error TS2698: The operand of a delete operator must be a property reference +tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithStringType.ts(37,46): error TS2698: The operand of a delete operator must be a property reference +tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithStringType.ts(40,8): error TS2698: The operand of a delete operator must be a property reference +tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithStringType.ts(43,8): error TS2698: The operand of a delete operator must be a property reference + + +==== tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithStringType.ts (13 errors) ==== + // delete operator on string type + var STRING: string; + var STRING1: string[] = ["", "abc"]; + + function foo(): string { return "abc"; } + + class A { + public a: string; + static foo() { return ""; } + } + module M { + export var n: string; + } + + var objA = new A(); + + // string type var + var ResultIsBoolean1 = delete STRING; + var ResultIsBoolean2 = delete STRING1; + + // string type literal + var ResultIsBoolean3 = delete ""; + ~~ +!!! error TS2698: The operand of a delete operator must be a property reference + var ResultIsBoolean4 = delete { x: "", y: "" }; + ~~~~~~~~~~~~~~~~ +!!! error TS2698: The operand of a delete operator must be a property reference + var ResultIsBoolean5 = delete { x: "", y: (s: string) => { return s; } }; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2698: The operand of a delete operator must be a property reference + + // string type expressions + var ResultIsBoolean6 = delete objA.a; + var ResultIsBoolean7 = delete M.n; + var ResultIsBoolean8 = delete STRING1[0]; + var ResultIsBoolean9 = delete foo(); + ~~~~~ +!!! error TS2698: The operand of a delete operator must be a property reference + var ResultIsBoolean10 = delete A.foo(); + ~~~~~~~ +!!! error TS2698: The operand of a delete operator must be a property reference + var ResultIsBoolean11 = delete (STRING + STRING); + ~~~~~~~~~~~~~~~~~ +!!! error TS2698: The operand of a delete operator must be a property reference + var ResultIsBoolean12 = delete STRING.charAt(0); + ~~~~~~~~~~~~~~~~ +!!! error TS2698: The operand of a delete operator must be a property reference + + // multiple delete operator + var ResultIsBoolean13 = delete delete STRING; + ~~~~~~~~~~~~~ +!!! error TS2698: The operand of a delete operator must be a property reference + var ResultIsBoolean14 = delete delete delete (STRING + STRING); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2698: The operand of a delete operator must be a property reference + ~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2698: The operand of a delete operator must be a property reference + ~~~~~~~~~~~~~~~~~ +!!! error TS2698: The operand of a delete operator must be a property reference + + // miss assignment operators + delete ""; + ~~ +!!! error TS2698: The operand of a delete operator must be a property reference + delete STRING; + delete STRING1; + delete foo(); + ~~~~~ +!!! error TS2698: The operand of a delete operator must be a property reference + delete objA.a,M.n; \ No newline at end of file diff --git a/tests/baselines/reference/deleteReadonly.errors.txt b/tests/baselines/reference/deleteReadonly.errors.txt new file mode 100644 index 0000000000000..c0fc3ee7dc396 --- /dev/null +++ b/tests/baselines/reference/deleteReadonly.errors.txt @@ -0,0 +1,28 @@ +tests/cases/compiler/deleteReadonly.ts(8,8): error TS2699: The operand of a delete operator cannot be a read-only property +tests/cases/compiler/deleteReadonly.ts(18,8): error TS2699: The operand of a delete operator cannot be a read-only property + + +==== tests/cases/compiler/deleteReadonly.ts (2 errors) ==== + interface A { + readonly b + } + var a: A = { + b: 123 + }; + + delete a.b; + ~~~ +!!! error TS2699: The operand of a delete operator cannot be a read-only property + + interface B { + readonly [k: string]: string + } + + var b: B = { + 'test': 'test' + }; + + delete b['test']; + ~~~~~~~~~ +!!! error TS2699: The operand of a delete operator cannot be a read-only property + \ No newline at end of file diff --git a/tests/baselines/reference/deleteReadonly.js b/tests/baselines/reference/deleteReadonly.js new file mode 100644 index 0000000000000..fd16bf270f69c --- /dev/null +++ b/tests/baselines/reference/deleteReadonly.js @@ -0,0 +1,30 @@ +//// [deleteReadonly.ts] +interface A { + readonly b +} +var a: A = { + b: 123 +}; + +delete a.b; + +interface B { + readonly [k: string]: string +} + +var b: B = { + 'test': 'test' +}; + +delete b['test']; + + +//// [deleteReadonly.js] +var a = { + b: 123 +}; +delete a.b; +var b = { + 'test': 'test' +}; +delete b['test']; diff --git a/tests/baselines/reference/exponentiationOperatorSyntaxError2.errors.txt b/tests/baselines/reference/exponentiationOperatorSyntaxError2.errors.txt index 134a883540efd..c08335f859889 100644 --- a/tests/baselines/reference/exponentiationOperatorSyntaxError2.errors.txt +++ b/tests/baselines/reference/exponentiationOperatorSyntaxError2.errors.txt @@ -1,19 +1,27 @@ tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorSyntaxError2.ts(5,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorSyntaxError2.ts(5,1): error TS17006: An unary expression with the 'delete' operator is not allowed in the left-hand side of an exponentiation expression. Consider enclosing the expression in parentheses. +tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorSyntaxError2.ts(5,8): error TS2698: The operand of a delete operator must be a property reference tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorSyntaxError2.ts(6,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorSyntaxError2.ts(6,1): error TS17006: An unary expression with the 'delete' operator is not allowed in the left-hand side of an exponentiation expression. Consider enclosing the expression in parentheses. +tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorSyntaxError2.ts(6,8): error TS2698: The operand of a delete operator must be a property reference tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorSyntaxError2.ts(7,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorSyntaxError2.ts(7,1): error TS17006: An unary expression with the 'delete' operator is not allowed in the left-hand side of an exponentiation expression. Consider enclosing the expression in parentheses. +tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorSyntaxError2.ts(7,8): error TS2698: The operand of a delete operator must be a property reference tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorSyntaxError2.ts(8,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorSyntaxError2.ts(8,1): error TS17006: An unary expression with the 'delete' operator is not allowed in the left-hand side of an exponentiation expression. Consider enclosing the expression in parentheses. +tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorSyntaxError2.ts(8,8): error TS2698: The operand of a delete operator must be a property reference tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorSyntaxError2.ts(11,6): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorSyntaxError2.ts(11,6): error TS17006: An unary expression with the 'delete' operator is not allowed in the left-hand side of an exponentiation expression. Consider enclosing the expression in parentheses. +tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorSyntaxError2.ts(11,13): error TS2698: The operand of a delete operator must be a property reference tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorSyntaxError2.ts(12,6): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorSyntaxError2.ts(12,6): error TS17006: An unary expression with the 'delete' operator is not allowed in the left-hand side of an exponentiation expression. Consider enclosing the expression in parentheses. +tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorSyntaxError2.ts(12,13): error TS2698: The operand of a delete operator must be a property reference tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorSyntaxError2.ts(13,6): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorSyntaxError2.ts(13,6): error TS17006: An unary expression with the 'delete' operator is not allowed in the left-hand side of an exponentiation expression. Consider enclosing the expression in parentheses. +tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorSyntaxError2.ts(13,13): error TS2698: The operand of a delete operator must be a property reference tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorSyntaxError2.ts(14,6): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorSyntaxError2.ts(14,6): error TS17006: An unary expression with the 'delete' operator is not allowed in the left-hand side of an exponentiation expression. Consider enclosing the expression in parentheses. +tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorSyntaxError2.ts(14,13): error TS2698: The operand of a delete operator must be a property reference tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorSyntaxError2.ts(16,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorSyntaxError2.ts(16,1): error TS17006: An unary expression with the 'typeof' operator is not allowed in the left-hand side of an exponentiation expression. Consider enclosing the expression in parentheses. tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorSyntaxError2.ts(17,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. @@ -81,7 +89,7 @@ tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorSyntaxE tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorSyntaxError2.ts(68,1): error TS17007: A type assertion expression is not allowed in the left-hand side of an exponentiation expression. Consider enclosing the expression in parentheses. -==== tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorSyntaxError2.ts (81 errors) ==== +==== tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorSyntaxError2.ts (89 errors) ==== // Error: early syntax error using ES7 SimpleUnaryExpression on left-hand side without () var temp: any; @@ -91,21 +99,29 @@ tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorSyntaxE !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~~~~~~~~~~ !!! error TS17006: An unary expression with the 'delete' operator is not allowed in the left-hand side of an exponentiation expression. Consider enclosing the expression in parentheses. + ~~~~~~ +!!! error TS2698: The operand of a delete operator must be a property reference delete ++temp ** 3; ~~~~~~~~~~~~~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~~~~~~~~~~ !!! error TS17006: An unary expression with the 'delete' operator is not allowed in the left-hand side of an exponentiation expression. Consider enclosing the expression in parentheses. + ~~~~~~ +!!! error TS2698: The operand of a delete operator must be a property reference delete temp-- ** 3; ~~~~~~~~~~~~~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~~~~~~~~~~ !!! error TS17006: An unary expression with the 'delete' operator is not allowed in the left-hand side of an exponentiation expression. Consider enclosing the expression in parentheses. + ~~~~~~ +!!! error TS2698: The operand of a delete operator must be a property reference delete temp++ ** 3; ~~~~~~~~~~~~~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~~~~~~~~~~ !!! error TS17006: An unary expression with the 'delete' operator is not allowed in the left-hand side of an exponentiation expression. Consider enclosing the expression in parentheses. + ~~~~~~ +!!! error TS2698: The operand of a delete operator must be a property reference 1 ** delete --temp ** 3; @@ -113,21 +129,29 @@ tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorSyntaxE !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~~~~~~~~~~ !!! error TS17006: An unary expression with the 'delete' operator is not allowed in the left-hand side of an exponentiation expression. Consider enclosing the expression in parentheses. + ~~~~~~ +!!! error TS2698: The operand of a delete operator must be a property reference 1 ** delete ++temp ** 3; ~~~~~~~~~~~~~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~~~~~~~~~~ !!! error TS17006: An unary expression with the 'delete' operator is not allowed in the left-hand side of an exponentiation expression. Consider enclosing the expression in parentheses. + ~~~~~~ +!!! error TS2698: The operand of a delete operator must be a property reference 1 ** delete temp-- ** 3; ~~~~~~~~~~~~~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~~~~~~~~~~ !!! error TS17006: An unary expression with the 'delete' operator is not allowed in the left-hand side of an exponentiation expression. Consider enclosing the expression in parentheses. + ~~~~~~ +!!! error TS2698: The operand of a delete operator must be a property reference 1 ** delete temp++ ** 3; ~~~~~~~~~~~~~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ~~~~~~~~~~~~~ !!! error TS17006: An unary expression with the 'delete' operator is not allowed in the left-hand side of an exponentiation expression. Consider enclosing the expression in parentheses. + ~~~~~~ +!!! error TS2698: The operand of a delete operator must be a property reference typeof --temp ** 3; ~~~~~~~~~~~~~ diff --git a/tests/baselines/reference/exponentiationOperatorWithInvalidSimpleUnaryExpressionOperands.errors.txt b/tests/baselines/reference/exponentiationOperatorWithInvalidSimpleUnaryExpressionOperands.errors.txt index f43cbd0042a04..24145c81158a4 100644 --- a/tests/baselines/reference/exponentiationOperatorWithInvalidSimpleUnaryExpressionOperands.errors.txt +++ b/tests/baselines/reference/exponentiationOperatorWithInvalidSimpleUnaryExpressionOperands.errors.txt @@ -19,16 +19,24 @@ tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithInv tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithInvalidSimpleUnaryExpressionOperands.ts(25,6): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithInvalidSimpleUnaryExpressionOperands.ts(26,6): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithInvalidSimpleUnaryExpressionOperands.ts(28,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithInvalidSimpleUnaryExpressionOperands.ts(28,9): error TS2698: The operand of a delete operator must be a property reference tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithInvalidSimpleUnaryExpressionOperands.ts(29,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithInvalidSimpleUnaryExpressionOperands.ts(29,9): error TS2698: The operand of a delete operator must be a property reference tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithInvalidSimpleUnaryExpressionOperands.ts(30,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithInvalidSimpleUnaryExpressionOperands.ts(30,9): error TS2698: The operand of a delete operator must be a property reference tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithInvalidSimpleUnaryExpressionOperands.ts(31,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithInvalidSimpleUnaryExpressionOperands.ts(31,9): error TS2698: The operand of a delete operator must be a property reference tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithInvalidSimpleUnaryExpressionOperands.ts(33,6): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithInvalidSimpleUnaryExpressionOperands.ts(33,14): error TS2698: The operand of a delete operator must be a property reference tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithInvalidSimpleUnaryExpressionOperands.ts(34,6): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithInvalidSimpleUnaryExpressionOperands.ts(34,14): error TS2698: The operand of a delete operator must be a property reference tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithInvalidSimpleUnaryExpressionOperands.ts(35,6): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithInvalidSimpleUnaryExpressionOperands.ts(35,14): error TS2698: The operand of a delete operator must be a property reference tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithInvalidSimpleUnaryExpressionOperands.ts(36,6): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithInvalidSimpleUnaryExpressionOperands.ts(36,14): error TS2698: The operand of a delete operator must be a property reference -==== tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithInvalidSimpleUnaryExpressionOperands.ts (28 errors) ==== +==== tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithInvalidSimpleUnaryExpressionOperands.ts (36 errors) ==== var temp: any; // Error: incorrect type on left-hand side @@ -99,25 +107,41 @@ tests/cases/conformance/es7/exponentiationOperator/exponentiationOperatorWithInv (delete --temp) ** 3; ~~~~~~~~~~~~~~~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + ~~~~~~ +!!! error TS2698: The operand of a delete operator must be a property reference (delete ++temp) ** 3; ~~~~~~~~~~~~~~~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + ~~~~~~ +!!! error TS2698: The operand of a delete operator must be a property reference (delete temp--) ** 3; ~~~~~~~~~~~~~~~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + ~~~~~~ +!!! error TS2698: The operand of a delete operator must be a property reference (delete temp++) ** 3; ~~~~~~~~~~~~~~~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + ~~~~~~ +!!! error TS2698: The operand of a delete operator must be a property reference 1 ** (delete --temp) ** 3; ~~~~~~~~~~~~~~~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + ~~~~~~ +!!! error TS2698: The operand of a delete operator must be a property reference 1 ** (delete ++temp) ** 3; ~~~~~~~~~~~~~~~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + ~~~~~~ +!!! error TS2698: The operand of a delete operator must be a property reference 1 ** (delete temp--) ** 3; ~~~~~~~~~~~~~~~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + ~~~~~~ +!!! error TS2698: The operand of a delete operator must be a property reference 1 ** (delete temp++) ** 3; ~~~~~~~~~~~~~~~ -!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. \ No newline at end of file +!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. + ~~~~~~ +!!! error TS2698: The operand of a delete operator must be a property reference \ No newline at end of file diff --git a/tests/baselines/reference/parserStrictMode16.errors.txt b/tests/baselines/reference/parserStrictMode16.errors.txt new file mode 100644 index 0000000000000..edcda2787e1fa --- /dev/null +++ b/tests/baselines/reference/parserStrictMode16.errors.txt @@ -0,0 +1,20 @@ +tests/cases/conformance/parser/ecmascript5/StrictMode/parserStrictMode16.ts(2,8): error TS2698: The operand of a delete operator must be a property reference +tests/cases/conformance/parser/ecmascript5/StrictMode/parserStrictMode16.ts(3,8): error TS2698: The operand of a delete operator must be a property reference +tests/cases/conformance/parser/ecmascript5/StrictMode/parserStrictMode16.ts(4,8): error TS2698: The operand of a delete operator must be a property reference +tests/cases/conformance/parser/ecmascript5/StrictMode/parserStrictMode16.ts(5,8): error TS2698: The operand of a delete operator must be a property reference + + +==== tests/cases/conformance/parser/ecmascript5/StrictMode/parserStrictMode16.ts (4 errors) ==== + "use strict"; + delete this; + ~~~~ +!!! error TS2698: The operand of a delete operator must be a property reference + delete 1; + ~ +!!! error TS2698: The operand of a delete operator must be a property reference + delete null; + ~~~~ +!!! error TS2698: The operand of a delete operator must be a property reference + delete "a"; + ~~~ +!!! error TS2698: The operand of a delete operator must be a property reference \ No newline at end of file diff --git a/tests/baselines/reference/symbolType3.errors.txt b/tests/baselines/reference/symbolType3.errors.txt index 7cc9e82b3b3da..bf7a5cf043800 100644 --- a/tests/baselines/reference/symbolType3.errors.txt +++ b/tests/baselines/reference/symbolType3.errors.txt @@ -1,3 +1,4 @@ +tests/cases/conformance/es6/Symbols/symbolType3.ts(2,8): error TS2699: The operand of a delete operator cannot be a read-only property tests/cases/conformance/es6/Symbols/symbolType3.ts(5,3): error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type. tests/cases/conformance/es6/Symbols/symbolType3.ts(6,3): error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type. tests/cases/conformance/es6/Symbols/symbolType3.ts(7,3): error TS2469: The '+' operator cannot be applied to type 'symbol'. @@ -6,9 +7,11 @@ tests/cases/conformance/es6/Symbols/symbolType3.ts(9,3): error TS2469: The '~' o tests/cases/conformance/es6/Symbols/symbolType3.ts(12,2): error TS2469: The '+' operator cannot be applied to type 'symbol'. -==== tests/cases/conformance/es6/Symbols/symbolType3.ts (6 errors) ==== +==== tests/cases/conformance/es6/Symbols/symbolType3.ts (7 errors) ==== var s = Symbol(); delete Symbol.iterator; + ~~~~~~~~~~~~~~~ +!!! error TS2699: The operand of a delete operator cannot be a read-only property void Symbol.toPrimitive; typeof Symbol.toStringTag; ++s; diff --git a/tests/baselines/reference/templateStringInDeleteExpression.errors.txt b/tests/baselines/reference/templateStringInDeleteExpression.errors.txt new file mode 100644 index 0000000000000..9218b93b6506f --- /dev/null +++ b/tests/baselines/reference/templateStringInDeleteExpression.errors.txt @@ -0,0 +1,7 @@ +tests/cases/conformance/es6/templates/templateStringInDeleteExpression.ts(1,8): error TS2698: The operand of a delete operator must be a property reference + + +==== tests/cases/conformance/es6/templates/templateStringInDeleteExpression.ts (1 errors) ==== + delete `abc${0}abc`; + ~~~~~~~~~~~~ +!!! error TS2698: The operand of a delete operator must be a property reference \ No newline at end of file diff --git a/tests/baselines/reference/templateStringInDeleteExpressionES6.errors.txt b/tests/baselines/reference/templateStringInDeleteExpressionES6.errors.txt new file mode 100644 index 0000000000000..9ea14c39f2b90 --- /dev/null +++ b/tests/baselines/reference/templateStringInDeleteExpressionES6.errors.txt @@ -0,0 +1,7 @@ +tests/cases/conformance/es6/templates/templateStringInDeleteExpressionES6.ts(1,8): error TS2698: The operand of a delete operator must be a property reference + + +==== tests/cases/conformance/es6/templates/templateStringInDeleteExpressionES6.ts (1 errors) ==== + delete `abc${0}abc`; + ~~~~~~~~~~~~ +!!! error TS2698: The operand of a delete operator must be a property reference \ No newline at end of file diff --git a/tests/cases/compiler/deleteReadonly.ts b/tests/cases/compiler/deleteReadonly.ts new file mode 100644 index 0000000000000..b7d35b3261b48 --- /dev/null +++ b/tests/cases/compiler/deleteReadonly.ts @@ -0,0 +1,18 @@ +interface A { + readonly b +} +var a: A = { + b: 123 +}; + +delete a.b; + +interface B { + readonly [k: string]: string +} + +var b: B = { + 'test': 'test' +}; + +delete b['test']; From 747f50f447a9f28b707c31607594a2e3ef13d058 Mon Sep 17 00:00:00 2001 From: Herrington Darkholme Date: Thu, 3 Nov 2016 13:19:16 +0800 Subject: [PATCH 3/4] migrate checkDelete to new property checking --- src/compiler/checker.ts | 15 +++++++++++---- src/compiler/types.ts | 1 - src/compiler/utilities.ts | 14 +++++++++++++- 3 files changed, 24 insertions(+), 6 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 7b4fd5803e321..b105721ba13c7 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -5777,7 +5777,7 @@ namespace ts { getIndexInfoOfType(objectType, IndexKind.String) || undefined; if (indexInfo) { - if (accessExpression && isAssignmentTarget(accessExpression) && indexInfo.isReadonly) { + if (accessExpression && indexInfo.isReadonly && (isAssignmentTarget(accessExpression) || isDeleteTarget(accessExpression))) { error(accessExpression, Diagnostics.Index_signature_in_type_0_only_permits_reading, typeToString(objectType)); return unknownType; } @@ -13550,9 +13550,16 @@ namespace ts { function checkDeleteExpression(node: DeleteExpression): Type { checkExpression(node.expression); - checkReferenceExpression(node.expression, - Diagnostics.The_operand_of_a_delete_operator_must_be_a_property_reference, - Diagnostics.The_operand_of_a_delete_operator_cannot_be_a_read_only_property); + const expr = skipParentheses(node.expression); + if (expr.kind !== SyntaxKind.PropertyAccessExpression && expr.kind !== SyntaxKind.ElementAccessExpression) { + error(expr, Diagnostics.The_operand_of_a_delete_operator_must_be_a_property_reference); + return booleanType; + } + const links = getNodeLinks(expr); + const symbol = getExportSymbolOfValueSymbolIfExported(links.resolvedSymbol); + if (symbol && isReadonlySymbol(symbol)) { + error(expr, Diagnostics.The_operand_of_a_delete_operator_cannot_be_a_read_only_property); + } return booleanType; } diff --git a/src/compiler/types.ts b/src/compiler/types.ts index e4c92c502a456..9e1b35c60da6f 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -2651,7 +2651,6 @@ namespace ts { resolvedType?: Type; // Cached type of type node resolvedSignature?: Signature; // Cached signature of signature node or call expression resolvedSymbol?: Symbol; // Cached name resolution result - resolvedIndexInfo?: IndexInfo; // Cached indexing info resolution result enumMemberValue?: number; // Constant value of enum member isVisible?: boolean; // Is this node visible hasReportedStatementInAmbientContext?: boolean; // Cache boolean if we report statements in ambient context diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 299f91be6625c..8e7b11ccf9115 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -1,4 +1,4 @@ -/// +/// /* @internal */ namespace ts { @@ -1666,6 +1666,18 @@ namespace ts { return getAssignmentTargetKind(node) !== AssignmentKind.None; } + // a node is delete target iff. it is PropertyAccessExpression/ElementAccessExpression with parentheses skipped + export function isDeleteTarget(node: Node): boolean { + if (node.kind !== SyntaxKind.PropertyAccessExpression && node.kind !== SyntaxKind.ElementAccessExpression) { + return false; + } + node = node.parent; + while (node && node.kind === SyntaxKind.ParenthesizedExpression) { + node = node.parent; + } + return node && node.kind === SyntaxKind.DeleteExpression; + } + export function isNodeDescendantOf(node: Node, ancestor: Node): boolean { while (node) { if (node === ancestor) return true; From 023d5caf3b4e51871ae73849be2dc60961c2012d Mon Sep 17 00:00:00 2001 From: Herrington Darkholme Date: Thu, 3 Nov 2016 13:25:58 +0800 Subject: [PATCH 4/4] accept new baseline --- .../computedPropertyNames3_ES5.errors.txt | 5 +- .../computedPropertyNames3_ES6.errors.txt | 5 +- .../controlFlowDeleteOperator.errors.txt | 23 ++++++++ .../reference/deleteOperator1.errors.txt | 13 ++++- .../deleteOperatorInStrictMode.errors.txt | 7 ++- ...deleteOperatorInvalidOperations.errors.txt | 11 +++- .../deleteOperatorWithAnyOtherType.errors.txt | 52 ++++++++++++++----- .../deleteOperatorWithBooleanType.errors.txt | 11 +++- .../deleteOperatorWithEnumType.errors.txt | 8 +-- .../deleteOperatorWithNumberType.errors.txt | 25 +++++++-- .../deleteOperatorWithStringType.errors.txt | 25 +++++++-- .../reference/deleteReadonly.errors.txt | 11 ++-- tests/baselines/reference/deleteReadonly.js | 3 ++ .../reference/parserStrictMode15.errors.txt | 7 ++- tests/cases/compiler/deleteReadonly.ts | 2 + 15 files changed, 167 insertions(+), 41 deletions(-) create mode 100644 tests/baselines/reference/controlFlowDeleteOperator.errors.txt diff --git a/tests/baselines/reference/computedPropertyNames3_ES5.errors.txt b/tests/baselines/reference/computedPropertyNames3_ES5.errors.txt index fd6f8e8bdc1c6..86e363c937789 100644 --- a/tests/baselines/reference/computedPropertyNames3_ES5.errors.txt +++ b/tests/baselines/reference/computedPropertyNames3_ES5.errors.txt @@ -2,12 +2,13 @@ tests/cases/conformance/es6/computedProperties/computedPropertyNames3_ES5.ts(4,1 tests/cases/conformance/es6/computedProperties/computedPropertyNames3_ES5.ts(5,9): error TS2378: A 'get' accessor must return a value. tests/cases/conformance/es6/computedProperties/computedPropertyNames3_ES5.ts(5,9): error TS2464: A computed property name must be of type 'string', 'number', 'symbol', or 'any'. tests/cases/conformance/es6/computedProperties/computedPropertyNames3_ES5.ts(5,17): error TS1102: 'delete' cannot be called on an identifier in strict mode. +tests/cases/conformance/es6/computedProperties/computedPropertyNames3_ES5.ts(5,17): error TS2698: The operand of a delete operator must be a property reference tests/cases/conformance/es6/computedProperties/computedPropertyNames3_ES5.ts(6,9): error TS2464: A computed property name must be of type 'string', 'number', 'symbol', or 'any'. tests/cases/conformance/es6/computedProperties/computedPropertyNames3_ES5.ts(7,16): error TS2378: A 'get' accessor must return a value. tests/cases/conformance/es6/computedProperties/computedPropertyNames3_ES5.ts(7,16): error TS2464: A computed property name must be of type 'string', 'number', 'symbol', or 'any'. -==== tests/cases/conformance/es6/computedProperties/computedPropertyNames3_ES5.ts (7 errors) ==== +==== tests/cases/conformance/es6/computedProperties/computedPropertyNames3_ES5.ts (8 errors) ==== var id; class C { [0 + 1]() { } @@ -21,6 +22,8 @@ tests/cases/conformance/es6/computedProperties/computedPropertyNames3_ES5.ts(7,1 !!! error TS2464: A computed property name must be of type 'string', 'number', 'symbol', or 'any'. ~~ !!! error TS1102: 'delete' cannot be called on an identifier in strict mode. + ~~ +!!! error TS2698: The operand of a delete operator must be a property reference set [[0, 1]](v) { } ~~~~~~~~ !!! error TS2464: A computed property name must be of type 'string', 'number', 'symbol', or 'any'. diff --git a/tests/baselines/reference/computedPropertyNames3_ES6.errors.txt b/tests/baselines/reference/computedPropertyNames3_ES6.errors.txt index 4299437777d5e..f287138661aaa 100644 --- a/tests/baselines/reference/computedPropertyNames3_ES6.errors.txt +++ b/tests/baselines/reference/computedPropertyNames3_ES6.errors.txt @@ -2,12 +2,13 @@ tests/cases/conformance/es6/computedProperties/computedPropertyNames3_ES6.ts(4,1 tests/cases/conformance/es6/computedProperties/computedPropertyNames3_ES6.ts(5,9): error TS2378: A 'get' accessor must return a value. tests/cases/conformance/es6/computedProperties/computedPropertyNames3_ES6.ts(5,9): error TS2464: A computed property name must be of type 'string', 'number', 'symbol', or 'any'. tests/cases/conformance/es6/computedProperties/computedPropertyNames3_ES6.ts(5,17): error TS1102: 'delete' cannot be called on an identifier in strict mode. +tests/cases/conformance/es6/computedProperties/computedPropertyNames3_ES6.ts(5,17): error TS2698: The operand of a delete operator must be a property reference tests/cases/conformance/es6/computedProperties/computedPropertyNames3_ES6.ts(6,9): error TS2464: A computed property name must be of type 'string', 'number', 'symbol', or 'any'. tests/cases/conformance/es6/computedProperties/computedPropertyNames3_ES6.ts(7,16): error TS2378: A 'get' accessor must return a value. tests/cases/conformance/es6/computedProperties/computedPropertyNames3_ES6.ts(7,16): error TS2464: A computed property name must be of type 'string', 'number', 'symbol', or 'any'. -==== tests/cases/conformance/es6/computedProperties/computedPropertyNames3_ES6.ts (7 errors) ==== +==== tests/cases/conformance/es6/computedProperties/computedPropertyNames3_ES6.ts (8 errors) ==== var id; class C { [0 + 1]() { } @@ -21,6 +22,8 @@ tests/cases/conformance/es6/computedProperties/computedPropertyNames3_ES6.ts(7,1 !!! error TS2464: A computed property name must be of type 'string', 'number', 'symbol', or 'any'. ~~ !!! error TS1102: 'delete' cannot be called on an identifier in strict mode. + ~~ +!!! error TS2698: The operand of a delete operator must be a property reference set [[0, 1]](v) { } ~~~~~~~~ !!! error TS2464: A computed property name must be of type 'string', 'number', 'symbol', or 'any'. diff --git a/tests/baselines/reference/controlFlowDeleteOperator.errors.txt b/tests/baselines/reference/controlFlowDeleteOperator.errors.txt new file mode 100644 index 0000000000000..720b368219c5d --- /dev/null +++ b/tests/baselines/reference/controlFlowDeleteOperator.errors.txt @@ -0,0 +1,23 @@ +tests/cases/conformance/controlFlow/controlFlowDeleteOperator.ts(15,12): error TS2698: The operand of a delete operator must be a property reference + + +==== tests/cases/conformance/controlFlow/controlFlowDeleteOperator.ts (1 errors) ==== + + function f() { + let x: { a?: number | string, b: number | string } = { b: 1 }; + x.a; + x.b; + x.a = 1; + x.b = 1; + x.a; + x.b; + delete x.a; + delete x.b; + x.a; + x.b; + x; + delete x; // No effect + ~ +!!! error TS2698: The operand of a delete operator must be a property reference + x; + } \ No newline at end of file diff --git a/tests/baselines/reference/deleteOperator1.errors.txt b/tests/baselines/reference/deleteOperator1.errors.txt index 964bdec9ea2ca..5cf2a63925d43 100644 --- a/tests/baselines/reference/deleteOperator1.errors.txt +++ b/tests/baselines/reference/deleteOperator1.errors.txt @@ -1,10 +1,19 @@ +tests/cases/compiler/deleteOperator1.ts(2,25): error TS2698: The operand of a delete operator must be a property reference +tests/cases/compiler/deleteOperator1.ts(3,21): error TS2698: The operand of a delete operator must be a property reference tests/cases/compiler/deleteOperator1.ts(4,5): error TS2322: Type 'boolean' is not assignable to type 'number'. +tests/cases/compiler/deleteOperator1.ts(4,24): error TS2698: The operand of a delete operator must be a property reference -==== tests/cases/compiler/deleteOperator1.ts (1 errors) ==== +==== tests/cases/compiler/deleteOperator1.ts (4 errors) ==== var a; var x: boolean = delete a; + ~ +!!! error TS2698: The operand of a delete operator must be a property reference var y: any = delete a; + ~ +!!! error TS2698: The operand of a delete operator must be a property reference var z: number = delete a; ~ -!!! error TS2322: Type 'boolean' is not assignable to type 'number'. \ No newline at end of file +!!! error TS2322: Type 'boolean' is not assignable to type 'number'. + ~ +!!! error TS2698: The operand of a delete operator must be a property reference \ No newline at end of file diff --git a/tests/baselines/reference/deleteOperatorInStrictMode.errors.txt b/tests/baselines/reference/deleteOperatorInStrictMode.errors.txt index 5952d8b829636..9d9e04d154c43 100644 --- a/tests/baselines/reference/deleteOperatorInStrictMode.errors.txt +++ b/tests/baselines/reference/deleteOperatorInStrictMode.errors.txt @@ -1,9 +1,12 @@ tests/cases/compiler/deleteOperatorInStrictMode.ts(3,8): error TS1102: 'delete' cannot be called on an identifier in strict mode. +tests/cases/compiler/deleteOperatorInStrictMode.ts(3,8): error TS2698: The operand of a delete operator must be a property reference -==== tests/cases/compiler/deleteOperatorInStrictMode.ts (1 errors) ==== +==== tests/cases/compiler/deleteOperatorInStrictMode.ts (2 errors) ==== "use strict" var a; delete a; ~ -!!! error TS1102: 'delete' cannot be called on an identifier in strict mode. \ No newline at end of file +!!! error TS1102: 'delete' cannot be called on an identifier in strict mode. + ~ +!!! error TS2698: The operand of a delete operator must be a property reference \ No newline at end of file diff --git a/tests/baselines/reference/deleteOperatorInvalidOperations.errors.txt b/tests/baselines/reference/deleteOperatorInvalidOperations.errors.txt index d50be713d0a9a..2ff0c764c5193 100644 --- a/tests/baselines/reference/deleteOperatorInvalidOperations.errors.txt +++ b/tests/baselines/reference/deleteOperatorInvalidOperations.errors.txt @@ -1,10 +1,13 @@ tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorInvalidOperations.ts(5,20): error TS1005: ',' expected. +tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorInvalidOperations.ts(5,26): error TS2698: The operand of a delete operator must be a property reference tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorInvalidOperations.ts(5,27): error TS1109: Expression expected. +tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorInvalidOperations.ts(8,22): error TS2698: The operand of a delete operator must be a property reference tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorInvalidOperations.ts(8,23): error TS1109: Expression expected. tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorInvalidOperations.ts(13,16): error TS1102: 'delete' cannot be called on an identifier in strict mode. +tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorInvalidOperations.ts(13,16): error TS2698: The operand of a delete operator must be a property reference -==== tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorInvalidOperations.ts (4 errors) ==== +==== tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorInvalidOperations.ts (7 errors) ==== // Unary operator delete var ANY; @@ -12,11 +15,15 @@ tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperator var BOOLEAN1 = ANY delete ; //expect error ~~~~~~ !!! error TS1005: ',' expected. + +!!! error TS2698: The operand of a delete operator must be a property reference ~ !!! error TS1109: Expression expected. // miss an operand var BOOLEAN2 = delete ; + +!!! error TS2698: The operand of a delete operator must be a property reference ~ !!! error TS1109: Expression expected. @@ -26,5 +33,7 @@ tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperator delete s; //expect error ~ !!! error TS1102: 'delete' cannot be called on an identifier in strict mode. + ~ +!!! error TS2698: The operand of a delete operator must be a property reference } } \ No newline at end of file diff --git a/tests/baselines/reference/deleteOperatorWithAnyOtherType.errors.txt b/tests/baselines/reference/deleteOperatorWithAnyOtherType.errors.txt index d92f1ffb1e763..64f41c84a0d94 100644 --- a/tests/baselines/reference/deleteOperatorWithAnyOtherType.errors.txt +++ b/tests/baselines/reference/deleteOperatorWithAnyOtherType.errors.txt @@ -1,23 +1,31 @@ +tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithAnyOtherType.ts(25,31): error TS2698: The operand of a delete operator must be a property reference +tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithAnyOtherType.ts(26,31): error TS2698: The operand of a delete operator must be a property reference tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithAnyOtherType.ts(27,31): error TS2698: The operand of a delete operator must be a property reference tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithAnyOtherType.ts(28,31): error TS2698: The operand of a delete operator must be a property reference +tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithAnyOtherType.ts(29,31): error TS2698: The operand of a delete operator must be a property reference +tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithAnyOtherType.ts(30,31): error TS2698: The operand of a delete operator must be a property reference tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithAnyOtherType.ts(33,31): error TS2698: The operand of a delete operator must be a property reference tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithAnyOtherType.ts(34,31): error TS2698: The operand of a delete operator must be a property reference tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithAnyOtherType.ts(42,32): error TS2698: The operand of a delete operator must be a property reference tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithAnyOtherType.ts(43,32): error TS2698: The operand of a delete operator must be a property reference -tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithAnyOtherType.ts(44,32): error TS2698: The operand of a delete operator must be a property reference -tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithAnyOtherType.ts(45,32): error TS2698: The operand of a delete operator must be a property reference +tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithAnyOtherType.ts(44,33): error TS2698: The operand of a delete operator must be a property reference tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithAnyOtherType.ts(45,33): error TS2365: Operator '+' cannot be applied to types 'undefined' and 'undefined'. -tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithAnyOtherType.ts(46,32): error TS2698: The operand of a delete operator must be a property reference +tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithAnyOtherType.ts(45,33): error TS2698: The operand of a delete operator must be a property reference tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithAnyOtherType.ts(46,33): error TS2365: Operator '+' cannot be applied to types 'null' and 'null'. -tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithAnyOtherType.ts(47,32): error TS2698: The operand of a delete operator must be a property reference +tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithAnyOtherType.ts(46,33): error TS2698: The operand of a delete operator must be a property reference tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithAnyOtherType.ts(47,33): error TS2365: Operator '+' cannot be applied to types 'undefined' and 'undefined'. +tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithAnyOtherType.ts(47,33): error TS2698: The operand of a delete operator must be a property reference tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithAnyOtherType.ts(50,32): error TS2698: The operand of a delete operator must be a property reference +tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithAnyOtherType.ts(50,39): error TS2698: The operand of a delete operator must be a property reference tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithAnyOtherType.ts(51,32): error TS2698: The operand of a delete operator must be a property reference tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithAnyOtherType.ts(51,39): error TS2698: The operand of a delete operator must be a property reference -tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithAnyOtherType.ts(51,46): error TS2698: The operand of a delete operator must be a property reference +tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithAnyOtherType.ts(51,47): error TS2698: The operand of a delete operator must be a property reference +tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithAnyOtherType.ts(54,8): error TS2698: The operand of a delete operator must be a property reference +tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithAnyOtherType.ts(55,8): error TS2698: The operand of a delete operator must be a property reference +tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithAnyOtherType.ts(57,8): error TS2698: The operand of a delete operator must be a property reference -==== tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithAnyOtherType.ts (17 errors) ==== +==== tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithAnyOtherType.ts (25 errors) ==== // delete operator on any type var ANY: any; @@ -43,7 +51,11 @@ tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperator // any type var var ResultIsBoolean1 = delete ANY1; + ~~~~ +!!! error TS2698: The operand of a delete operator must be a property reference var ResultIsBoolean2 = delete ANY2; + ~~~~ +!!! error TS2698: The operand of a delete operator must be a property reference var ResultIsBoolean3 = delete A; ~ !!! error TS2698: The operand of a delete operator must be a property reference @@ -51,7 +63,11 @@ tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperator ~ !!! error TS2698: The operand of a delete operator must be a property reference var ResultIsBoolean5 = delete obj; + ~~~ +!!! error TS2698: The operand of a delete operator must be a property reference var ResultIsBoolean6 = delete obj1; + ~~~~ +!!! error TS2698: The operand of a delete operator must be a property reference // any type literal var ResultIsBoolean7 = delete undefined; @@ -74,41 +90,49 @@ tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperator ~~~~~~~ !!! error TS2698: The operand of a delete operator must be a property reference var ResultIsBoolean16 = delete (ANY + ANY1); - ~~~~~~~~~~~~ + ~~~~~~~~~~ !!! error TS2698: The operand of a delete operator must be a property reference var ResultIsBoolean17 = delete (null + undefined); - ~~~~~~~~~~~~~~~~~~ -!!! error TS2698: The operand of a delete operator must be a property reference ~~~~~~~~~~~~~~~~ !!! error TS2365: Operator '+' cannot be applied to types 'undefined' and 'undefined'. - var ResultIsBoolean18 = delete (null + null); - ~~~~~~~~~~~~~ + ~~~~~~~~~~~~~~~~ !!! error TS2698: The operand of a delete operator must be a property reference + var ResultIsBoolean18 = delete (null + null); ~~~~~~~~~~~ !!! error TS2365: Operator '+' cannot be applied to types 'null' and 'null'. - var ResultIsBoolean19 = delete (undefined + undefined); - ~~~~~~~~~~~~~~~~~~~~~~~ + ~~~~~~~~~~~ !!! error TS2698: The operand of a delete operator must be a property reference + var ResultIsBoolean19 = delete (undefined + undefined); ~~~~~~~~~~~~~~~~~~~~~ !!! error TS2365: Operator '+' cannot be applied to types 'undefined' and 'undefined'. + ~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2698: The operand of a delete operator must be a property reference // multiple delete operators var ResultIsBoolean20 = delete delete ANY; ~~~~~~~~~~ +!!! error TS2698: The operand of a delete operator must be a property reference + ~~~ !!! error TS2698: The operand of a delete operator must be a property reference var ResultIsBoolean21 = delete delete delete (ANY + ANY1); ~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS2698: The operand of a delete operator must be a property reference ~~~~~~~~~~~~~~~~~~~ !!! error TS2698: The operand of a delete operator must be a property reference - ~~~~~~~~~~~~ + ~~~~~~~~~~ !!! error TS2698: The operand of a delete operator must be a property reference // miss assignment operators delete ANY; + ~~~ +!!! error TS2698: The operand of a delete operator must be a property reference delete ANY1; + ~~~~ +!!! error TS2698: The operand of a delete operator must be a property reference delete ANY2[0]; delete ANY, ANY1; + ~~~ +!!! error TS2698: The operand of a delete operator must be a property reference delete obj1.x; delete obj1.y; delete objA.a; diff --git a/tests/baselines/reference/deleteOperatorWithBooleanType.errors.txt b/tests/baselines/reference/deleteOperatorWithBooleanType.errors.txt index 3f653671e2ec8..5d65f8f718ab0 100644 --- a/tests/baselines/reference/deleteOperatorWithBooleanType.errors.txt +++ b/tests/baselines/reference/deleteOperatorWithBooleanType.errors.txt @@ -1,14 +1,17 @@ +tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithBooleanType.ts(17,31): error TS2698: The operand of a delete operator must be a property reference tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithBooleanType.ts(20,31): error TS2698: The operand of a delete operator must be a property reference tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithBooleanType.ts(21,31): error TS2698: The operand of a delete operator must be a property reference tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithBooleanType.ts(26,31): error TS2698: The operand of a delete operator must be a property reference tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithBooleanType.ts(27,31): error TS2698: The operand of a delete operator must be a property reference tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithBooleanType.ts(30,31): error TS2698: The operand of a delete operator must be a property reference +tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithBooleanType.ts(30,38): error TS2698: The operand of a delete operator must be a property reference tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithBooleanType.ts(33,8): error TS2698: The operand of a delete operator must be a property reference +tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithBooleanType.ts(34,8): error TS2698: The operand of a delete operator must be a property reference tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithBooleanType.ts(35,8): error TS2698: The operand of a delete operator must be a property reference tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithBooleanType.ts(36,8): error TS2698: The operand of a delete operator must be a property reference -==== tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithBooleanType.ts (8 errors) ==== +==== tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithBooleanType.ts (11 errors) ==== // delete operator on boolean type var BOOLEAN: boolean; @@ -26,6 +29,8 @@ tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperator // boolean type var var ResultIsBoolean1 = delete BOOLEAN; + ~~~~~~~ +!!! error TS2698: The operand of a delete operator must be a property reference // boolean type literal var ResultIsBoolean2 = delete true; @@ -49,12 +54,16 @@ tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperator var ResultIsBoolean8 = delete delete BOOLEAN; ~~~~~~~~~~~~~~ !!! error TS2698: The operand of a delete operator must be a property reference + ~~~~~~~ +!!! error TS2698: The operand of a delete operator must be a property reference // miss assignment operators delete true; ~~~~ !!! error TS2698: The operand of a delete operator must be a property reference delete BOOLEAN; + ~~~~~~~ +!!! error TS2698: The operand of a delete operator must be a property reference delete foo(); ~~~~~ !!! error TS2698: The operand of a delete operator must be a property reference diff --git a/tests/baselines/reference/deleteOperatorWithEnumType.errors.txt b/tests/baselines/reference/deleteOperatorWithEnumType.errors.txt index 103070d15dc8e..f515e3b7b7071 100644 --- a/tests/baselines/reference/deleteOperatorWithEnumType.errors.txt +++ b/tests/baselines/reference/deleteOperatorWithEnumType.errors.txt @@ -1,12 +1,12 @@ tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithEnumType.ts(7,31): error TS2698: The operand of a delete operator must be a property reference tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithEnumType.ts(8,31): error TS2698: The operand of a delete operator must be a property reference tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithEnumType.ts(11,31): error TS2699: The operand of a delete operator cannot be a read-only property -tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithEnumType.ts(12,31): error TS2698: The operand of a delete operator must be a property reference +tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithEnumType.ts(12,32): error TS2698: The operand of a delete operator must be a property reference tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithEnumType.ts(15,31): error TS2698: The operand of a delete operator must be a property reference tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithEnumType.ts(15,38): error TS2698: The operand of a delete operator must be a property reference tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithEnumType.ts(16,31): error TS2698: The operand of a delete operator must be a property reference tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithEnumType.ts(16,38): error TS2698: The operand of a delete operator must be a property reference -tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithEnumType.ts(16,45): error TS2698: The operand of a delete operator must be a property reference +tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithEnumType.ts(16,46): error TS2698: The operand of a delete operator must be a property reference tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithEnumType.ts(19,8): error TS2698: The operand of a delete operator must be a property reference tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithEnumType.ts(20,8): error TS2698: The operand of a delete operator must be a property reference tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithEnumType.ts(21,8): error TS2699: The operand of a delete operator cannot be a read-only property @@ -32,7 +32,7 @@ tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperator ~~~~~~~~~~ !!! error TS2699: The operand of a delete operator cannot be a read-only property var ResultIsBoolean4 = delete (ENUM[0] + ENUM1["B"]); - ~~~~~~~~~~~~~~~~~~~~~~ + ~~~~~~~~~~~~~~~~~~~~ !!! error TS2698: The operand of a delete operator must be a property reference // multiple delete operators @@ -46,7 +46,7 @@ tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperator !!! error TS2698: The operand of a delete operator must be a property reference ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS2698: The operand of a delete operator must be a property reference - ~~~~~~~~~~~~~~~~~~~~~~ + ~~~~~~~~~~~~~~~~~~~~ !!! error TS2698: The operand of a delete operator must be a property reference // miss assignment operators diff --git a/tests/baselines/reference/deleteOperatorWithNumberType.errors.txt b/tests/baselines/reference/deleteOperatorWithNumberType.errors.txt index bb35f3338b932..f908bee9686c5 100644 --- a/tests/baselines/reference/deleteOperatorWithNumberType.errors.txt +++ b/tests/baselines/reference/deleteOperatorWithNumberType.errors.txt @@ -1,18 +1,23 @@ +tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithNumberType.ts(18,31): error TS2698: The operand of a delete operator must be a property reference +tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithNumberType.ts(19,31): error TS2698: The operand of a delete operator must be a property reference tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithNumberType.ts(22,31): error TS2698: The operand of a delete operator must be a property reference tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithNumberType.ts(23,31): error TS2698: The operand of a delete operator must be a property reference tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithNumberType.ts(24,31): error TS2698: The operand of a delete operator must be a property reference tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithNumberType.ts(30,31): error TS2698: The operand of a delete operator must be a property reference tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithNumberType.ts(31,32): error TS2698: The operand of a delete operator must be a property reference -tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithNumberType.ts(32,32): error TS2698: The operand of a delete operator must be a property reference +tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithNumberType.ts(32,33): error TS2698: The operand of a delete operator must be a property reference tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithNumberType.ts(35,32): error TS2698: The operand of a delete operator must be a property reference +tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithNumberType.ts(35,39): error TS2698: The operand of a delete operator must be a property reference tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithNumberType.ts(36,32): error TS2698: The operand of a delete operator must be a property reference tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithNumberType.ts(36,39): error TS2698: The operand of a delete operator must be a property reference -tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithNumberType.ts(36,46): error TS2698: The operand of a delete operator must be a property reference +tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithNumberType.ts(36,47): error TS2698: The operand of a delete operator must be a property reference tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithNumberType.ts(39,8): error TS2698: The operand of a delete operator must be a property reference +tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithNumberType.ts(40,8): error TS2698: The operand of a delete operator must be a property reference +tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithNumberType.ts(41,8): error TS2698: The operand of a delete operator must be a property reference tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithNumberType.ts(42,8): error TS2698: The operand of a delete operator must be a property reference -==== tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithNumberType.ts (12 errors) ==== +==== tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithNumberType.ts (17 errors) ==== // delete operator on number type var NUMBER: number; var NUMBER1: number[] = [1, 2]; @@ -31,7 +36,11 @@ tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperator // number type var var ResultIsBoolean1 = delete NUMBER; + ~~~~~~ +!!! error TS2698: The operand of a delete operator must be a property reference var ResultIsBoolean2 = delete NUMBER1; + ~~~~~~~ +!!! error TS2698: The operand of a delete operator must be a property reference // number type literal var ResultIsBoolean3 = delete 1; @@ -55,19 +64,21 @@ tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperator ~~~~~~~ !!! error TS2698: The operand of a delete operator must be a property reference var ResultIsBoolean11 = delete (NUMBER + NUMBER); - ~~~~~~~~~~~~~~~~~ + ~~~~~~~~~~~~~~~ !!! error TS2698: The operand of a delete operator must be a property reference // multiple delete operator var ResultIsBoolean12 = delete delete NUMBER; ~~~~~~~~~~~~~ +!!! error TS2698: The operand of a delete operator must be a property reference + ~~~~~~ !!! error TS2698: The operand of a delete operator must be a property reference var ResultIsBoolean13 = delete delete delete (NUMBER + NUMBER); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS2698: The operand of a delete operator must be a property reference ~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS2698: The operand of a delete operator must be a property reference - ~~~~~~~~~~~~~~~~~ + ~~~~~~~~~~~~~~~ !!! error TS2698: The operand of a delete operator must be a property reference // miss assignment operators @@ -75,7 +86,11 @@ tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperator ~ !!! error TS2698: The operand of a delete operator must be a property reference delete NUMBER; + ~~~~~~ +!!! error TS2698: The operand of a delete operator must be a property reference delete NUMBER1; + ~~~~~~~ +!!! error TS2698: The operand of a delete operator must be a property reference delete foo(); ~~~~~ !!! error TS2698: The operand of a delete operator must be a property reference diff --git a/tests/baselines/reference/deleteOperatorWithStringType.errors.txt b/tests/baselines/reference/deleteOperatorWithStringType.errors.txt index 9ffde0a8f97cb..c15e6b47433f9 100644 --- a/tests/baselines/reference/deleteOperatorWithStringType.errors.txt +++ b/tests/baselines/reference/deleteOperatorWithStringType.errors.txt @@ -1,19 +1,24 @@ +tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithStringType.ts(18,31): error TS2698: The operand of a delete operator must be a property reference +tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithStringType.ts(19,31): error TS2698: The operand of a delete operator must be a property reference tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithStringType.ts(22,31): error TS2698: The operand of a delete operator must be a property reference tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithStringType.ts(23,31): error TS2698: The operand of a delete operator must be a property reference tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithStringType.ts(24,31): error TS2698: The operand of a delete operator must be a property reference tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithStringType.ts(30,31): error TS2698: The operand of a delete operator must be a property reference tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithStringType.ts(31,32): error TS2698: The operand of a delete operator must be a property reference -tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithStringType.ts(32,32): error TS2698: The operand of a delete operator must be a property reference +tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithStringType.ts(32,33): error TS2698: The operand of a delete operator must be a property reference tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithStringType.ts(33,32): error TS2698: The operand of a delete operator must be a property reference tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithStringType.ts(36,32): error TS2698: The operand of a delete operator must be a property reference +tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithStringType.ts(36,39): error TS2698: The operand of a delete operator must be a property reference tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithStringType.ts(37,32): error TS2698: The operand of a delete operator must be a property reference tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithStringType.ts(37,39): error TS2698: The operand of a delete operator must be a property reference -tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithStringType.ts(37,46): error TS2698: The operand of a delete operator must be a property reference +tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithStringType.ts(37,47): error TS2698: The operand of a delete operator must be a property reference tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithStringType.ts(40,8): error TS2698: The operand of a delete operator must be a property reference +tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithStringType.ts(41,8): error TS2698: The operand of a delete operator must be a property reference +tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithStringType.ts(42,8): error TS2698: The operand of a delete operator must be a property reference tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithStringType.ts(43,8): error TS2698: The operand of a delete operator must be a property reference -==== tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithStringType.ts (13 errors) ==== +==== tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithStringType.ts (18 errors) ==== // delete operator on string type var STRING: string; var STRING1: string[] = ["", "abc"]; @@ -32,7 +37,11 @@ tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperator // string type var var ResultIsBoolean1 = delete STRING; + ~~~~~~ +!!! error TS2698: The operand of a delete operator must be a property reference var ResultIsBoolean2 = delete STRING1; + ~~~~~~~ +!!! error TS2698: The operand of a delete operator must be a property reference // string type literal var ResultIsBoolean3 = delete ""; @@ -56,7 +65,7 @@ tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperator ~~~~~~~ !!! error TS2698: The operand of a delete operator must be a property reference var ResultIsBoolean11 = delete (STRING + STRING); - ~~~~~~~~~~~~~~~~~ + ~~~~~~~~~~~~~~~ !!! error TS2698: The operand of a delete operator must be a property reference var ResultIsBoolean12 = delete STRING.charAt(0); ~~~~~~~~~~~~~~~~ @@ -65,13 +74,15 @@ tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperator // multiple delete operator var ResultIsBoolean13 = delete delete STRING; ~~~~~~~~~~~~~ +!!! error TS2698: The operand of a delete operator must be a property reference + ~~~~~~ !!! error TS2698: The operand of a delete operator must be a property reference var ResultIsBoolean14 = delete delete delete (STRING + STRING); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS2698: The operand of a delete operator must be a property reference ~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS2698: The operand of a delete operator must be a property reference - ~~~~~~~~~~~~~~~~~ + ~~~~~~~~~~~~~~~ !!! error TS2698: The operand of a delete operator must be a property reference // miss assignment operators @@ -79,7 +90,11 @@ tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperator ~~ !!! error TS2698: The operand of a delete operator must be a property reference delete STRING; + ~~~~~~ +!!! error TS2698: The operand of a delete operator must be a property reference delete STRING1; + ~~~~~~~ +!!! error TS2698: The operand of a delete operator must be a property reference delete foo(); ~~~~~ !!! error TS2698: The operand of a delete operator must be a property reference diff --git a/tests/baselines/reference/deleteReadonly.errors.txt b/tests/baselines/reference/deleteReadonly.errors.txt index c0fc3ee7dc396..1846f139d86a3 100644 --- a/tests/baselines/reference/deleteReadonly.errors.txt +++ b/tests/baselines/reference/deleteReadonly.errors.txt @@ -1,8 +1,9 @@ tests/cases/compiler/deleteReadonly.ts(8,8): error TS2699: The operand of a delete operator cannot be a read-only property -tests/cases/compiler/deleteReadonly.ts(18,8): error TS2699: The operand of a delete operator cannot be a read-only property +tests/cases/compiler/deleteReadonly.ts(18,8): error TS2542: Index signature in type 'B' only permits reading. +tests/cases/compiler/deleteReadonly.ts(20,12): error TS2542: Index signature in type 'B' only permits reading. -==== tests/cases/compiler/deleteReadonly.ts (2 errors) ==== +==== tests/cases/compiler/deleteReadonly.ts (3 errors) ==== interface A { readonly b } @@ -24,5 +25,9 @@ tests/cases/compiler/deleteReadonly.ts(18,8): error TS2699: The operand of a del delete b['test']; ~~~~~~~~~ -!!! error TS2699: The operand of a delete operator cannot be a read-only property +!!! error TS2542: Index signature in type 'B' only permits reading. + + delete ((((b['test'])))); + ~~~~~~~~~ +!!! error TS2542: Index signature in type 'B' only permits reading. \ No newline at end of file diff --git a/tests/baselines/reference/deleteReadonly.js b/tests/baselines/reference/deleteReadonly.js index fd16bf270f69c..bdfdf155546de 100644 --- a/tests/baselines/reference/deleteReadonly.js +++ b/tests/baselines/reference/deleteReadonly.js @@ -17,6 +17,8 @@ var b: B = { }; delete b['test']; + +delete ((((b['test'])))); //// [deleteReadonly.js] @@ -28,3 +30,4 @@ var b = { 'test': 'test' }; delete b['test']; +delete ((((b['test'])))); diff --git a/tests/baselines/reference/parserStrictMode15.errors.txt b/tests/baselines/reference/parserStrictMode15.errors.txt index 0bcaaf337860e..8217590123616 100644 --- a/tests/baselines/reference/parserStrictMode15.errors.txt +++ b/tests/baselines/reference/parserStrictMode15.errors.txt @@ -1,11 +1,14 @@ tests/cases/conformance/parser/ecmascript5/StrictMode/parserStrictMode15.ts(2,8): error TS1102: 'delete' cannot be called on an identifier in strict mode. tests/cases/conformance/parser/ecmascript5/StrictMode/parserStrictMode15.ts(2,8): error TS2304: Cannot find name 'a'. +tests/cases/conformance/parser/ecmascript5/StrictMode/parserStrictMode15.ts(2,8): error TS2698: The operand of a delete operator must be a property reference -==== tests/cases/conformance/parser/ecmascript5/StrictMode/parserStrictMode15.ts (2 errors) ==== +==== tests/cases/conformance/parser/ecmascript5/StrictMode/parserStrictMode15.ts (3 errors) ==== "use strict"; delete a; ~ !!! error TS1102: 'delete' cannot be called on an identifier in strict mode. ~ -!!! error TS2304: Cannot find name 'a'. \ No newline at end of file +!!! error TS2304: Cannot find name 'a'. + ~ +!!! error TS2698: The operand of a delete operator must be a property reference \ No newline at end of file diff --git a/tests/cases/compiler/deleteReadonly.ts b/tests/cases/compiler/deleteReadonly.ts index b7d35b3261b48..cdab3f2eb234d 100644 --- a/tests/cases/compiler/deleteReadonly.ts +++ b/tests/cases/compiler/deleteReadonly.ts @@ -16,3 +16,5 @@ var b: B = { }; delete b['test']; + +delete ((((b['test']))));