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

feat: Add initial TypeScript autocomplete support #35

Merged
merged 5 commits into from
Dec 18, 2018

Conversation

markdalgleish
Copy link
Member

@markdalgleish markdalgleish commented Dec 6, 2018

Before starting webpack, if we detect a tsconfig.json file, we now use react-docgen-typescript to parse the prop types of all React components in the current working directory. For now, only string prop values are supported. On a component-by-component basis, we use the static types if they're available, otherwise we fall back to the existing strategy via parse-prop-types.

There aren't any automated tests for this, but I've added a TypeScript example for manual testing. I've added a Cypress test for the existing autocomplete behaviour to ensure that we haven't regressed.

In order to test this automatically, we'll need to improve our test suite to support multiple test projects, but I'm happy to leave that for another PR.

@hipstersmoothie
Copy link

Works great 🎉

screen shot 2018-12-06 at 1 02 23 am

@hipstersmoothie
Copy link

One thing you might want to add is the ability to configure react-dogen-typescript's config. https://github.com/styleguidist/react-docgen-typescript#parseroptions

In my storybook i use that to exclude the HTML attributes using propFilter.

@markdalgleish
Copy link
Member Author

@hipstersmoothie I might look into something like this as a follow-up PR.

@DavidHooper
Copy link
Contributor

Looks great, any ETA on when this will be released?

lib/getStaticTypes.js Show resolved Hide resolved
lib/getStaticTypes.js Outdated Show resolved Hide resolved
Copy link
Contributor

@jackhurley23 jackhurley23 left a comment

Choose a reason for hiding this comment

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

Looks good!

@markdalgleish markdalgleish merged commit 39046d7 into master Dec 18, 2018
@markdalgleish markdalgleish deleted the typescript-autocomplete branch December 18, 2018 01:00
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

4 participants