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
Search Terms:
never, extends, generic, conditional type Code
type MakesSense = never extends never ? 'yes' : 'no' // Resolves to 'yes'
type ExtendsNever<T> = T extends never ? 'yes' : 'no'
type MakesSenseToo = ExtendsNever<{}> // Resolves to 'no'
type Huh = ExtendsNever<never> // Expect to resolve to 'yes', actually resolves to never
Expected behavior:
Huh should resolve to 'yes', as MakesSense does.
Actual behavior:
Huh resolves to never.
For another variant, you can change ExtendsNever to
type ExtendsNever<T extends never> = T extends never ? 'yes' : 'no'