Skip to content

Fix ExactOptionalize changing never to undefined - #35

Merged
Mrtenz merged 2 commits into
mainfrom
mrtenz/fix-never-type
Apr 3, 2025
Merged

Fix ExactOptionalize changing never to undefined#35
Mrtenz merged 2 commits into
mainfrom
mrtenz/fix-never-type

Conversation

@Mrtenz

Copy link
Copy Markdown
Member

never is a subtype of all types, so in this case, if Schema[K] is never, K is used:

Schema[K]extendsExactOptionalStruct<any,any> ? K : never;

This is problematic when using a struct type like Record<string, never>. This was previously incorrectly changed into Record<string, undefined>. After this change, the type is not affected.

@Mrtenz
Mrtenz marked this pull request as ready for review April 3, 2025 13:28
@Mrtenz
Mrtenz requested a review from a teamApril 3, 2025 13:28

@hmalik88hmalik88 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we should add some tests for these utils?

@Mrtenz
Mrtenzforce-pushed the mrtenz/fix-never-type branch from e16b153 to 802df0bCompareApril 3, 2025 15:23

@rekmarksrekmarks left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@Mrtenz
Mrtenz enabled auto-merge (squash) April 3, 2025 15:29
@Mrtenz
Mrtenz merged commit 367fa86 into mainApr 3, 2025
@Mrtenz
Mrtenz deleted the mrtenz/fix-never-type branch April 3, 2025 15:33
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@Mrtenz@rekmarks@hmalik88