Skip to content

TS Conformance Phase 1.5 (deferred): load tsc lib.d.ts files into type checker #99

@nickna

Description

@nickna

Part of #80. Deferred — track only, do not start until Phase 1 (errors baseline) is shipped, stable, and we have evidence the deferred work is worth doing.

Context

#83 deliberately punts on lib resolution: when a conformance test sets // @lib: es2015,dom, our runner ignores the directive and the type checker uses its hard-coded SharpTS defaults. This is a pragmatic Phase-1 decision but it has real consequences:

This issue tracks the eventual fix: parse tsc's lib.*.d.ts files (vendored at external/typescript/src/lib/) into the type checker so it sees the same world model tsc does for each test.

Why deferred

  • Big lift, blocks delivery. The lib files are large (es5.d.ts = 4,567 lines, dom.generated.d.ts = 28,578 lines, ~33k for a typical es5+dom test). They use dense TS — declaration merging, ambient modules, complex generic / conditional / mapped types — and parsing them will surface latent bugs in our parser/checker.
  • No code path today. SharpTS globals are hard-coded in TypeChecker.*.cs partials, not loaded from any .d.ts. Switching to file-loaded globals is a structural refactor of the type checker, not a feature addition.
  • Phase 1 needs to ship first. We need the runner to actually surface what's failing before we know whether lib plumbing is the bottleneck or whether other type-checker bugs dominate the divergence.

What this would unlock

  • Type-B test failures become real signal instead of Skipped.
  • DOM, WebWorker, and lib-conditional tests stop being effectively unrunnable.
  • Sets up TS Conformance Phase 3 (deferred): per-node *.types / *.symbols introspection #88 (per-node *.types / *.symbols baseline) for direct success — that work needs identical world models on both sides.
  • Removes the asterisk on "SharpTS conformance" — Pass would mean what it says.

Pre-conditions before picking up

  1. Phase 1 baseline is committed and stable for at least one release cycle.
  2. The lib-drift skip filter has produced a list of tests it's hiding — quantify the type-B problem before solving it.
  3. We've decided whether SharpTS wants to support multiple --lib choices (matches tsc) or pick one frozen lib version. The former is genuinely complex.

Out of scope

  • Self-hosting SharpTS implementations in TS. Conflated with this idea in earlier discussion but unrelated. Built-in implementations stay in C# (perf, bootstrapping, can't self-host Math.sqrt/Date.now etc.). This issue is about signatures only — what the type checker knows, not what runs at runtime.

Reference

  • external/typescript/src/lib/ — the vendored lib files at the pinned TS tag.
  • TypeSystem/TypeChecker.Properties.cs, TypeSystem/TypeCategoryResolver.cs — where current hard-coded global resolution lives.
  • Runtime/BuiltIns/ — implementations (out of scope for this issue, stay in C#).

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions