Flag 'importsNotUsedAsValues' is deprecated and will stop functioning in TypeScript 5.5

avatar
Borislav Hadzhiev

Last updated: Feb 29, 2024
4 min

banner

# Table of Contents

  1. Flag 'importsNotUsedAsValues' is deprecated and will stop functioning in TypeScript 5.5
  2. Setting the ignoreDeprecations key to 5.0
  3. Using the verbatimModuleSyntax flag instead
  4. Option 'target=ES6' is deprecated and will stop functioning in TypeScript 5.5
  5. Flag 'suppressImplicitAnyIndexErrors' is deprecated and will stop functioning in TypeScript 5.5
  6. Option 'noStrictGenericChecks' is deprecated and will stop functioning in TypeScript 5.5
  7. Option 'out' is deprecated and will stop functioning in TypeScript 5.5.

# Flag 'importsNotUsedAsValues' is deprecated and will stop functioning in TypeScript 5.5

The tsconfig.json error "Flag 'importsNotUsedAsValues' is deprecated and will stop functioning in TypeScript 5.5." occurs because the importsNotUsedAsValues key is deprecated and will be removed in TypeScript 5.5.

To resolve the issue, use the verbatimModuleSyntax property instead or set the ignoreDeprecations key to 5.0.

option imports not used as values deprecated

The article addresses the following errors:

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

# Setting the ignoreDeprecations key to 5.0

If you simply want to ignore the deprecations warning:

  1. Open your tsconfig.json file (it is located in your project's root directory, next to package.json).
  2. Set the ignoreDeprecations key to 5.0 in your compilerOptions object.
tsconfig.json
{ "compilerOptions": { "ignoreDeprecations": "5.0", // your other properties below } }

set ignore deprecations to 5 0

The following configuration flags have been marked as deprecated in TypeScript version 5.0:

  • noImplicitUseStrict
  • keyofStringsOnly
  • suppressExcessPropertyErrors
  • suppressImplicitAnyIndexErrors
  • noStrictGenericChecks
  • charset
  • target: ES3
  • out
  • prepend in project references
  • implicitly OS-specific newLine

If you need to check your TypeScript version, follow the instructions in this article.

Even if you haven't set the deprecated importsNotUsedAsValues property in your tsconfig.json file, your config file might be extending from another file that has set the property.

Once the ignoreDeprecations key is set to 5.0, the deprecation warnings are not shown.

# Using the verbatimModuleSyntax flag instead

The importsNotUsedAsValues flag is used to make you specify the type modifier in import statements that import a type.

index.ts
// correct (uses type modifier) import type {User} from './user' // incorrect (does not use type modifier) import {User} from './user'

The preserveValueImports and isolatedModules flags are related.

Understanding the 3 flags is kind of confusing, so TypeScript v5.0 introduces a new option called verbatimModuleSyntax to simplify this.

When the verbatimModuleSyntax is set to true:

  1. Any imports or exports without a type modifier are left around.
  2. Anything that uses the type modifier is dropped entirely.

You can remove the importsNotUsedAsValues flag from your tsconfig.json file and set the verbatimModuleSyntax flag instead.

tsconfig.json
{ "compilerOptions": { "verbatimModuleSyntax": true, // 👇️ remove this // "importsNotUsedAsValues": "error", // ... your other properties below } }

You can read more about the verbatimModuleSyntax flag in this section of the TypeScript docs.

# Option 'target=ES6' is deprecated and will stop functioning in TypeScript 5.5

If you get the error "Option 'target=ES6' is deprecated and will stop functioning in TypeScript 5.5. Specify compilerOptions: 5.0 to silence the error", set the target property in your tsconfig.json file to ES5.

tsconfig.json
{ "compilerOptions": { "target": "ES5", } }

Support for the ES3 runtimes has been removed.

Instead, you should use the ES5 runtime because all modern browsers support ES5 features.

# Flag 'suppressImplicitAnyIndexErrors' is deprecated and will stop functioning in TypeScript 5.5

The suppressImplicitAnyIndexErrors flag has been deprecated.

The flag disables errors that are caused when indexing an object that doesn't support indexing.

You should remove the flag from your tsconfig.json file as it was always meant to be temporary.

Instead, you can use an index signature to the relevant type.

Alternatively, you can disable the deprecation warning by setting the ignoreDeprecations property in your tsconfig.json file.

tsconfig.json
{ "compilerOptions": { "ignoreDeprecations": "5.0", // your other properties below } }

# Option 'noStrictGenericChecks' is deprecated and will stop functioning in TypeScript 5.5

The error "Option 'noStrictGenericChecks' is deprecated and will stop functioning in TypeScript 5.5. Specify compilerOption '"ignoreDeprecations": "5.0"' to silence this error" is shown because the noStrictGenericChecks flag has been deprecated.

The flag was previously used to disable checks related to constraints of generic types but often causes issues.

To resolve the issue, remove the noStrictGenericChecks flag from your tsconfig.json file and correct your typings or use a type assertion.

# Option 'out' is deprecated and will stop functioning in TypeScript 5.5.

If you get the error "Option 'out' is deprecated and will stop functioning in TypeScript 5.5. Specify compilerOption '"ignoreDeprecations": "5.0"' to silence this error.", use the outFile flag instead.

Open your tsconfig.json file and replace the out flag with the outFile flag.

When the outFile flag is specified, all global (non-module) files are concatenated into the single output file that is specified.

You can read more about the outFile flag in this section of the TypeScript docs.

I wrote a book in which I share everything I know about how to become a better, more efficient programmer.
book cover
You can use the search field on my Home Page to filter through all of my articles.