{"record":{"id":"642700600bb69858","repo":"denoland/deno","slug":"cannot-generate-declarations-for-files-with-differ","errorCode":null,"errorMessage":"Cannot generate declarations for files with different compiler option scopes.\n'{}' uses scope '{}' but '{}' uses scope '{}'.\nSeparate these files into different invocations.","messagePattern":"Cannot generate declarations for files with different compiler option scopes\\.\n'(.+?)' uses scope '(.+?)' but '(.+?)' uses scope '(.+?)'\\.\nSeparate these files into different invocations\\.","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"cli/tools/transpile.rs","lineNumber":278,"sourceCode":"      specifiers,\n      crate::graph_util::BuildGraphWithNpmOptions {\n        is_dynamic: false,\n        loader: None,\n        npm_caching: cli_options.default_npm_caching_strategy(),\n      },\n    )\n    .await?;\n\n  // Validate that all files share the same compiler options scope, since\n  // TSC type-checks all files in a single pass.\n  let compiler_options_resolver = factory.compiler_options_resolver()?;\n  let first_specifier = &root_names[0].0;\n  let (first_key, _) =\n    compiler_options_resolver.entry_for_specifier(first_specifier);\n  for (specifier, _) in root_names.iter().skip(1) {\n    let (key, _) = compiler_options_resolver.entry_for_specifier(specifier);\n    if key != first_key {\n      anyhow::bail!(\n        \"Cannot generate declarations for files with different compiler option scopes.\\n\\\n         '{}' uses scope '{}' but '{}' uses scope '{}'.\\n\\\n         Separate these files into different invocations.\",\n        first_specifier,\n        first_key,\n        specifier,\n        key,\n      );\n    }\n  }\n\n  let type_checker = factory.type_checker().await?;\n  let result = type_checker.emit_declarations(\n    Arc::new(graph),\n    root_names,\n    cli_options.ts_type_lib_window(),\n  )?;\n","sourceCodeStart":260,"sourceCodeEnd":296,"githubUrl":"https://github.com/denoland/deno/blob/89f33cbef296a2b287f323d42de54c871fa69c77/cli/tools/transpile.rs#L260-L296","documentation":"With `--declaration`, TSC type-checks all root names in a single pass under one set of compiler options. Every file's compiler-options scope (derived from its nearest deno.json/tsconfig) must resolve to the same scope key; any mismatch aborts before checking starts because the results would be inconsistent.","triggerScenarios":"`deno transpile --declaration a.ts b.ts` where a.ts and b.ts resolve to different compiler-options scopes — e.g. they sit in different workspace members with per-package deno.json compilerOptions.","commonSituations":"Monorepos invoking one transpile command across package boundaries; mixing files inside and outside a workspace root that carries its own compilerOptions.","solutions":["Split into one invocation per scope: run transpile --declaration separately inside each workspace member","Invoke from a directory where all inputs resolve to a single config scope","Drop --declaration — plain transpilation does not require matching scopes"],"exampleFix":"# before (a.ts and b.ts in different workspace members)\ndeno transpile --declaration packages/one/a.ts packages/two/b.ts\n# after\n(cd packages/one && deno transpile --declaration a.ts --outdir dist)\n(cd packages/two && deno transpile --declaration b.ts --outdir dist)","handlingStrategy":"validation","validationCode":"# bash: one invocation per workspace member\nfor member in packages/*/; do\n  (cd \"$member\" && deno transpile --declaration src/*.ts --outdir dist) || exit 1\ndone","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never span workspace-member boundaries in a single --declaration invocation","Group inputs by their nearest deno.json before building the command","Run plain transpile (no --declaration) when scopes must differ"],"tags":["cli","transpile","declarations","configuration","monorepo"],"backgroundTag":null,"analyzedSha":"89f33cbef296a2b287f323d42de54c871fa69c77","analyzedAt":"2026-08-16T07:54:21.310Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}