8000 docs(eslint-plugin): [ban-types] add reference on how to type an empt… · dopecodez/typescript-eslint@7af66a7 · GitHub
[go: up one dir, main page]

Skip to content

Commit 7af66a7

Browse files
docs(eslint-plugin): [ban-types] add reference on how to type an empty object (typescript-eslint#2758)
1 parent 4b89571 commit 7af66a7

File tree

2 files changed

+2
-0
lines changed

2 files changed

+2
-0
lines changed

packages/eslint-plugin/docs/rules/ban-types.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ The default options provide a set of "best practices", intended to provide safet
7474
- It accepts class declarations, which will fail when called, as they are called without the `new` keyword.
7575
- Avoid the `Object` and `{}` types, as they mean "any non-nullish value".
7676
- This is a point of confusion for many developers, who think it means "any object type".
77+
- See [this comment for more information](https://github.com/typescript-eslint/typescript-eslint/issues/2063#issuecomment-675156492).
7778
- Avoid the `object` type, as it is currently hard to use due to not being able to assert that keys exist.
7879
- See [microsoft/TypeScript#21732](https://github.com/microsoft/TypeScript/issues/21732).
7980

packages/eslint-plugin/src/rules/ban-types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ const defaultTypes: Types = {
9393
'`{}` actually means "any non-nullish value".',
9494
'- If you want a type meaning "any object", you probably want `Record<string, unknown>` instead.',
9595
'- If you want a type meaning "any value", you probably want `unknown` instead.',
96+
'- If you want a type meaning "empty object", you probably want `Record<string, never>` instead.',
9697
].join('\n'),
9798
},
9899
object: {

0 commit comments

Comments
 (0)
0