-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Bug: [no-base-to-string] False negative for unknown
type
#10862
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
+1 Note this came up in discussion before here: #10005 (comment) and restrict-template-expressions does flag @typescript-eslint/triage-team |
This is actually working by design - the rule purposely ignores any/unknown. The reason we ignore it is because we cannot reason about the types. Generally we ignore any/unknown in our rules. I can see that you added tests for this case in #10432 Kirk heh. I'm personally in favour of always ignoring any/unknown and instead always and relegating the handling of those types to the |
Hmm, that makes sense for |
|
Well, that was basically my question here: #10005 (comment). My understanding of that conversation was that
Why is |
Lol that is pretty funny 😀. Granted the context, I'm pretty sure that that was more of a descriptive snapshot of relevant codepaths that I wanted to be sure my changes didn't change, rather than a normative belief on my part 😁 |
For logging functions I like to use a export type Json = boolean | number | string | null | JsonArray | JsonRecord
export interface JsonRecord {
readonly [key: string]: Json
}
export interface JsonArray extends ReadonlyArray<Json> {}
export const log = (value: Json) => {
// …
}; |
log({ toJSON() { throw "Oopsies"; } }); Isn't JavaScript just the best language? |
Haha, yeah, I know it's not bulletproof, but I think it strikes a good balance. |
As for |
Accepting PRs for an opt-in option with a name like |
Before You File a Bug Report Please Confirm You Have Done The Following...
Playground Link
https://typescript-eslint.io/play/#ts=5.7.2&fileType=.tsx&code=PTAEFEA8AcFMGMAusAmpYCcMHsMBpQBzbRUbAO1gDpRBQcgCgBlRDAS3MIAoBvAXwEoA3PXooEAGwCGGWKHgUAzqUgAuUAFdyAa3LYA7uWEgIMBMjSYc%2BIiVC7KNQDLkTFuy6Qh9IA&eslintrc=N4KABGBEBOCuA2BTAzpAXGUEKQAIBcBPABxQGNoBLY-AWhXkoDt8B6Jge1oCMBDZRLXxdk%2BKkwDm6MACZwYAL4gFQA&tsconfig=N4KABGBEDGD2C2AHAlgGwKYCcDyiAuysAdgM6QBcYoEEkJemy0eAcgK6qoDCAFutAGsylBm3TgwAXxCSgA&tokens=false
Repro Code
ESLint Config
tsconfig
Expected Result
Expected error.
Actual Result
No error.
Additional Info
No response
The text was updated successfully, but these errors were encountered: