{"record":{"id":"3fe4406fdd250cb7","repo":"parcel-bundler/parcel","slug":"dynamic-diagnostic-from-typescript-compiler-error","errorCode":null,"errorMessage":"[dynamic diagnostic from TypeScript compiler errors]","messagePattern":"\\[dynamic diagnostic from TypeScript compiler errors\\]","errorType":"exception","errorClass":"ThrowableDiagnostic","httpStatus":null,"severity":"error","filePath":"packages/transformers/typescript-types/src/TSTypesTransformer.js","lineNumber":159,"sourceCode":"            codeHighlights: [\n              {\n                start,\n                end,\n                message: escapeMarkdown(diagnosticMessage),\n              },\n            ],\n          };\n        }\n      }\n\n      return {\n        message: escapeMarkdown(diagnosticMessage),\n        codeFrames: codeframe ? [codeframe] : undefined,\n      };\n    });\n\n    if (host.outputCode == null) {\n      throw new ThrowableDiagnostic({diagnostic: parcelDiagnostics});\n    } else {\n      for (let d of parcelDiagnostics) {\n        logger.warn(d);\n      }\n    }\n\n    let code = nullthrows(host.outputCode);\n    code = code.substring(0, code.lastIndexOf('//# sourceMappingURL'));\n\n    let map = JSON.parse(nullthrows(host.outputMap));\n    map.sources = map.sources.map(source =>\n      path.join(path.dirname(asset.filePath), source),\n    );\n\n    let sourceMap = null;\n    if (map.mappings) {\n      sourceMap = new SourceMap(options.projectRoot);\n      sourceMap.addVLQMap(map);","sourceCodeStart":141,"sourceCodeEnd":177,"githubUrl":"https://github.com/parcel-bundler/parcel/blob/59484858a1a0bcbb71f74088956bb437a2db6505/packages/transformers/typescript-types/src/TSTypesTransformer.js#L141-L177","documentation":"Thrown by @parcel/transformer-typescript-types when the TypeScript compiler produced no output code (host.outputCode == null), meaning tsc emitted at least one diagnostic. The collected parcelDiagnostics (built from tsc's error list, each with a markdown-escaped message and codeframe) are wrapped in a ThrowableDiagnostic and thrown, halting the type-generation pipeline.","triggerScenarios":"The TSTypesTransformer runs the TS compiler to emit .d.ts type artifacts; if ANY source/type error is reported, outputCode stays null and the transformer throws the whole diagnostic list instead of writing types.","commonSituations":"A project enabling @parcel/transformer-typescript-types with existing type errors, a tsconfig with too-strict settings (noImplicitAny, strictNullChecks) newly turned on, a dependency whose @types are missing, or .d.ts files that reference modules not resolvable in the type context.","solutions":["Read the surfaced codeframe(s) and fix the underlying TS error in the cited source file.","Run `tsc --noEmit -p tsconfig.json` locally to reproduce and enumerate every error before rebuilding.","Temporarily relax the offending tsconfig flag (e.g. strict: false) to confirm the root cause, then re-enable.","Install missing @types/* packages or add a custom .d.ts module declaration for untyped deps."],"exampleFix":"// before: const x: number = \"not a number\";\n// after:  const x: number = 42;","handlingStrategy":"validation","validationCode":"import { execSync } from 'child_process';\n// run tsc before invoking the types transformer\ntry {\n  execSync('npx tsc --noEmit -p tsconfig.json', { stdio: 'pipe' });\n} catch (e) {\n  console.error('Type errors must be fixed before type emission:\\n' + e.stdout?.toString());\n  process.exit(1);\n}","typeGuard":null,"tryCatchPattern":"try {\n  await tsTypesTransformer.transform({asset});\n} catch (e) {\n  if (e instanceof ThrowableDiagnostic) {\n    for (const d of e.diagnostics) console.error(`${d.filePath}:${d.codeHighlights?.[0]?.start}`);\n  }\n  throw e;\n}","preventionTips":["Run `tsc --noEmit` in CI to fail before the type transformer runs.","Keep tsconfig strictness aligned with what the team can satisfy.","Install @types/* for every untyped dependency."],"tags":["typescript","type-checking","parcel-transformer","tsconfig"],"backgroundTag":null,"analyzedSha":"59484858a1a0bcbb71f74088956bb437a2db6505","analyzedAt":"2026-08-13T04:06:35.925Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}