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
Empty types and types with never as a key behave differently #56691
I suggest simplifying the example to something like type A = {[K in never]: any} which reproduces the behavior without the added distraction of conditional types.
changed the title [-]Empty mapped type and unknown behave strangely[/-][+]Empty types and types with `never` as a key behave differently[/+]on Dec 6, 2023
I'm not committing to take a fix for this since it's pretty niche, but if it's straightforward and doesn't break/slow down something else, we can take a PR
Activity
MartinJohns commentedon Dec 6, 2023
What is that mapped type supposed to do?
Regardless, this seems intentional: https://www.typescriptlang.org/docs/handbook/release-notes/typescript-4-8.html#improved-intersection-reduction-union-compatibility-and-narrowing
kazatsuyu commentedon Dec 6, 2023
If the possible assignment of
unknowntonull | undefeind | {}is intentional, then the behavior ofais correct, butbshould not be an error.jcalz commentedon Dec 6, 2023
I suggest simplifying the example to something like
type A = {[K in never]: any}which reproduces the behavior without the added distraction of conditional types.Relevant: #49119 and #49119 (comment)
kazatsuyu commentedon Dec 6, 2023
Well, it certainly looks like the problem is not that I mapped
{}, but that I created a type withneverkey.[-]Empty mapped type and unknown behave strangely[/-][+]Empty types and types with `never` as a key behave differently[/+]RyanCavanaugh commentedon Dec 8, 2023
I suppose the steelmanned version of the issue looks like this
RyanCavanaugh commentedon Dec 8, 2023
I'm not committing to take a fix for this since it's pretty niche, but if it's straightforward and doesn't break/slow down something else, we can take a PR