Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
  •  
  •  
  •  
The diff you're trying to view is too large. We only load the first 3000 changed files.
4 changes: 3 additions & 1 deletion internal/checker/checker.go
Original file line number Diff line number Diff line change
Expand Up @@ -14497,7 +14497,9 @@ func (c *Checker) resolveExternalModule(location *ast.Node, moduleReference stri
if ancestor == nil {
ancestor = ast.FindAncestor(location, ast.IsImportEqualsDeclaration)
if ancestor != nil {
contextSpecifier = ancestor.AsImportEqualsDeclaration().ModuleReference.AsExternalModuleReference().Expression
if moduleRefrence := ancestor.AsImportEqualsDeclaration().ModuleReference; moduleRefrence.Kind == ast.KindExternalModuleReference {
contextSpecifier = moduleRefrence.AsExternalModuleReference().Expression
}
}
}
}
Expand Down
19 changes: 12 additions & 7 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
host Host
impl *nodeBuilderImpl
ctxStack []*NodeBuilderContext
basicHost Host
impl *nodeBuilderImpl
}

// EmitContext implements NodeBuilderInterface.
Expand All @@ -32,10 +32,15 @@ func (b *NodeBuilder) enterContext(enclosingDeclaration *ast.Node, flags nodebui
enclosingSymbolTypes: make(map[ast.SymbolId]*Type),
remappedSymbolReferences: make(map[ast.SymbolId]*ast.Symbol),
}
if tracker == nil {
tracker = NewSymbolTrackerImpl(b.impl.ctx, nil, b.host)
b.impl.ctx.tracker = tracker
// 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)
b.impl.ctx.tracker = tracker
}

