{"record":{"id":"06eef6ac8201183e","repo":"denoland/deno","slug":"invalid-declaration-file-path","errorCode":null,"errorMessage":"Invalid declaration file path","messagePattern":"Invalid declaration file path","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"cli/tools/transpile.rs","lineNumber":373,"sourceCode":"  } else {\n    PathBuf::from(tsc_file_name)\n  };\n\n  if let Some(outdir) = output_dir {\n    // --outdir: preserve relative directory structure\n    let outdir = cwd.join(outdir);\n    let relative = path.strip_prefix(cwd).map_err(|_| {\n      anyhow::anyhow!(\n        \"Declaration file {} is not under the current directory\",\n        path.display()\n      )\n    })?;\n    Ok(outdir.join(relative))\n  } else if let Some(base_dir) = output_base_dir {\n    // -o: place .d.ts next to the output file\n    let file_name = path\n      .file_name()\n      .ok_or_else(|| anyhow::anyhow!(\"Invalid declaration file path\"))?;\n    Ok(base_dir.join(file_name))\n  } else {\n    // No output specified: place next to source file\n    Ok(path)\n  }\n}\n\n/// SWC's code generator always writes a single space after a block\n/// comment's closing `*/`, regardless of whether the original source had a\n/// newline. For multi-line block comments (typically JSDoc) this collapses\n/// the comment onto the same line as the following statement. This function\n/// walks the emitted source and replaces that single space with a newline\n/// (plus the comment's own leading indentation) when the preceding block\n/// comment spans multiple lines.\nfn restore_block_comment_newlines(input: &str) -> String {\n  let bytes = input.as_bytes();\n  let n = bytes.len();\n  let mut out: Vec<u8> = Vec::with_capacity(n);","sourceCodeStart":355,"sourceCodeEnd":391,"githubUrl":"https://github.com/denoland/deno/blob/9ad36f7a2cce60488e6ec52283efb32efddaf93a/cli/tools/transpile.rs#L355-L391","documentation":"In `-o` (single output) mode the emitted declaration is written as base_dir + file_name (cli/tools/transpile.rs:369-374). Path::file_name() returns None only for degenerate paths that terminate in `..` or name the filesystem root, so this guard is practically unreachable through normal `deno transpile` usage — it exists to keep a malformed tsc-reported name from producing a bogus output path.","triggerScenarios":"A tsc-reported declaration specifier whose path normalizes to something ending in `..` (pathological tsconfig references or generated virtual file names).","commonSituations":"Not seen in normal use; would indicate a highly unusual compiler/emit configuration.","solutions":["Re-run with explicit, concrete input file paths (no trailing .. segments or generated virtual paths).","If it reproduces, record the exact deno transpile invocation and the tsconfig/deno.json in effect and report it upstream."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":["Give deno transpile concrete input filenames without trailing .. or virtual path segments.","If you never see this error, ignore it — it guards a degenerate case unreachable in normal use."],"tags":["transpile","path","edge-case"],"backgroundTag":"invalid-file-path","analyzedSha":"9ad36f7a2cce60488e6ec52283efb32efddaf93a","analyzedAt":"2026-08-20T13:07:44.778Z","contentChangedAt":"2026-08-20T13:07:44.778Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}