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

Flow type annotations #87

Closed
wants to merge 5 commits into from
Closed

Flow type annotations #87

wants to merge 5 commits into from

Conversation

acdlite
Copy link
Collaborator

@acdlite acdlite commented Jun 13, 2015

Opening this PR to track adding Flow annotations. So far I've completed Redux.js. Looks like the biggest thing we'll have to give up is const, as Flow supports neither that nor let. I think that trade off is worth it.

We'll also want to integrate Flow into our automated tests.

Prior to this my experience with Flow was the "Hello, World!" example on their website, so if I do something wrong please let me know :)

Addresses #83.

@gaearon
Copy link
Contributor

gaearon commented Jun 13, 2015

Everything is mixed haha.

I like this. Want to see more :-)

@acdlite
Copy link
Collaborator Author

acdlite commented Jun 13, 2015

@gaearon Haha, that's a good thing in this case! Not making any assumptions about action or state types :)

@acdlite
Copy link
Collaborator Author

acdlite commented Jun 13, 2015

@gaearon How about this: I'll create a types.js file with all the basic types we deal with in Redux. We will have an Action and State type that simply aliases to mixed, for clarity.

@gaearon
Copy link
Contributor

gaearon commented Jun 13, 2015

I like this.

@acdlite
Copy link
Collaborator Author

acdlite commented Jun 14, 2015

Still can't figure out how to use union types to implement function overloading.

@skevy
Copy link
Contributor

skevy commented Jun 14, 2015

I haven't tested this...but have you guys considered running the code base through babel first (and blacklisting flow so that it keeps the types) and then running it through the flow type checker? If that worked; it would allow all ES2015+ features to stay and still get the benefits of type checking.

@skevy
Copy link
Contributor

skevy commented Jun 14, 2015

Looks like this guy is doing it http://www.keendevelopment.ch/flow-babel-gulp-es6/

@gaearon gaearon mentioned this pull request Jun 15, 2015
@ooflorent
Copy link
Contributor

Why did you convert const to var?

@gaearon
Copy link
Contributor

gaearon commented Jun 16, 2015

Why did you convert const to var?

See the first post:

Looks like the biggest thing we'll have to give up is const, as Flow supports neither that nor let.

Although it may be possible to do it some another way:

http://www.keendevelopment.ch/flow-babel-gulp-es6/

@acdlite
Copy link
Collaborator Author

acdlite commented Jun 16, 2015

I'm kind of stuck on this PR until someone can explain to me how to properly use union types to implement function overloading. Any Flow experts out there?

@taylorhakes
Copy link
Contributor

I am not very familiar with Flow, but the issue is being caused by this line in createDispatcher.

return compose(...middlewares, dispatch);

If you take out dispatch, it stops complaining. I am not sure this is an issue with function overloading, but I am having a hard time figuring out what it wants.

I noticed #166 will conflict with this pull request. The issue may be solved because the createDispatcher function is being removed.

Do you want me to take this over or would you like to continue? I can fix the code conflicted, add the code not covered in 166 and resubmit.

@acdlite
Copy link
Collaborator Author

acdlite commented Jun 23, 2015

We should probably wait until 1.0 when the API is stable. After that, feel free!

@winkler1
Copy link

Here's a way to run Flow when files change... very useful when tweaking the config, fast feedback loop.

npm i --save-dev onchange && ./node_modules/onchange/cli.js '**/*' -- flow check

@hzoo
Copy link

hzoo commented Jun 24, 2015

@acdlite About function overloading - http://flowtype.org/docs/union-intersection-types.html you can use intersections (&)

// Intersections are well-suited to mimic function overloading.
declare var f: ((x: number) => void) & ((x: string) => void);

@gaearon
Copy link
Contributor

gaearon commented Jul 12, 2015

Superseded by #87.

@gaearon gaearon closed this Jul 12, 2015
@gaearon
Copy link
Contributor

gaearon commented Jul 12, 2015

Whoops, inception! I meant by #254.

@gaearon gaearon deleted the flow branch July 12, 2015 23:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants