Skip to content

chore: use TypeScript parser instead of line matching in update_pw.mjs - #337

Merged
mxschmitt merged 2 commits into
mainfrom
chore/update-pw-ts-parser
Oct 8, 2026
Merged

mxschmitt merged 2 commits into
mainfrom
chore/update-pw-ts-parser

Conversation

@mxschmitt

@mxschmitt mxschmitt commented Oct 8, 2026 •

Copy link
Copy Markdown
Owner

Summary

update_pw.mjs built the Monaco autocompletion types (frontend/src/components/Editor/types.txt) by editing the upstream .d.ts files line by line. This PR swaps that for edits based on an AST from the TypeScript 7 experimental API (typescript/unstable/*):

  • stripFileHeader() → stripModuleSyntax(): parses each file and removes top-level import/import =/export … from statements whose module can't resolve in the concatenated file (relative paths and Node.js builtins). It also removes the file header (copyright, /// directives) but keeps any comment block directly attached to the first remaining statement.
  • expect-types path rewrite: replaces the split('\n').map(line.replace(...)) with rewriteModuleSpecifiers(). This only rewrites string literals that are module specifiers (in import/export declarations, import = and import('…') types) and keeps the original quote style.
  • All five files are parsed in one API session using an in-memory virtual FS (createVirtualFileSystem).
  • Because the API is experimental, the script checks that every edited node's text matches what it expects at that offset. If the API ever reports offsets in a different unit, the script fails instead of writing a broken types.txt.
  • Adds a small root package.json with typescript@^7.0.2 (the same version as frontend/), and updates CONTRIBUTING/AGENTS to run npm ci first.

Output changes

I diffed the old and new scripts on the same upstream files. The new script only adds back two comments that the line scanner was dropping by mistake:

  • the JSDoc on Serializable (structs.d.ts); the old scanner treated it as part of the copyright header
  • the URLPattern explanation comment (types.d.ts)

The @ts-ignored zod imports are kept, as before. Running tsc 7 over the old and new types.txt gives the same diagnostics.

The second commit regenerates types.txt (Playwright 1.64.0) with the new script. On top of #336 the only change is the two restored comments (5 lines).

Testing

  • Ran updateFrontendTypes() with the old and new scripts and diffed the results (only the two comments above differ).
  • Synthetic checks: /// + copyright header removal, // @ts-ignore kept on a remaining first import, specifier rewrite in import type, export * from and import('…') (other string literals left alone).
  • tsc --noEmit on old and new output: same error set.

🤖 Generated with Claude Code

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 8, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-08T21:33:47.742700Z 0fe07ba PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

mxschmitt and others added 2 commits October 8, 2026 14:40
Replace the line-based stripFileHeader() and the line-based
expect-types path rewrite with edits driven by the TypeScript 7
(experimental) API AST.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Generated from playwright-core/playwright 1.64.0. Compared to the
line-based script this keeps the JSDoc of `Serializable` and the
`URLPattern` comment.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@mxschmitt
mxschmitt force-pushed the chore/update-pw-ts-parser branch from c9a2576 to d9d87e9 Compare October 8, 2026 21:41
@mxschmitt
mxschmitt merged commit 23dcec9 into main Oct 8, 2026
10 checks passed
@mxschmitt
mxschmitt deleted the chore/update-pw-ts-parser branch October 8, 2026 21:41
@flakiness-io

flakiness-io Bot commented Oct 8, 2026

Copy link
Copy Markdown

Test Results Summary

This comment shows the latest test results for this pull request.

Commit Status Test Results CI Runs
d9d87e9 ✅ Passed 50 passed · 1 flaky 1 runs
⚠️ 1 flaky

⚠️ Ubuntu 24.04 · firefox e2e/tests/visual.spec.ts:137 › should handle platform core related features › should handle the timeout correctly

View full report

ℹ️ About Flakiness.io in GitHub

Your team has set up Flakiness.io pull request comments. This comment is updated when

  • The first test results arrive for this pull request
  • A later run reports more results for the same commit
  • A new commit is pushed and tested

Flakiness.io rewrites the comment in place, so it always reflects the most recently tested commit.

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.

1 participant