parcel-bundler/parcel · error · ThrowableDiagnostic

[dynamic diagnostic from TypeScript compiler errors]

Error message

[dynamic diagnostic from TypeScript compiler errors]

What it means

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.

Source

Thrown at packages/transformers/typescript-types/src/TSTypesTransformer.js:159

            codeHighlights: [
              {
                start,
                end,
                message: escapeMarkdown(diagnosticMessage),
              },
            ],
          };
        }
      }

      return {
        message: escapeMarkdown(diagnosticMessage),
        codeFrames: codeframe ? [codeframe] : undefined,
      };
    });

    if (host.outputCode == null) {
      throw new ThrowableDiagnostic({diagnostic: parcelDiagnostics});
    } else {
      for (let d of parcelDiagnostics) {
        logger.warn(d);
      }
    }

    let code = nullthrows(host.outputCode);
    code = code.substring(0, code.lastIndexOf('//# sourceMappingURL'));

    let map = JSON.parse(nullthrows(host.outputMap));
    map.sources = map.sources.map(source =>
      path.join(path.dirname(asset.filePath), source),
    );

    let sourceMap = null;
    if (map.mappings) {
      sourceMap = new SourceMap(options.projectRoot);
      sourceMap.addVLQMap(map);

View on GitHub (pinned to 59484858a1)

Solutions

  1. Read the surfaced codeframe(s) and fix the underlying TS error in the cited source file.
  2. Run `tsc --noEmit -p tsconfig.json` locally to reproduce and enumerate every error before rebuilding.
  3. Temporarily relax the offending tsconfig flag (e.g. strict: false) to confirm the root cause, then re-enable.
  4. Install missing @types/* packages or add a custom .d.ts module declaration for untyped deps.

Example fix

// before: const x: number = "not a number";
// after:  const x: number = 42;
Defensive patterns

Strategy: validation

Validate before calling

import { execSync } from 'child_process';
// run tsc before invoking the types transformer
try {
  execSync('npx tsc --noEmit -p tsconfig.json', { stdio: 'pipe' });
} catch (e) {
  console.error('Type errors must be fixed before type emission:\n' + e.stdout?.toString());
  process.exit(1);
}

Try / catch

try {
  await tsTypesTransformer.transform({asset});
} catch (e) {
  if (e instanceof ThrowableDiagnostic) {
    for (const d of e.diagnostics) console.error(`${d.filePath}:${d.codeHighlights?.[0]?.start}`);
  }
  throw e;
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of parcel-bundler/parcel@59484858a1 (2026-08-13). Data as JSON: /api/errors/3fe4406fdd250cb7. Report an issue: GitHub.