Skip to content

Write non-missing undefined on mapped type results into output #59208

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

weswigham
Copy link
Member

Fixes #59056

@typescript-bot typescript-bot added Author: Team For Milestone Bug PRs that fix a bug with a specific milestone labels Jul 9, 2024
@weswigham weswigham marked this pull request as draft July 9, 2024 20:25
@weswigham weswigham changed the title Write non-missing undefined missing from reused node into output Write non-missing undefined on mapped type results into output Jul 9, 2024
@weswigham weswigham requested a review from jakebailey July 9, 2024 21:53
@weswigham weswigham marked this pull request as ready for review July 9, 2024 21:53
@weswigham
Copy link
Member Author

This is a bit of a compromise fix - when we see a property that came from a mapped type (or reverse mapped type) instantiation where the input and output are optional, if the type contains an actual undefined (and not missing) type, we now always write that | undefined to the output. It's not strictly required outside of exactOptionalPropertyTypes (since the optional prop and the optional prop with an | undefined are functionally identical), but keeps the output consistent between the two modes. More relevantly, under exactOptionalPropertyTypes, we only add the | undefined to the preserved node if there's a real, explicit undefined in the type. By limiting this to only the results of mapped type instantiations, I think I make it so this has no impact on isolatedDeclarations behaviors (since those can't resolve a mapped type).

@jakebailey jakebailey closed this Jul 10, 2024
@jakebailey jakebailey reopened this Jul 10, 2024
@jakebailey
Copy link
Member

I think we want this?

@typescript-bot cherry-pick this to release-5.5

@typescript-bot
Copy link
Collaborator

typescript-bot commented Jul 10, 2024

Starting jobs; this comment will be updated as builds start and complete.

Command Status Results
cherry-pick this to release-5.5 ✅ Started ✅ Results

@weswigham weswigham merged commit ed17a89 into microsoft:main Jul 10, 2024
29 checks passed
@typescript-bot
Copy link
Collaborator

Hey, @jakebailey! I've created #59230 for you. This involved updating baselines; please check the diff.

DanielRosenwasser pushed a commit that referenced this pull request Jul 19, 2024
…e-5.5 (#59230)

Co-authored-by: Wesley Wigham <[email protected]>
Co-authored-by: Jake Bailey <[email protected]>
@sandersn sandersn removed this from PR Backlog Apr 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Author: Team For Milestone Bug PRs that fix a bug with a specific milestone
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Declaration emit change in 5.5 with exactOptionalPropertyTypes
3 participants