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

Make it easier for to use fbjs and flow together #64

Closed
clentfort opened this issue Sep 30, 2015 · 6 comments
Closed

Make it easier for to use fbjs and flow together #64

clentfort opened this issue Sep 30, 2015 · 6 comments

Comments

@clentfort
Copy link

I don't really know if/how this could be achieved but using flow in a project using any project that uses fbjs make flow throw a lot of errors by default.

Take a simple project that uses react and react-relay. This throws 20 errors on an empty project with an empty .flowconfig

flow check                                                                                                                                      [20:30:35]

/home/christian/relay-flow-starter-kit/node_modules/react-relay/node_modules/fbjs/flow/include/Deferred.js:14:15,32: Promise
Required module not found

/home/christian/relay-flow-starter-kit/node_modules/react-relay/node_modules/fbjs/flow/include/PromiseMap.js:15:16,34: Deferred
Required module not found

/home/christian/relay-flow-starter-kit/node_modules/react-relay/node_modules/fbjs/flow/include/PromiseMap.js:17:17,36: invariant
Required module not found

/home/christian/relay-flow-starter-kit/node_modules/react-relay/node_modules/fbjs/flow/include/PromiseMap.js:19:31,39: Promise
Required module not found

/home/christian/relay-flow-starter-kit/node_modules/react-relay/node_modules/fbjs/flow/include/fetchWithRetries.js:16:28,58: ExecutionEnvironment
Required module not found

/home/christian/relay-flow-starter-kit/node_modules/react-relay/node_modules/fbjs/flow/include/fetchWithRetries.js:17:15,32: Promise
Required module not found

/home/christian/relay-flow-starter-kit/node_modules/react-relay/node_modules/fbjs/flow/include/fetchWithRetries.js:19:15,32: sprintf
Required module not found

/home/christian/relay-flow-starter-kit/node_modules/react-relay/node_modules/fbjs/flow/include/fetchWithRetries.js:20:13,28: fetch
Required module not found

/home/christian/relay-flow-starter-kit/node_modules/react-relay/node_modules/fbjs/flow/include/fetchWithRetries.js:21:15,32: warning
Required module not found

/home/christian/relay-flow-starter-kit/node_modules/react-relay/node_modules/fbjs/flow/include/resolveImmediate.js:13:15,32: Promise
Required module not found

/home/christian/relay-flow-starter-kit/node_modules/react/node_modules/fbjs/flow/include/Deferred.js:14:15,32: Promise
Required module not found

/home/christian/relay-flow-starter-kit/node_modules/react/node_modules/fbjs/flow/include/PromiseMap.js:15:16,34: Deferred
Required module not found

/home/christian/relay-flow-starter-kit/node_modules/react/node_modules/fbjs/flow/include/PromiseMap.js:17:17,36: invariant
Required module not found

/home/christian/relay-flow-starter-kit/node_modules/react/node_modules/fbjs/flow/include/PromiseMap.js:19:31,39: Promise
Required module not found

/home/christian/relay-flow-starter-kit/node_modules/react/node_modules/fbjs/flow/include/fetchWithRetries.js:16:28,58: ExecutionEnvironment
Required module not found

/home/christian/relay-flow-starter-kit/node_modules/react/node_modules/fbjs/flow/include/fetchWithRetries.js:17:15,32: Promise
Required module not found

/home/christian/relay-flow-starter-kit/node_modules/react/node_modules/fbjs/flow/include/fetchWithRetries.js:19:15,32: sprintf
Required module not found

/home/christian/relay-flow-starter-kit/node_modules/react/node_modules/fbjs/flow/include/fetchWithRetries.js:20:13,28: fetch
Required module not found

/home/christian/relay-flow-starter-kit/node_modules/react/node_modules/fbjs/flow/include/fetchWithRetries.js:21:15,32: warning
Required module not found

/home/christian/relay-flow-starter-kit/node_modules/react/node_modules/fbjs/flow/include/resolveImmediate.js:13:15,32: Promise
Required module not found

Found 20 errors

I can fix these error by mimicking the relay's .flowconfig but this gets really cumbersome. Is there anything that can be done to improve on this situation?

@sophiebits
Copy link
Contributor

