Flow-for-vscode: Hover on "import" line shows as "any"

Created on 15 Jul 2017  路  17Comments  路  Source: flowtype/flow-for-vscode

Whenever I import anything from a module, hovering over it always shows it as any. And the flow highlight syntax treats it as any.

Screenshots:

  • we see on hover FontWeight is shown as any:
  • we see here that FontWeight is not defined as any:

Most helpful comment

The problem is that the plugin can't get the real type if you write import like this
import type { ApplicationActions } from "./application";

try with

import { type ApplicationActions } from "./application";

All 17 comments

Here is steps to reproduce for another example:

  1. react-native init blah
  2. add file to root types.js with:

    type Rawr = number;
    export type { Rawr }
    
  3. In index.ios.js do:

    import type { Rawr } from './types'
    const blah: Rawr = 'rawaa';
    

Screenshots:
types.js - http://i.imgur.com/ZdRvIbR.png
index.ios.js - http://i.imgur.com/msMY3g6.png
(notice in index.ios.js screenshot in bottom left Flow: 100.0% and no error highlighting)

i have flow-bin installed globally at 0.47 and it matches that found in my projects .flowconfig

I'm reasonably sure that what you're seeing here is the VS Code TypeScript inferred types- Flow messages have the prefix "Flow: "

@orta Oh you are totally right!!

So the types are working right. Its just the hover on the import is showing incorrect:

Hover of import is showing typescript:

But hover over the used type after import is showing correct:

I've been having the same issue for quite some time. @Noitidart have you found a solution? Flow is not nearly as useful with this issue.

@DarrylD I found no solution. I can only just use the import then hover to see if it is correct.

Same problem for me. Created a new react app using create-react-app installed flow and the addon to vs code. Always shows any for me when doing import type.

@Noitidart, I think it's not a case of hover showing the 'wrong' type information, it should show both sets of type information (as you can't currently turn the typescript hover type info off in code).

I'm seeing something similar whereby flow-for-vscode doesn't show type information for even a locally declared type.

The problem is that the plugin can't get the real type if you write import like this
import type { ApplicationActions } from "./application";

try with

import { type ApplicationActions } from "./application";

Having a similar issue.
This does not recognise the type import

import type { ProfileConfig } from './ProfileConfig';

This does.

import { type ProfileConfig } from './ProfileConfig';

Can we get hover support for

import type { ProfileConfig } from './ProfileConfig';

Otherwise we have babel trying to do a lot for nothing on our CRA app.

I got the same problem.

image

1潞 problem:
If I hovered the import types, always display type any as shown in the picture above.
2潞 problem:
As displayed in line number 25 in the left file you'll see:
case 'asd':
The type 'asd' is not defined in the action type and should catch the error.
If I place the types in the same file and not import them it works as expected.

Any news with this? It is painful to work with flow in vscode currently.

I got the same problem.

image

1潞 problem:
If I hovered the import types, always display type any as shown in the picture above.
2潞 problem:
As displayed in line number 25 in the left file you'll see:
case 'asd':
The type 'asd' is not defined in the action type and should catch the error.
If I place the types in the same file and not import them it works as expected.

Just figure out that I misspelled the @flow initial comment in the types.js file. I had a space between @ and flow.

Try using latest flow version. Hover working fine with it.

How do we reopen this issue? We are using latest 0.102.0 and it's not fixed.

Nevermind, was exporting an import from an index.js and the index.js was missing // @flow.

Was this page helpful?
0 / 5 - 0 ratings