-
Notifications
You must be signed in to change notification settings - Fork 12.8k
TS 5.1.0 dev type inference regression when combining conditional/intersection/recursive type #53211
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
This changed in #52392 , cc @ahejlsberg |
It's interesting that this changed, but given that the originating PR is a bug fix, this needs a clearer demonstration (i.e. short repro, or one that clearly shows why something is wrong) of an actual defect for us to investigate further. |
Tamagui is breaking after upgrading to 5.1, but it's also hard to set up an exact reproduction (yet easy to see in the monorepo). If you run
I can see the type is TamaguiComponent and the fourth argument is a real value, but for some reason in TS 5.1 it returns unknown now. Will investigate further, but we're getting a lot of bug reports and confused users suddenly from this. |
Found the answer, I had defined TamaguiComponent like this: export type TamaguiComponent<
Props = any,
Ref = any,
BaseProps = {},
VariantProps = {},
ParentStaticProperties = {}
> = ReactComponentWithRef<Props, Ref> &
StaticComponentObject<Props, Ref> &
ParentStaticProperties Basically we didn't use the BaseProps and VariantProps, I guess TS throws that information away. So I changed to: export type TamaguiComponent<
Props = any,
Ref = any,
BaseProps = {},
VariantProps = {},
ParentStaticProperties = {}
> = ReactComponentWithRef<Props, Ref> &
StaticComponentObject<Props, Ref> &
ParentStaticProperties & {
__baseProps: BaseProps
__variantProps: VariantProps
} And it keeps the information around. |
Bug Report
Vue team is witnessing a new weird type behavior difference when upgrading TypeScript.
The typing difference is very subtle. I'm sorry I cannot provide a more concise example here. (The example has already been reduced from 500+ lines to 70 lines ).
The original usage is simple https://tsplay.dev/mxjRXw. I have attached the standalone example in the issue. All critical parts are commented.
🔎 Search Terms
Sorry I could not find a good search term.
🕗 Version & Regression Information
⏯ Playground Link
5.1.0
4.9.5
💻 Code
🙁 Actual behavior
A1
should always be'yes'
in TS 5.1.0.🙂 Expected behavior
A1
is'no'
in TS5.1.0, but'yes'
in TS4.9.5The text was updated successfully, but these errors were encountered: