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

"typescript.suggest.enabled": false still shows TypeScript suggestions if cache was once initiated #111031

Closed
christianvuerings opened this issue Nov 20, 2020 · 6 comments
Assignees
Labels
javascript JavaScript support issues *question Issue represents a question, should be posted to StackOverflow (VS Code)

Comments

@christianvuerings
Copy link

  • VSCode Version: 1.51.1
  • OS Version: macOS 10.15.7

Steps to Reproduce

  1. Open a JavaScript file which imports a project which has types on DefinitelyTyped:
import { Box } from 'gestalt';

const Modal = () => {
  return (
    <Box bottom />
  )
}
  1. Hover over bottom
  2. Show you the TypeScript types
  3. Set "typescript.suggest.enabled": false
  4. Reload (CMD+R) or restart VSCode
  5. Hover over bottom
  6. Still shows the TypeScript types

Current Workaround

Delete the TypeScript cache

  1. Set "typescript.suggest.enabled": false
  2. Remove TypeScript cache: rm -rf ~/.cache/typescript/4.0/node_modules/@types/gestalt/
  3. Hover over bottom
  4. TypeScript types don't show up

This is less than ideal since:

  1. The cache automatically gets populated for any project/workspace that imports the library and does not have "typescript.suggest.enabled": false set
  2. We have to ask our developers to perform this manual step each time

Other Notes

  • Does this issue occur when all extensions are disabled with code --disable-extensions?
    • Yes, since this does not disable the built-in vscode.typescript-language-features
  • Our team uses Flow types so we would like to disable the TypeScript suggestions for our project
@IllusionMH
Copy link
Contributor

IllusionMH commented Nov 20, 2020

For JS files you should use javascript.suggest.enabled.

Could you please clarify what initial problem you want to solve with removing these types?

Why not instruct users to put "typescript.disableAutomaticTypeAcquisition": true into their settings.json for projects?

Or if they have jsconfig.json to put there typeAcquisition.exlude?

{
  "typeAcquisition": {
    "exclude": ["gestalt"]
  }
}

UDP. or disable ATA

{
  "typeAcquisition": {
    "enable": false
  }
}

See https://www.typescriptlang.org/tsconfig#typeAcquisition for more details.

@mjbvz mjbvz added *question Issue represents a question, should be posted to StackOverflow (VS Code) javascript JavaScript support issues labels Nov 20, 2020
@christianvuerings
Copy link
Author

@IllusionMH "typescript.disableAutomaticTypeAcquisition": true, is exactly what we needed, thank you!

Could you please clarify what initial problem you want to solve with removing these types?

The initial problem we were trying to solve is the CMD+click on a prop would always open a modal where we still had to choose between TypeScript and Flow, instead of directly taking you to the flow type

image

Now, with "typescript.disableAutomaticTypeAcquisition": true, we no longer have that issue and it directly takes us to the type:

image

@IllusionMH
Copy link
Contributor

If yoy are going to use Flow instead of TS it's recommended to desable built-in TS extension for this workspace to avoid conflicts between two language services. See https://marketplace.visualstudio.com/items?itemName=flowtype.flow-for-vscode#setup
https://code.visualstudio.com/Docs/languages/javascript#_can-i-use-other-javascript-tools-like-flow

And linked instructions: https://code.visualstudio.com/docs/nodejs/working-with-javascript#_disable-javascript-support

Even with ATA disabled, some of modules in project might bring @types/* modules in their devDependencies and TS might use those.

@christianvuerings
Copy link
Author

@IllusionMH thanks - we already had the following options set to disable the TypeScript integration but the suggestions still showed up:

"javascript.validate.enable": false,
"typescript.validate.enable": false,

Is there a way to programmatically, without each developer having to manually follow these steps, disable the vscode.typescript-language-features extension? We're trying to make their setup as seamless as possible.

@IllusionMH
Copy link
Contributor

I'm not aware of any.
Looks like request for this API was declined #15466, but #40239 might help if implemented.

Disabling TS should be only done once per workspace which shouldn't be hard.

@github-actions github-actions bot locked and limited conversation to collaborators Jan 4, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
javascript JavaScript support issues *question Issue represents a question, should be posted to StackOverflow (VS Code)
Projects
None yet
Development

No branches or pull requests

4 participants
@christianvuerings @IllusionMH @mjbvz and others