Skip to content

Commit 1b8c68d

Browse files
Revert "Add check for delete expression must be optional (#37921)" (#38154)
This reverts commit 39beb1d.
1 parent 84c83da commit 1b8c68d

14 files changed

+4
-856
lines changed

src/compiler/checker.ts

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -27682,23 +27682,12 @@ namespace ts {
2768227682
}
2768327683
const links = getNodeLinks(expr);
2768427684
const symbol = getExportSymbolOfValueSymbolIfExported(links.resolvedSymbol);
27685-
if (symbol) {
27686-
if (isReadonlySymbol(symbol)) {
27687-
error(expr, Diagnostics.The_operand_of_a_delete_operator_cannot_be_a_read_only_property);
27688-
}
27689-
27690-
checkDeleteExpressionMustBeOptional(expr, getTypeOfSymbol(symbol));
27685+
if (symbol && isReadonlySymbol(symbol)) {
27686+
error(expr, Diagnostics.The_operand_of_a_delete_operator_cannot_be_a_read_only_property);
2769127687
}
2769227688
return booleanType;
2769327689
}
2769427690

27695-
function checkDeleteExpressionMustBeOptional(expr: AccessExpression, type: Type) {
27696-
const AnyOrUnknownOrNeverFlags = TypeFlags.AnyOrUnknown | TypeFlags.Never;
27697-
if (strictNullChecks && !(type.flags & AnyOrUnknownOrNeverFlags) && !(getFalsyFlags(type) & TypeFlags.Undefined)) {
27698-
error(expr, Diagnostics.The_operand_of_a_delete_operator_must_be_optional);
27699-
}
27700-
}
27701-
2770227691
function checkTypeOfExpression(node: TypeOfExpression): Type {
2770327692
checkExpression(node.expression);
2770427693
return typeofType;

src/compiler/diagnosticMessages.json

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2963,10 +2963,6 @@
29632963
"category": "Error",
29642964
"code": 2789
29652965
},
2966-
"The operand of a 'delete' operator must be optional.": {
2967-
"category": "Error",
2968-
"code": 2790
2969-
},
29702966

29712967
"Import declaration '{0}' is using private name '{1}'.": {
29722968
"category": "Error",

tests/baselines/reference/controlFlowDeleteOperator.errors.txt

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
tests/cases/conformance/controlFlow/controlFlowDeleteOperator.ts(10,12): error TS2790: The operand of a 'delete' operator must be optional.
21
tests/cases/conformance/controlFlow/controlFlowDeleteOperator.ts(14,12): error TS2703: The operand of a 'delete' operator must be a property reference.
32

43

5-
==== tests/cases/conformance/controlFlow/controlFlowDeleteOperator.ts (2 errors) ====
4+
==== tests/cases/conformance/controlFlow/controlFlowDeleteOperator.ts (1 errors) ====
65
function f() {
76
let x: { a?: number | string, b: number | string } = { b: 1 };
87
x.a;
@@ -13,8 +12,6 @@ tests/cases/conformance/controlFlow/controlFlowDeleteOperator.ts(14,12): error T
1312
x.b;
1413
delete x.a;
1514
delete x.b;
16-
~~~
17-
!!! error TS2790: The operand of a 'delete' operator must be optional.
1815
x.a;
1916
x.b;
2017
x;

tests/baselines/reference/deleteChain.errors.txt

Lines changed: 0 additions & 66 deletions
This file was deleted.

tests/baselines/reference/deleteExpressionMustBeOptional(strict=false).errors.txt

Lines changed: 0 additions & 46 deletions
This file was deleted.

tests/baselines/reference/deleteExpressionMustBeOptional(strict=false).js

Lines changed: 0 additions & 57 deletions
This file was deleted.

tests/baselines/reference/deleteExpressionMustBeOptional(strict=false).symbols

Lines changed: 0 additions & 118 deletions
This file was deleted.

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy