目录

@typescript-eslint/no-non-null-assertion

Disallow non-null assertions using the ! postfix operator.

Rule Configuration

// code-linter.json5
{
  "rules": {
    "@typescript-eslint/no-non-null-assertion": "error"
  }
}

Options

This rule is not configurable.

Example of Correct Code

interface Example {
  property?: string;
}

declare const example: Example;
export const includesBaz = example.property?.includes('baz') ?? false;

Example of Incorrect Code

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');

Rule Set

plugin:@typescript-eslint/all

For details about how to configure Code Linter check rules, see Code Linter.