Skip to content

tsgo fails to resolve namespace symbols in non-extends contexts across files #961

Open
@yujiang

Description

@yujiang

🧾 Environment

npx tsgo -v
Version 7.0.0-dev.20250526.1

🧠 Summary

tsgo correctly handles extends A in a namespace context (as fixed in PR #66), but still fails to resolve namespace-scoped symbols like A, Afunc across files in other contexts such as:

  • function return types
  • constructor calls
  • parameter types
  • direct function calls

This leads to incorrect JavaScript output and runtime errors.


✅ Expected Behavior

All references to A and Afunc should be qualified as game.A and game.Afunc, matching how tsc behaves.


🔬 Minimal Reproduction

a.ts

namespace game {
  export class A {
    func() {
      console.log('A.func');
    }
  }

  export function Afunc() {
    console.log('Afunc');
  }
}

#### b.ts
namespace game {
  export class B extends A {
    override func() {
      console.log('B.func');
    }
  }
  Afunc(); 
}

#### b.js compiled by tsgo
var game;
(function (game) {
    class B extends A { // expect game.A
        func() {
            console.log('B.func');
        }
    }
    game.B = B;
    Afunc(); // expect game.Afunc
})(game || (game = {}));

Metadata

Metadata

Assignees

Labels

Domain: EmitRelated to emit, AST printing, Program emit funcsDomain: Type CheckingRelated to type checking, grammar checking

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions