Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
008ab55
Always have host
jakebailey Aug 15, 2025
2122679
Merge branch 'main' into jabaile/symbol-baseline-fixes-but-always-host
jakebailey Oct 2, 2025
3003264
Merge branch 'main' into jabaile/symbol-baseline-fixes-but-always-host
jakebailey Oct 6, 2025
e129f20
Update baselines
jakebailey Oct 6, 2025
866dc24
Merge branch 'main' into jabaile/symbol-baseline-fixes-but-always-host
jakebailey Oct 31, 2025
1aa7abd
cleanup
jakebailey Oct 31, 2025
9aaa856
Merge branch 'main' into jabaile/symbol-baseline-fixes-but-always-host
jakebailey Nov 6, 2025
1f914f9
Merge branch 'main' into jabaile/symbol-baseline-fixes-but-always-host
jakebailey Nov 10, 2025
225240c
Merge branch 'main' into jabaile/symbol-baseline-fixes-but-always-host
jakebailey Nov 18, 2025
8c88a39
Merge branch 'main' into jabaile/symbol-baseline-fixes-but-always-host
jakebailey Dec 2, 2025
68916dd
Merge branch 'main' into jabaile/symbol-baseline-fixes-but-always-host
jakebailey Dec 3, 2025
95acbec
Merge branch 'main' into jabaile/symbol-baseline-fixes-but-always-host
jakebailey Dec 3, 2025
386d8f8
fix manual
jakebailey Dec 3, 2025
d4fc726
Merge branch 'main' into jabaile/symbol-baseline-fixes-but-always-host
jakebailey Dec 9, 2025
51ad453
Merge branch 'main' into jabaile/symbol-baseline-fixes-but-always-host
jakebailey Dec 17, 2025
9d5be58
update
jakebailey Dec 17, 2025
be34a2b
Merge branch 'main' into jabaile/symbol-baseline-fixes-but-always-host
jakebailey Jan 31, 2026
2351449
uh oh, unstable
jakebailey Jan 31, 2026
996cef4
hmm
jakebailey Jan 31, 2026
e4cc67e
Fix nondeterminism
jakebailey Jan 31, 2026
d22a70f
Merge branch 'main' into jabaile/symbol-baseline-fixes-but-always-host
jakebailey Feb 5, 2026
462ee68
Merge branch 'main' into jabaile/symbol-baseline-fixes-but-always-host
jakebailey Feb 5, 2026
47d3908
Merge branch 'main' into jabaile/symbol-baseline-fixes-but-always-host
jakebailey Feb 10, 2026
cd9000f
Fix fourslash
jakebailey Feb 10, 2026
133eb7e
Undo random bad merge
jakebailey Feb 10, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
18 changes: 6 additions & 12 deletions internal/checker/nodebuilder.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import (
)

type NodeBuilder struct {
ctxStack []*NodeBuilderContext
basicHost Host
impl *NodeBuilderImpl
ctxStack []*NodeBuilderContext
host Host
impl *NodeBuilderImpl
}

