Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tsconfig throws errors with TypeScript 5.0 #6

Closed
mxschmitt opened this issue Jan 27, 2023 · 8 comments · Fixed by #9
Closed

tsconfig throws errors with TypeScript 5.0 #6

mxschmitt opened this issue Jan 27, 2023 · 8 comments · Fixed by #9

Comments

@mxschmitt
Copy link

mxschmitt commented Jan 27, 2023

Currently these two options are set: importsNotUsedAsValues and preserveValueImports:

tsconfig/tsconfig.json

Lines 19 to 23 in 5b93351

// For `<script setup>`
// See <https://devblogs.microsoft.com/typescript/announcing-typescript-4-5-beta/#preserve-value-imports>
"preserveValueImports": true,
// Enforce using `import type` instead of `import` for types
"importsNotUsedAsValues": "error",

which result with TypeScript 5.0-beta in an error.

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

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

Workaround:

{
  "compilerOptions": {
    "ignoreDeprecations": "5.0"
  }
}

in your config.

mxschmitt added a commit to microsoft/playwright that referenced this issue Mar 16, 2023
TypeScript in v5 emits a warning and this ends up in exit code 1. See
vuejs/tsconfig#6 for more information. This CL
will make TypeScript still end up in exit code 0 even tho these warnings
are emitted until they fixed it upstream and released a new version of
their config.
@mat813
Copy link

mat813 commented Mar 17, 2023

TypeScript 5.0 is out now.

@doberkofler
Copy link

I'm using @tsconfig/node18-strictest and get the following error:

error TS5101: Option 'importsNotUsedAsValues' is deprecated and will stop functioning in TypeScript 5.5. Specify compilerOption '"ignoreDeprecations": "5.0"' to silence this error.
  Use 'verbatimModuleSyntax' instead.
{
  "extends": "@tsconfig/node18-strictest",
  "compilerOptions": {
    "module": "esnext"
  },
  "ts-node": {
    "esm": true
  }
}

@recallwei
Copy link

+1

1 similar comment
@zokizuan
Copy link

zokizuan commented Apr 2, 2023

+1

@green-anger
Copy link

If you use TS 5.0 in package.json, e.g.

"devDependencies": {
  ...
  "typescript": "^5.0.3"
}

then in your tsconfig.json you can now use Verbatim Module Syntax which replaces the two options, in their respective TSConfig Reference sections it says:

Deprecated in favor of verbatimModuleSyntax.

When you add it, you'll get another error:

Option 'isolatedModules' is redundant and cannot be specified with option 'verbatimModuleSyntax'.

So, in the end the following config worked for me:

"compilerOptions": {
  ...
  // "isolatedModules": true,
  // "preserveValueImports": true,
  // "importsNotUsedAsValues": "error",
  "verbatimModuleSyntax": true,
}

@verata-veritatis
Copy link

My tsconfig.app.json uses @vue/tsconfig/tsconfig.web.json, so using verbatimModuleSyntax doesn't help in this case...

@joerick
Copy link
Contributor

joerick commented Apr 14, 2023

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

This worked for me:

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

@yisuslopez45
Copy link

Si estás usando @vue/tsconfig/tsconfig.web.json o similar, puede restablecer las propiedades que están cometiendo errores cuando habilita verbatimModuleSyntax

Esto funcionó para mí:

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

solved my problem

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

9 participants