Skip to content

Commit

Permalink
docs(eslint-plugin): mention alternatives in no-explicit-any (#8370)
Browse files Browse the repository at this point in the history
  • Loading branch information
JoshuaKGoldberg committed Feb 5, 2024
1 parent aa5edf7 commit f892a72
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions packages/eslint-plugin/docs/rules/no-explicit-any.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ The `any` type in TypeScript is a dangerous "escape hatch" from the type system.
Using `any` disables many type checking rules and is generally best used only as a last resort or when prototyping code.
This rule reports on explicit uses of the `any` keyword as a type annotation.

Preferable alternatives to `any` include:

- If the type is known, describing it in an `interface` or `type`
- If the type is not known, using the safer `unknown` type

> TypeScript's `--noImplicitAny` compiler option prevents an implied `any`, but doesn't prevent `any` from being explicitly used the way this rule does.
## Examples
Expand Down

0 comments on commit f892a72

Please sign in to comment.