7The Rust port should be structurally as close to the TypeScript as possible: viewing the TS and Rust side by side, the logic should look, read, and feel similar while working naturally in Rust.
8
9▶**Current status**: M1-M13 fully implemented. All statement types, expression types, destructuring, function expressions, JSX, switch/try-catch, for-of/in, optional chaining, and recursive lowering are complete. No `todo!()` stubs remain. `cargo check` passes. Remaining work: test against fixtures and fix divergences from TypeScript output.
10
11**Known issues to fix:**
· · ·
12- All collection types must use `IndexMap`/`IndexSet` (from the `indexmap` crate), not `BTreeMap`/`BTreeSet`/`HashMap`/`HashSet`. This is critical for `HIR.blocks` where `BTreeMap` destroys RPO insertion ordering.
13▶- Functions `lower_function`, `lower_function_to_value`, `gather_captured_context`, `lower_object_property_key`, `lower_type` take `&Expression`. The AST crate uses `Expression` for keys and doesn't have standalone `Function`/`ObjectPropertyKey`/`TypeAnnotation` types, so `&Expression` is correct for the current AST structure. When these functions are implemented, they should pattern-match on the specific expression variants internally.
14- `VariableBinding::Identifier.binding_kind` is `String` — must be a `BindingKind` enum.
15- `HirBuilder` is missing `component_scope: ScopeId` field (needed for `gather_captured_context` in M9).
· · ·
33 Cargo.toml
34 src/
35▶ lib.rs # HIR types: HirFunction, BasicBlock, Instruction, Terminal, Place, etc.
36 environment.rs # Environment struct (arenas, counters, config)
37 react_compiler_diagnostics/
· · ·
57### 1. No NodePath — Work Directly with AST Structs + ScopeInfo
58
59▶The TypeScript `lower()` takes a `NodePath<t.Function>` and uses Babel's traversal API (`path.get()`, `path.scope.getBinding()`, etc.) extensively. The Rust port works with deserialized `react_compiler_ast` structs and the `ScopeInfo` from step 2.
60
61**TypeScript pattern:**
· · ·
62```typescript
63▶function lowerStatement(builder: HIRBuilder, stmtPath: NodePath<t.Statement>) {
64 switch (stmtPath.type) {
65 case 'IfStatement': {
+ 49 more matches in this file