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

Allow using workspace typescript version #682

Closed
mlzzen opened this issue Feb 6, 2018 · 18 comments
Closed

Allow using workspace typescript version #682

mlzzen opened this issue Feb 6, 2018 · 18 comments

Comments

@mlzzen
Copy link

mlzzen commented Feb 6, 2018

Info

  • Platform: win7
  • Vetur version: 0.11.7
  • VS Code version: 1.19.3

Problem

tim 20180206100745

There is no error at compile time. But vscode prompt error.
I had updated ts 2.7.1 global, set "typescript.tsdk": "C:/Users/Administrator/AppData/Roaming/npm/node_modules/typescript/lib" and switch ts version to 2.7.1 in .ts file.But it don't work in .vue file. I guess it still use default version ts of vscode in .vue file.
So I hope I can switch ts version in .vue file like in .ts file.

@delaneyj
Copy link

delaneyj commented Feb 7, 2018

I'm seeing the same issue. Is there something we are missing with config of language server in vscode? Just updated to 1.20 and seeing the same issue.

@goszczynskip
Copy link
Contributor

I've created PR (#686) but as long as it isn't merged you will be seeing errors.
However, you can do quick fix. You need to update typescript version inside extension files

  1. in console go to \%user_profile%\.vscode\extensions\octref.vetur-0.11.7
  2. run there yarn upgrade typescript@latest
  3. change directory to .\server
  4. run again yarn upgrade typescript@latest

@neumannjan
Copy link

neumannjan commented Mar 11, 2018

In my opinion, .vue files should be handled by the same tsserver as .ts files. In vscode we have the ability to switch between a globally installed version, the version bundled with vscode and the version used by the project. I believe that Vetur should be able to provide the same functionality.

@polothy
Copy link

polothy commented Mar 13, 2018

In my opinion, .vue files should be handled by the same tsserver as .ts files.

This would hopefully also give us those quick fixes via the light bulb as well.

@AndrewBogushevich
Copy link

When we can expect release of this fix? vue-cli 3 ts template is not supported by vetur right now.

@HerringtonDarkholme
Copy link
Member

Hi @AndrewBogushevich , you can download the new release here.
https://github.com/vuejs/vetur/releases/tag/0.11.8

@polothy
Copy link

polothy commented Apr 12, 2018

Will this go into the marketplace or is that no longer a thing and we should grab them from tags?

@doliver3
Copy link

doliver3 commented Apr 17, 2018

I just installed the latest version of visual studio code and Vetur today.
However, the latest shown is 0.11.7.
https://marketplace.visualstudio.com/items?itemName=octref.vetur

When will this 0.11.8 version be published so it can be directly updated in the Visual Studio Code extensions?

I agree Vetur should use the same version of Typescript as Visual Studio Code. I agree with @kogli that this should be handled to prevent chasing down errors that are not actually errors at all - just version mismatches.

Also I recommend that the Vetur plugin put the Typescript version in the footer like .ts files do so it is clear which version of Typescript is being used.

@habbes
Copy link

habbes commented May 9, 2018

I have the same issue. I tried uninstalling, deleting and reinstalling the extension, it still installs the 0.11.7 version, so the problem persists.
To workaround this I followed @goszczynskip's advice and upgraded the typescript dependencies in the extension directory.

@ZSkycat
Copy link

ZSkycat commented May 10, 2018

@habbes
here can download 0.11.8 Preview
https://github.com/vuejs/vetur/releases

@tbsvttr
Copy link

tbsvttr commented May 11, 2018

@goszczynskip Thank you so much!

@octref octref changed the title Can't switch ts version in .vue file Allow using workspace typescript version Feb 9, 2019
@octref octref added this to the February 2019 milestone Feb 9, 2019
@kuanyui
Copy link

kuanyui commented Feb 12, 2019

Is currently any way to specify the typescript binary location of Vetur?

I encounter same issue when I upgrade the version of TypeScript in my project to 3.3.3, however the version of TypeScript shipped with the latest release of Vuetur (0.15.0) is 2.8.4 (vetur/server/package.json).

This situation makes my project build failed but Vetur shows no error.

// lib.dom.d.ts in TS 3.3.3
interface DragEvent extends MouseEvent {
    /**
     * Returns the DataTransfer object for the event.
     */
    readonly dataTransfer: DataTransfer | null;
}

