Skip to content

Commit 399cebb

Browse files
Revert "Add check for delete expression must be optional (#37921)"
This reverts commit 39beb1d.
1 parent d7e437a commit 399cebb

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
@@ -27583,23 +27583,12 @@ namespace ts {
2758327583
}
2758427584
const links = getNodeLinks(expr);
2758527585
const symbol = getExportSymbolOfValueSymbolIfExported(links.resolvedSymbol);
27586-
if (symbol) {
27587-
if (isReadonlySymbol(symbol)) {
27588-
error(expr, Diagnostics.The_operand_of_a_delete_operator_cannot_be_a_read_only_property);
27589-
}
27590-
27591-
checkDeleteExpressionMustBeOptional(expr, getTypeOfSymbol(symbol));
27586+
if (symbol && isReadonlySymbol(symbol)) {
27587+
error(expr, Diagnostics.The_operand_of_a_delete_operator_cannot_be_a_read_only_property);
2759227588
}
2759327589
return booleanType;
2759427590
}
2759527591

27596-
function checkDeleteExpressionMustBeOptional(expr: AccessExpression, type: Type) {
27597-
const AnyOrUnknownOrNeverFlags = TypeFlags.AnyOrUnknown | TypeFlags.Never;
27598-
if (strictNullChecks && !(type.flags & AnyOrUnknownOrNeverFlags) && !(getFalsyFlags(type) & TypeFlags.Undefined)) {
27599-
error(expr, Diagnostics.The_operand_of_a_delete_operator_must_be_optional);
27600-
}
27601-
}
27602-
2760327592
function checkTypeOfExpression(node: TypeOfExpression): Type {
2760427593
checkExpression(node.expression);
2760527594
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