Skip to content

Fetch TypeScript standard libs at the bundled compiler version - #437

Merged
augustjk merged 4 commits into
mainfrom
fix-typescript-lib-version
Nov 19, 2026
Merged

augustjk merged 4 commits into
mainfrom
fix-typescript-lib-version

Conversation

@augustjk

@augustjk augustjk commented Nov 18, 2026 •

Copy link
Copy Markdown
Collaborator

The TypeScript worker fetches the standard lib typings (lib.dom.d.ts, lib.esnext.d.ts, ...) from the CDN at typescript@latest, unless the project's package.json pins a typescript version. latest is now TypeScript 7, whose npm package no longer contains those files, so the requests 404 and the worker gets no standard typings.

This breaks type checking and completions that rely on the standard libs in any playground that doesn't pin typescript. In CI it shows up as three failing completions tests.

Fix

When the project doesn't specify a typescript version, use the version of the compiler bundled in the worker (ts.version, currently 5.6.2). The lib files need to match the compiler that reads them anyway. A typescript version in the project's package.json still takes precedence.

Note that this default applies to the typescript package as a whole: a project that imports typescript itself without pinning it now gets typings for the bundled version rather than latest.

Tests

  • Updated the existing standard-lib test to expect the bundled version, with a TypeScript 7 entry that has no lib files in the fake CDN alongside it.
  • Added a test that a typescript version in package.json is still used.
  • Updated one fixture in typescript-worker_test.ts that relied on latest.
  • Locally, the full wtr suite passes on Chromium and WebKit, including the three completions tests that were failing. I couldn't run Firefox locally.

Also in this PR: workflow changes needed for CI to pass

These are only here so the checks on this PR can run and pass. None of them changes what is tested.

  • Pin the runner to ubuntu-24.04. ubuntu-latest now resolves to Ubuntu 26.04, where our pinned Playwright (1.46.1) can't install its system dependencies, so npx playwright install-deps fails before any test starts. This applies to the three workflows that install Playwright (test, deploy-demo, version-module), until Playwright is upgraded.
  • Pin actions to commit hashes. Required by the zizmor check. Each action is pinned to the commit its previous tag pointed to, with the version kept as a comment.
  • Restrict token permissions. Every workflow now defaults to contents: read. The deploy-demo job additionally gets contents: write, which it needs to push to gh-pages.
  • Don't persist checkout credentials in lint, test and version-module, which never use them. deploy-demo keeps them, because its deploy step pushes with them; that zizmor finding is suppressed with a rationale.

ubuntu-latest now resolves to Ubuntu 26.04, where the pinned Playwright version (1.46.1) cannot install its system dependencies: it falls back to the 24.04 package list, and packages such as libicu74 and libvpx9 do not exist there. Pin the workflows that install Playwright to ubuntu-24.04 until Playwright is upgraded.
Standard lib typings (lib.dom.d.ts etc.) were fetched from the CDN at typescript@latest unless the project pinned a typescript version. Since TypeScript 7 was published, the latest package no longer contains those files, so the worker got no standard typings. That broke type checking and completions that rely on them, and the completions tests.

Default to the version of the TypeScript compiler bundled in the worker instead, which is the version the lib files need to match anyway. A typescript version in the project's package.json still takes precedence.
The zizmor check requires every action reference to be pinned to a commit hash. Pin each action to the commit its current tag points to, so behaviour is unchanged, and keep the version as a comment.
Address the remaining zizmor findings:

- Give every workflow a read-only default token (contents: read). The deploy-demo job additionally gets contents: write, which it needs to push to gh-pages.
- Stop the checkout action from persisting credentials in lint, test and version-module, which never use them. deploy-demo keeps them, because its deploy step pushes with them; that finding is suppressed with a rationale.
@augustjk
augustjk added this pull request to stack #439 November 18, 2026 19:08
@augustjk
augustjk merged commit 73b97d5 into main Nov 19, 2026
20 checks passed
@augustjk
augustjk deleted the fix-typescript-lib-version branch November 19, 2026 17:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants