19

Does anybody know how to fix this tsconfig error?

Flag 'importsNotUsedAsValues' is deprecated and will stop functioning in TypeScript 5.5. Specify 'ignoreDeprecations: "5.0"' to silence this error. Use 'verbatimModuleSyntax' instead.

I use vscode and created new Vue project instance using Vite

Not sure if I should silence this error or there is a specific solution on how to edit tsconfig?

mikemaccana
  • 110,530
  • 99
  • 389
  • 494
  • I'll guess you're seeing the same issue as this one? https://github.com/vuejs/tsconfig/issues/6 – orjan Mar 16 '23 at 20:03

5 Answers5

9

According to the verbatimModuleSyntax instead of

"importsNotUsedAsValues": "error"

You should use

"verbatimModuleSyntax": true

See the details in the pull request.

Originally answered here.

torusJKL
  • 184
  • 1
  • 4
7

You can hide this warning by adding the following command in tsconfig.json of your project:

{
  "compilerOptions": {
    "ignoreDeprecations": "5.0",
    ....
  }
}
MRAH
  • 151
  • 3
  • 50
    Maybe it's just me, but i'm really against silencing deprecation warnings. I'd much rather have the exact solution that actually fixes the problem, or at least understand what the problem is and where does it stem from. – Tal Kohavy Feb 21 '23 at 12:22
  • 6
    I don't even have `importsNotUsedAsValues` anywhere in my code and I'm still getting this error, so I'd rather not silence it until I know why it's being thrown. – Jeff Harris Mar 17 '23 at 00:15
  • 1
    Found it. Tried to edit, but apparently I wanted 5.2 minutes. My `tsconfig.json` is extending a `@vue` config that's using it. – Jeff Harris Mar 17 '23 at 00:22
  • 1
    Here is the issue on GitHub for this incompatibillity: https://github.com/vuejs/tsconfig/issues/6 – Josef Reichardt Mar 20 '23 at 07:03
5

Had the same issue, got it fixed using this workaround from the GitHub issue:

If you're using @vue/tsconfig/tsconfig.web.json or similar, you can reset those properties that are erroring when you enable verbatimModuleSyntax

{
  "extends": "@vue/tsconfig/tsconfig.web.json",
  "compilerOptions": {
    // workaround for https://github.com/vuejs/tsconfig/issues/6
    "preserveValueImports": false,
    "importsNotUsedAsValues": "remove",
    "verbatimModuleSyntax": true,
    // end workaround
  },
}

I saw you used @vue/tsconfig/tsconfig.web.json.

djbartolini
  • 71
  • 1
  • 4
3

This issue began appearing when I updated VS code, I am not even using typescript on my project but it seems VS code is using typescript 5, the ignoreDeprecations in compilerOptions solution by MRAH did help in my case.

If you are using typescript for the project however, you would want to click the TS banner in your status bar:

click TS banner in vs code status bar

then Switch Version, finally select the typescript version your project workspace uses:

enter image description here

Dale Ryan
  • 473
  • 4
  • 9
0

mine was restricted by the network(domain) i was, changing toprivate then worked fine.