Option importsNotUsedAsValues is deprecated
Asked Answered
A

2

7

Could someone help me with this jsonfig.json file for a svelte project? It's saying that the importsNotUsedAsValues option should be replaced with 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"]
}

The full error message is

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

Allx answered 9/4, 2023 at 9:45 Comment(1)
And what exactly is the problem?Deese
R
9

According to the verbatimModuleSyntax instead of

"importsNotUsedAsValues": "error"

You should use

"verbatimModuleSyntax": true

See the details in the pull request.

Rosiorosita answered 10/4, 2023 at 0:13 Comment(0)
A
0

I think this resolved the issue for me:

// tsconfig.json
{
  "extends": "./.svelte-kit/tsconfig.json",
  "compilerOptions": {
    ...other compiler options here...
    "verbatimModuleSyntax": true,
    "importsNotUsedAsValues": "remove",
    "preserveValueImports": false
  }
  ...rest of your config here...
}
Addlebrained answered 20/10, 2023 at 1:54 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.