8000 Add Default Export to Flow Type definitions by ccorcos · Pull Request #961 · immutable-js/immutable-js · GitHub
[go: up one dir, main page]

Skip to content

Conversation

@ccorcos
Copy link
@ccorcos ccorcos commented Aug 29, 2016

This PR solves this issue:

#854

In the Flow documentation the show an example where you define library definitions in the libs option. So you may be inclined to use these type declarations by having the following in your flowconfig:

[libs]
./node_modules/immutable-js/dist/immutable.js.flow

The problem with this approach is that those type definitions are now global. Anytime you define a Map type, its going to defer to the Immutable Map and ever the window.Map type definition.

In a separate part of the documentation the talk about delcaration files using the .js.flow approach. Now instead of adding the files as a global declaration in libs, you can simply import immutable from 'immutable' and everything just works :)

@ghost
Copy link
ghost commented Aug 29, 2016

Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. In order for us to review and merge your code, please sign up at https://code.facebook.com/cla - and if you have received this in error or have any questions, please drop us a line at cla@fb.com. Thanks!

@ccorcos
Copy link
Author
ccorcos commented Aug 29, 2016

Just signed the contributors license agreement

@ghost ghost added the CLA Signed label Aug 29, 2016
@ghost
Copy link
ghost commented Aug 29, 2016

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Facebook open source project. Thanks!

@ccorcos
Copy link
Author
ccorcos commented Aug 29, 2016

I also want to mention that it would be great if we could somehow get some strong typing behind Map and List literals. For example, If I have something like Immutable.toJS({a: 1, b: 'hello'}) where I could define this as a strict schema that can be validated by the type checker rather than everything be nullable generic Maps.

@lacker
Copy link
lacker commented Dec 6, 2016

Does this PR still make sense now that we merged #878 ?

@kozlitinaelja
Copy link
Contributor

@ccorcos, is the issue addressed in this PR still exists? If no, please, close. 😅

@ccorcos
Copy link
Author
ccorcos commented Feb 12, 2017

@kozlitinaelja yes -- the definitions are still declared globally. Therefore, you can only have one Map which refers to the immutable Map and not window.Map.

https://flowtype.org/docs/declarations.html#declaration-files

leebyron added a commit that referenced this pull request Feb 14, 2017
@leebyron
Copy link
Collaborator

@ccorcos could you recommend a way to test this change that would otherwise currently fail? I just added a flow type test that ensures the native es6 collections can be used alongside the Immutable.js ones.

@ccorcos
Copy link
Author
ccorcos commented Feb 15, 2017

Are you doing import Immutable from 'Immutable'?

leebyron added a commit that referenced this pull request Mar 1, 2017
The flow type definition tests added in #878 relied on declaring a module, which required .flowconfig to explicitly include the flow definition files, and made exports unclear. This reverts some of the structural changes to the immutable.js.flow from that PR and simplifies the .flowconfig test file to ensure tests are against the *local* copy of immutable. This uncovered a few issues with tests including a mistaken sense that types were exportes as classes and that Set intersections were causing issues.

Fixes #961
leebyron added a commit that referenced this pull request Mar 1, 2017
The flow type definition tests added in #878 relied on declaring a module, which required .flowconfig to explicitly include the flow definition files, and made exports unclear. This reverts some of the structural changes to the immutable.js.flow from that PR and simplifies the .flowconfig test file to ensure tests are against the *local* copy of immutable. This uncovered a few issues with tests including a mistaken sense that types were exportes as classes and that Set intersections were causing issues.

Fixes #961
@sghall
Copy link
sghall commented Mar 3, 2017

In case anyone else lands here. Doing...

import * as Immutable from 'immutable

is a workaround until there's a release that resolves the issue. That got rid of the flow errors for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants

0