-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enhancement: [ban-types] Allow {} in the recommended config #8697
Comments
Just read microsoft/TypeScript#57735 and filed #8700 as a result. For clarity, the intent of the two issues I'm filing are:
If #8700 is resolved before this one, that's great too. |
Strong 👎 (this issue and #8700 also seem like duplicates?) |
From what I understand: this is about removing the ban in |
They're one and the same though. The rule supports banning |
Closing per #8700 (comment). We can always revisit this if v9 shows that many users are still confused by the |
Before You File a Proposal Please Confirm You Have Done The Following...
My proposal is suitable for this project
Link to the rule's documentation
https://typescript-eslint.io/rules/ban-types
Description
The
{}
has long been a source of confusion in TypeScript. It means "any non-nullish value, but with no known fields". That includes objects like{}
and{ value: 1 }
, primitives liketrue
and""
, arrays like[]
, and general class instances likenew Error()
.Because users so often get confused by
{}
allowing primitives liketrue
and""
, theban-types
rule suggests users use something more restrictive. Specifically its default options include:That's pretty strict... at the cost of user convenience.
Now that #8364 is in, we have the ability to provide more lenient default options for the
recommended*
configs vs. thestrict*
configs.Proposal: let's remove the restriction on
{}
from the defaultban-types
options inrecommended
configs, and leave them in forstrict
configs?Fail
Pass
Additional Info
@RyanCavanaugh, the dev lead for TypeScript, is not a fan of the way it is now 😄: https://bsky.app/profile/searyanc.dev/post/3knqtqcjhpn2d
See also #5947 for past discussion around objects and
ban-types
The text was updated successfully, but these errors were encountered: