Skip to content

fix(js-semantic): register ambient signature scopes#9476

Merged
dyc3 merged 2 commits intobiomejs:mainfrom
masterkain:feat/fix-ambient-module-signature-panic
Mar 21, 2026
Merged

fix(js-semantic): register ambient signature scopes#9476
dyc3 merged 2 commits intobiomejs:mainfrom
masterkain:feat/fix-ambient-module-signature-panic

Conversation

@masterkain
Copy link
Contributor

Summary

This registers ambient class constructor/getter/setter signature scopes in the semantic model builder so scope_node_by_range stays in sync with the scope events emitted for TypeScript ambient declarations.

It fixes a panic when Biome analyzes ambient modules like declare module "jsoneditor" { ... } where a class signature references a local type alias.

This PR was created with AI assistance (OpenAI Codex).

Test Plan

  • cargo test -p biome_js_semantic
  • cargo test -p biome_js_semantic ok_semantic_model_ambient_module_type_alias_and_class -- --nocapture
  • cargo clippy -p biome_js_semantic --lib --tests -- -D warnings
  • just format

Docs

  • Changeset added
  • No website docs update needed

@changeset-bot
Copy link

changeset-bot bot commented Mar 13, 2026

🦋 Changeset detected

Latest commit: d89bfbb

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 the L-JavaScript Language: JavaScript and super languages label Mar 13, 2026
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 13, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 4bb223f7-c637-41da-b796-87c47b6e313b

📥 Commits

Reviewing files that changed from the base of the PR and between bc8addc and 33cebf2.

📒 Files selected for processing (3)
  • .changeset/fix-ambient-module-signature-panic.md
  • crates/biome_js_semantic/src/semantic_model/builder.rs
  • crates/biome_js_semantic/src/semantic_model/tests.rs
🚧 Files skipped from review as they are similar to previous changes (3)
  • .changeset/fix-ambient-module-signature-panic.md
  • crates/biome_js_semantic/src/semantic_model/builder.rs
  • crates/biome_js_semantic/src/semantic_model/tests.rs

Walkthrough

This change registers three TypeScript class-member signature node kinds (TS_CONSTRUCTOR_SIGNATURE_CLASS_MEMBER, TS_GETTER_SIGNATURE_CLASS_MEMBER, TS_SETTER_SIGNATURE_CLASS_MEMBER) as scope-bound in the semantic model builder to avoid a panic during semantic analysis of ambient modules that reference local type aliases. A regression test exercises an ambient module with a type alias and class signatures and asserts scope-node mapping completeness.

Possibly related PRs

Suggested reviewers

  • dyc3
  • ematipico
🚥 Pre-merge checks | ✅ 2
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main change: registering ambient signature scopes in the semantic model to fix panics.
Description check ✅ Passed The description clearly explains the fix, its purpose, and provides comprehensive test and documentation guidance.

✏️ 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
📝 Coding Plan
  • Generate coding plan for human review comments

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

Tip

You can make CodeRabbit's review stricter and more nitpicky using the `assertive` profile, if that's what you prefer.

Change the reviews.profile setting to assertive to make CodeRabbit's nitpick more issues in your PRs.

@masterkain
Copy link
Contributor Author

this looks related to #9475

that repro includes an abstract getter signature in a class (get busEventName(): K), and this patch fixes the missing semantic scope-node registration for TS_GETTER_SIGNATURE_CLASS_MEMBER together with the sibling constructor/setter signature kinds

i have not minimized #9475 separately yet, so i cannot claim full coverage, but this change is a plausible fix or at least part of it

Copy link
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.

🧹 Nitpick comments (1)
.changeset/fix-ambient-module-signature-panic.md (1)

1-5: Minor: Consider linking to an issue if one exists.

The changeset is well-written for end users. If there's an associated GitHub issue for this panic, the coding guidelines suggest using the format Fixed [#NUMBER](issue link): ... for bug fix changesets. If no issue exists, this is fine as-is.

As per coding guidelines: "For bug fix changesets, start with 'Fixed [#NUMBER](issue link): ...' format"

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.changeset/fix-ambient-module-signature-panic.md around lines 1 - 5, The
changeset message should use the bug-fix format required by guidelines: update
the opening sentence of .changeset/fix-ambient-module-signature-panic.md so it
begins with "Fixed [`#NUMBER`](https://github.com/OWNER/REPO/issues/NUMBER):"
followed by the existing description (e.g., "Fixed [`#1234`](link): Fixed a panic
when Biome analyzed ambient TypeScript modules containing class constructor,
getter, or setter signatures that reference local type aliases..."); if there is
no issue, explicitly state that no issue exists and leave as-is per guidelines.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In @.changeset/fix-ambient-module-signature-panic.md:
- Around line 1-5: The changeset message should use the bug-fix format required
by guidelines: update the opening sentence of
.changeset/fix-ambient-module-signature-panic.md so it begins with "Fixed
[`#NUMBER`](https://github.com/OWNER/REPO/issues/NUMBER):" followed by the
existing description (e.g., "Fixed [`#1234`](link): Fixed a panic when Biome
analyzed ambient TypeScript modules containing class constructor, getter, or
setter signatures that reference local type aliases..."); if there is no issue,
explicitly state that no issue exists and leave as-is per guidelines.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 4ab52783-35d3-4eba-b775-dfd58e5e043d

📥 Commits

Reviewing files that changed from the base of the PR and between 1f30838 and bc8addc.

📒 Files selected for processing (3)
  • .changeset/fix-ambient-module-signature-panic.md
  • crates/biome_js_semantic/src/semantic_model/builder.rs
  • crates/biome_js_semantic/src/semantic_model/tests.rs

@masterkain masterkain force-pushed the feat/fix-ambient-module-signature-panic branch from 8994596 to 33cebf2 Compare March 13, 2026 21:11
@codspeed-hq
Copy link

codspeed-hq bot commented Mar 13, 2026

Merging this PR will not alter performance

✅ 58 untouched benchmarks
⏩ 156 skipped benchmarks1


Comparing masterkain:feat/fix-ambient-module-signature-panic (d89bfbb) with main (f8660b8)2

Open in CodSpeed

Footnotes

  1. 156 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 (fd977ae) during the generation of this report, so f8660b8 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

@ematipico
Copy link
Member

@masterkain I can't merge this PR due to conflicts

@dyc3 dyc3 merged commit 97b80a8 into biomejs:main Mar 21, 2026
18 checks passed
@github-actions github-actions bot mentioned this pull request Mar 21, 2026
@masterkain
Copy link
Contributor Author

mm can you please check if I missed TS_GETTER_SIGNATURE_TYPE_MEMBER in the conflict ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

L-JavaScript Language: JavaScript and super languages

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants