Skip to content

fix(formatter): don't remove quotes when type memeber is new#8945

Merged
fireairforce merged 2 commits intomainfrom
fix-8354
Feb 2, 2026
Merged

fix(formatter): don't remove quotes when type memeber is new#8945
fireairforce merged 2 commits intomainfrom
fix-8354

Conversation

@fireairforce
Copy link
Copy Markdown
Member

Summary

closes: #8354

When type member contains new, don't remove the quotes around it:

Before:

// Input:
type X = {
    'new'(): string;
};

// Format Output:
type X = {
   new(): string;
}

After:

// Input:
type X = {
    'new'(): string;
};

// Format Output:
type X = {
   'new'(): string;
}

Test Plan

Add snapshot test case

Docs

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Feb 2, 2026

🦋 Changeset detected

Latest commit: dc3b257

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 13 packages
Name Type
@biomejs/biome Patch
@biomejs/cli-win32-x64 Patch
@biomejs/cli-win32-arm64 Patch
@biomejs/cli-darwin-x64 Patch
@biomejs/cli-darwin-arm64 Patch
@biomejs/cli-linux-x64 Patch
@biomejs/cli-linux-arm64 Patch
@biomejs/cli-linux-x64-musl Patch
@biomejs/cli-linux-arm64-musl Patch
@biomejs/wasm-web Patch
@biomejs/wasm-bundler Patch
@biomejs/wasm-nodejs Patch
@biomejs/backend-jsonrpc Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions github-actions Bot added A-Formatter Area: formatter L-JavaScript Language: JavaScript and super languages labels Feb 2, 2026
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Feb 2, 2026

Walkthrough

Adds a guard in LiteralStringNormaliser::normalise_type_member to prevent removing quotes when the raw content is the literal "new". The change integrates an is_new_keyword check into the existing can_remove_quotes logic so type members named new remain quoted. A TypeScript test was added to verify a quoted 'new'() member stays quoted and is not converted into a construct signature.

Suggested reviewers

  • ematipico
🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title 'fix(formatter): don't remove quotes when type memeber is new' accurately describes the main change—preventing quote removal for 'new' type members.
Description check ✅ Passed The description clearly relates to the changeset, explaining the fix with before/after examples and mentioning the added test case.
Linked Issues check ✅ Passed The PR successfully addresses issue #8354 by implementing logic to preserve quotes for type members named 'new', preventing them from becoming construct signatures.
Out of Scope Changes check ✅ Passed All changes are directly scoped to fixing the issue: formatter logic update, test case addition, and changelog entry—no extraneous modifications detected.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix-8354

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Fix all issues with AI agents
In @.changeset/kind-cities-read.md:
- Line 5: Fix the typo in the changeset description by replacing the misspelled
word "memeber" with "member" in the .changeset/kind-cities-read.md content (the
line reading "Don't remove quotes when type memeber is new."). Ensure the
corrected sentence reads "Don't remove quotes when type member is new." and
commit the updated file.
- Line 16: The example output incorrectly turned the quoted method signature
into a property: replace the incorrect `'new()': string;` with the correct
quoted method signature `'new'(): string;` so the output preserves a method
named 'new' (with parentheses) rather than a property; update the example output
to match the original input signature `'new'(): string;` wherever the incorrect
`'new()': string;` appears.

"@biomejs/biome": patch
---

Fixed [#8354](https://github.com/biomejs/biome/issues/8354): Don't remove quotes when type memeber is new.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Typo: "memeber" should be "member".

📝 Proposed fix
-Fixed [`#8354`](https://github.com/biomejs/biome/issues/8354): Don't remove quotes when type memeber is new.
+Fixed [`#8354`](https://github.com/biomejs/biome/issues/8354): Don't remove quotes when type member is new.
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
Fixed [#8354](https://github.com/biomejs/biome/issues/8354): Don't remove quotes when type memeber is new.
Fixed [`#8354`](https://github.com/biomejs/biome/issues/8354): Don't remove quotes when type member is new.
🤖 Prompt for AI Agents
In @.changeset/kind-cities-read.md at line 5, Fix the typo in the changeset
description by replacing the misspelled word "memeber" with "member" in the
.changeset/kind-cities-read.md content (the line reading "Don't remove quotes
when type memeber is new."). Ensure the corrected sentence reads "Don't remove
quotes when type member is new." and commit the updated file.

Comment thread .changeset/kind-cities-read.md
@codspeed-hq
Copy link
Copy Markdown

codspeed-hq Bot commented Feb 2, 2026

Merging this PR will not alter performance

✅ 58 untouched benchmarks
⏩ 95 skipped benchmarks1


Comparing fix-8354 (dc3b257) with main (3ab203a)2

Open in CodSpeed

Footnotes

  1. 95 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.

  2. No successful run was found on main (9dc99cc) during the generation of this report, so 3ab203a was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

Copy link
Copy Markdown
Member

@siketyan siketyan left a comment

Choose a reason for hiding this comment

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

Do you know is there any other keywords that cannot be dequoted?

@fireairforce
Copy link
Copy Markdown
Member Author

Do you know is there any other keywords that cannot be dequoted?

Not sure, maybe constructor also? it seems that prettier will not dequote the case under ts type member key:

image

@fireairforce
Copy link
Copy Markdown
Member Author

fireairforce commented Feb 2, 2026

maybe we don't need to dequote all the keywords here? what do you think? @siketyan

@ematipico
Copy link
Copy Markdown
Member

@fireairforce
Copy link
Copy Markdown
Member Author

@fireairforce that's part of the known differences

https://biomejs.dev/formatter/differences-with-prettier/#prettier-doesnt-unquote-some-object-properties-that-are-valid-javascript-identifiers

thanks for your remind~ so it will be better to just fix the new case here?

@fireairforce fireairforce merged commit fa66fe3 into main Feb 2, 2026
17 checks passed
@fireairforce fireairforce deleted the fix-8354 branch February 2, 2026 12:23
@github-actions github-actions Bot mentioned this pull request Feb 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-Formatter Area: formatter L-JavaScript Language: JavaScript and super languages

Projects

None yet

Development

Successfully merging this pull request may close these issues.

📝 Formatter incorrectly unquotes 'new' method, turning it into a construct signature

3 participants