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
{{ message }}
Repository navigation
NonNullable behaves differently when passing a property type from this #36061
There's another similar issue to this one to do with this and NonNullable<this> not being compatible, but in this case the issue is that when we do a property access on this, we actually get the constraint of the access (so we report the "current" type rather than this["prop"]), which, when NonNullable'd, then produces a (less precise) result.
#26942 is a dupe with a slightly inaccurate answer (even adding a cast is not sufficient, because of what I described above).
Activity
AnyhowStep commentedon Jan 7, 2020
Workaround,
Playground
RyanCavanaugh commentedon Jan 13, 2020
Wesley Wigham (@weswigham) can you link to the proper duplicate please
shilangyu commentedon Feb 23, 2020
Tried v3.8, still seems to not work. I also tried to find the duplicate issue but I couldn't (probably a broader topic)
weswigham commentedon Mar 4, 2020
There's another similar issue to this one to do with
thisandNonNullable<this>not being compatible, but in this case the issue is that when we do a property access onthis, we actually get the constraint of the access (so we report the "current" type rather thanthis["prop"]), which, whenNonNullable'd, then produces a (less precise) result.#26942 is a dupe with a slightly inaccurate answer (even adding a cast is not sufficient, because of what I described above).
JoniJnm commentedon Mar 10, 2023
Works since 4.8
https://www.typescriptlang.org/docs/handbook/release-notes/typescript-4-8.html#improved-intersection-reduction-union-compatibility-and-narrowing
#49119