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

Intellisense does not work for Exact Types #432

Open
frednomoon opened this issue Sep 22, 2021 · 17 comments
Open

Intellisense does not work for Exact Types #432

frednomoon opened this issue Sep 22, 2021 · 17 comments

Comments

@frednomoon
Copy link

Apologies for the React specific example but thats my use case - its pretty simple either way.

/* @flow */

import * as React from "react";
const TestExact = (props: {| foo: string |}) => <div>{props.foo}</div>;
const TestInexact = (props: { foo: string }) => <div>{props.foo}</div>;

const Example = () => (
  <div>
    <TestExact foo="bar" />
    <TestInexact foo="bar" />
  </div>
);

In this example I am able to get intellisense when writing the Inexact example:
image

However when writing the Exact Typed version I get no intellisense when writing the props.

This is extremely frustrating because I would like to use Exact Types for the various advantages it gives, however given the dev experience is severely lacking I dont think it will be worthwhile.

Any questions let me know. Interesting to hear thoughts on this.

@frednomoon
Copy link
Author

Okay actually the Non-React-Specific version of this seems to make the issue clearer:

image

I think the problem for me is that my intellisense is just being provided by VSCode / typescript, which obviously cannot read Exact types because they dont exist in TS. Maybe I need to disable VSCode intellisense to allow the Flow extension to take over?

@vrama628
Copy link
Contributor

Have you disabled TypeScript from running on Flow files, as recommended in the setup instructions?

@frednomoon
Copy link
Author

Yes I've tried all of that. I already have javascript.validate.enable option to false and if I disable the typescript stuff I just loose all intellisense altogether. I have tried reloading VScode multiple times with everything disabled - it just seems like the Flow extension is not doing any intellisense at all.

@noppa
Copy link

noppa commented Sep 22, 2021

What does your flowconfig look like? Does Flow work correctly when running from the command line (i.e. does it correctly show type error if you do something like const a: number = 'foo'in the file)?

@frednomoon
Copy link
Author

Yeah everything else from Flow is working absolutely fine, which I guess is why its taken me over a year of usage to realise the intellisense wasnt working correctly.

Running from the command line identifies errors, and the error highlighting in the editor also works correctly.

@noppa
Copy link

noppa commented Sep 22, 2021

If you open the Output panel (ctrl+shift+U or View->Output) and then from the dropdown "Flow", does it show any errors or other useful info?

@frednomoon
Copy link
Author

If you open the Output panel (ctrl+shift+U or View->Output) and then from the dropdown "Flow", does it show any errors or other useful info?

no it does not.

@Brianzchen
Copy link

facebook/flow#8723
related issue. Something's wrong not with exact objects, but explicit exact object syntax.

@frednomoon
Copy link
Author

Yeah the problem here is that the Flow intellisense just doesnt work at all. Unfortunate!

@alielmajdaoui
Copy link

@frednomoon any updates about this issue?

@frednomoon
Copy link
Author

@frednomoon any updates about this issue?

@alielmajdaoui nah nothing. as far as I can tell the feature just legit does not work... expecting to be permanently stuck between wanting to use Exact Types for clarity vs Inexact Types for a dev experience that isnt a complete disaster

@alielmajdaoui
Copy link

@frednomoon I would go with the 2nd option too!

Btw, IntelliSense doesn't work with all utility types. I don't know why these very important and helpful features aren't being implemented.

@vrama628
Copy link
Contributor

vrama628 commented Nov 9, 2021

Flow does support Intellisense for inexact types and utility types, and there is no logic in the flow-for-vscode extension that would make it work for some and not others.

if I disable the typescript stuff I just loose all intellisense altogether.

I really feel like the problem is not with exact types, but rather, flow-for-vscode isn't working at all for some of you.

If you open the Output panel (ctrl+shift+U or View->Output) and then from the dropdown "Flow", does it show any errors or other useful info?

It's strange that there is no output here whatsoever. If VSCode is running the extension at all, there should be at least a line that says "Checking flow-bin in [...]" if you've opened a javascript file in a flow project while the extension is installed. If that's not the case, is there anything mentioning "flow-for-vscode" in the "Log (Extension Host)" output pane? Also, what are your extension settings -- maybe try resetting the extension's settings to default temporarily to see if that fixes anything?

@Brianzchen
Copy link

@frednomoon maybe more helpful if you can share a larger screenshot of your current vscode env? For example showing what's in the flow output logs + the task bar at the bottom to give @vrama628 more debugging context?

@frednomoon
Copy link
Author

frednomoon commented Nov 10, 2021

Yeah @vrama628 I completely agree - I actually said this in a previous comment. I am sure that I am not getting any Intellisense from the Flow plugin (rather than it being broken for certain things) and that Typescript is simply picking up what it can while it is enabled.

However I have also attempted to get this working with Typescript etc fully disabled as per the instructions. When I do this, I just get zero intelliense (from neither flow nor typescript).

Here is the lower part of my VSCode
grafik
As you can see the flow plugin is running

And here is the output from the Flow channel with various bits redacted (just since im at work):

[Info  - 2:41:13 PM - ***/.flowconfig] Unable to verify SHASUM256.txt.sign:
ENOENT: no such file or directory, open '/Users****/node_modules/flow-bin/SHASUM256.txt.sign'
[Info  - 2:41:14 PM - ***/.flowconfig] Found flow using option `useNPMPackagedFlow`
[Info  - 2:41:14 PM - ***/.flowconfig] Using flow '/Users***/node_modules/flow-bin/flow-osx-v0.108.0/flow' (v0.108.0)
Launching Flow server for /Users/***
Spawned flow server (pid=49586)
Logs will go to ***.log
Monitor logs will go to ***
[Info  - 2:41:14 PM] Starting Flow server

I am fairly sure that the Flow server/ plugin is working... As you can see from this screenshot, I am getting totally accurate / useful syntax highlighting from Flow. But as you can also see, I get am not getting any Intellisense when I type an "f". Maybe we are talking at cross-purposes here - but my expectation is that the Intellisense should identify that there is a prop which begins with an "f" and suggest an auto completion and tell me what type it is anticipating (this is what VSCode typescript intellisense natively does).

grafik

@frednomoon
Copy link
Author

Please let me know if there is anything else I can send though, and thanks very much for your help.

@frednomoon
Copy link
Author

As for the "extension settings" I guess you just mean anything I have in my settings.json relating to the Flow extension?
I only had this one line:
"flow.useCodeSnippetOnFunctionSuggest": false
Not sure why that had been added but changing it doesnt seem to make a difference anyway.

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

5 participants