microsoft/typescript-go · error

transpilation produced no output

Error message

transpilation produced no output

What it means

transpileModule / transpileDeclaration returned a nil *transpile.Output while the context was not canceled, so the handler surfaces a bare error with no sentinel. A nil output is an internal bail-out of the transpiler rather than a normal diagnostics-bearing result, so this indicates a compiler bug or an aborted run that failed to report through diagnostics.

Source

Thrown at internal/api/session.go:1262

}

func transpileOutput(ctx context.Context, input string, options TranspileOptions, declaration bool) (*TranspileOutputResponse, error) {
	transpileOptions := transpile.Options{
		CompilerOptions:   options.CompilerOptions,
		FileName:          options.FileName,
		ReportDiagnostics: options.ReportDiagnostics,
	}
	var output *transpile.Output
	if declaration {
		output = transpile.TranspileDeclaration(ctx, input, transpileOptions)
	} else {
		output = transpile.TranspileModule(ctx, input, transpileOptions)
	}
	if output == nil {
		if err := ctx.Err(); err != nil {
			return nil, err
		}
		return nil, errors.New("transpilation produced no output")
	}
	return &TranspileOutputResponse{
		OutputText:    output.OutputText,
		Diagnostics:   NewDiagnosticResponses(output.Diagnostics),
		SourceMapText: output.SourceMapText,
	}, nil
}

// handleGetSourceFile returns a source file from a project within a snapshot.
func (s *Session) handleGetSourceFile(ctx context.Context, params *GetSourceFileParams) (any, error) {
	sd, err := s.getSnapshotData(params.Snapshot)
	if err != nil {
		return nil, err
	}

	program, err := sd.getProgram(params.Project)
	if err != nil {
		return nil, err

View on GitHub (pinned to 1bcfa18d79)

Solutions

  1. Retry once with a fresh, generously-deadlined context
  2. Reduce the input to the smallest repro and check diagnostics settings (reportDiagnostics: true) to surface real errors
  3. If it reproduces, report an upstream issue with the input, since nil-output-with-live-context is not an expected result

Example fix

// before
out, err := transpileModule(ctx, hugeInput, opts) // err: transpilation produced no output
return err

// after
out, err := transpileModule(ctx, hugeInput, opts)
if isNoOutputErr(err) {
    ctx2, cancel := context.WithTimeout(context.Background(), 30*time.Second)
    defer cancel()
    out, err = transpileModule(ctx2, hugeInput, opts)
}
Defensive patterns

Strategy: retry

Validate before calling

// Nothing to pre-validate reliably (internal nil-output), but bound the context:
ctx, cancel := context.WithTimeout(ctx, 30*time.Second)
defer cancel()

Type guard

func isNoTranspileOutput(err error) bool {
    return err != nil && strings.Contains(err.Error(), "transpilation produced no output")
}

Try / catch

out, err := transpileOnce(ctx, input, opts)
if isNoTranspileOutput(err) && ctx.Err() == nil {
    ctx2, cancel := context.WithTimeout(context.Background(), 60*time.Second)
    defer cancel()
    out, err = transpileOnce(ctx2, input, opts) // single retry with fresh context
}
if err != nil { return err } // now a genuine bug: report upstream with the input

Prevention

When it happens

Trigger: A transpile-internal error path that returns nil instead of an output with diagnostics; a context canceled mid-transpile in a race where ctx.Err() is still nil at the check; pathological input triggering an unhandled case in the transpiler.

Common situations: Aggressive client timeouts around transpile of very large files; nightly typescript-go builds with transpiler regressions; fuzzed or generated inputs exercising unusual syntax.

Related errors


AI-assisted analysis of microsoft/typescript-go@1bcfa18d79 (2026-08-16). Data as JSON: /api/errors/30325f3b0271ba4e. Report an issue: GitHub.