Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
49 lines (38 sloc) 720 Bytes

Disallow extra non-null assertion (no-extra-non-null-assertion)

Rule Details

Examples of incorrect code for this rule:

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;
}

Examples of correct code for this rule:

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;
}

How to use

{
  "@typescript-eslint/no-extra-non-null-assertion": ["error"]
}
You can’t perform that action at this time.