Skip to content

fix(codegen): print type for TSImportEqualsDeclaration#20128

Merged
graphite-app[bot] merged 1 commit intomainfrom
c/03-08-fix_codegen_print_type_for_tsimportequalsdeclaration
Mar 9, 2026
Merged

fix(codegen): print type for TSImportEqualsDeclaration#20128
graphite-app[bot] merged 1 commit intomainfrom
c/03-08-fix_codegen_print_type_for_tsimportequalsdeclaration

Conversation

@camc314
Copy link
Contributor

@camc314 camc314 commented Mar 8, 2026

No description provided.

Copy link
Contributor Author

camc314 commented Mar 8, 2026


How to use the Graphite Merge Queue

Add either label to this PR to merge it via the merge queue:

  • 0-merge - adds this PR to the back of the merge queue
  • hotfix - for urgent hot fixes, skip the queue and merge this PR next

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

This stack of pull requests is managed by Graphite. Learn more about stacking.

@codspeed-hq
Copy link

codspeed-hq bot commented Mar 8, 2026

Merging this PR will not alter performance

✅ 53 untouched benchmarks
⏩ 3 skipped benchmarks1


Comparing c/03-08-fix_codegen_print_type_for_tsimportequalsdeclaration (d2cb420) with c/03-08-fix_codegen_print_type_arguments_for_jsxopeningelement (24faba2)

Open in CodSpeed

Footnotes

  1. 3 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@camc314 camc314 force-pushed the c/03-08-fix_codegen_print_type_for_tsimportequalsdeclaration branch from 0af9bff to 9971afa Compare March 8, 2026 19:43
@camc314 camc314 marked this pull request as ready for review March 8, 2026 19:43
Copilot AI review requested due to automatic review settings March 8, 2026 19:43
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the TypeScript codegen to correctly emit the type modifier for TSImportEqualsDeclaration nodes (i.e., import type Foo = require("...")), and adds a regression test to cover the behavior.

Changes:

  • Print type in codegen output when TSImportEqualsDeclaration.import_kind is Type.
  • Add an integration test case for import type X = require(...).

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
crates/oxc_codegen/src/gen.rs Emits import type for type-only TSImportEqualsDeclaration.
crates/oxc_codegen/tests/integration/ts.rs Adds a regression test for import type ... = require(...).

You can also share your feedback on Copilot code review. Take the survey.

@camc314 camc314 force-pushed the c/03-08-fix_codegen_print_type_for_tsimportequalsdeclaration branch 2 times, most recently from f2c4ac1 to b152150 Compare March 8, 2026 20:14
@camc314 camc314 force-pushed the c/03-08-fix_codegen_print_type_arguments_for_jsxopeningelement branch from 7b10e62 to 24faba2 Compare March 8, 2026 21:49
@camc314 camc314 force-pushed the c/03-08-fix_codegen_print_type_for_tsimportequalsdeclaration branch from b152150 to d2cb420 Compare March 8, 2026 21:49
@Dunqing Dunqing added the 0-merge Merge with Graphite Merge Queue label Mar 9, 2026
Copy link
Member

Dunqing commented Mar 9, 2026

Merge activity

@graphite-app graphite-app bot force-pushed the c/03-08-fix_codegen_print_type_arguments_for_jsxopeningelement branch from 24faba2 to 5a246ec Compare March 9, 2026 01:01
@graphite-app graphite-app bot force-pushed the c/03-08-fix_codegen_print_type_for_tsimportequalsdeclaration branch from d2cb420 to 36b2e56 Compare March 9, 2026 01:01
@graphite-app graphite-app bot removed the 0-merge Merge with Graphite Merge Queue label Mar 9, 2026
Base automatically changed from c/03-08-fix_codegen_print_type_arguments_for_jsxopeningelement to main March 9, 2026 01:12
@graphite-app graphite-app bot merged commit 36b2e56 into main Mar 9, 2026
22 checks passed
@graphite-app graphite-app bot deleted the c/03-08-fix_codegen_print_type_for_tsimportequalsdeclaration branch March 9, 2026 01:13
Dunqing added a commit that referenced this pull request Mar 9, 2026
…Gen impls

We've had multiple bugs where new fields were added to AST structs but
the codegen `Gen`/`GenExpr` implementations forgot to handle them
(e.g., #20124 `declare` for TSInterfaceDeclaration, #20125 parens for
TSNonNullExpression, #20127 type_arguments for JSXOpeningElement,
#20128 type for TSImportEqualsDeclaration). These bugs are silent —
the code compiles fine but produces incorrect output.

This test uses `syn` to parse AST struct definitions and cross-reference
them against the codegen `Gen`/`GenExpr` implementations, detecting any
struct fields that are never accessed. It catches:

- Direct `self.field` accesses in Gen/GenExpr impl blocks
- Field accesses via helper functions (e.g., `print_if(stmt: &IfStatement)`)
- Field accesses through enum wrapper match arms (e.g., `Binaryish::Binary(e) => e.left`)

Fields that are intentionally not printed (internal metadata like `node_id`,
`scope_id`, or fields accessed via methods like `as_str()`) are tracked in
explicit skip lists with comments explaining why.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
camc314 pushed a commit that referenced this pull request Mar 9, 2026
### 🚀 Features

- e8547cc parser: Report error for using declarations in ambient
contexts (#19934) (camc314)
- 8345318 allocator: Add methods for boxed slices `ArenaBox<[T]>`
(#19968) (overlookmotel)
- f83be30 allocator: Add `Vec::push_fast` method (#19959)
(overlookmotel)

### 🐛 Bug Fixes

- 291d867 transformer_plugins: Unwrap ChainExpression after define
replacement removes optional markers (#20058) (IWANABETHATGUY)
- 36b2e56 codegen: Print type for TSImportEqualsDeclaration (#20128)
(camc314)
- 5a246ec codegen: Print type arguments for JSXOpeningElement (#20127)
(camc314)
- a40870e codegen: Preserve parens for TSNonNullExpression (#20125)
(camc314)
- ae830b2 codegen: Print `declare` for `TSInterfaceDeclaration` (#20124)
(camc314)
- 92cfb14 linter/plugins: Fix types for `walkProgram` and
`walkProgramWithCfg` (#20081) (overlookmotel)
- ee0491e apps,napi: Explicitly specify libs in tsconfigs (#20071)
(camc314)
- 588009e codegen: Print `static` keyword for TSIndexSignature (#19755)
(Dunqing)
- 5a8799c codegen: Print `with_clause` for `ExportNamedDeclaration`
(#20002) (Dunqing)
- 7502afe parser: Correct capacity for tokens `Vec` (#19967)
(overlookmotel)

### ⚡ Performance

- 4ea8f9a napi: Remove `napi_build::setup()` from `oxc_napi` to avoid
redundant rebuilds (#20094) (Boshen)
- 2baa5fb napi: Unify build-test profile to coverage for cache sharing
(#20090) (Boshen)
- 8ba61dd parser: Make pushing tokens faster (#19960) (overlookmotel)

Co-authored-by: Boshen <1430279+Boshen@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-codegen Area - Code Generation C-bug Category - Bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants