Skip to content

Fix optional types not registering as such outside of TS strict mode #40

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

jeromepl
Copy link

@jeromepl jeromepl commented Feb 5, 2023

On a project with strict TS config turned off, I discovered that the generated propTypes were always marked with isRequired

This PR fixes this and adds testing for this additional typescript config scenario.

Reviewing with whitespace changes turned off will make it easier to review test/index.test.ts

Comment on lines -443 to +438
return t.unionNode([t.elementNode('node'), t.undefinedNode()]);
return t.unionNode([t.undefinedNode(), t.elementNode('node')]);
Copy link
Author

Choose a reason for hiding this comment

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

Using the convention that undefinedNode always comes first in a unionNode makes it easy to compare the expected to actual objects in the tests.
This was the quick fix instead of creating a matcher for jest that would ignore array order within union nodes.
It's also why I had to change a couple of the output.json test files to reorder elements.

@jeromepl
Copy link
Author

@merceyz have you had a chance to take a look?

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.

1 participant