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
TypeScript support #325
Comments
I'm all for reducing the number of dependencies, but we also use recast's ability to resolve identifiers to their value expressions, i.e. https://github.com/reactjs/react-docgen/blob/master/src/utils/resolveToValue.js#L156 It would be good to compare the differences between the Typescript and Flow ASTs. I'd assume that recast provides some abstraction over them, but not sure. |
Recast traditional my makes stuff like resolveToValue easier than straight Babel, but the current babel API is better nowadays. Nodes have a Honestly I'd like to remove recast, if only because it avoids a context shift between AST tools I use regularly :P As for typescript I do think recast is probably abstracting the differences, the plain AST from babel attempts to match the actual typescript AST nodes for annotations which are fairly different from flows |
I am working on TypeScript support here: #348. If you're interested in helping out with testing, please feel free to leave feedback on the PR! |
Let's get
react-docgen
working with TypeScript. What will it take?recast
added support for TypeScript in 2018, and from #316 it looks like @jquense has been working on getting the parser integrated withreact-docgen
.I haven't worked with recast, and I'm not sure how different the output is between Flow and TS.
But the the actual types are very similar. Here's the example from the Readme in TypeScript.
The only real change i did was changing
subvalue: ?boolean
tosubvalue: boolean | null
, which seems like the way to make values nullable.Input
Output
All flow types are currently exported under their own key "flowType". Following this structure, it would seem obvious to just add a new "typeScript" key?
The text was updated successfully, but these errors were encountered: