Skip to content
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

Fix: Simplify handle all types #414

Merged
merged 10 commits into from Jul 2, 2022
Merged

Conversation

skarab42
Copy link
Collaborator

@skarab42 skarab42 commented Jul 1, 2022

Related to #408 (comment)

  • Fix the case where the type to be simplified is a function. In this case we return the type without modification.

test-d/simplify.ts Outdated Show resolved Hide resolved
@skarab42 skarab42 changed the title fix: Simplify handle function type Fix: Simplify handle function type Jul 1, 2022
@skarab42
Copy link
Collaborator Author

skarab42 commented Jul 1, 2022

@sindresorhus I think I have found a trick to support any type without testing all cases. The strategy is if the simplified type extends the source type then we return the simplified type otherwise the source.

I also added the deep option to apply the simplification recursively.

source/simplify.d.ts Outdated Show resolved Hide resolved
source/simplify.d.ts Show resolved Hide resolved
@skarab42 skarab42 changed the title Fix: Simplify handle function type Fix: Simplify handle all types Jul 2, 2022
@sindresorhus sindresorhus merged commit 96fe795 into sindresorhus:main Jul 2, 2022
skarab42 added a commit to skarab42/type-fest that referenced this pull request Jul 3, 2022
Co-authored-by: Sindre Sorhus <sindresorhus@gmail.com>
@skarab42 skarab42 deleted the fix-simplify branch August 16, 2022 12:05
Sign up for free to 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.

None yet

2 participants