Vue-cli: Update Typescript used to 3.7.2

Created on 7 Nov 2019  路  6Comments  路  Source: vuejs/vue-cli

What problem does this feature solve?

when updating a project to use typescript 3.7.2 which includes optional chaining, the new syntax is not supported in .vue files since it's still using an older version of typescript.

We should not get a syntax error for things like foo?.bar which is a new optional chaining syntax introduced in typescript 3.7.2

What does the proposed API look like?

no linting errors on proper 3.7.4 typescript syntax

Most helpful comment

Updated in the 4.2 release.

All 6 comments

Since you did not produce a reproduction of the problem, I assume the following:

  1. The problem does not happen during compilation
  2. The problem happens in your editor (VSCode)
  3. You are using the Vetur extension for .vue file support.

I think that by default Vetur is using the typescript version that VSCode comes with, not the one you installed in your node_modules.

You can do enable "vetur.useWorkspaceDependencies" (check autocomplete for exact option name) in your vscode settings to tell vetur to always use the version installed in your project.

It seems this is missing from the vetur docs. If this indeed solves your issue, please open an issue in the vetur repository asking for the docs to include this.

@vue/cli-plugin-typescript and ts-loader require typescript as peerDependencies
"typescript": ">=2" for @vue/cli-plugin-typescript
"typescript": "*" for ts-loader

So, the version of tsc used to compile is the version you installed in your project.
In my case, the problem is that I installed typescript as a global package as well.
I upgraded the project typescript, so the global package remained the old version.

yarn global upgrade typescript or npm update -g typescript did solve my problem

It seems that there is nothing to update in vue/cli-plugin-typescript
In my case

  1. VS Code used its own old version of Typescript. I changed it according to this manual https://code.visualstudio.com/docs/typescript/typescript-compiling#_using-newer-typescript-versions
  2. tsconfig.json had in compilerOptions "target": "esnext", I changed it to "target": "es2020",.

Now it highlights and compiles ok.

For reference similar issues on this topic: #4680, #4738

Has anyone got [email protected] working alongside ESLint?

Updated in the 4.2 release.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

OmgImAlexis picture OmgImAlexis  路  3Comments

PrimozRome picture PrimozRome  路  3Comments

joshuajohnson814 picture joshuajohnson814  路  3Comments

BusyHe picture BusyHe  路  3Comments

brandon93s picture brandon93s  路  3Comments