The TypeScript compiler (tsc) is failing because it encountered an option in your tsconfig.json file that it doesn’t recognize.
Here’s what’s actually breaking: tsc is a state machine. It reads your configuration, builds an internal model of what you want it to do, and then executes. When it hits an unknown compiler option, it halts the state machine before it even starts processing your code, because it can’t build a valid execution plan. It’s like asking a chef to make a dish with an ingredient they’ve never heard of – they can’t proceed.
The most common causes, from most to least frequent:
-
Typo in the Compiler Option: You’ve simply misspelled an option. This is incredibly common.
- Diagnosis: Visually inspect your
tsconfig.jsonfor common typos. Look for extra letters, missing letters, or swapped characters. For example,targettinstead oftarget, orstrictNullChecksinstead ofstrictNullChecks. - Fix: Correct the spelling. If you intended
target: "es2020", ensure it’s spelled exactly like that. - Why it works:
tschas a predefined list of valid compiler options. A typo means the option isn’t on that list, so correcting the spelling makes it recognizable.
- Diagnosis: Visually inspect your
-
Using a Deprecated or Removed Option: You’re using an option that was valid in an older version of TypeScript but has since been removed.
- Diagnosis: Check the TypeScript release notes or documentation for the version you’re using. Search for the option listed in the error. For example,
noEmitHelperswas removed. - Fix: Remove the deprecated option from your
tsconfig.json. If its functionality is needed, find its modern equivalent. FornoEmitHelpers, the modern approach is often to rely on module bundlers or specific import strategies. - Why it works:
tscno longer recognizes options that have been officially removed from its supported set.
- Diagnosis: Check the TypeScript release notes or documentation for the version you’re using. Search for the option listed in the error. For example,
-
Option Belongs to a Specific Plugin or Transformer: The option is not a built-in TypeScript compiler option but rather one provided by a third-party plugin (like
typescript-eslintor a Babel plugin for TypeScript).- Diagnosis: Examine the problematic option. If it’s not in the official TypeScript handbook, it’s likely from a plugin. For instance,
eslintmight introduce options thattscitself doesn’t understand if not properly configured. - Fix: Ensure the relevant plugin is installed and configured correctly. For
eslintoptions, you’d typically configure them within your.eslintrc.jsor.eslintrc.jsonfile, nottsconfig.json. If it’s a transformer, make sure it’s listed in thepluginsortransformersarray of yourtsconfig.jsonif the plugin requires it. - Why it works:
tsccan be extended. Plugins register their options with the compiler. If the plugin isn’t installed or its registration process isn’t followed,tscwon’t know about its options.
- Diagnosis: Examine the problematic option. If it’s not in the official TypeScript handbook, it’s likely from a plugin. For instance,
-
Incorrect Case Sensitivity: While most
tsconfig.jsonkeys are case-insensitive in practice, some underlying parsers or configurations might be sensitive, or you might have a mix-up.- Diagnosis: Double-check the casing of your compiler options. Standard practice is camelCase, like
strictNullChecks. - Fix: Ensure all compiler options follow the standard camelCase convention. For example, change
STRICTNULLCHECKStostrictNullChecks. - Why it works: Although less common for standard options, strict parsing can occur, and adhering to convention avoids potential issues.
- Diagnosis: Double-check the casing of your compiler options. Standard practice is camelCase, like
-
Using an Option from a Future TypeScript Version: You’ve copied a
tsconfig.jsonfrom a project using a newer TypeScript version that includes options not present in your currently installed version.- Diagnosis: Compare the option in your
tsconfig.jsonwith the documentation for the exact version of TypeScript you have installed (tsc --version). - Fix: Either upgrade your TypeScript version to match the
tsconfig.json(npm install typescript@latestoryarn add typescript@latest) or remove the unsupported option from yourtsconfig.json. - Why it works: Each TypeScript version has a specific set of recognized compiler options. An option from a later version simply doesn’t exist in an earlier one.
- Diagnosis: Compare the option in your
-
Corrupted
tsconfig.jsonFile: The file itself might be malformed due to an incomplete save, copy-paste error, or encoding issues.- Diagnosis: Open
tsconfig.jsonin a text editor. Look for syntax errors like missing commas, unclosed brackets, or invalid characters. Ensure the file is saved with UTF-8 encoding. - Fix: Correct the syntax errors or re-create the
tsconfig.jsonfile from scratch, carefully adding only known, valid options. - Why it works:
tscparsestsconfig.jsonas JSON. If the JSON is invalid, it can’t even read the options, leading to errors before it gets to option validation.
- Diagnosis: Open
After fixing the unknown compiler option, the next error you’ll likely encounter is related to type checking or module resolution, as tsc can now attempt to process your code.