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

Props: Fix typescript unspecified default value #9873

Merged
merged 1 commit into from Feb 20, 2020
Merged

Conversation

shilman
Copy link
Member

@shilman shilman commented Feb 16, 2020

Issue: #9827

What I did

Mapping a function that takes two arguments passes the index as the second argument. Fixed & tested!

How to test

See updated snapshots & chromatic changes

@shilman shilman added addon: docs block: props bug patch:yes Bugfix & documentation PR that need to be picked to main branch labels Feb 16, 2020
@shilman shilman added this to the 5.3.x milestone Feb 16, 2020
@patricklafrance
Copy link
Member

Is it really the following line that fix the issue?

https://github.com/storybookjs/storybook/pull/9873/files#diff-3211380902a8842f1636fd47078eeb11L26

@shilman
Copy link
Member Author

shilman commented Feb 17, 2020

@patricklafrance Yes, AFAICT. i'm not familiar with your code yet, so perhaps there's a better fix elsewhere. the rest of the PR is just updated (fixed) snapshots

@patricklafrance
Copy link
Member

I don't understand how it could be the problem.

Furthermore if the user is not using react-docgen for TS, he doesn't go through this code. I can't find which version of SB he is running, is he on an alpha version with react-docgen?

@shilman
Copy link
Member Author

shilman commented Feb 17, 2020

@patricklafrance You don't need to know anything about the user's setup for this. The problem is repro'd multiple times in the snapshot tests, and the fix appears to be working. What am I missing?

@patricklafrance
Copy link
Member

patricklafrance commented Feb 17, 2020

@shilman

Unless you are using react-docgen, the "typescript" codepath shouldn't be followed because it's based on the name of the type property.

In react-docgen, you have the following:

  • type -> propTypes path
  • tsType -> typescript path
  • flowType -> flow path

https://github.com/reactjs/react-docgen#result-data-structure

When using react-docgen for propTypes and react-doc-typescript you get type for both so the code always go through the "propTypes" codepath.

Overall if it fix a bug I don't mind, I am asking because I don't understand how it could fix something.

@shilman
Copy link
Member Author

shilman commented Feb 17, 2020

Does that mean that the typescript handling code is basically unused in 5.3?

@patricklafrance
Copy link
Member

@shilman unless something changes after my last commit, YES.

It was going to be used once I rework the docs presets to include react-docgen-typescript-loader and provide a default config that would set typePropName to tsType.

@shilman shilman merged commit 3aa12e9 into next Feb 20, 2020
@ndelangen ndelangen deleted the 9827-ts-default-values branch February 20, 2020 17:26
@shilman shilman added the patch:done Patch/release PRs already cherry-picked to main/release branch label Feb 25, 2020
shilman added a commit that referenced this pull request Feb 25, 2020
Props: Fix typescript unspecified default value
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
addon: docs block: props bug patch:done Patch/release PRs already cherry-picked to main/release branch patch:yes Bugfix & documentation PR that need to be picked to main branch
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants