Further optional delete corrections (#44862)

* Add more tests.

* Accepted baselines.

* Switch to testing the symbol's flags.

* Accepted baselines.
This commit is contained in:
Daniel Rosenwasser
2021-07-01 18:44:22 -07:00
committed by GitHub
parent e3d6189e3a
commit 248b2c3fc1
10 changed files with 339 additions and 21 deletions

View File

@@ -31411,7 +31411,7 @@ namespace ts {
const type = getTypeOfSymbol(symbol);
if (strictNullChecks &&
!(type.flags & (TypeFlags.AnyOrUnknown | TypeFlags.Never)) &&
!(exactOptionalPropertyTypes ? hasQuestionToken(symbol.valueDeclaration!) : getFalsyFlags(type) & TypeFlags.Undefined)) {
!(exactOptionalPropertyTypes ? symbol.flags & SymbolFlags.Optional : getFalsyFlags(type) & TypeFlags.Undefined)) {
error(expr, Diagnostics.The_operand_of_a_delete_operator_must_be_optional);
}
}