Skip to content
Tutorials Center
My learning

Topics

TypeScript Reference ยท Error Codes Worth Knowing

TypeScript errors TS5023 and TS6046: unknown or invalid compiler options

TS5023 means tsc does not know an option name; TS6046 means the value is not allowed. See typical causes, such as version mismatches and typos, and how to fix them.

Two related errors come from option handling. TS5023 reads Unknown compiler option 'noImplicitAnyy'. and means the option name is not one this compiler version knows. TS6046 reads Argument for '--target' option must be: 'es5', 'es6', ... and means the name is valid but the value is not in the allowed list. Both are reported before any source file is checked.

They apply to command-line flags and to compilerOptions in tsconfig.json. In a tsconfig.json the error may carry a different number or wording (for example TS5024 for a wrong value type), but the causes and fixes are the same.

TEXT
tsc --noImplicitAnyy main.ts
error TS5023: Unknown compiler option '--noImplicitAnyy'.

tsc --target es2099 main.ts
error TS6046: Argument for '--target' option must be: ...

Try it

These errors come from the compiler's own command line and tsconfig.json, which a single-file example cannot exercise, so the snippets are read-only. The runnable part below prints which compiler options your own code relies on, as a checklist to compare with your configuration.

TypeScript A checklist to verify against your tsconfig

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with node:readline or readFileSync(0)), it gets the next line from this box.

JSON
{
  "compilerOptions": {
    "strict": true,
    "target": "es2024",
    "module": "nodenext",
    "noImplicitAnyy": true
  }
}

The last line triggers TS5023 in the editor and in tsc -p ..

Syntax

Symptom Likely cause Fix
TS5023 on a name you spelled correctly The compiler is older than the option, for example erasableSyntaxOnly on an old install. Upgrade TypeScript, or check which tsc runs with npx tsc --version.
TS5023 on a typo The name is misspelt (noImplicitAnyy). Copy the name from tsc --all.
TS5023 for an option that was removed The option was dropped in a newer release. Delete it or use the replacement.
TS6046 Value is outside the allowed set. Use one of the listed values, e.g. nodenext instead of node20.
Different compiler in editor and CI The editor uses its bundled TypeScript. Select the workspace version or pin it in package.json.

Usage notes

  • List valid options and values with tsc --all (see tsc --help), and print the effective configuration with tsc --showConfig.
  • Check the version first. Many "unknown option" reports are really "old compiler". Versions lists when major options appeared.
  • extends can import the problem. The bad option may come from a base config; --showConfig reveals where each value comes from.
  • Deprecated options produce a different error (TS5101 and friends) with a hint about how long they will keep working.
  • Boolean flags on the command line take no value (--strict). Set values in the tsconfig when you need false.
  • Comments and trailing commas are allowed in tsconfig.json (it is parsed as JSONC), so they are not the cause.