-
-
Notifications
You must be signed in to change notification settings - Fork 524
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
💅 Evolving any is considered implicit any by noImplicitAnyLet
#1883
Comments
Good point. We should certainly rename the rule and add more cases. |
Another case of control flow inference for which biome does not check: class Example {
b
// ^? inferred as number
constructor() {
this.b = 2
}
} Playground This is practically the same case as |
@Conaclos |
@fujiyamaorange |
I plan to redefine this case as valid because it seems a kind of evolving any type according to @bgenia .
I also referred this article. |
This could make the rule useless? Instead, I could create a new rule let a; // the current `noImplicitAny`
const b = [];
let c = null; If you would like to work on this new rule, you are welcomed :) |
Oh, fantastic! Let me try this! |
@Conaclos |
We have noEvolvingAny lint rule now, so I close this issue. |
Environment information
Rule name
lint/suspicious/noImplicitAnyLet
Playground link
https://biomejs.dev/playground/?code=LwAvACAARQB2AG8AbAB2AGkAbgBnACAAYQBuAHkAIABpAHMAIABjAG8AbgBzAGkAZABlAHIAZQBkACAAaQBtAHAAbABpAGMAaQB0ACAAYQBuAHkACgBsAGUAdAAgAGIACgBiACAAPQAgADEACgAKAC8ALwAgAEUAdgBvAGwAdgBpAG4AZwAgAGEAcgByAGEAeQAgAGkAcwAgAGkAZwBuAG8AcgBlAGQACgBjAG8AbgBzAHQAIABhAHIAcgAgAD0AIABbAF0ACgBhAHIAcgAuAHAAdQBzAGgAKAAxACkACgBhAHIAcgAuAHAAdQBzAGgAKAAiAGgAZQBsAGwAbwAiACkACgA%3D
Expected result
Evolving any
This case should be only marked as "implicit any" if
noImplicitAny
tsconfig option is set tofalse
. If the purpose of this rule is specifically to forbid using evolving any I suggest at least changing the rationale in the docs because currently it does not make sense.The docs say that this is a "dangerous escape hatch" and typescript's
noImplicitAny
doesn't report this case, this is because it's not actually anany
. This is a separate feature which allows inferring variable type from assignments. This is type safe.Example 1
Example 2
See microsoft/TypeScript#11263 microsoft/TypeScript#45369 microsoft/TypeScript#54414
Evolving arrays
This behavior also exists in a form of evolving arrays, for which biome does not check.
Example 1
Example 2
If this rule is meant to ban evolving types, I suggest banning this too.
See microsoft/TypeScript#11432 microsoft/TypeScript#43752
Code of Conduct
The text was updated successfully, but these errors were encountered: