-
Notifications
You must be signed in to change notification settings - Fork 12.6k
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
Potential regression in 4.2 - Calling .map
on T[] | Y[]
is now callable but leads to an implicit any error
#42646
Comments
.map
on T[] | Y[]
is now callback but leads to an implicit any error.map
on T[] | Y[]
is now callable but leads to an implicit any error
It's not a regression (definitionally, going from can't call at all to implicitly any is a less restrictive error - now you can explicitly annotate it and actually resolve the call), and we already have #42620 open to improve the experience further~ |
But why does it allow specifically related issue: #35045 |
|
Is there any chance for |
Not in the immediate future, no. The |
I see, thanks. For some reason, I thought these methods are disallowed because of type safety. E.g., what can be |
Anyway, wouldn't it be a helpful trick to implicitly transform |
@weswigham It's not clear to me how your PR relates to this issue, do you have a playground link I can poke around with? |
@tom-sherman Previously, such calls were disallowed because merging signatures for generic overloaded functions is a tricky procedure, and it wasn't implemented. Now, in some cases, it became possible. After merging that PR, it'll be possible in more cases. Hopefully, we'll read more on that in the release blog post. |
Now that it works for |
An isolated real-world case to demo how this issue is a pain: import * as Babel from "@babel/types";
import { TSESTree } from "@typescript-eslint/typescript-estree";
type Node = Babel.Node | TSESTree.Node;
declare const node: Node;
if (
(node.type === "GenericTypeAnnotation" || node.type === "TSTypeReference") &&
(!node.typeParameters ||
node.typeParameters.params.length <= 2 && node.typeParameters.params.every(n => true))
) { }
|
Closing as fixed in #53489; reading the PR, it has this case as a test. |
Bug Report
π Search Terms
expression not callable union arrays
π Version & Regression Information
This changed between versions 4.1.3 and 4.2 beta
β― Playground Link
https://www.typescriptlang.org/play?ts=4.1.3#code/CYUwxgNghgTiAEYD2A7AzgF3gDwFzxQFcBbAIxBgG0BdeAH3kxgEsUBzGgKE+wDpioABwAUAM3gBeAHzxRASiA
https://www.typescriptlang.org/play?ts=4.2.0-beta#code/CYUwxgNghgTiAEYD2A7AzgF3gDwFzxQFcBbAIxBgG0BdeAH3kxgEsUBzGgKE+wDpioABwAUAM3gBeAHzxRASiA
π» Code
π Actual behavior
.map
is now callable butf
as an implicit type ofany
, leading to an implicit any error.π Expected behavior
The current behaviour in 4.1.3 is to mark the
map()
call as not callable as well asf
should have an implicit any type.I don't know if this is a regression but I'm raising it because this change in behaviour is not documented in the release notes.
The text was updated successfully, but these errors were encountered: