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

Declaring types in libdef does not detect some errors, declaring them locally works well #4342

Closed
istarkov opened this issue Jul 8, 2017 · 6 comments

Comments

@istarkov
Copy link

istarkov commented Jul 8, 2017

As an example compose function
here works well

But if I move compose definition into library definition like here in some situation flow stopped to detect some errors.
(It works well for a lot of other situations but don't work with current)

@calebmer
Copy link
Contributor

calebmer commented Jul 22, 2017

I’m not sure if declare module works outside of library definition files. (So it would not work on https://flow.org/try)

Could you put together an example in a small GitHub repo?

@istarkov
Copy link
Author

istarkov commented Jul 24, 2017

@calebmer thank you for help, seems like you are right and declare module does not work inside /try
here https://github.com/istarkov/flow-compose-error is the example to reproduce a problem
It's different from above - but with the near same behaviour - errors depend on where compose is defined.
Here is the partial copy of above project README.

src/goodCompose.js uses internally defined compose

src/badCompose.js uses libdef flow-typed/recompose for compose

Except compose definition location both files share the same code.
definition of compose is also same

After run yarn flow we see good error for internally defined Compose, and something strange for libdef compose

See screenshots

src/goodCompose.js

image

src/badCompose.js

image

@calebmer
Copy link
Contributor

You are actually getting the expected error here 😊

Math.round() takes a number, but your first enhancer returns a string for p.

I agree that this error message is way to hard to diagnose, though 😖

@istarkov
Copy link
Author

The problem is not in error, the problem that it different for the same compose definition, and depends on compose location.
And in one case error is easily readable, and not in the other

@sibelius
Copy link

is this still valid?

@SamChou19815
Copy link
Contributor

The difference between libdef and local mode should be fixed a long time ago

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

4 participants