// EmitContext implements NodeBuilderInterface.
Expand All @@ -20,6 +20,7 @@ func (b *NodeBuilder) EmitContext() *printer.EmitContext {
func (b *NodeBuilder) enterContext(enclosingDeclaration *ast.Node, flags nodebuilder.Flags, internalFlags nodebuilder.InternalFlags, tracker nodebuilder.SymbolTracker) {
b.ctxStack = append(b.ctxStack, b.impl.ctx)
b.impl.ctx = &NodeBuilderContext{
host: b.host,
tracker: tracker,
flags: flags,
internalFlags: internalFlags,
Expand All @@ -32,14 +33,7 @@ func (b *NodeBuilder) enterContext(enclosingDeclaration *ast.Node, flags nodebui
enclosingSymbolTypes: make(map[ast.SymbolId]*Type),
remappedSymbolReferences: make(map[ast.SymbolId]*ast.Symbol),
}
// TODO: always provide this; see https://github.com/microsoft/typescript-go/pull/1588#pullrequestreview-3125218673
var moduleResolverHost Host
if tracker != nil {
moduleResolverHost = tracker.GetModuleSpecifierGenerationHost()
} else if internalFlags&nodebuilder.InternalFlagsDoNotIncludeSymbolChain != 0 {
moduleResolverHost = b.basicHost
}
tracker = NewSymbolTrackerImpl(b.impl.ctx, tracker, moduleResolverHost)
tracker = NewSymbolTrackerImpl(b.impl.ctx, tracker)
b.impl.ctx.tracker = tracker
}

Expand Down Expand Up @@ -182,7 +176,7 @@ func NewNodeBuilder(ch *Checker, e *printer.EmitContext) *NodeBuilder {

func NewNodeBuilderEx(ch *Checker, e *printer.EmitContext, idToSymbol map[*ast.IdentifierNode]*ast.Symbol) *NodeBuilder {
impl := newNodeBuilderImpl(ch, e, idToSymbol)
return &NodeBuilder{impl: impl, ctxStack: make([]*NodeBuilderContext, 0, 1), basicHost: ch.program}
return &NodeBuilder{impl: impl, ctxStack: make([]*NodeBuilderContext, 0, 1), host: ch.program}
}

func (c *Checker) getNodeBuilder() *NodeBuilder {
Expand Down
5 changes: 3 additions & 2 deletions internal/checker/nodebuilderimpl.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ type NodeBuilderSymbolLinks struct {
specifierCache module.ModeAwareCache[string]
}
type NodeBuilderContext struct {
host Host
tracker nodebuilder.SymbolTracker
approximateLength int
encounteredError bool
Expand Down Expand Up @@ -1157,7 +1158,7 @@ func (b *NodeBuilderImpl) getSpecifierForModuleSymbol(symbol *ast.Symbol, overri
return stringutil.StripQuotes(symbol.Name)
}
}
if b.ctx.enclosingFile == nil || b.ctx.tracker.GetModuleSpecifierGenerationHost() == nil {
if b.ctx.enclosingFile == nil {
if isAmbientModuleSymbolName(symbol.Name) {
return stringutil.StripQuotes(symbol.Name)
}
Expand Down Expand Up @@ -1189,7 +1190,7 @@ func (b *NodeBuilderImpl) getSpecifierForModuleSymbol(symbol *ast.Symbol, overri
// just like how the declaration emitter does for the ambient module declarations - we can easily accomplish this
// using the `baseUrl` compiler option (which we would otherwise never use in declaration emit) and a non-relative
// specifier preference
host := b.ctx.tracker.GetModuleSpecifierGenerationHost()
host := b.ctx.host
specifierCompilerOptions := b.ch.compilerOptions
specifierPref := modulespecifiers.ImportModuleSpecifierPreferenceProjectRelative
endingPref := modulespecifiers.ImportModuleSpecifierEndingPreferenceNone
Expand Down
13 changes: 2 additions & 11 deletions internal/checker/symboltracker.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,16 @@ package checker

import (
"github.com/microsoft/typescript-go/internal/ast"
"github.com/microsoft/typescript-go/internal/modulespecifiers"
"github.com/microsoft/typescript-go/internal/nodebuilder"
)

type SymbolTrackerImpl struct {
context *NodeBuilderContext
inner nodebuilder.SymbolTracker
DisableTrackSymbol bool
tchost Host
}

func NewSymbolTrackerImpl(context *NodeBuilderContext, tracker nodebuilder.SymbolTracker, tchost Host) *SymbolTrackerImpl {
func NewSymbolTrackerImpl(context *NodeBuilderContext, tracker nodebuilder.SymbolTracker) *SymbolTrackerImpl {
if tracker != nil {
for {
t, ok := tracker.(*SymbolTrackerImpl)
Expand All @@ -24,14 +22,7 @@ func NewSymbolTrackerImpl(context *NodeBuilderContext, tracker nodebuilder.Symbo
}
}

return &SymbolTrackerImpl{context, tracker, false, tchost}
}

func (this *SymbolTrackerImpl) GetModuleSpecifierGenerationHost() modulespecifiers.ModuleSpecifierGenerationHost {
if this.inner == nil {
return this.tchost
}
return this.inner.GetModuleSpecifierGenerationHost()
return &SymbolTrackerImpl{context, tracker, false}
}

func (this *SymbolTrackerImpl) TrackSymbol(symbol *ast.Symbol, enclosingDeclaration *ast.Node, meaning ast.SymbolFlags) bool {
Expand Down
2 changes: 0 additions & 2 deletions internal/fourslash/_scripts/failingTests.txt
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,6 @@ TestLocalFunction
TestMemberListInReopenedEnum
TestMemberListInWithBlock
TestMemberListOfExportedClass
TestModuleReexportedIntoGlobalQuickInfo
TestMultilineCommentBeforeOpenBrace
TestMultiModuleFundule
TestNgProxy1
Expand Down Expand Up @@ -472,7 +471,6 @@ TestQuickInfoFromContextualUnionType3
TestQuickInfoFunctionKeyword
TestQuickInfoGenerics
TestQuickInfoGetterSetter
TestQuickInfoImportNonunicodePath
TestQuickInfoInInvalidIndexSignature
TestQuickInfoInJsdocInTsFile1
TestQuickInfoInOptionalChain
Expand Down
3 changes: 0 additions & 3 deletions internal/nodebuilder/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,10 @@ package nodebuilder

import (
"github.com/microsoft/typescript-go/internal/ast"
"github.com/microsoft/typescript-go/internal/modulespecifiers"
)

// TODO: previously all symboltracker methods were optional, but now they're required.
Copy link

Copilot AI Feb 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The TODO comment is now misleading: this interface no longer includes the (previously required) module-specifier host method, and the change in this PR makes the host come from NodeBuilderContext instead. Update or remove this comment so it reflects the current design (host is always provided by NodeBuilder rather than via the tracker).

Suggested change
// TODO: previously all symboltracker methods were optional, but now they're required.
// SymbolTracker provides callbacks used by the node builder; all methods are required, and any
// host or module-specifier context is supplied via NodeBuilderContext rather than this interface.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I honestly don't know how this suggestion is an improvement

type SymbolTracker interface {
GetModuleSpecifierGenerationHost() modulespecifiers.ModuleSpecifierGenerationHost

TrackSymbol(symbol *ast.Symbol, enclosingDeclaration *ast.Node, meaning ast.SymbolFlags) bool
ReportInaccessibleThisError()
ReportPrivateInBaseOfClassExpression(propertyName string)
Expand Down
6 changes: 0 additions & 6 deletions internal/transformers/declarations/tracker.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"github.com/microsoft/typescript-go/internal/checker"
"github.com/microsoft/typescript-go/internal/core"
"github.com/microsoft/typescript-go/internal/diagnostics"
"github.com/microsoft/typescript-go/internal/modulespecifiers"
"github.com/microsoft/typescript-go/internal/printer"
"github.com/microsoft/typescript-go/internal/scanner"
)
Expand All @@ -17,11 +16,6 @@ type SymbolTrackerImpl struct {
fallbackStack []*ast.Node
}

// GetModuleSpecifierGenerationHost implements checker.SymbolTracker.
func (s *SymbolTrackerImpl) GetModuleSpecifierGenerationHost() modulespecifiers.ModuleSpecifierGenerationHost {
return s.host
}

// PopErrorFallbackNode implements checker.SymbolTracker.
func (s *SymbolTrackerImpl) PopErrorFallbackNode() {
s.fallbackStack = s.fallbackStack[:len(s.fallbackStack)-1]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ export declare function styled(): Color;

=== file2.ts ===
import { styled } from "./file1";
>styled : () => import("color").default
>styled : () => import("./color").default

export const A = styled();
>A : import("color").default
>styled() : import("color").default
>styled : () => import("color").default
>A : import("./color").default
>styled() : import("./color").default
>styled : () => import("./color").default

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export default 2 + 2;
>2 : 2

export as namespace Foo;
>Foo : typeof import("foo")
>Foo : typeof import("./foo")

=== foo2.d.ts ===
export = 2 + 2;
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export function Timestamped<TBase extends Constructor>(Base: TBase) {
=== index.ts ===
import { wrapClass, Timestamped } from "./wrapClass";
>wrapClass : (param: any) => typeof Wrapped
>Timestamped : <TBase extends import("wrapClass").Constructor<{}>>(Base: TBase) => { new (...args: any[]): (Anonymous class); prototype: Timestamped.(Anonymous class); } & TBase
>Timestamped : <TBase extends import("./wrapClass").Constructor<{}>>(Base: TBase) => { new (...args: any[]): (Anonymous class); prototype: Timestamped.(Anonymous class); } & TBase

export default wrapClass(0);
>wrapClass(0) : typeof Wrapped
Expand All @@ -63,7 +63,7 @@ export class User {
export class TimestampedUser extends Timestamped(User) {
>TimestampedUser : TimestampedUser
>Timestamped(User) : Timestamped.(Anonymous class) & User
>Timestamped : <TBase extends import("wrapClass").Constructor<{}>>(Base: TBase) => { new (...args: any[]): (Anonymous class); prototype: Timestamped.(Anonymous class); } & TBase
>Timestamped : <TBase extends import("./wrapClass").Constructor<{}>>(Base: TBase) => { new (...args: any[]): (Anonymous class); prototype: Timestamped.(Anonymous class); } & TBase
>User : typeof User

constructor() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import { wrapClass, Timestamped } from "./wrapClass";
>wrapClass : (param: any) => typeof Wrapped
->Timestamped : <TBase extends import("./wrapClass").Constructor>(Base: TBase) => { new (...args: any[]): (Anonymous class); prototype: Timestamped<any>.(Anonymous class); } & TBase
+>Timestamped : <TBase extends import("wrapClass").Constructor<{}>>(Base: TBase) => { new (...args: any[]): (Anonymous class); prototype: Timestamped.(Anonymous class); } & TBase
+>Timestamped : <TBase extends import("./wrapClass").Constructor<{}>>(Base: TBase) => { new (...args: any[]): (Anonymous class); prototype: Timestamped.(Anonymous class); } & TBase

export default wrapClass(0);
>wrapClass(0) : typeof Wrapped
Expand All @@ -30,7 +30,7 @@
->Timestamped(User) : Timestamped<typeof User>.(Anonymous class) & User
->Timestamped : <TBase extends import("./wrapClass").Constructor>(Base: TBase) => { new (...args: any[]): (Anonymous class); prototype: Timestamped<any>.(Anonymous class); } & TBase
+>Timestamped(User) : Timestamped.(Anonymous class) & User
+>Timestamped : <TBase extends import("wrapClass").Constructor<{}>>(Base: TBase) => { new (...args: any[]): (Anonymous class); prototype: Timestamped.(Anonymous class); } & TBase
+>Timestamped : <TBase extends import("./wrapClass").Constructor<{}>>(Base: TBase) => { new (...args: any[]): (Anonymous class); prototype: Timestamped.(Anonymous class); } & TBase
>User : typeof User

constructor() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@

=== file1.ts ===
function foo() {}
>foo : typeof import("file1.ts")
>foo : typeof import("./file1")

namespace foo {
>foo : typeof import("file1.ts")
>foo : typeof import("./file1")

export var v = 1;
>v : number
>1 : 1
}
export = foo;
>foo : typeof import("file1.ts")
>foo : typeof import("./file1")

=== file2.ts ===
import x = require("./file1");
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@

=== file1.ts ===
class foo {}
>foo : import("file1.ts")
>foo : import("./file1")

namespace foo {
>foo : typeof import("file1.ts")
>foo : typeof import("./file1")

export var v = 1;
>v : number
>1 : 1
}
export = foo;
>foo : import("file1.ts")
>foo : import("./file1")

=== file2.ts ===
import x = require("./file1");
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ declare module "express" {
>"express" : typeof import("express")

function e(): e.Express;
>e : typeof import("express.d.ts")
>e : typeof import("express")
>e : any

namespace e {
>e : typeof import("express.d.ts")
>e : typeof import("express")

interface IRoute {
all(...handler: RequestHandler[]): IRoute;
Expand Down Expand Up @@ -101,7 +101,7 @@ declare module "express" {
}

export = e;
>e : typeof import("express.d.ts")
>e : typeof import("express")
}

=== augmentation.ts ===
Expand Down

This file was deleted.

Loading
Loading