Skip to content

Latest commit

 

History

History
64 lines (49 loc) · 938 Bytes

no-extra-non-null-assertion.md

File metadata and controls

64 lines (49 loc) · 938 Bytes
description
Disallow extra non-null assertion.

🛑 This file is source code, not the primary documentation location! 🛑

See https://typescript-eslint.io/rules/no-extra-non-null-assertion for documentation.

Rule Details

Examples of code for this rule:

❌ Incorrect

const foo: { bar: number } | null = null;
const bar = foo!!!.bar;
function foo(bar: number | undefined) {
  const bar: number = bar!!!;
}
function foo(bar?: { n: number }) {
  return bar!?.n;
}

✅ Correct

const foo: { bar: number } | null = null;
const bar = foo!.bar;
function foo(bar: number | undefined) {
  const bar: number = bar!;
}
function foo(bar?: { n: number }) {
  return bar?.n;
}

Options

// .eslintrc.json
{
  "rules": {
    "@typescript-eslint/no-extra-non-null-assertion": "error"
  }
}

This rule is not configurable.