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
TypeScript seems to be unable to resolve the conditional assignment to context with the conditional type C extends undefined ? Array<T> : NonNullable<C>
π Expected behavior
tsc should be able to deduce that the type of context matches the type of callback's this type hint.
Additional information about the issue
I tried a number of different variations for the conditional assignment of context, trying to see if the problem was with when I was this to context, but all of the ones I tried gave me variations of the same error.
this ?? thisArg
typeof thisArg === "undefined" ? this : thisArg
typeof thisArg === "undefined" ? this : <NonNullable<C>> thisArg
(Obviously using <any> in any number of places in the code would work around the issue.)
The text was updated successfully, but these errors were encountered:
π Search Terms
"conditional this type"
π Version & Regression Information
β― Playground Link
https://www.typescriptlang.org/play?ts=5.2.2#code/GYVwdgxgLglg9mABAWwIYAcA8AVANAVVwGFEBeRcAEwFNgYxrKA+ACigAsYBnALkQEEAToNQBPHE1yIIqADayARqggBrPm069EJagA8o1MJS4Ujteo0QB+AcLETEfAHIInIeagWzqmIpMQAbnIg1Hx4iPQ0unxgIMgK1IJSqHaiYQDaALoAlGRMiISIHNxCAOZWfETZfPhZiADeAFCILdIIXFCIgtRc7lA1deRZANzNrRDtnRNgBvpkRZpl1jbFXKOtiMBwgogs3p0w8wAMwxGImAvcAHTeYKUcpwDUjzC5TRsb0x1F86vpMJl1h8Wl9OiB5jJ5EpVFdIbIWNNZlApMiIijNNkgcDur1ZFB-pl5iAsYgAL5jFrdKAgQRIHF9Uak0ZAA
π» Code
π Actual behavior
TypeScript seems to be unable to resolve the conditional assignment to
context
with the conditional typeC extends undefined ? Array<T> : NonNullable<C>
π Expected behavior
tsc should be able to deduce that the type of context matches the type of
callback
'sthis
type hint.Additional information about the issue
I tried a number of different variations for the conditional assignment of
context
, trying to see if the problem was with when I wasthis
tocontext
, but all of the ones I tried gave me variations of the same error.this ?? thisArg
typeof thisArg === "undefined" ? this : thisArg
typeof thisArg === "undefined" ? this : <NonNullable<C>> thisArg
(Obviously using
<any>
in any number of places in the code would work around the issue.)The text was updated successfully, but these errors were encountered: