pcardune / flowtype-hoc-exploration Goto Github PK
View Code? Open in Web Editor NEWA repository to play around with flowtype and higher-order react components.
License: MIT License
A repository to play around with flowtype and higher-order react components.
License: MIT License
Thanks for your notes-- they were really informative for me!
Did you notice different Flow behavior when the code is in different files?
When the code is all in 1 file (Profile.js) here: https://github.com/saltycrane/flowtype-hoc-exploration/tree/fc09e5f3a0eb62d500c31d996a16610ab682f8e1
I get 2 errors as expected:
$ npm run -s flow
Profile.js:25
25: <LoggedProfile
^ React element `LoggedProfile`
26: username={1234}
^^^^ number. This type is incompatible with
6: function Profile(props:{username:string, onEdit:Function}) {
^^^^^^ string
Profile.js:25
25: <LoggedProfile
^ React element `LoggedProfile`
27: onEdit={"not implemented yet"}
^^^^^^^^^^^^^^^^^^^^^ string. This type is incompatible with
6: function Profile(props:{username:string, onEdit:Function}) {
^^^^^^^^ function type
Found 2 errors
Then I modified the code into 2 files (App.js and Profile.js) here: https://github.com/saltycrane/flowtype-hoc-exploration/tree/4e3150217dc62ef960a8b4e80680bee772a14307
And I got this unexpected error:
$ npm run -s flow
Profile.js:22
22: const LoggedProfile = logOnRender(Profile);
^^^^^^^^^^^^^^^^^^^^ type parameter `FirstOrderProps` of function call. Missing annotation
Found 1 error
Then I separated the code into 3 files (App.js, Profile.js and logOnRender.js) here: https://github.com/saltycrane/flowtype-hoc-exploration/tree/b56850c3cbf95cd9702f3e6fd53adcc4d8e760bc
And I got 0 errors which is not expected:
$ npm run -s flow
No errors!
Just wondering if you have seen this. I am using Flow 0.33.0 and Node v6.4.0.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.