Yes, @gabelevi is working on a solution to this since we need it at FB too.

@zpao zpao changed the title Make it easier for applications using projects that depend on fbjs Make it easier for to use fbjs and flow together Sep 30, 2015
@danvk
Copy link

danvk commented Oct 19, 2015

I ran into this today after updating to React 0.14 on a project. I nixed the errors by adding this to my .flowconfig:

[ignore]
.*react/node_modules/fbjs.*

@madbence
Copy link

npm@3 flattens the directory structure, so with node@5 you should ignore .*node_modules/fbjs.* (my travis builds were failing with v5 node).

@sophiebits
Copy link
Contributor

Gonna partially commandeer this issue. Running flow with a fresh install of fbjs gives:

node_modules/react/node_modules/fbjs/lib/PromiseMap.js.flow:15
 15: var Deferred = require('Deferred');
                    ^^^^^^^^^^^^^^^^^^^ Deferred. Required module not found

node_modules/react/node_modules/fbjs/lib/PromiseMap.js.flow:17
 17: var invariant = require('invariant');
                     ^^^^^^^^^^^^^^^^^^^^ invariant. Required module not found

node_modules/react/node_modules/fbjs/lib/fetchWithRetries.js.flow:16
 16: var ExecutionEnvironment = require('ExecutionEnvironment');
                                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ExecutionEnvironment. Required module not found

node_modules/react/node_modules/fbjs/lib/fetchWithRetries.js.flow:19
 19: var sprintf = require('sprintf');
                   ^^^^^^^^^^^^^^^^^^ sprintf. Required module not found

node_modules/react/node_modules/fbjs/lib/fetchWithRetries.js.flow:20
 20: var fetch = require('fetch');
                 ^^^^^^^^^^^^^^^^ fetch. Required module not found

node_modules/react/node_modules/fbjs/lib/fetchWithRetries.js.flow:21
 21: var warning = require('warning');
                   ^^^^^^^^^^^^^^^^^^ warning. Required module not found


Found 6 errors

because we don't currently rewrite the require paths in .flow files so you're required to have haste module resolution in order to make things typecheck. If we relativize the requires this problem should hopefully go away.

@zpao
Copy link
Member

zpao commented Sep 27, 2016

I think this should be pretty much fixed now that #182 shipped in v0.8.5. We had fixed the require issues a while back. #185 has one more piece that we're missing but it's not for fbjs directly at the moment.

@zpao zpao closed this as completed Sep 27, 2016
@bchenSyd
Copy link

I had the same issue with -- [email protected]

?[0m?[0m
?[0m?[0;4mnode_modules/fbjs/lib/minBy.js.flow:27?[0m?[0m
?[0m?[0;1m 27: ?[0m?[0m    if (!seenFirst || ?[0m?[31mcompare(b, (minB: any))?[0m?[0m < 0) {?[0m?[0;1m
                           ^^^^^^^^^^^^^^^^^^^^^^^ function call. Function cannot be called on possibly null value?[0m?[0m?[0m?[0m
?[0m?[0;1m 27: ?[0m?[0m    if (!seenFirst || ?[0m?[31mcompare?[0m?[0m(b, (minB: any)) < 0) {?[0m?[0;1m
                           ^^^^^^^ null?[0m?[0m?[0m?[0m
?[0m?[0m
?[0m?[0;4mnode_modules/fbjs/lib/minBy.js.flow:27?[0m?[0m
?[0m?[0;1m 27: ?[0m?[0m    if (!seenFirst || ?[0m?[31mcompare(b, (minB: any))?[0m?[0m < 0) {?[0m?[0;1m
                           ^^^^^^^^^^^^^^^^^^^^^^^ function call. Function cannot be called on possibly undefined value?[0m?[0m?[0m?[0m
?[0m?[0;1m 27: ?[0m?[0m    if (!seenFirst || ?[0m?[31mcompare?[0m?[0m(b, (minB: any)) < 0) {?[0m?[0;1m
                           ^^^^^^^ undefined?[0m?[0m?[0m?[0m
?[0m?[0m
?[0m
Found 17 errors

sorry for the terrible display as I'm using git-bash on a windows box

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

No branches or pull requests

6 participants