Skip to content

Commit

Permalink
docs(eslint-plugin): no-unnecessary-type-assertion: Add non-null oper…
Browse files Browse the repository at this point in the history
…ator example (#253)

* docs(eslint-plugin): Add non-null operator example

* format
  • Loading branch information
bradzacher committed Feb 12, 2019
1 parent 225fc26 commit 7be5657
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions packages/eslint-plugin/docs/rules/no-unnecessary-type-assertion.md
Expand Up @@ -27,6 +27,12 @@ type Foo = 3;
const foo = 3 as Foo;
```

```ts
function foo(x: number): number {
return x!; // unnecessary non-null
}
```

Examples of **correct** code for this rule:

```ts
Expand All @@ -37,6 +43,12 @@ const foo = <number>3;
const foo = 3 as number;
```

```ts
function foo(x: number | undefined): number {
return x!;
}
```

### Options

This rule optionally takes an object with a single property `typesToIgnore`, which can be set to a list of type names to ignore.
Expand Down

0 comments on commit 7be5657

Please sign in to comment.