Draft
Conversation
Adopted from the parallel tracing branch: - Add "path" argument to checkDeferredNode, checkVariableDeclaration, and checkExpression trace points, matching the TypeScript reference implementation which includes the source file path for these events. - Add PopAll() method to both Tracing and CheckerTracing types, matching TypeScript's tracing.popAll() which closes all open events at once. This is used in the language server session for cleanup.
Match TypeScript's behavior of using `aliasSymbol ?? symbol` when determining firstDeclaration for type descriptors. Previously only the type's direct symbol was used, causing union types created via type aliases (e.g. `type Nullable<T> = T | null | undefined`) to be missing their firstDeclaration. Now these types correctly point back to their alias declaration site. On the typeslayer project this adds ~2,800 firstDeclaration entries per checker for union types that have an aliasSymbol.
Include TypeFlagsTemplateLiteral in the Display() condition alongside
TypeFlagsLiteral, so that template literal types (e.g. `${number}`)
get their string representation in the trace output. This goes beyond
TypeScript's current behavior but provides useful diagnostic info for
these types that would otherwise have no display or firstDeclaration.
Extend Display() to compute typeToString for Union and Intersection types in addition to Anonymous, Literal, and TemplateLiteral types. Anonymous unions and intersections can't have firstDeclaration (they have no symbol or aliasSymbol), but display text makes them identifiable in trace output. For example, a previously opaque union now shows: display: "CodeRouteToPath<TRouter> | FileRouteToPath<...>" This increases display coverage from ~39% to ~75% of all types.
jakebailey
reviewed
Feb 27, 2026
| return NewCheckerWithTracer(program, nil, nil) | ||
| } | ||
|
|
||
| func NewCheckerWithTracer(program Program, tracer TypeTracer, tr *tracing.CheckerTracing) (*Checker, *sync.Mutex) { |
Member
There was a problem hiding this comment.
I don't particularly like that we have this variant... what was wrong with the approach I had in my branch?
jakebailey
reviewed
Feb 27, 2026
| } | ||
|
|
||
| func (c *Checker) checkDeferredNode(node *ast.Node) { | ||
| c.tracing.Push(tracing.PhaseCheck, "checkDeferredNode", false, "kind", strconv.Itoa(int(node.Kind)), "pos", strconv.Itoa(node.Pos()), "end", strconv.Itoa(node.End()), "path", ast.GetSourceFileOfNode(node).FileName()) |
Member
There was a problem hiding this comment.
All tracing calls should do an if c.tracing != nil check; these are expensive operations to be doing on ever single node.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
this is a work in progress PR to add tracing so we can get types.json and trace.json files as was in the TypeScript codebase.