func (b *NodeBuilder) popContext() {
Expand Down Expand Up @@ -173,7 +178,7 @@ func (b *NodeBuilder) TypeToTypeNode(typ *Type, enclosingDeclaration *ast.Node,

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

func (c *Checker) getNodeBuilder() *NodeBuilder {
Expand Down
20 changes: 10 additions & 10 deletions internal/checker/nodebuilderimpl.go
Original file line number Diff line number Diff line change
Expand Up @@ -450,15 +450,15 @@ func (b *nodeBuilderImpl) symbolToNode(symbol *ast.Symbol, meaning ast.SymbolFla
if name != nil && ast.IsComputedPropertyName(name) {
return name
}
if b.ch.valueSymbolLinks.Has(symbol) {
nameType := b.ch.valueSymbolLinks.Get(symbol).nameType
if nameType != nil && nameType.flags&(TypeFlagsEnumLiteral|TypeFlagsUniqueESSymbol) != 0 {
oldEnclosing := b.ctx.enclosingDeclaration
b.ctx.enclosingDeclaration = nameType.symbol.ValueDeclaration
result := b.f.NewComputedPropertyName(b.symbolToExpression(nameType.symbol, meaning))
b.ctx.enclosingDeclaration = oldEnclosing
return result
}
}
if b.ch.valueSymbolLinks.Has(symbol) {
nameType := b.ch.valueSymbolLinks.Get(symbol).nameType
if nameType != nil && nameType.flags&(TypeFlagsEnumLiteral|TypeFlagsUniqueESSymbol) != 0 {
oldEnclosing := b.ctx.enclosingDeclaration
b.ctx.enclosingDeclaration = nameType.symbol.ValueDeclaration
result := b.f.NewComputedPropertyName(b.symbolToExpression(nameType.symbol, meaning))
b.ctx.enclosingDeclaration = oldEnclosing
return result
}
}
}
Expand Down Expand Up @@ -972,7 +972,7 @@ type sortedSymbolNamePair struct {
func (b *nodeBuilderImpl) getSymbolChain(symbol *ast.Symbol, meaning ast.SymbolFlags, endOfChain bool, yieldModuleSymbol bool) []*ast.Symbol {
accessibleSymbolChain := b.ch.getAccessibleSymbolChain(symbol, b.ctx.enclosingDeclaration, meaning, b.ctx.flags&nodebuilder.FlagsUseOnlyExternalAliasing != 0)
qualifierMeaning := meaning
if len(accessibleSymbolChain) > 0 {
if len(accessibleSymbolChain) > 1 {
qualifierMeaning = getQualifiedLeftMeaning(meaning)
}
if len(accessibleSymbolChain) == 0 ||
Expand Down
16 changes: 7 additions & 9 deletions internal/checker/symboltracker.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,17 @@ type SymbolTrackerImpl struct {
}

func NewSymbolTrackerImpl(context *NodeBuilderContext, tracker nodebuilder.SymbolTracker, tchost Host) *SymbolTrackerImpl {
var inner nodebuilder.SymbolTracker
if tracker != nil {
inner = tracker.GetInnerSymbolTracker()
if inner == nil {
inner = tracker
for {
t, ok := tracker.(*SymbolTrackerImpl)
if !ok {
break
}
tracker = t.inner
}
}

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

func (this *SymbolTrackerImpl) GetModuleSpecifierGenerationHost() modulespecifiers.ModuleSpecifierGenerationHost {
Expand All @@ -32,10 +34,6 @@ func (this *SymbolTrackerImpl) GetModuleSpecifierGenerationHost() modulespecifie
return this.inner.GetModuleSpecifierGenerationHost()
}

func (this *SymbolTrackerImpl) GetInnerSymbolTracker() nodebuilder.SymbolTracker {
return this.inner
}

func (this *SymbolTrackerImpl) TrackSymbol(symbol *ast.Symbol, enclosingDeclaration *ast.Node, meaning ast.SymbolFlags) bool {
if !this.DisableTrackSymbol {
if this.inner != nil && this.inner.TrackSymbol(symbol, enclosingDeclaration, meaning) {
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 @@ -277,7 +277,6 @@ TestMemberListInReopenedEnum
TestMemberListInWithBlock
TestMemberListOfExportedClass
TestMemberListOnContextualThis
TestModuleReexportedIntoGlobalQuickInfo
TestNgProxy1
TestNoQuickInfoForLabel
TestNoQuickInfoInWhitespace
Expand Down Expand Up @@ -364,7 +363,6 @@ TestQuickInfoFromContextualType
TestQuickInfoFunctionKeyword
TestQuickInfoGenerics
TestQuickInfoGetterSetter
TestQuickInfoImportNonunicodePath
TestQuickInfoInInvalidIndexSignature
TestQuickInfoInJsdocInTsFile1
TestQuickInfoInOptionalChain
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (

func TestModuleReexportedIntoGlobalQuickInfo(t *testing.T) {
t.Parallel()
t.Skip()

defer testutil.RecoverAndFail(t, "Panic on fourslash test")
const content = `// @Filename: /node_modules/@types/three/index.d.ts
export class Vector3 {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (

func TestQuickInfoImportNonunicodePath(t *testing.T) {
t.Parallel()
t.Skip()

defer testutil.RecoverAndFail(t, "Panic on fourslash test")
const content = `// @Filename: /江南今何在/tmp.ts
export const foo = 1;
Expand Down
1 change: 0 additions & 1 deletion internal/nodebuilder/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
// TODO: previously all symboltracker methods were optional, but now they're required.
type SymbolTracker interface {
GetModuleSpecifierGenerationHost() modulespecifiers.ModuleSpecifierGenerationHost
GetInnerSymbolTracker() SymbolTracker

TrackSymbol(symbol *ast.Symbol, enclosingDeclaration *ast.Node, meaning ast.SymbolFlags) bool
ReportInaccessibleThisError()
Expand Down
2 changes: 1 addition & 1 deletion internal/testutil/tsbaseline/type_symbol_baseline.go
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,7 @@ func (walker *typeWriterWalker) writeTypeOrSymbol(node *ast.Node, isSymbolWalk b
var symbolString strings.Builder
symbolString.Grow(256)
symbolString.WriteString("Symbol(")
symbolString.WriteString(strings.ReplaceAll(fileChecker.SymbolToString(symbol), ast.InternalSymbolNamePrefix, "__"))
symbolString.WriteString(strings.ReplaceAll(fileChecker.SymbolToStringEx(symbol, node.Parent, ast.SymbolFlagsNone, checker.SymbolFormatFlagsAllowAnyNodeKind), ast.InternalSymbolNamePrefix, "__"))
count := 0
for _, declaration := range symbol.Declarations {
if count >= 5 {
Expand Down
5 changes: 0 additions & 5 deletions internal/transformers/declarations/tracker.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"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/nodebuilder"
"github.com/microsoft/typescript-go/internal/printer"
"github.com/microsoft/typescript-go/internal/scanner"
)
Expand All @@ -23,10 +22,6 @@ func (s *SymbolTrackerImpl) GetModuleSpecifierGenerationHost() modulespecifiers.
return s.host
}

func (s *SymbolTrackerImpl) GetInnerSymbolTracker() nodebuilder.SymbolTracker {
return nil
}

// 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 @@ -9,16 +9,16 @@ export function bar();

=== a.ts ===
import { default as Foo } from "./b";
>default : Symbol("b", Decl(b.d.ts, 0, 0))
>default : Symbol(Foo, Decl(b.d.ts, 0, 0))
>Foo : Symbol(Foo, Decl(a.ts, 0, 8))

Foo.bar();
>Foo.bar : Symbol(bar, Decl(b.d.ts, 0, 22))
>Foo.bar : Symbol(Foo.bar, Decl(b.d.ts, 0, 22))
>Foo : Symbol(Foo, Decl(a.ts, 0, 8))
>bar : Symbol(bar, Decl(b.d.ts, 0, 22))
>bar : Symbol(Foo.bar, Decl(b.d.ts, 0, 22))

Foo.foo();
>Foo.foo : Symbol(foo, Decl(b.d.ts, 0, 0))
>Foo.foo : Symbol(Foo.foo, Decl(b.d.ts, 0, 0))
>Foo : Symbol(Foo, Decl(a.ts, 0, 8))
>foo : Symbol(foo, Decl(b.d.ts, 0, 0))
>foo : Symbol(Foo.foo, Decl(b.d.ts, 0, 0))

Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ class A {
>A : Symbol(A, Decl(circularControlFlowNarrowingWithCurrentElement01.ts, 0, 0))

next: A | null = null;
>next : Symbol(next, Decl(circularControlFlowNarrowingWithCurrentElement01.ts, 0, 9))
>next : Symbol(A.next, Decl(circularControlFlowNarrowingWithCurrentElement01.ts, 0, 9))
>A : Symbol(A, Decl(circularControlFlowNarrowingWithCurrentElement01.ts, 0, 0))

constructor(readonly children: (A | null)[]) {}
>children : Symbol(children, Decl(circularControlFlowNarrowingWithCurrentElement01.ts, 3, 14))
>children : Symbol(A.children, Decl(circularControlFlowNarrowingWithCurrentElement01.ts, 3, 14))
>A : Symbol(A, Decl(circularControlFlowNarrowingWithCurrentElement01.ts, 0, 0))
}

Expand All @@ -33,34 +33,34 @@ function getNodes(): A[] {
>firstChild : Symbol(firstChild, Decl(circularControlFlowNarrowingWithCurrentElement01.ts, 12, 7))

if (out.length) {
>out.length : Symbol(length, Decl(lib.es5.d.ts, --, --))
>out.length : Symbol(Array.length, Decl(lib.es5.d.ts, --, --))
>out : Symbol(out, Decl(circularControlFlowNarrowingWithCurrentElement01.ts, 7, 7))
>length : Symbol(length, Decl(lib.es5.d.ts, --, --))
>length : Symbol(Array.length, Decl(lib.es5.d.ts, --, --))

current = current.next;
>current : Symbol(current, Decl(circularControlFlowNarrowingWithCurrentElement01.ts, 9, 5))
>current.next : Symbol(next, Decl(circularControlFlowNarrowingWithCurrentElement01.ts, 0, 9))
>current.next : Symbol(A.next, Decl(circularControlFlowNarrowingWithCurrentElement01.ts, 0, 9))
>current : Symbol(current, Decl(circularControlFlowNarrowingWithCurrentElement01.ts, 9, 5))
>next : Symbol(next, Decl(circularControlFlowNarrowingWithCurrentElement01.ts, 0, 9))
>next : Symbol(A.next, Decl(circularControlFlowNarrowingWithCurrentElement01.ts, 0, 9))

continue;
}

for (let i = 0; i < current.children.length; i++) {
>i : Symbol(i, Decl(circularControlFlowNarrowingWithCurrentElement01.ts, 19, 12))
>i : Symbol(i, Decl(circularControlFlowNarrowingWithCurrentElement01.ts, 19, 12))
>current.children.length : Symbol(length, Decl(lib.es5.d.ts, --, --))
>current.children : Symbol(children, Decl(circularControlFlowNarrowingWithCurrentElement01.ts, 3, 14))
>current.children.length : Symbol(Array.length, Decl(lib.es5.d.ts, --, --))
>current.children : Symbol(A.children, Decl(circularControlFlowNarrowingWithCurrentElement01.ts, 3, 14))
>current : Symbol(current, Decl(circularControlFlowNarrowingWithCurrentElement01.ts, 9, 5))
>children : Symbol(children, Decl(circularControlFlowNarrowingWithCurrentElement01.ts, 3, 14))
>length : Symbol(length, Decl(lib.es5.d.ts, --, --))
>children : Symbol(A.children, Decl(circularControlFlowNarrowingWithCurrentElement01.ts, 3, 14))
>length : Symbol(Array.length, Decl(lib.es5.d.ts, --, --))
>i : Symbol(i, Decl(circularControlFlowNarrowingWithCurrentElement01.ts, 19, 12))

const child = current.children[i];
>child : Symbol(child, Decl(circularControlFlowNarrowingWithCurrentElement01.ts, 20, 11))
>current.children : Symbol(children, Decl(circularControlFlowNarrowingWithCurrentElement01.ts, 3, 14))
>current.children : Symbol(A.children, Decl(circularControlFlowNarrowingWithCurrentElement01.ts, 3, 14))
>current : Symbol(current, Decl(circularControlFlowNarrowingWithCurrentElement01.ts, 9, 5))
>children : Symbol(children, Decl(circularControlFlowNarrowingWithCurrentElement01.ts, 3, 14))
>children : Symbol(A.children, Decl(circularControlFlowNarrowingWithCurrentElement01.ts, 3, 14))
>i : Symbol(i, Decl(circularControlFlowNarrowingWithCurrentElement01.ts, 19, 12))

if (child) {
Expand All @@ -74,30 +74,30 @@ function getNodes(): A[] {
>child : Symbol(child, Decl(circularControlFlowNarrowingWithCurrentElement01.ts, 20, 11))

firstChild.next = current.next;
>firstChild.next : Symbol(next, Decl(circularControlFlowNarrowingWithCurrentElement01.ts, 0, 9))
>firstChild.next : Symbol(A.next, Decl(circularControlFlowNarrowingWithCurrentElement01.ts, 0, 9))
>firstChild : Symbol(firstChild, Decl(circularControlFlowNarrowingWithCurrentElement01.ts, 12, 7))
>next : Symbol(next, Decl(circularControlFlowNarrowingWithCurrentElement01.ts, 0, 9))
>current.next : Symbol(next, Decl(circularControlFlowNarrowingWithCurrentElement01.ts, 0, 9))
>next : Symbol(A.next, Decl(circularControlFlowNarrowingWithCurrentElement01.ts, 0, 9))
>current.next : Symbol(A.next, Decl(circularControlFlowNarrowingWithCurrentElement01.ts, 0, 9))
>current : Symbol(current, Decl(circularControlFlowNarrowingWithCurrentElement01.ts, 9, 5))
>next : Symbol(next, Decl(circularControlFlowNarrowingWithCurrentElement01.ts, 0, 9))
>next : Symbol(A.next, Decl(circularControlFlowNarrowingWithCurrentElement01.ts, 0, 9))
}

child.next = current.next;
>child.next : Symbol(next, Decl(circularControlFlowNarrowingWithCurrentElement01.ts, 0, 9))
>child.next : Symbol(A.next, Decl(circularControlFlowNarrowingWithCurrentElement01.ts, 0, 9))
>child : Symbol(child, Decl(circularControlFlowNarrowingWithCurrentElement01.ts, 20, 11))
>next : Symbol(next, Decl(circularControlFlowNarrowingWithCurrentElement01.ts, 0, 9))
>current.next : Symbol(next, Decl(circularControlFlowNarrowingWithCurrentElement01.ts, 0, 9))
>next : Symbol(A.next, Decl(circularControlFlowNarrowingWithCurrentElement01.ts, 0, 9))
>current.next : Symbol(A.next, Decl(circularControlFlowNarrowingWithCurrentElement01.ts, 0, 9))
>current : Symbol(current, Decl(circularControlFlowNarrowingWithCurrentElement01.ts, 9, 5))
>next : Symbol(next, Decl(circularControlFlowNarrowingWithCurrentElement01.ts, 0, 9))
>next : Symbol(A.next, Decl(circularControlFlowNarrowingWithCurrentElement01.ts, 0, 9))
}
}

current = firstChild || current.next;
>current : Symbol(current, Decl(circularControlFlowNarrowingWithCurrentElement01.ts, 9, 5))
>firstChild : Symbol(firstChild, Decl(circularControlFlowNarrowingWithCurrentElement01.ts, 12, 7))
>current.next : Symbol(next, Decl(circularControlFlowNarrowingWithCurrentElement01.ts, 0, 9))
>current.next : Symbol(A.next, Decl(circularControlFlowNarrowingWithCurrentElement01.ts, 0, 9))
>current : Symbol(current, Decl(circularControlFlowNarrowingWithCurrentElement01.ts, 9, 5))
>next : Symbol(next, Decl(circularControlFlowNarrowingWithCurrentElement01.ts, 0, 9))
>next : Symbol(A.next, Decl(circularControlFlowNarrowingWithCurrentElement01.ts, 0, 9))
}

return out;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ declare namespace knex {
>knex : Symbol(knex, Decl(index.d.ts, 10, 32), Decl(index.ts, 0, 14))

export { Knex };
>Knex : Symbol(Knex, Decl(index.d.ts, 13, 10))
>Knex : Symbol(knex.Knex, Decl(index.d.ts, 13, 10))
}

declare namespace Knex {
Expand All @@ -28,7 +28,7 @@ declare namespace Knex {
>Interface : Symbol(Interface, Decl(index.d.ts, 16, 24))

method(): ShouldJustBeAny;
>method : Symbol(method, Decl(index.d.ts, 17, 23))
>method : Symbol(Interface.method, Decl(index.d.ts, 17, 23))
>ShouldJustBeAny : Symbol(ShouldJustBeAny, Decl(index.d.ts, 0, 0))
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ declare namespace Knex {
}

export = knex;
>knex : typeof import("knex")
>knex : typeof import("index.ts")

=== index.ts ===
import "knex";
declare module "knex" {
>"knex" : typeof import("knex")
>"knex" : typeof import("node_modules/knex/index")

namespace Knex {
>Knex : typeof Knex
Expand Down
Loading
Loading