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

huangapple go评论59阅读模式
英文:

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

问题

有人知道如何修复这个tsconfig错误吗?

标志'importsNotUsedAsValues'已被弃用,并将在TypeScript 5.5中停止工作。指定'ignoreDeprecations: "5.0"'以消除此错误。请使用'verbatimModuleSyntax'代替。

我使用VSCode,并使用Vite创建了新的Vue项目实例。

不确定是否应该消除此错误,还是有特定的解决方法来编辑tsconfig?

英文:

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?

答案1

得分: 10

根据verbatimModuleSyntax,而不是

"importsNotUsedAsValues": "error"

你应该使用

"verbatimModuleSyntax": true

pull request中查看详细信息。

最初的回答在这里

英文:

According to the verbatimModuleSyntax instead of

"importsNotUsedAsValues": "error"

You should use

"verbatimModuleSyntax": true

See the details in the pull request.

Originally answered here.

答案2

得分: 7

你可以通过在项目的 tsconfig.json 中添加以下命令来隐藏此警告:

{
  "compilerOptions": {
    "ignoreDeprecations": "5.0",
    ....
  }
}
英文:

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

{
  "compilerOptions": {
    "ignoreDeprecations": "5.0",
    ....
  }
}

答案3

得分: 5

以下是翻译好的部分:

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

"如果您使用的是 @vue/tsconfig/tsconfig.web.json 或类似的配置文件,您可以重置启用 verbatimModuleSyntax 时出错的属性。"

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

"我看到您使用了 @vue/tsconfig/tsconfig.web.json。"

英文:

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.

答案4

得分: 3

这个问题是在我更新了VS Code后开始出现的,我甚至并没有在我的项目中使用 TypeScript,但似乎 VS Code 使用了 TypeScript 5,MRAH 提出的在 compilerOptions 中使用 ignoreDeprecations 的解决方案在我的情况下起到了帮助作用。

然而,如果你的项目确实在使用 TypeScript,你可以点击状态栏中的 TS 横幅:

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

然后选择 Switch Version,最后选择你的项目工作区所使用的 TypeScript 版本:

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

英文:

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:

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

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

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

答案5

得分: 0

我的网络受到了限制,我改成私人网络后就可以正常使用。

英文:

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

huangapple
  • 本文由 发表于 2023年2月14日 22:30:11
  • 转载请务必保留本文链接:https://go.coder-hub.com/75449286.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定