Skip to content

Conversation

@davnicwil
Copy link
Contributor

@davnicwil davnicwil commented Sep 5, 2018

A new typescript.suggestions.enabled config (boolean, default true)

Setting false removes all autocomplete suggestions provided by typescript via the built-in typescript-language-features extension.

The default is true, so that existing behaviour remains the same.

Why?

The typescript autocomplete suggestions are a great feature, when you're working on a typescript project.

image

But when you're working on a flow project using the flow-for-vscode plugin, it provides its own autocomplete suggestions via flow. So your autocomplete gets littered with duplicate suggestions coming from both typescript and flow:

image

What this config does is turns off the typescript suggestions, so you get this instead:

image

I.e. no duplicates, only theflow-for-vscode suggestions. Problem solved.

Prior Issues

There have been a few existing issues raised about this problem both on the flow-for-vscode project and here.

Quoting from the third issue there

We have requests to support disabling all TS functionality. Instead of introducing a setting we should allow disabling built in extensions.

So, what am I doing submitting a PR for a setting? Why doesn't #17068 solve the problem?

Well, the thing is, as I commented here, I don't want to disable all of the javascript & typescript extension. I only want to disable the autocomplete suggestions coming from typescript.

Why? Because the extension also provides some other functionality I can't do without.

  • Cmd+click to imports and variable definitions
  • Name based suggestions in js
  • There may be others (I haven't spent enough time with the extension turned off to find them all!)

It's actually worse to lose this functionality, than to just deal with the duplicates in autocomplete. So this is definitely not a solution to the problem.

I really believe vscode needs the ability to turn off typescript autocomplete, specifically. Flow support provided via the awesome flow-for-vscode combined with all of the rest vscode's great feature set makes it a really good editor for flow projects, but this autocomplete issue is one of the last remaining obvious and annoying things that just get in the way of productivity. And it's so easy to fix!


Just a note, my PR here is just a reference implementation to highlight how simple this change could possibly be to land. I have tested it in real usage and with my own workflow it is working well, but I may have missed some corner cases / features I don't use. I'm more than happy to fix anything that's pointed out myself, or just to have this completely redone by someone who knows more in depth about how this could be done better if my implementation is too simple/naive. I just want this feature in mainline vscode! And I know a lot of other people do too.

@msftclas
Copy link

msftclas commented Sep 5, 2018

CLA assistant check
All CLA requirements met.

element: Proto.CompletionEntry,
completionConfiguration: CompletionConfiguration
) {
const isNameSuggestion = element.kind === PConst.Kind.warning
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs a semicolon 😬

(agree with the refactoring here btw, much more readable 👍)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, right. Reflexes 😄

@mjbvz mjbvz self-assigned this Sep 5, 2018
@mjbvz
Copy link
Collaborator

mjbvz commented Sep 5, 2018

The idea behind this PR seems fine. However I believe this new setting should disable all completions from js/ts, including name based suggestions. This is what similar settings like javascript.format.enable and javascript.validate.enable do, as it lets another extension fully take over responsibility for these areas

Also keep in mind that we make no guarantees that our built-in js/ts support will work at all for flow code (and operations like formatting or refactoring may even break flow code). That's why we recommend disabling the built-in js/ts support if you are using the flow extension. The flow extension really needs to implement these tooling feature on their side to ensure they work properly

@davnicwil
Copy link
Contributor Author

davnicwil commented Sep 5, 2018

Great. You are right about the approach of having extensions take over full responsibility for things being better. But that might take a while and this config change is pretty simple (and would also be simple to remove later) and solves the problem today.

I will remove the distinction between name suggestions / others, and just have it disable every suggestion. You make a good point that it would break from the convention a bit.

@svipas
Copy link
Contributor

svipas commented Sep 6, 2018

You can now manage built-in extensions: https://code.visualstudio.com/updates/v1_21#_extensions which will disable TS/JS autocomplete and you can easily use flow in VS Code, so why this is needed? Or I'm missing something?

@noppa
Copy link

noppa commented Sep 6, 2018

If you disable the builtin "TypeScript and JavaScript Language Features" extension, you'll loose a whole lot of other things than autocomplete suggestions, too. JSDoc completion, symbol renaming etc.
Although @mjbvz does make a valid point about those being the responsibility of the Flow extension in this case.

@svipas
Copy link
Contributor

svipas commented Sep 6, 2018

@noppa Thanks, good to know. Also, I totally agree with @mjbvz it is Flow extension responsibility, but as I know they actually don't care and to be honest TypeScript is way better since it works way faster, you get refactoring for file names, paths, etc. If you really want good support for Flow and to use VS Code you should create your own extension.

Maybe it makes sense to control built-in JS/TS language features instead of disabling them all, like checkboxes with variuos features like renaming, jsdoc completion, linting, autocompletion, etc. I believe it would be good feature request.

@davnicwil
Copy link
Contributor Author

@svipben

So why this is needed?

That question is answered in the PR description in the section under So, what am I doing submitting a PR for a setting? Why doesn't #17068 solve the problem?

If you really want good support for Flow and to use VS Code you should create your own extension.

I like the flow-for-vscode extension, it's working well for me. I just want to remove one annoying thing: the duplicate autocomplete suggestions.

Maybe it makes sense to control built-in JS/TS language features instead of disabling them all

This is a simple change that solves a specific problem. That might be a good feature for that other people need for broader usecases but this PR is just focused on disabling JS/TS autocomplete suggestions for a nicer experience working with flow and flow-for-vscode. I don't think we should complicate things.

@mjbvz mjbvz merged commit b9dbeb9 into microsoft:master Sep 10, 2018
@mjbvz
Copy link
Collaborator

mjbvz commented Sep 10, 2018

Just a heads up: I'm renaming this setting to typescript.suggest.enabled and javascript.suggest.enabled to be consistent with our other extensions

@mjbvz mjbvz added this to the September 2018 milestone Sep 10, 2018
@github-actions github-actions bot locked and limited conversation to collaborators Mar 27, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants