You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
typeComponentPublicInstance<C,Options>={$options: Options&'intersection anything'// intersection here is critical}&ExtractComputedReturns<C>// this type intersection is importanttypeWhatEver<T>=Textends1 ? true : falsetypeMixinToOptionTypes<T>=TextendsComponentOptionsBase<
infer C,1,1>
? OptionTypesType<C>
: nevertypeIntersectionMixin<T>=WhatEver<T>extendstrue// a conditional is required here for reproduction
? OptionTypesType<{}>
: MixinToOptionTypes<T>typeCreateComponentPublicInstance<Mixinextends1,Extendsextends1,>=ComponentPublicInstance<(IntersectionMixin<Mixin>&IntersectionMixin<Extends>)['C'],ComponentOptionsBase<{},Mixin,Extends>>interfaceComponentOptionsBase<_CextendsComputedOptions,Mixinextends1,Extendsextends1,>{data?: (this: CreateComponentPublicInstance<Mixin,Extends>,)=>{}// a function property is required, method syntax cannot reproduce.}typeComputedGetter=(...args: any[])=>anytypeComputedOptions=Record<string,ComputedGetter|{get: ComputedGetter}// a union type for getter is required>typeExtractComputedReturns<Textendsany>={[keyinkeyofT]: T[key]extends{get: (...args: any[])=> infer TReturn}
? TReturn
: T[key]extends(...args: any[])=> infer TReturn
? TReturn
: never}typeOptionTypesType<C={}>={C: C}typeMixin=1;typeExtend=1;typeA1=ComponentOptionsBase<any,Mixin,Extend>&{sth?:never}exporttypeTest1=A1extendsComponentOptionsBase<any,any,any>?'yes':'no'// ^? expect Yes, got No in TS 5.1.0, but Yes in 4.9.5// following types are for reference. They behave the same.typeA2=ComponentOptionsBase<any,Mixin,Extend>exporttypeTest2=A2extendsComponentOptionsBase<any,any,any>?'yes':'no'// ^? yestypeA3=ComponentOptionsBase<any,Mixin,any>&{sth?:never}exporttypeTest3=A3extendsComponentOptionsBase<any,any,any>?'yes':'no'// ^? yestypeA4=ComponentOptionsBase<any,any,Extend>&{sth?:never}exporttypeTest4=A4extendsComponentOptionsBase<any,any,any>?'yes':'no'// ^? yes
🙁 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.5
The text was updated successfully, but these errors were encountered:
HerringtonDarkholme
changed the title
TS 5.1.0 dev gave wrong answer when combining conditional/intersection/recursive type
TS 5.1.0 dev type inference regression when combining conditional/intersection/recursive type
Mar 12, 2023
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 yarn up typescript and then yarn build you can see a ton of type errors coming in, it seems due to a very simple GetVariantProps helper which just does:
type GetVariantProps<A extends StylableComponent> = A extends TamaguiComponent<
any,
any,
any,
infer V
>
? V
: {}
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.
Uh oh!
There was an error while loading. Please reload this page.
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: