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

Improve documentation for typescript.tsdk to make workspace usage clearer #42243

Closed
OliverJAsh opened this issue Jan 27, 2018 · 10 comments
Closed

Improve documentation for typescript.tsdk to make workspace usage clearer #42243

OliverJAsh opened this issue Jan 27, 2018 · 10 comments

Comments

@OliverJAsh
Copy link
Contributor

@OliverJAsh OliverJAsh commented Jan 27, 2018

The typescript.tsdk setting is documented as follows:

Specifies the folder path containing the tsserver and lib*.d.ts files to use.

Given the name of this setting and its corresponding documentation, if this setting is specified in workspace settings, it's reasonable for a user to expect for VSCode to begin using that TS version.

However, that is not the case. In addition to this step, the user must manually configure the TypeScript version through the UI. https://code.visualstudio.com/docs/languages/typescript#_using-the-workspace-version-of-typescript

I understand this additional opt-in step is required for security reasons, as detailed in #30069 (comment).

However I would like VSCode to make this requirement clearer. The documentation for typescript.tsdk should make it clear that VSCode will not automatically use the specified version and additional steps are required.

As part of this I also think the relationship between the typescript.tsdk setting and the UI's TypeScript version controls could be a lot clearer. After playing around with the setting, I was eventually able to infer that typescript.tsdk defines the "global" or "workspace" TypeScript version (depending on whether it's a user or workspace setting) as seen in the UI's TypeScript version picker. The current documentation for typescript.tsdk, however, suggests that it simply sets the TypeScript version—with no mention of the required additional steps.

@mjbvz mjbvz self-assigned this Jan 27, 2018
@mjbvz
Copy link
Contributor

@mjbvz mjbvz commented Jan 27, 2018

PRs welcome for vscode-docs and/or the setting itself

@OliverJAsh
Copy link
Contributor Author

@OliverJAsh OliverJAsh commented Jan 31, 2018

@mjbvz A few ideas:

  • When a user opens a workspace for the first time, and that workspace has a typescript.tsdk setting, VSCode could prompt the user to approve the TS version.
  • When a user sets the typescript.tsdk setting, VSCode could prompt the user to approve the TS version.
@marcobeltempo
Copy link
Contributor

@marcobeltempo marcobeltempo commented Feb 16, 2018

I am interested in working on this issue.

@mjbvz Do you suggest implementing a prompt after confirming tsdkVersion was set?
vscode/extensions/typescript/src/utils/versionProvider.ts

		// Allow TS developers to provide custom version
		const tsdkVersion = workspace.getConfiguration().get<string | undefined>('typescript.tsdk_version', undefined);
		if (tsdkVersion) {
			return API.fromVersionString(tsdkVersion);
		}
		return undefined;
	}
@mjbvz
Copy link
Contributor

@mjbvz mjbvz commented Feb 16, 2018

@marcobeltempo Sure. I personally think the "prompt when the workspace has a typescript.tsdk" would be the more useful of the two. We actually used to have this logic but removed it.

Two considerations:

  • The prompt/notification should only happen if there is a workspace tsdk setting.
  • The prompt/notification should only happen once per workspace. Use a workspaceState: Memento to track this

The prompt used to happen when we started the tsserver itself: https://github.com/Microsoft/vscode/blob/master/extensions/typescript/src/typescriptServiceClient.ts#L336 You'd probably want to look at the VersionPicker class too for implementing this. Let me know if you need some additional pointers or if you have any questions

@marcobeltempo
Copy link
Contributor

@marcobeltempo marcobeltempo commented Mar 2, 2018

@mjbvz if the workspace "typescript.tsdk" is set, do we want the check to happen on startup...

  1. only if the bundled version is being used
  2. if the local version us being used, should we display an information message?
  3. check to see if the workspace "typescript.tsdk" is set at any point after startup and display an appropriate message
@jedrichards
Copy link

@jedrichards jedrichards commented Dec 4, 2018

Furthermore, although out of scope of this ticket, shouldn't the presence of a local typescript module in node_modules also be seen as a reason to prompt the user to use that TypeScipt version?

@ryardley
Copy link

@ryardley ryardley commented Mar 12, 2019

After update the Typescript tsdk setting appears to not be valid in version 1.32.1 macOs. I assume this affects this issue.

image

@ryardley
Copy link

@ryardley ryardley commented Mar 12, 2019

So it appears I had a borked vscode setup. I had to totally reinstall to fix another issue. Please ignore the above.

@Svish
Copy link

@Svish Svish commented Sep 24, 2019

This seriously needs to be fixed... I honestly thought adding the typescript.tsdk to my .vscode/settings.json was how to make VS Code use the correct version of Typescript. Only discovered today, pretty much by accident, when looking in the Typescript Output console that it was actually "Using tsserver from: wrong path". Tried searching in the settings thing on how to switch, but nothing there. Having to manually click on a tiny number in the status bar, that I didn't even know was there, is not exactly an obvious mechanic...

I don't understand why VS Code can't just automatically switch to using the given typescript version if it is specified in the workspace settings? But if for some reason it can't do that, there needs to at least be some sort of prompt/notification. "Hey, you just added the typescript.tsdk to settings.json / opened a workspace with typescript.tsdk defined; Would you like me to completely ignore it like I have all these months, or to actually use it?"

@mjbvz mjbvz added this to the September 2019 milestone Sep 27, 2019
@mjbvz mjbvz closed this in e5efdb4 Sep 27, 2019
@mjbvz
Copy link
Contributor

@mjbvz mjbvz commented Sep 27, 2019

Prompting is now being tracked by #65546. That issue also explains why we can't execute code in your workspace automatically

Besides expanding the in product tsdk setting documentation with e5efdb4, I made a quick pass improving our website docs around this: microsoft/vscode-docs@22b8efb

If you still feel the documentation could be clearer, please just submit a PR. You can use the two changes I linked to to see what files you need to edit

@vscodebot vscodebot bot locked and limited conversation to collaborators Nov 11, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
7 participants