-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Closed
Labels
package: eslint-pluginIssues related to @typescript-eslint/eslint-pluginIssues related to @typescript-eslint/eslint-pluginwontfixThis will not be worked onThis will not be worked onworking as intendedIssues that are closed as they are working as intendedIssues that are closed as they are working as intended
Description
A lot of type declaration is using Type Aliases
, to let user fill in.
For example a interface like this: (I got it from an official repo)
interface Custom<
Detail = Record<string, any>,
TargetDataset = Record<string, any>,
CurrentTargetDataset = Record<string, any>,
Mark = Record<string, any>
> extends Base<TargetDataset, CurrentTargetDataset, Mark> {
detail: Detail;
}
Sometimes detail is just an empty object! So it's good for me to write Custom<{}>
, but V3 will throw an error ( not even a warning)
Don't use `{}` as a type. `{}` 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.
In order to stop this error, I have to write Custom<Record<never,never>>
, which is unneeded and a waste of time.
So stop baning {}
by default. May packages are holding certain objects for certain data, and to prevent the Cannot read property 'xxx' of undefined
, they are usually initialize with {}
, so If I know that those fields are not containing any data, I should use {}
puncsky
Metadata
Metadata
Assignees
Labels
package: eslint-pluginIssues related to @typescript-eslint/eslint-pluginIssues related to @typescript-eslint/eslint-pluginwontfixThis will not be worked onThis will not be worked onworking as intendedIssues that are closed as they are working as intendedIssues that are closed as they are working as intended