{"record":{"id":"30325f3b0271ba4e","repo":"microsoft/typescript-go","slug":"transpilation-produced-no-output","errorCode":null,"errorMessage":"transpilation produced no output","messagePattern":"transpilation produced no output","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/api/session.go","lineNumber":1262,"sourceCode":"}\n\nfunc transpileOutput(ctx context.Context, input string, options TranspileOptions, declaration bool) (*TranspileOutputResponse, error) {\n\ttranspileOptions := transpile.Options{\n\t\tCompilerOptions:   options.CompilerOptions,\n\t\tFileName:          options.FileName,\n\t\tReportDiagnostics: options.ReportDiagnostics,\n\t}\n\tvar output *transpile.Output\n\tif declaration {\n\t\toutput = transpile.TranspileDeclaration(ctx, input, transpileOptions)\n\t} else {\n\t\toutput = transpile.TranspileModule(ctx, input, transpileOptions)\n\t}\n\tif output == nil {\n\t\tif err := ctx.Err(); err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\treturn nil, errors.New(\"transpilation produced no output\")\n\t}\n\treturn &TranspileOutputResponse{\n\t\tOutputText:    output.OutputText,\n\t\tDiagnostics:   NewDiagnosticResponses(output.Diagnostics),\n\t\tSourceMapText: output.SourceMapText,\n\t}, nil\n}\n\n// handleGetSourceFile returns a source file from a project within a snapshot.\nfunc (s *Session) handleGetSourceFile(ctx context.Context, params *GetSourceFileParams) (any, error) {\n\tsd, err := s.getSnapshotData(params.Snapshot)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tprogram, err := sd.getProgram(params.Project)\n\tif err != nil {\n\t\treturn nil, err","sourceCodeStart":1244,"sourceCodeEnd":1280,"githubUrl":"https://github.com/microsoft/typescript-go/blob/1bcfa18d79a3be41772223d5c05dfe4480e614ff/internal/api/session.go#L1244-L1280","documentation":"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.","triggerScenarios":"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.","commonSituations":"Aggressive client timeouts around transpile of very large files; nightly typescript-go builds with transpiler regressions; fuzzed or generated inputs exercising unusual syntax.","solutions":["Retry once with a fresh, generously-deadlined context","Reduce the input to the smallest repro and check diagnostics settings (reportDiagnostics: true) to surface real errors","If it reproduces, report an upstream issue with the input, since nil-output-with-live-context is not an expected result"],"exampleFix":"// before\nout, err := transpileModule(ctx, hugeInput, opts) // err: transpilation produced no output\nreturn err\n\n// after\nout, err := transpileModule(ctx, hugeInput, opts)\nif isNoOutputErr(err) {\n    ctx2, cancel := context.WithTimeout(context.Background(), 30*time.Second)\n    defer cancel()\n    out, err = transpileModule(ctx2, hugeInput, opts)\n}","handlingStrategy":"retry","validationCode":"// Nothing to pre-validate reliably (internal nil-output), but bound the context:\nctx, cancel := context.WithTimeout(ctx, 30*time.Second)\ndefer cancel()","typeGuard":"func isNoTranspileOutput(err error) bool {\n    return err != nil && strings.Contains(err.Error(), \"transpilation produced no output\")\n}","tryCatchPattern":"out, err := transpileOnce(ctx, input, opts)\nif isNoTranspileOutput(err) && ctx.Err() == nil {\n    ctx2, cancel := context.WithTimeout(context.Background(), 60*time.Second)\n    defer cancel()\n    out, err = transpileOnce(ctx2, input, opts) // single retry with fresh context\n}\nif err != nil { return err } // now a genuine bug: report upstream with the input","preventionTips":["Set generous deadlines on transpile calls; tight timeouts race the nil-output check","Enable reportDiagnostics so real errors surface as diagnostics rather than surprises","Keep the failing input around; nil-output-with-live-context is reportable upstream"],"tags":["transpile","internal-error","context","api"],"backgroundTag":null,"analyzedSha":"1bcfa18d79a3be41772223d5c05dfe4480e614ff","analyzedAt":"2026-08-16T02:12:00.115Z","schemaVersion":2},"datasetVersion":"2026-08-16T03:17:38.424Z"}