Skip to content
New issue

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

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

Already on GitHub? # to your account

fix: Improve type output for narrowed interfaces (intersect members of unions instead) #370

Merged
merged 3 commits into from
Aug 18, 2024

Conversation

kitten
Copy link
Member

@kitten kitten commented Aug 18, 2024

Summary

I noticed that the types on interfaces and unions could become quite complex and the type output wasn't nice to read.

Instead of asking TypeScript to narrow using an intersection, we can instead manually narrow any union, since they're expanded in extends types.

Note: I'm not 100% sure what the type performance impact of this change might be, but the benchmarks indicate that it's negligible.

Follow-up to #368
But issue is also visible before the above PR was merged. It was just rarer

Set of changes

  • Expand union types before intersecting

Copy link

changeset-bot bot commented Aug 18, 2024

🦋 Changeset detected

Latest commit: 9bab4f9

The changes in this PR will be included in the next version bump.

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@kitten kitten marked this pull request as ready for review August 18, 2024 17:36
@kitten kitten merged commit 1a2df0e into main Aug 18, 2024
2 checks passed
@kitten kitten deleted the fix/improve-type-output-on-unions branch August 18, 2024 17:39
@github-actions github-actions bot mentioned this pull request Aug 18, 2024
kitten added a commit that referenced this pull request Aug 18, 2024
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants