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 BUG: This is a misplaced error #9119

Open
ayroblu opened this issue Feb 15, 2024 · 3 comments
Open

FLOW BUG: This is a misplaced error #9119

ayroblu opened this issue Feb 15, 2024 · 3 comments
Labels

Comments

@ayroblu
Copy link

ayroblu commented Feb 15, 2024

Flow version: 0.226.0

On upgrading to 0.226, I get this error:

Cannot instantiate Connector because Arg3 [1] is underconstrained by BindActionCreatorObject [2]. Either add explicit
type arguments or cast the expression to your expected type. (FLOW BUG: This is a misplaced error. The original error
was raised in file app/components/FollowHostButton.js).
[underconstrained-implicit-instantiation]

     app/components/Component/connect.js
      22|     FOLLOW_BUTTON_CONTEXT
      23|   ),
      24|   follow: users.follow,
      25| })): Connector<FollowButtonProps, {||}, Actions>);
      26|

     app/redux/connect.js
 [1]  46|   <Arg1, Arg2, Arg3, Action>(
        :
 [2] 124| export type BindActionCreatorObject<ActionCreators: {}> = $ObjMap<
     125|   ActionCreators,
     126|   BindActionCreator
     127| >;

I'm specifically calling out the "FLOW BUG", which is confusing. Is this error correct? If I open in VS Code it flashes briefly with the underline, but then doesn't show the error.

@gkz
Copy link
Member

gkz commented Feb 16, 2024

Can you try replacing your $ObjMap with mapped types? https://flow.org/en/docs/types/mapped-types/

@SamChou19815
Copy link
Contributor

The error is correct, the BUG refers to the fact that the error is misplaced: it's raised as a result of checking file a but raised in file b. Our LSP implementation assumes this doesn't happen, so it results in confusing experience in your IDE. If you want help fixing the error, you will need to include more context.

@ayroblu
Copy link
Author

ayroblu commented Feb 16, 2024

I see. I can try to migrate to mapped types.

However, this syntax works in TypeScript playground but doesn't work in Flow playground
Please let me know if there's a better syntax for it:

declare function f(s: string, n?: number): boolean;
type Tuple = Parameters<typeof f>;
declare function g(...args: Parameters<typeof f>): boolean;
g("hi")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants