microsoft/TypeScript · error · Error

Unknown value '${value}' for compiler option '${name}'.

Error message

Unknown value '${value}' for compiler option '${name}'.

What it means

Thrown by setCompilerOptionsFromHarnessSetting when optionValue reports errors while parsing a known compiler option's value — i.e. the option name is recognised but the supplied string value cannot be coerced to the option's declared type (e.g. an invalid enum map entry or malformed list). The errors array from parsing is non-empty.

Source

Thrown at src/harness/harnessIO.ts:294

        return optionsIndex.get(name.toLowerCase());
    }

    export function setCompilerOptionsFromHarnessSetting(settings: TestCaseParser.CompilerSettings, options: ts.CompilerOptions & HarnessOptions): void {
        for (const name in settings) {
            if (ts.hasProperty(settings, name)) {
                const value = settings[name];
                if (value === undefined) {
                    throw new Error(`Cannot have undefined value for compiler option '${name}'.`);
                }
                if (name === "typeScriptVersion") {
                    continue;
                }
                const option = getCommandLineOption(name);
                if (option) {
                    const errors: ts.Diagnostic[] = [];
                    options[option.name] = optionValue(option, value, errors);
                    if (errors.length > 0) {
                        throw new Error(`Unknown value '${value}' for compiler option '${name}'.`);
                    }
                }
                else {
                    throw new Error(`Unknown compiler option '${name}'.`);
                }
            }
        }
    }

    function optionValue(option: ts.CommandLineOption, value: string, errors: ts.Diagnostic[]): any {
        switch (option.type) {
            case "boolean":
                return value.toLowerCase() === "true";
            case "string":
                return value;
            case "number": {
                const numverValue = parseInt(value, 10);
                if (isNaN(numverValue)) {

View on GitHub (pinned to b465fdbfe1)

Solutions

  1. Check the option's allowed values in optionDeclarations / commandLineOptions and supply a valid one.
  2. Correct the typo or malformed element identified by the value in the message.
  3. If the value is version-specific, confirm the harness TypeScript revision supports it.

Example fix

// before
// @module: comonjs
// after
// @module: commonjs
Defensive patterns

Strategy: validation

Validate before calling

// Cross-check map-type option values against allowed entries before setting
function validateMapOption(name: string, value: string, allowed: readonly string[]) {
    if (!allowed.includes(value)) {
        throw new Error(`'${value}' is not valid for '${name}'. Allowed: ${allowed.join(", ")}`);
    }
}

Prevention

When it happens

Trigger: A test setting supplies a value that fails the option's parse rules: an unrecognised value for a map-type option (e.g. an invalid 'target' or 'module' name), a malformed list element, or a custom-type parse failure.

Common situations: Typo in an enum-like value (e.g. module: 'comonjs'), an invalid list member, or using a value valid in a newer/older TypeScript version than the harness option set supports.

Related errors


AI-assisted analysis of microsoft/TypeScript@b465fdbfe1 (2026-08-12). Data as JSON: /api/errors/c43dc81676d85087. Report an issue: GitHub.