Skip to content

Conversation

@CompuIves
Copy link
Contributor

Code that's parsed as follows:

const a = new Map<string, number>();

Is printed by codegen as follows:

const a = new Map();

While for CallExpression we do render them:

const a = test<string, number>();

Is rendered the same.

This PR adds support for rendering type parameters also for new expressions.

Copilot AI review requested due to automatic review settings November 22, 2025 13:43
@graphite-app
Copy link
Contributor

graphite-app bot commented Nov 22, 2025

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.

@github-actions github-actions bot added A-codegen Area - Code Generation C-bug Category - Bug labels Nov 22, 2025
Copilot finished reviewing on behalf of CompuIves November 22, 2025 13:45
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 fixes a bug in the TypeScript codegen where type arguments were not being printed for new expressions. Previously, new Map<string, number>() would be incorrectly printed as new Map(), while call expressions like test<string, number>() were already handled correctly.

Key changes:

  • Added type argument printing support for NewExpression in the codegen
  • Added test coverage for new expressions with type arguments

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
crates/oxc_codegen/src/gen.rs Added logic to print type arguments for NewExpression, following the same pattern used by CallExpression
crates/oxc_codegen/tests/integration/ts.rs Added test case to verify new expressions with type arguments are printed correctly

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@codspeed-hq
Copy link

codspeed-hq bot commented Nov 22, 2025

CodSpeed Performance Report

Merging #15963 will not alter performance

Comparing CompuIves:codegen-newexpression-type-arg (9f9e5d6) with main (6c72e84)

Summary

✅ 42 untouched
⏩ 3 skipped1

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.

@CompuIves CompuIves force-pushed the codegen-newexpression-type-arg branch from d808a71 to 9e65fc4 Compare November 22, 2025 14:37
@CompuIves CompuIves force-pushed the codegen-newexpression-type-arg branch from 9e65fc4 to 9f9e5d6 Compare November 22, 2025 14:37
@Boshen Boshen added the 0-merge Merge with Graphite Merge Queue label Nov 24, 2025
@Boshen Boshen merged commit e2ca770 into oxc-project:main Nov 24, 2025
28 checks passed
@graphite-app
Copy link
Contributor

graphite-app bot commented Nov 24, 2025

Merge activity

  • Nov 24, 7:49 AM UTC: @CompuIves we removed the merge queue label because we could not find a Graphite account associated with your GitHub profile.

You must have a Graphite account in order to use the merge queue. Create an account and try again using this link

@graphite-app graphite-app bot removed the 0-merge Merge with Graphite Merge Queue label Nov 24, 2025
overlookmotel pushed a commit that referenced this pull request Nov 24, 2025
### 💥 BREAKING CHANGES

- cbb27fd ast: [**BREAKING**] Add `TSGlobalDeclaration` type (#15712)
(overlookmotel)

### 🚀 Features

- 0c1f82b linter/plugins: Add `tokens` property to `Program` (#16020)
(overlookmotel)
- 6cff132 span: Add `Span::merge_within` method (#15869) (sapphi-red)
- 102365d allocator/vec: Add `Vec::into_bump_slice` method (#15770)
(Dunqing)

### 🐛 Bug Fixes

- e2ca770 codegen: Add support for printing type arguments in new
expressions (#15963) (Ives van Hoorne)
- 2bd3cb6 apps, editors, napi: Fix `oxlint-disable` comments (#16014)
(overlookmotel)
- 622cb5e parser: Preserve legal comments with @preserve/@license when
preceded by other annotations (#15929) (copilot-swe-agent)
- 7c46a9e transformer/tagged-template-transform: Handle `\n` escape
sequences (#15830) (Dunqing)
- f386efc minifier: Avoid generating invalid spans (#15778) (sapphi-red)
- d4ff004 parser: Forbid invalid modifiers on `module` and `global`
(#15723) (overlookmotel)
- 2191ae9 semantic: Allow reserved keywords in typescript ambient
contexts (#15495) (sapphi-red)
- 7d1ebad isolated-declarations: Incorrect nested namespace output in
isolated declarations (#15800) (copilot-swe-agent)

### ⚡ Performance

- b4b0ed8 transformer/typescript: Reverse order of checks (#15722)
(overlookmotel)

### 📚 Documentation

- c81a331 data_structures: Doc comments on fields of `Stack` (#15793)
(overlookmotel)
- cfae31d allocator: Use `allocator` as var name in examples (#15781)
(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