{"record":{"id":"edafe9acdd479b1d","repo":"microsoft/TypeScript","slug":"value-must-be-a-number-got-json-stringify-valu","errorCode":null,"errorMessage":"Value must be a number, got: ${JSON.stringify(value)}","messagePattern":"Value must be a number, got: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/harness/harnessIO.ts","lineNumber":313,"sourceCode":"                    }\r\n                }\r\n                else {\r\n                    throw new Error(`Unknown compiler option '${name}'.`);\r\n                }\r\n            }\r\n        }\r\n    }\r\n\r\n    function optionValue(option: ts.CommandLineOption, value: string, errors: ts.Diagnostic[]): any {\r\n        switch (option.type) {\r\n            case \"boolean\":\r\n                return value.toLowerCase() === \"true\";\r\n            case \"string\":\r\n                return value;\r\n            case \"number\": {\r\n                const numverValue = parseInt(value, 10);\r\n                if (isNaN(numverValue)) {\r\n                    throw new Error(`Value must be a number, got: ${JSON.stringify(value)}`);\r\n                }\r\n                return numverValue;\r\n            }\r\n            // If not a primitive, the possible types are specified in what is effectively a map of options.\r\n            case \"list\":\r\n            case \"listOrElement\":\r\n                return ts.parseListTypeOption(option, value, errors);\r\n            default:\r\n                return ts.parseCustomTypeOption(option as ts.CommandLineOptionOfCustomType, value, errors);\r\n        }\r\n    }\r\n\r\n    export interface TestFile {\r\n        unitName: string;\r\n        content: string;\r\n        fileOptions?: any;\r\n    }\r\n\r","sourceCodeStart":295,"sourceCodeEnd":331,"githubUrl":"https://github.com/microsoft/TypeScript/blob/b465fdbfe175304d9b977da137b2c178ae1091d3/src/harness/harnessIO.ts#L295-L331","documentation":"Thrown by optionValue when a compiler option declared with type 'number' receives a string that parseInt(value, 10) cannot parse (result isNaN). This is the numeric branch of the option-value parser invoked from setCompilerOptionsFromHarnessSetting.","triggerScenarios":"A test setting assigns a non-numeric string to a number-typed option, e.g. @target: 'esnext' on a numeric option, or @someNumberOption: 'abc'. The value arrives as a raw string from the test config.","commonSituations":"Misidentifying an option's type, supplying a textual value where a numeric one is expected, or a stray non-digit character in the value.","solutions":["Confirm the option expects a number (check its type in optionDeclarations) and supply a numeric string.","Remove any non-numeric characters (units, suffixes) from the value.","If the option is actually an enum/map type, the harness optionDeclarations may need correcting rather than the value."],"exampleFix":"// before\n// @maxNodeModuleJsDepth: deep\n// after\n// @maxNodeModuleJsDepth: 2","handlingStrategy":"validation","validationCode":"function validateNumericOption(value: string) {\n    if (Number.isNaN(parseInt(value, 10))) {\n        throw new Error(`'${value}' is not numeric`);\n    }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Confirm the option's declared type before supplying a value.","Strip units/suffixes from numeric settings."],"tags":["harness","compiler-options","configuration","type-mismatch"],"backgroundTag":null,"analyzedSha":"b465fdbfe175304d9b977da137b2c178ae1091d3","analyzedAt":"2026-08-12T05:38:42.698Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}