microsoft/typescript-go · error · ErrClientError
%w: failed to decode AST: %w
Error message
%w: failed to decode AST: %w
What it means
Error "%w: failed to decode AST: %w" thrown in microsoft/typescript-go.
Source
Thrown at internal/api/session.go:2506
}
}
if params.Flags != 0 {
return setup.checker.TypeToStringEx(t, enclosingDeclaration, checker.TypeFormatFlags(params.Flags), nil), nil
}
return setup.checker.TypeToStringEx(t, enclosingDeclaration, checker.TypeFormatFlagsAllowUniqueESSymbolType|checker.TypeFormatFlagsUseAliasDefinedOutsideCurrentScope, nil), nil
}
// handlePrintNode decodes a binary-encoded AST node and prints it to text.
func (s *Session) handlePrintNode(_ context.Context, params *PrintNodeParams) (string, error) {
data, err := base64.StdEncoding.DecodeString(params.Data)
if err != nil {
return "", fmt.Errorf("%w: invalid base64 data: %w", ErrClientError, err)
}
node, err := encoder.DecodeNodes(data)
if err != nil {
return "", fmt.Errorf("%w: failed to decode AST: %w", ErrClientError, err)
}
p := printer.NewPrinter(printer.PrinterOptions{
PreserveSourceNewlines: params.PreserveSourceNewlines,
NeverAsciiEscape: params.NeverAsciiEscape,
TerminateUnterminatedLiterals: params.TerminateUnterminatedLiterals,
}, printer.PrintHandlers{}, nil)
return p.Emit(node, nil), nil
}
func (s *Session) handleEmit(ctx context.Context, params *EmitParams) (*EmitResponse, error) {
program, options, err := s.getEmitOptions(params)
if err != nil {
return nil, err
}
options.WriteFile = func(fileName string, text string, _ *compiler.WriteFileData) error {
return s.projectSession.FS().WriteFile(fileName, text)
}View on GitHub (pinned to 1bcfa18d79)
When it happens
Trigger: Thrown at internal/api/session.go:2506 when the library encounters an invalid state.
Common situations: See trigger scenarios.
Understand the failure class
- Parsing and encoding errors: unexpected token, malformed input — why parsers reject input and how to find the real culprit.
AI-assisted analysis of microsoft/typescript-go@1bcfa18d79 (2026-08-16).
Data as JSON: /api/errors/f7514e93cb344da6.
Report an issue: GitHub.