Skip to content

Commit

Permalink
docs(eslint-plugin): [ban-types] add reference on how to type an empt…
Browse files Browse the repository at this point in the history
…y object (#2758)
  • Loading branch information
martinfrancois committed Nov 17, 2020
1 parent 4b89571 commit 7af66a7
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 0 deletions.
1 change: 1 addition & 0 deletions packages/eslint-plugin/docs/rules/ban-types.md
Expand Up @@ -74,6 +74,7 @@ The default options provide a set of "best practices", intended to provide safet
- It accepts class declarations, which will fail when called, as they are called without the `new` keyword.
- Avoid the `Object` and `{}` types, as they mean "any non-nullish value".
- This is a point of confusion for many developers, who think it means "any object type".
- See [this comment for more information](https://github.com/typescript-eslint/typescript-eslint/issues/2063#issuecomment-675156492).
- Avoid the `object` type, as it is currently hard to use due to not being able to assert that keys exist.
- See [microsoft/TypeScript#21732](https://github.com/microsoft/TypeScript/issues/21732).

Expand Down
1 change: 1 addition & 0 deletions packages/eslint-plugin/src/rules/ban-types.ts
Expand Up @@ -93,6 +93,7 @@ const defaultTypes: Types = {
'`{}` actually means "any non-nullish value".',
'- If you want a type meaning "any object", you probably want `Record<string, unknown>` instead.',
'- If you want a type meaning "any value", you probably want `unknown` instead.',
'- If you want a type meaning "empty object", you probably want `Record<string, never>` instead.',
].join('\n'),
},
object: {
Expand Down

0 comments on commit 7af66a7

Please sign in to comment.