【发布时间】:2020-12-21 10:01:39
【问题描述】:
这是打字稿代码中出现的新错误。
我无法实现它背后的逻辑
Documentation
/*When using the delete operator in strictNullChecks,
the operand must now be any, unknown, never, or be optional
(in that it contains undefined in the type). Otherwise, use of the delete operator is an error.*/
interface Thing {
prop: string;
}
function f(x: Thing) {
delete x.prop; // throws error = The operand of a 'delete' operator must be optional.
}
【问题讨论】:
-
你的问题包括答案...
When using the delete operator in strictNullChecks, the operand must now be any, unknown, never, or be optional
标签: javascript typescript