选项 importNotUsedAsValues 已弃用

2024-04-03

有人可以帮我解决这个问题吗jsonfig.json为一个精简的项目文件?它说的是importsNotUsedAsValues选项应替换为verbatimModuleSyntax.

{
  "compilerOptions": {
    "moduleResolution": "Node",
    "target": "ESNext",
    "module": "ESNext",
    /**
     * svelte-preprocess cannot figure out whether you have
     * a value or a type, so tell TypeScript to enforce using
     * `import type` instead of `import` for Types.
     */
    "importsNotUsedAsValues": "error",
    "isolatedModules": true,
    "resolveJsonModule": true,
    /**
     * To have warnings / errors of the Svelte compiler at the
     * correct position, enable source maps by default.
     */
    "sourceMap": true,
    "esModuleInterop": true,
    "skipLibCheck": true,
    "forceConsistentCasingInFileNames": true,
    /**
     * Typecheck JS in `.svelte` and `.js` files by default.
     * Disable this if you'd like to use dynamic types.
     */
    "checkJs": true
  },
  /**
   * Use global.d.ts instead of compilerOptions.types
   * to avoid limiting type declarations.
   */
  "include": ["src/**/*.d.ts", "src/**/*.js", "src/**/*.svelte"]
}

完整的错误消息是

选项“importsNotUsedAsValues”已弃用,并将在 TypeScript 5.5 中停止运行。指定 compilerOption '"ignoreDeprecations": "5.0"' 来消除此错误。请改用“verbatimModuleSyntax”。


根据逐字模块语法 https://www.typescriptlang.org/tsconfig#verbatimModuleSyntax代替

"importsNotUsedAsValues": "error"

你应该使用

"verbatimModuleSyntax": true

请参阅中的详细信息拉取请求 https://github.com/microsoft/TypeScript/pull/52203.

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

选项 importNotUsedAsValues 已弃用 的相关文章

随机推荐