// lib.dom.d.ts in TS 2.8.4 (Vetur 0.15.0)
interface DragEvent extends MouseEvent {
    readonly dataTransfer: DataTransfer;
    initDragEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, viewArg: Window, detailArg: number, screenXArg: number, screenYArg: number, clientXArg: number, clientYArg: number, ctrlKeyArg: boolean, altKeyArg: boolean, shiftKeyArg: boolean, metaKeyArg: boolean, buttonArg: number, relatedTargetArg: EventTarget, dataTransferArg: DataTransfer): void;
    msConvertURL(file: File, targetType: string, targetURL?: string): void;
}

I've created PR (#686) but as long as it isn't merged you will be seeing errors.
However, you can do quick fix. You need to update typescript version inside extension files
1. in console go to \%user_profile%\.vscode\extensions\octref.vetur-0.11.7
2. run there yarn upgrade typescript@latest
3. change directory to .\server
4. run again yarn upgrade typescript@latest

I encountered lots of errors and still failed in the end when trying this way (with npm i typescript@latest --save --force to replace yarn upgrade typescript@latest):

npm WARN using --force I sure hope you know what you are doing.
npm ERR! path /home/USER/.vscode/extensions/octref.vetur-0.15.0/server/node_modules/prettier-eslint/node_modules/.bin/eslint
npm ERR! code EEXIST
npm ERR! Refusing to delete /home/USER/.vscode/extensions/octref.vetur-0.15.0/server/node_modules/prettier-eslint/node_modules/.bin/eslint: is outside /home/USER/.vscode/extensions/octref.vetur-0.15.0/server/node_modules/prettier-eslint/node_modules/eslint and not a link
npm ERR! File exists: /home/USER/.vscode/extensions/octref.vetur-0.15.0/server/node_modules/prettier-eslint/node_modules/.bin/eslint
npm ERR! Move it away, and try again.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/USER/.npm/_logs/2019-02-12T02_20_49_360Z-debug.log

After rm the indicated file, another error appears. It's a looping hell.

@octref
Copy link
Member

octref commented Mar 20, 2019

In 0.17, you can do "vetur.useWorkspaceDependencies": true.

ts

@mpawelski
Copy link

Hi, I have a small question (to @octref ?).

from release notes I see:

Note that vetur.useWorkspaceDependencies can only be configured in user settings (no workspace setting) and defaults to false because Vetur should not run 3rd party code without user's explicit approval.

Currently this setting does not affect prettier and other formatters, where workspace dependencies is preferred, but this will change in the future.

Is there a plan to actually allow this to be a workspace settings. I just want to tell my team to install Vetur (and couple of other VS plugins) and clone the project. All setting like autoformatting on save with prettier is a workspace setting. Why this one should be different?

because Vetur should not run 3rd party code without user's explicit approval.

You can argue that if user decided to work on specific workspace then he agrees to run 3rd party code that this workspace requires.

@octref
Copy link
Member

octref commented Aug 6, 2019

Imagine I mod the TypeScript server that sends all sourcefiles to a remote location, put that in a project, and enable this setting as workspace setting.

The goal is not for convenience. It is that user has to opt-in. You acknowledge the risk of trusting all the dependencies installed in a specific project. The out of box experience has no risk.

I plan to change formatters as well, so you have to explicitly set a user setting for it to load local dependencies.

@octref
Copy link
Member

octref commented Aug 6, 2019

You can argue that if user decided to work on specific workspace then he agrees to run 3rd party code that this workspace requires.

There's a small difference. "Formatting" is an explicit action and you would agree that "since I'm running this I'm passing my source to the extension", whereas the TS server can run in the background as soon as you open the workspace with no user interaction.

Bottom line: If user don't initiate any command or run any script, just browsing around, it needs to be safe.

@arcanis arcanis mentioned this issue Feb 27, 2020
3 tasks
@glen-84
Copy link

glen-84 commented Jun 16, 2020

@octref,

What about using the typescript.tsdk setting by default, which the user has already opted into?

It's quite confusing when *.ts files are using one version of TypeScript, and *.vue files are using another.

@octref
Copy link
Member

octref commented Jun 17, 2020

@glen-84 Please open a new issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests