-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Bug: [no-empty-object-type] false positive/incorrect fixes for default type parameter #9761
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
Comments
The suggestions are there for common cases; neither of them are equivalent to export interface I<P extends Record<string, string> = {}> {
params: P;
}
const x: I = { params: 1 }; // Allowed You can use |
Yeah this reporting is entirely correct and using In this case Josh's suggestion is correct - you have a generic constraint, so use the constraint as the default. Though you probably want something like @typescript-eslint/triage-team -- what do we think about adding a suggestion here: |
Hmmm, negative—I don't think that is going to help in most cases and really complicates the code. |
-1 from me, too, I'd rather avoid blessing |
I meant specifically if the code is of the form |
Yeah, I meant—this is not always, if ever, going to be what the user intends, and only solves a handful of cases out-of-the-box. |
Oh, I misunderstood, thanks for clarifying. +/- 0 from me on this 🤷♂️ |
Okay then it seems like we're in agreement - this is working as intended and no changes shall be made. |
Before You File a Bug Report Please Confirm You Have Done The Following...
Playground Link
https://typescript-eslint.io/play/#ts=5.5.2&fileType=.tsx&code=KYDwDg9gTgLgBASwHY2FAZgQwMbDgSQB4AFOUVJAEwGc4AlYbaSw6mKZAcwBo42OknAHxwAvHADeAXxESAsACg4cMJiiYAttQBccYgG5FUoA&eslintrc=N4KABGBEBOCuA2BTAzpAXGUEKQAIBcBPABxQGNoBLY-AWhXkoDt8B6Jge3oFsbDaOAIwBWiMnSKl0URNGgdokcGAC%2BIFUA&tsconfig=N4KABGBEDGD2C2AHAlgGwKYCcDyiAuysAdgM6QBcYoEEkJemy0eFYDAruuGAL4g9A&tokens=false
Repro Code
ESLint Config
tsconfig
Expected Result
I'm not sure this should even produce an error. Neither of the suggested fixes works.
Actual Result
The
{}
("empty object") type allows any non-nullish value, including literals like0
and""
.object
instead.unknown
instead. 5:55 - 5:57Additional Info
No response
The text was updated successfully, but these errors were encountered: