typescript/no-extra-non-null-assertion Correctness
What it does
Disallow extra non-null assertions.
Why is this bad?
The !
non-null assertion operator in TypeScript is used to assert that a value's type does not include null or undefined. Using the operator any more than once on a single value does nothing.
Example
ts
const foo: { bar: number } | null = null;
const bar = foo!!!.bar;
How to use
To enable this rule in the CLI or using the config file, you can use:
bash
oxlint --deny typescript/no-extra-non-null-assertion
json
{
"rules": {
"typescript/no-extra-non-null-assertion": "error"
}
}