delete is applied to a variable, which it cannot remove
What it finds
delete x where x is a variable: delete removes properties, not variables. In strict code, which modules and classes always are, it is a syntax error; elsewhere it does nothing and gives false. To drop a value, assign undefined or null.
The name must refer to a variable, function, class, parameter or import that the file declares. Undeclared names are left alone, since deleting a global created by plain assignment works in sloppy code.
From the rule's source, delete_variable.rs.
let cache: Record<string, number> | undefined = {}; function f(param: number, obj: { a?: number }) { delete cache;tx0 reports: delete cannot remove the variable cache delete param;tx0 reports: delete cannot remove the variable param delete (f);tx0 reports: delete cannot remove the variable f delete obj.a; delete cache?.["x"]; delete undeclared;} Turn it on, off or suppress it
The rule runs in every tier. To turn it off for a project, set its level in tx0.toml:
[rules]
"tx0/ts:delete-variable" = "off"To keep one finding, suppress it with a reason. tx0 suppress ID --reason "..." writes the comment on the line before the code:
// tx0: ignore[tx0/ts:delete-variable] reason="..."tx0 explain tx0/ts:delete-variable shows the same in the terminal. Found a false positive? Report it.