-
Notifications
You must be signed in to change notification settings - Fork 12.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11990 from HerringtonDarkholme/delete-readonly
fix #11480, disallow delete operator on readonly property or index signature
- Loading branch information
Showing
28 changed files
with
774 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
tests/baselines/reference/await_unaryExpression_es2017_1.errors.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
tests/cases/conformance/async/es2017/await_unaryExpression_es2017_1.ts(7,12): error TS2703: The operand of a delete operator must be a property reference | ||
tests/cases/conformance/async/es2017/await_unaryExpression_es2017_1.ts(11,12): error TS2703: 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 TS2703: The operand of a delete operator must be a property reference | ||
} | ||
|
||
async function bar2() { | ||
delete await 42; // OK | ||
~~~~~~~~ | ||
!!! error TS2703: The operand of a delete operator must be a property reference | ||
} | ||
|
||
async function bar3() { | ||
void await 42; | ||
} | ||
|
||
async function bar4() { | ||
+await 42; | ||
} |
21 changes: 21 additions & 0 deletions
21
tests/baselines/reference/await_unaryExpression_es2017_2.errors.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
tests/cases/conformance/async/es2017/await_unaryExpression_es2017_2.ts(3,12): error TS2703: The operand of a delete operator must be a property reference | ||
tests/cases/conformance/async/es2017/await_unaryExpression_es2017_2.ts(7,12): error TS2703: 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 TS2703: The operand of a delete operator must be a property reference | ||
} | ||
|
||
async function bar2() { | ||
delete await 42; | ||
~~~~~~~~ | ||
!!! error TS2703: The operand of a delete operator must be a property reference | ||
} | ||
|
||
async function bar3() { | ||
void await 42; | ||
} |
29 changes: 29 additions & 0 deletions
29
tests/baselines/reference/await_unaryExpression_es6_1.errors.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
tests/cases/conformance/async/es6/await_unaryExpression_es6_1.ts(7,12): error TS2703: The operand of a delete operator must be a property reference | ||
tests/cases/conformance/async/es6/await_unaryExpression_es6_1.ts(11,12): error TS2703: 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 TS2703: The operand of a delete operator must be a property reference | ||
} | ||
|
||
async function bar2() { | ||
delete await 42; // OK | ||
~~~~~~~~ | ||
!!! error TS2703: The operand of a delete operator must be a property reference | ||
} | ||
|
||
async function bar3() { | ||
void await 42; | ||
} | ||
|
||
async function bar4() { | ||
+await 42; | ||
} |
21 changes: 21 additions & 0 deletions
21
tests/baselines/reference/await_unaryExpression_es6_2.errors.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
tests/cases/conformance/async/es6/await_unaryExpression_es6_2.ts(3,12): error TS2703: The operand of a delete operator must be a property reference | ||
tests/cases/conformance/async/es6/await_unaryExpression_es6_2.ts(7,12): error TS2703: 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 TS2703: The operand of a delete operator must be a property reference | ||
} | ||
|
||
async function bar2() { | ||
delete await 42; | ||
~~~~~~~~ | ||
!!! error TS2703: The operand of a delete operator must be a property reference | ||
} | ||
|
||
async function bar3() { | ||
void await 42; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
tests/baselines/reference/controlFlowDeleteOperator.errors.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
tests/cases/conformance/controlFlow/controlFlowDeleteOperator.ts(15,12): error TS2703: 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 TS2703: The operand of a delete operator must be a property reference | ||
x; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,19 @@ | ||
tests/cases/compiler/deleteOperator1.ts(2,25): error TS2703: The operand of a delete operator must be a property reference | ||
tests/cases/compiler/deleteOperator1.ts(3,21): error TS2703: 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 TS2703: 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 TS2703: The operand of a delete operator must be a property reference | ||
var y: any = delete a; | ||
~ | ||
!!! error TS2703: 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'. | ||
!!! error TS2322: Type 'boolean' is not assignable to type 'number'. | ||
~ | ||
!!! error TS2703: The operand of a delete operator must be a property reference |
7 changes: 5 additions & 2 deletions
7
tests/baselines/reference/deleteOperatorInStrictMode.errors.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 TS2703: 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. | ||
!!! error TS1102: 'delete' cannot be called on an identifier in strict mode. | ||
~ | ||
!!! error TS2703: The operand of a delete operator must be a property reference |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.