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

Support ts(x) file parsing using CLI #391

Merged
merged 1 commit into from Oct 16, 2019
Merged

Support ts(x) file parsing using CLI #391

merged 1 commit into from Oct 16, 2019

Conversation

Kureev
Copy link
Contributor

@Kureev Kureev commented Oct 2, 2019

Why

The current implementation of react-docgen CLI doesn't support passing a single *.ts(x) file for parsing. As you can see from the source code, internal function parse is called with only one parameter (content of the required file), however, in order to specify that the file should be parsed according to the TypeScript spec, we need pass options to the babelParser that should contain a filename with ts(x) extension. If we don't pass filePath (see my patch), options object will become empty and flow parser will be used instead (which is incompatible with some TypeScript features).

Scope of the bug

This bug only affects react-codegen CLI tool

Solution

Pass filePath along with the file content

@danez
Copy link
Collaborator

danez commented Oct 16, 2019

Good catch, thanks for that.

@danez danez merged commit a1f9b9a into reactjs:master Oct 16, 2019
danez pushed a commit that referenced this pull request Oct 16, 2019
@Kureev Kureev deleted the cli-ts-parsing-support branch October 18, 2019 00:21
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 28, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants