Skip to content

Commit 2285fa3

Browse files
committed
Revert "Add check for delete expression must be optional"
This reverts commit 76937c3.
1 parent 5a76afe commit 2285fa3

14 files changed

+4
-620
lines changed

src/compiler/checker.ts

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -27564,27 +27564,14 @@ namespace ts {
2756427564
if (expr.kind === SyntaxKind.PropertyAccessExpression && isPrivateIdentifier((expr as PropertyAccessExpression).name)) {
2756527565
error(expr, Diagnostics.The_operand_of_a_delete_operator_cannot_be_a_private_identifier);
2756627566
}
27567-
2756827567
const links = getNodeLinks(expr);
2756927568
const symbol = getExportSymbolOfValueSymbolIfExported(links.resolvedSymbol);
27570-
if (symbol) {
27571-
if (isReadonlySymbol(symbol)) {
27572-
error(expr, Diagnostics.The_operand_of_a_delete_operator_cannot_be_a_read_only_property);
27573-
}
27574-
27575-
checkDeleteExpressionMustBeOptional(expr, getTypeOfSymbol(symbol));
27569+
if (symbol && isReadonlySymbol(symbol)) {
27570+
error(expr, Diagnostics.The_operand_of_a_delete_operator_cannot_be_a_read_only_property);
2757627571
}
27577-
2757827572
return booleanType;
2757927573
}
2758027574

27581-
function checkDeleteExpressionMustBeOptional(expr: AccessExpression, type: Type) {
27582-
const AnyOrUnknownOrNeverFlags = TypeFlags.AnyOrUnknown | TypeFlags.Never;
27583-
if (strictNullChecks && !(type.flags & AnyOrUnknownOrNeverFlags) && !(getFalsyFlags(type) & TypeFlags.Undefined)) {
27584-
error(expr, Diagnostics.The_operand_of_a_delete_operator_must_be_optional);
27585-
}
27586-
}
27587-
2758827575
function checkTypeOfExpression(node: TypeOfExpression): Type {
2758927576
checkExpression(node.expression);
2759027577
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 & 30 deletions
This file was deleted.

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

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

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

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

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

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

0 commit comments

Comments
 (0)