-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Some long function return expressions no longer evaluated in 5.5 #58937
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
Workaround: just put the export type inferPipe<t, pipe> =
- pipe extends (In: t) => unknown ? (In: t) => ReturnType<pipe> : never
+ pipe extends (In: t) => unknown ? ReturnType<pipe> extends infer R ? (In: t) => R : never : never
export type inferPipe2<t, pipe> =
pipe extends (In: t) => unknown ?
- (In: t) => ReturnType<pipe> extends infer n extends number ? n
- : ReturnType<pipe> extends infer s extends string ? s
- : ReturnType<pipe> extends infer b extends boolean ? b
+ ReturnType<pipe> extends infer n extends number ? (In: t) => n
+ : ReturnType<pipe> extends infer s extends string ? (In: t) => s
+ : ReturnType<pipe> extends infer b extends boolean ? (In: t) => b
: never
: never |
@whzx5byb From the original post, there is a simpler work around in this case:
It's possible I'll be able to propagate a similar strategy through the multiple layers in which this is occurring in ArkType, but too early to know for sure yet, particularly that it wouldn't interfere with parameter inference at all which can be very sensitive. Even if I can find a way to work around it, writing things this way is neither natural nor intuitive whereas a more straightforward approach can lead to very bad outcomes. As I've been working on potential refactors of ArkType to accommodate this, I've frequently seen return expressions like If I understood what @jakebailey mentioned correctly, this is based on the same code that determines what to write to |
I think @dragomirtitian mentioned he was looking into this one. |
I think this issue is broader than that. As discussed in Linked Effect Issue. |
I spent a little bit of time trying to figure out what was going on here and sent a potential fix (which I'm not 100% certain of). Try using the build at #59170 (comment) and see if that seems to fix things for your cases. No guarantees, this PR is extremely unscientific. |
π Search Terms
function return type inferred isolatedDeclarations regression
π Version & Regression Information
This changed occurred as a result of
2b4e7e34e7a40fe0d886aec6f799954420f2ac0c
(#58546)β― Playground Link
https://tsplay.dev/WY7ZbN
π» Code
π Actual behavior
Trivially evaluated
ReturnType
not evaluated on hover.π Expected behavior
It should be evaluated
Additional information about the issue
The example from the playground can worked around by inferring a variable in the position of
unknown
to get the return type directly instead of using theReturnType
alias.This causes a massive regression in the quality of hover displays for many types in ArkType, which I'm still working to determine if can be avoided as-is.
If the team does decide it wants to address this, it would be a huge relief to me to know so I can avoid trying to find workarounds that may involve changing significant parts of the code base to have hovers that were previously a couple dozen characters long be remotely readable after 5.5.
The text was updated successfully, but these errors were encountered: