Disallow non-null assertions using the ! postfix operator.
// code-linter.json5
{
"rules": {
"@typescript-eslint/no-non-null-assertion": "error"
}
} interface Example {
property?: string;
}
declare const example: Example;
export const includesBaz = example.property?.includes('baz') ?? false; interface Example {
property?: string;
}
declare const example: Example;
// Do not use "example.property!" to perform non-null assertion.
export const includesBaz = example.property!.includes('baz'); plugin:@typescript-eslint/all
For details about how to configure Code Linter check rules, see Code Linter.