Skip to content

feat(react): Support new flow 0.53 annotations #209

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

Merged
merged 1 commit into from
Sep 5, 2017
Merged

feat(react): Support new flow 0.53 annotations #209

merged 1 commit into from
Sep 5, 2017

Conversation

danez
Copy link
Collaborator

@danez danez commented Aug 24, 2017

Fixes #207

@oliviertassinari
Copy link

Material-UI project is looking forward seeing this PR released.
@danez Thanks for working on it!

@danez danez merged commit fbc62b1 into reactjs:master Sep 5, 2017
@danez danez deleted the support-flow-53 branch September 5, 2017 11:19
@danrot
Copy link

danrot commented Sep 5, 2017

Thanks a lot! Any idea when will this be released?

@danez
Copy link
Collaborator Author

danez commented Sep 5, 2017

It is released now as 2.18.0

@rosskevin
Copy link
Contributor

I'm trying out 2.18.0 on material-ui/v1-beta and it is still failing to parse the first file. I'm trying to isolate where it is, but I do know it is falling through in the flowParsePrimaryType. If others are having problems or finding quirks, please let us know.

I'll see if I can get an isolated test case figured out.

@danez
Copy link
Collaborator Author

danez commented Sep 5, 2017

Do you have an error? Or are the docs incorrect?

@oliviertassinari
Copy link

@rosskevin I have been applying the fix locally with success. (a week ago with flow 0.53 no 0.54).

@rosskevin
Copy link
Contributor

I have an error, it is failing on a stateless function. @oliviertassinari good to know, I'm using 2.18.0 release on the tip of v1-beta.

Looking at the package to see if the change made it.

@rosskevin
Copy link
Contributor

rosskevin commented Sep 5, 2017

This failure originates in react-docgen's babylon at flowParsePrimaryType. Versioning issue?

$ rimraf pages/api/* && babel-node ./docs/scripts/buildApi.js
Error parsing src for /Users/kross/projects/material-ui/src/Avatar/Avatar.js
/Users/kross/projects/material-ui/docs/scripts/buildApi.js:87
    throw err;
    ^

SyntaxError: Unexpected token (53:21)
    at Parser.pp.raise (/Users/kross/projects/material-ui/node_modules/react-docgen/node_modules/babylon/lib/parser/location.js:24:13)
    at Parser.pp.unexpected (/Users/kross/projects/material-ui/node_modules/react-docgen/node_modules/babylon/lib/parser/util.js:82:8)
    at Parser.pp.flowParsePrimaryType (/Users/kross/projects/material-ui/node_modules/react-docgen/node_modules/babylon/lib/plugins/flow.js:552:8)
    at Parser.pp.flowParsePostfixType (/Users/kross/projects/material-ui/node_modules/react-docgen/node_modules/babylon/lib/plugins/flow.js:557:38)
    at Parser.pp.flowParsePrefixType (/Users/kross/projects/material-ui/node_modules/react-docgen/node_modules/babylon/lib/plugins/flow.js:573:17)
    at Parser.pp.flowParseIntersectionType (/Users/kross/projects/material-ui/node_modules/react-docgen/node_modules/babylon/lib/plugins/flow.js:579:19)
    at Parser.pp.flowParseUnionType (/Users/kross/projects/material-ui/node_modules/react-docgen/node_modules/babylon/lib/plugins/flow.js:589:19)
    at Parser.pp.flowParseType (/Users/kross/projects/material-ui/node_modules/react-docgen/node_modules/babylon/lib/plugins/flow.js:600:19)
    at Parser.pp.flowParseTypeParameterInstantiation (/Users/kross/projects/material-ui/node_modules/react-docgen/node_modules/babylon/lib/plugins/flow.js:217:27)
    at Parser.pp.flowParseGenericType (/Users/kross/projects/material-ui/node_modules/react-docgen/node_modules/babylon/lib/plugins/flow.js:364:32)
error Command failed with exit code 1.
yarn list babylon
yarn list v0.27.5
├─ [email protected]
├─ [email protected]
│  └─ [email protected]
└─ [email protected]
   ├─ [email protected]
   │  └─ [email protected]
   └─ [email protected]
 yarn why babylon
yarn why v0.27.5
[1/4] Why do we have the module "babylon"...?
[2/4] Initialising dependency graph...
[3/4] Finding dependency...
[4/4] Calculating file sizes...
info Has been hoisted to "babylon"
info Reasons this module exists
   - "babel-core" depends on it
   - "babel-eslint" depends on it
   - "babel-plugin-preval" depends on it
   - "next#babel-core" depends on it
   - "next#styled-jsx#babel-traverse" depends on it

@rosskevin
Copy link
Contributor

Failure is on children?: Element<*>, I also have component?: string | ComponentType<*> but I commented it out on the hunch that the Element inference was breaking it.

@rosskevin
Copy link
Contributor

I'm going to pull and add some children test cases instead of working from the outside.

@danez
Copy link
Collaborator Author

danez commented Sep 5, 2017

Babylon 5 - which is used by react-docgen v2 - does not support * (The flow infere operator, or whatever it is called :) ). You will want to use react-docgen v3-beta, but I haven't released a new version of react-docgen v3-beta with the flow-react fix yet as I had some test issues. I wanted to investigate later.

ajs139 added a commit to ajs139/react-styleguidist that referenced this pull request Sep 5, 2017
Update React Docgen for support of the new Flow 0.53 annotations:
reactjs/react-docgen#209
ajs139 added a commit to ajs139/react-styleguidist that referenced this pull request Sep 5, 2017
Update React Docgen for support of the new Flow 0.53 annotations:
reactjs/react-docgen#209
sapegin pushed a commit to styleguidist/react-styleguidist that referenced this pull request Sep 5, 2017
Update React Docgen for support of the new Flow 0.53 annotations:
reactjs/react-docgen#209
@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.

4 participants