-
Notifications
You must be signed in to change notification settings - Fork 111
Import type dont recognize the type and returns any #23
Comments
Can you specify version of VSCode and flow version? |
flow 0.30.0 |
I get the same thing with the same version of flow 0.30.0 and vscode 1.4.0 (extension version is 0.0.3). I also see that starting vscode with this extension doesn't start up the flow server and there are no errors. But even I already have flow running via command line or nuclide, I still have this 'imported types' problem in vscode. So even if flow's running, I don't thing the extension is connecting to the flow server. Without being able to connect to the flow server, I don't see how vscode would be able to reconcile the imported flow types. |
Facing the same issue. Happy to PR if someone could point me in the right direction. |
Same issue here too. |
Same issue with vscode 1.5.3 and flow 0.33. |
Same issue with VSCode 1.7.2 and flow 0.36. Extension version 0.4.0. |
Same issue with the below: // @flow
import type { StorageEntry } from './StrategyStorage';
export default class Strategy {
constructor(strategy: StorageEntry) {
strategy;
}
} From the file: export type StorageEntry = {
Path: string,
Content: {},
Attributes: {},
}; On vscode 1.8.1, extension 0.4.0 |
I get this too on 1.8.1 |
+1 |
@crisys11 reason for closing? |
Works well in vs code 1.9.1 and plugin 0.5.0 |
I'm still seeing this issue with VSCode 1.9.1 and version 0.5.0 of the plugin. |
I think there has been a misunderstanding. |
Anyone has found a workaround? |
@im-sven are you sure, that flow extension is correctly installed and configured? Do you see type hinting like on screenshot in section [Flow], or you see only automatic intellisense info with 'any'. Check that file have correct header. Maybe you need to use Check language that used for file(on the right bottom line). It's must be just 'Javascript'. If you still have this issue, I think that this is something related to VSCode itself, and his resolver autocomplete resolver. |
@Arilas thanks for your comment. After starting a completely fresh project, I couldn't reproduce the behaviour. It seemed that it was caused by an incorrect I suspect it was caused by using the
and not handling this correctly in Flow. In my case (for illustrational purposes), it was fixed by updating the
Hope it can point other people in the right direction when facing similar issues. |
I'm not using webpack and I'm still seeing this issue. Just installed VSCode and flow plugin for the first time. |
Same problem here. First time user, just freshly installed. it is not working. |
@Leeds-eBooks @MoeSattler Can you specify what exactly don't work for you? Is it hover and/or autocomplete? Because it's related to different APIs of VSCode. |
@Arilas It's both actually. When I work out how to do a screenshot of a hover effect I will paste it here, but basically if I |
Both for me too |
Do you have flow annotation for file with types? Do you have global nodejs installation or use nvm or similar tools. Do you have globally installed flow-bin or just dev dependency? Did you configure |
Yes,
I use nvm. But in any case, flow-for-vscode is working fine in its other features.
Globally installed.
No. |
Have exactly the same issue here. Flow version 0.38, import Foo from './types' works (although I have "[flow] [flow] Named import from module import type {Foo} from './types' doesn't. types.js: export type Foo = {bar: number}; UPD: just tried to update flow to 0.43 - same issue.
|
Ok, I can't pretend I know the root cause, but(!):
class Bar extends React.Component {
props: {
foo: Foo
}
render() {
const { bar } = this.props.foo;
}
}
Is it something we can help you fixing, @Arilas? |
@greeze answer worked for me:
People still experience this issue? |
I'm not using |
Same issues( |
@TwFlem with export * all work, thx! |
Same issue, doesn't work :( |
Make sure that you are adding |
Hey there all.
Is this okay ? |
@Khachatour Of course, that is fine. I think this issue is fixed now anyway? |
I found why it was happening for me. I have js and css in the same folder with the same base name, and for Flow to see the import (CSS Modules) and not report an error, I added the ext to options: [options] The problem is that is sees foo.js and foo.css and I guess picks the file alphabetically, or randomly, or causes a problem and reports the type as any. So now I must use the .js extension in my import, or move the css somewhere else. |
Ya it does but then it would have problem with |
Same here. vs code 1.28.2
// @flow
import type Map from 'mapbox-gl/src/ui/map';
declare type MapboxMap = Map; This resolves correctly: But everywhere in the project it resolves to any in VS Code: Although if I run flow on source code it works fine. |
I still have issue with such way
but dont have with
But what is right way to do ? This doc doesn't give right example In google i see different syntax in articles |
What fixed it for me, and how I think I should have been doing it in the first place(?) was to move all my type files into the Then I don't need to manually import all of my types, they just work. |
This really should not have been closed. Its still an issue and renders this extension almost useless if using a code base that does imports the way the flow docs specify - |
This comment has been minimized.
This comment has been minimized.
For anyone stumbling upon this, suggest checking out this thread and this comment: facebook/flow#338 (comment) |
Still happens with me, import type returns type any |
I have the same issue. |
@BrunoQuaresma Are you talking about pizza-r0b issue? |
@Mayank1791989 yeap. |
I think any is coming from typescript plugin not from this plugin. |
This works for me |
@seanyesmunt answer worked for me. I am using flow-typed. This was solved by moving my types exports into the flow-typed folder (in my case |
What worked for me was: And very important: don't forget to add |
When i import a type from another file, dont recognize the type:
Code
./typefile.js
autocomplete recognize var "a" with "any" type
Notes
The text was updated successfully, but these errors were encountered: