microsoft/typescript-go · error
failed to marshal type %d: %w
Error message
failed to marshal type %d: %w
What it means
Error "failed to marshal type %d: %w" thrown in microsoft/typescript-go.
Source
Thrown at internal/tracing/tracing.go:520
t.mu.Lock()
types := slices.Clone(t.types)
t.mu.Unlock()
if len(types) == 0 {
return nil
}
var sb strings.Builder
// Write opening bracket (no newline so type ID matches line number)
sb.WriteString("[")
recursionIdentityMap := make(map[any]int)
for i, typ := range types {
descriptor := t.buildTypeDescriptor(typ, recursionIdentityMap)
if err := json.MarshalWrite(&sb, descriptor); err != nil {
return fmt.Errorf("failed to marshal type %d: %w", typ.Id(), err)
}
if i < len(types)-1 {
sb.WriteString(",\n")
}
}
sb.WriteString("]\n")
return t.fs.WriteFile(t.typesPath, sb.String())
}
// TypeDescriptor represents a type in the output JSON
type TypeDescriptor struct {
ID uint32 `json:"id"`
IntrinsicName string `json:"intrinsicName,omitzero"`
SymbolName string `json:"symbolName,omitzero"`
RecursionID *int `json:"recursionId,omitzero"`View on GitHub (pinned to 1bcfa18d79)
When it happens
Trigger: Thrown at internal/tracing/tracing.go:520 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of microsoft/typescript-go@1bcfa18d79 (2026-08-16).
Data as JSON: /api/errors/8a07a2164b335225.
Report an issue: GitHub.