[rust-compiler] Add TDD fixtures for TS module-interop statements#36704
Closed
poteto wants to merge 1 commit into
Closed
[rust-compiler] Add TDD fixtures for TS module-interop statements#36704poteto wants to merge 1 commit into
poteto wants to merge 1 commit into
Conversation
This was referenced Jun 6, 2026
48eb0d1 to
a12b3d8
Compare
fb7d3cc to
1e41304
Compare
Pin how TSImportEqualsDeclaration, TSExportAssignment, and TSNamespaceExportDeclaration must behave: the statement is preserved in output and the file's functions still compile, as the TS reference already does. The three frontends share the broken symptom today via three different root causes: the Babel/NAPI path throws "Failed to parse AST JSON: unknown variant ..." (the typed AST's tagged enums have no catch-all) and fails the whole file; the SWC converter explicitly rewrites the statements to EmptyStatement, erasing them from output with no error and no event; OXC todo!()-panics in its converter (deferred). The fixtures use the bare todo- prefix rather than error.*: snap asserts error.* fixtures throw on the TS side, and these compile cleanly there. All three function bodies allocate so the compiled snapshots visibly memoize; combined with the e2e events comparison, a degenerate whole-file bailout cannot pass them. Known-red until the fix slices land: Babel and SWC e2e on these three fixtures, and test-babel-ast.sh (both round_trip and scope_resolution_rename deserialize the same fixture JSON). TS-side snap is green. SproutTodoFilter skips only the namespace fixture: export as namespace is .d.ts-shaped and sprout's evaluator transform cannot process it; the other two transform to CJS and evaluate fine.
1e41304 to
e4141db
Compare
a12b3d8 to
ee61071
Compare
Collaborator
Author
|
Closing: this stack's content is being ported directly to the umbrella PR branch (rust-research, #36173) rather than staged through pr-36173. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
import lib = require(...),export = x, andexport as namespace X. The TypeScript reference compiles files containing these statements and preserves them in output. The Rust port previously broke on each frontend in a different way: the Babel/NAPI path threwFailed to parse AST JSON: unknown variant ...and failed the whole file, the SWC converter rewrote the statements toEmptyStatement(silently deleting them from output), and OXC panics in its converter (deferred, documented).todo-prefix rather thanerror.*: snap assertserror.*fixtures throw on the TS side, and these compile cleanly there. They are renamed to their finalts-*names later in this stack as both frontends go green, matching the existingtodo-convention for known Rust-side gaps.SproutTodoFilterskips only the namespace fixture (sprout's evaluator transform cannot processexport as namespace); TODO.md documents the cross-frontend state and the planned fixes.Known-red at this point in the stack
Babel and SWC e2e fail on exactly these three fixtures, and
test-babel-ast.shfails on them at AST deserialization. The next two PRs in this stack turn them green (Babel first, then SWC). TS-side snap is green throughout.Test plan
yarn snap -p 'todo-ts-*': 3 Tests, 3 PassedStack
pr-36173Merge order: bottom up.