-
-
Notifications
You must be signed in to change notification settings - Fork 297
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
Add custom importers for importing types/values #464
Conversation
I might have run into a problem when testing this against some local code today. Need to dig in further. |
Squashed commit of the following: commit 3b3bbf6 Author: Daniel Tschinder <daniel@tschinder.de> Date: Thu Nov 21 21:52:40 2019 +0100 Add additional test commit 048646d Author: Daniel Tschinder <daniel@tschinder.de> Date: Thu Nov 21 21:41:41 2019 +0100 Fix order of deps commit e69ef4f Author: Daniel Tschinder <daniel@tschinder.de> Date: Thu Nov 21 21:39:59 2019 +0100 Add mjs commit 26874ee Merge: 02649b7 b3601b6 Author: Daniel Tschinder <daniel@tschinder.de> Date: Fri Oct 25 22:25:43 2019 +0200 Merge branch 'master' into importing # Conflicts: # src/utils/isReactComponentClass.js commit 02649b7 Merge: 8c0a15f aa54200 Author: Daniel Tschinder <daniel@tschinder.de> Date: Fri Oct 25 22:21:51 2019 +0200 Merge branch 'master' into importing # Conflicts: # src/__tests__/__snapshots__/main-test.js.snap # src/__tests__/fixtures/component_28.tsx commit 8c0a15f Author: Devon Govett <devongovett@gmail.com> Date: Sat May 4 17:56:04 2019 -0700 Missing typedef commit 08b5e7f Author: Devon Govett <devongovett@gmail.com> Date: Sat May 4 17:45:34 2019 -0700 Fix lint commit c180af8 Author: Devon Govett <devongovett@gmail.com> Date: Sat May 4 15:08:19 2019 -0700 Support named re-exports commit 80200c8 Author: Devon Govett <devongovett@gmail.com> Date: Sat May 4 13:18:59 2019 -0700 Handle recursive imports commit 79a814f Author: Devon Govett <devongovett@gmail.com> Date: Sat May 4 13:09:16 2019 -0700 Support export all declaration commit 840ca88 Author: Devon Govett <devongovett@gmail.com> Date: Fri May 3 23:25:57 2019 -0700 Handle namespace imports commit 268b828 Author: Devon Govett <devongovett@gmail.com> Date: Fri May 3 22:51:00 2019 -0700 Add noop browser version of resolveImportedValue commit 00b3d35 Author: Devon Govett <devongovett@gmail.com> Date: Sun Apr 28 21:59:00 2019 -0700 Initial support for importing prop types
This is not airtight. 1. We may need to make this configurable with a pragma comment. 2. We should probably shallowly resolve the import and record the file and exported name of the alias, instead of just the local name.
…ure for better type safety
…ons, update tests
Alright, I think this is ready for an initial review while I continue the follow up work of adding test for What do you think @danez? |
Heroic work @phated 🎖️ 🏅 🥇 |
It's probably worth mentioning; I bootstrapped this into a large project that I'm working on and it works splendidly! |
@phated wow! |
@phated can i use this with you repository? In npm |
I will merge now and release an alpha version with it. Feel free to create follow up PRs for the tests, bugfixes etc.
|
@danez - Any documentation on usage of this please? Using imported proptypes has been an issue for us for a while. If there is no documentation showing how to enable this in the alpha version, we may have to move away from docgen. |
@danez @phated I guess note that imported types aren't supported is redundant, right? https://github.com/reactjs/react-docgen/blob/master/README.md#flow-and-typescript-support |
Alright, I think this is ready to get some serious feedback. Promoting from draft!
Building on the excellent work by @devongovett and @motiz88, I've been trying to implement the requested changes in #352 (specifically #352 (comment))
What I've done
parse
method, but if using thedefaultParse
frommain.js
, it is an additional option that can be specified. This is to make everything backwards compatible.fsImporter
and wrapped it in a factory function so the module lookup and cache could be configured. This also allows caching to be done for entire run of react-docgen (if you have a way to reuse your cache, it can even be done between runs).Stuff I still need to do:
makeFsImporter