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

CSF: Infer defaultValue of argtype based on arg #15798

Merged
merged 1 commit into from
Sep 6, 2021

Conversation

yannbf
Copy link
Member

@yannbf yannbf commented Aug 9, 2021

An extension on top of #14356

What I did

ArgTypes is now able to infer the values based on the Args being passed.
If a custom argtype is being passed (that's not a key of passed down Args), it will still infer the correct properties, but defaultValue will be of type unknown.

How to test

  • Is this testable with Jest or Chromatic screenshots? no
  • Does this need a new example in the kitchen sink apps? not necessarily
  • Does this need an update to the documentation? not sure [?]

If your answer is yes to any of these, please make sure to include it in your PR.

@yannbf yannbf added maintenance User-facing maintenance tasks typescript csf args labels Aug 9, 2021
@nx-cloud
Copy link

nx-cloud bot commented Aug 9, 2021

Nx Cloud Report

CI ran the following commands for commit 814a5f8. Click to see the status, the terminal output, and the build insights.

📂 See all runs for this branch

Status Command
#000000 nx run-many --target=prepare --all --parallel --max-parallel=15

Sent with 💌 from NxCloud.

@yannbf
Copy link
Member Author

yannbf commented Aug 9, 2021

Hey @maxmezzomo! Thanks a lot for the previous contribution you did in #14356! I noticed that the autocompletion was not happening from keys that were not defined in the Args, so I added a fix to that. I also thought it would be nice to get type inference from the property (as in Args<key>) and added that as well.

What do you think?

@yannbf yannbf changed the title feat(types): infer defaultValue of argtype based on arg CSF: infer defaultValue of argtype based on arg Aug 9, 2021
Copy link
Member

@shilman shilman left a comment

Choose a reason for hiding this comment

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

LGTM 💪

@shilman shilman changed the title CSF: infer defaultValue of argtype based on arg CSF: Infer defaultValue of argtype based on arg Aug 10, 2021
@yannbf yannbf force-pushed the feature/argtypes-inference branch from bfc6632 to 814a5f8 Compare August 31, 2021 21:40
@yannbf
Copy link
Member Author

yannbf commented Sep 5, 2021

@shilman this seems good to go!

@shilman shilman added this to the 6.4 PRs milestone Sep 5, 2021
@shilman shilman merged commit e0661a0 into next Sep 6, 2021
@shilman shilman deleted the feature/argtypes-inference branch September 6, 2021 13:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
args csf maintenance User-facing maintenance tasks typescript
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants