{"record":{"id":"e4e92274d6294190","repo":"denoland/deno","slug":"failed-to-parse-e","errorCode":null,"errorMessage":"failed to parse {}: {e}","messagePattern":"failed to parse (.+?): (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cli/tsc/tsconfig_gen.rs","lineNumber":63,"sourceCode":"/// `extends` and carries the npm project `references` - WITHOUT mutating the\n/// user's file. `native_check` writes the returned value to a temp config in the\n/// project root and points tsc at it, so the user's own options (including\n/// path-based ones like `rootDirs`/`baseUrl` and any `include`/`files`) still\n/// resolve relative to the project, exactly as if tsc read their file directly.\npub fn build_check_root_overlay(\n  project_root: &Path,\n  user_tsconfig_path: &Path,\n) -> Result<Value, std::io::Error> {\n  let content = std::fs::read_to_string(user_tsconfig_path)?;\n  // An unparseable tsconfig is a hard error (matching `ensure_root_tsconfig`)\n  // rather than silently degrading to `{}` - which would check with none of the\n  // user's options and report a misleading clean.\n  let parsed: Option<Value> = jsonc_parser::parse_to_serde_value(\n    &content,\n    &jsonc_parser::ParseOptions::default(),\n  )\n  .map_err(|e| {\n    std::io::Error::new(\n      std::io::ErrorKind::InvalidData,\n      format!(\"failed to parse {}: {e}\", user_tsconfig_path.display()),\n    )\n  })?;\n  let mut value = parsed.unwrap_or_else(|| json!({}));\n  if !value.is_object() {\n    value = json!({});\n  }\n\n  // Read the generated config once (for its `types` and `references`).\n  let deno_tsconfig = project_root.join(\".deno\").join(\"tsconfig.json\");\n  let deno_value = std::fs::read_to_string(&deno_tsconfig)\n    .ok()\n    .and_then(|t| serde_json::from_str::<Value>(&t).ok());\n\n  {\n    let obj = value.as_object_mut().unwrap();\n","sourceCodeStart":45,"sourceCodeEnd":81,"githubUrl":"https://github.com/denoland/deno/blob/9ad36f7a2cce60488e6ec52283efb32efddaf93a/cli/tsc/tsconfig_gen.rs#L45-L81","documentation":"During tsconfig generation (`cli/tsc/tsconfig_gen.rs`), Deno reads the user's tsconfig as JSONC with `jsonc_parser`. An unparseable file is a hard `io::ErrorKind::InvalidData` failure — deliberately not degraded to `{}`, which would check with none of the user's options and report a misleading clean result. The message includes the file path and the parser's error detail `{e}` (line/column of the syntax error).","triggerScenarios":"Running the command that generates/merges tsconfig state (e.g. `deno sync-types` and related flows) when the tsconfig.json at the printed path has a syntax error: unbalanced braces, stray tokens, truncation. Comments and trailing commas are fine — jsonc_parser accepts them.","commonSituations":"Hand-edited tsconfig with a typo; file truncated by a crashed editor or interrupted write; copy-paste from docs introducing smart quotes or stray characters.","solutions":["Open the printed path and fix the syntax error at the position given by `{e}` (e.g. `expected ',' or '}' at line N`).","If the file is disposable, delete or rename it and re-run the command to regenerate from scratch.","Add a JSONC parse check to CI lint so bad tsconfig never reaches the Deno command."],"exampleFix":"# before\n$ deno sync-types\n# → failed to parse /repo/tsconfig.json: expected ',' or '}' at line 12 col 3\n\n# after\n$ $EDITOR tsconfig.json   # fix the syntax error at the reported position\n$ deno sync-types","handlingStrategy":"validation","validationCode":"# validate tsconfig parses as JSONC before running the command\ndeno eval 'import { parse } from \"jsr:@std/jsonc\"; parse(Deno.readTextSync(\"tsconfig.json\"));'","typeGuard":null,"tryCatchPattern":"try {\n  await runDeno(\"sync-types\");\n} catch (err) {\n  if (String(err).includes(\"failed to parse\")) {\n    // open the named file at the reported line/column and fix\n  } else throw err;\n}","preventionTips":["Lint tsconfig.json (JSONC-aware) in CI","Resolve editor/merge conflicts fully before syncing","Keep tsconfig edits small and parse-check after each change"],"tags":["tsconfig","jsonc","parse-error","deno-sync-types","invalid-data"],"backgroundTag":"invalid-json-config","analyzedSha":"9ad36f7a2cce60488e6ec52283efb32efddaf93a","analyzedAt":"2026-08-20T13:07:44.778Z","contentChangedAt":"2026-08-20T13:07:44.778Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}