How to fix "Flag 'importsNotUsedAsValues' is deprecated and will stop functioning in TypeScript 5.5."?
Asked Answered
C

5

23

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?

Canadian answered 14/2, 2023 at 14:30 Comment(1)
I'll guess you're seeing the same issue as this one? github.com/vuejs/tsconfig/issues/6Blindage
S
14

According to the verbatimModuleSyntax instead of

"importsNotUsedAsValues": "error"

You should use

"verbatimModuleSyntax": true

See the details in the pull request.

Originally answered here.

Survival answered 20/4, 2023 at 13:52 Comment(0)
O
8

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.

Orontes answered 28/4, 2023 at 2:48 Comment(0)
H
6

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

{
  "compilerOptions": {
    "ignoreDeprecations": "5.0",
    ....
  }
}
Hyaloplasm answered 20/2, 2023 at 21:57 Comment(4)
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.Jugendstil
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.Glair
Found it. Tried to edit, but apparently I wanted 5.2 minutes. My tsconfig.json is extending a @vue config that's using it.Glair
Here is the issue on GitHub for this incompatibillity: github.com/vuejs/tsconfig/issues/6Perforate
V
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 VScode and has 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

Vaca answered 7/4, 2023 at 3:58 Comment(0)
C
0

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

Chrisy answered 7/6, 2023 at 11:58 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.