Skip to content

refactor(linter): extract ambient TypeScript declaration helper#22572

Merged
graphite-app[bot] merged 1 commit into
mainfrom
codex/refactor-ambient-ts-declaration
May 19, 2026
Merged

refactor(linter): extract ambient TypeScript declaration helper#22572
graphite-app[bot] merged 1 commit into
mainfrom
codex/refactor-ambient-ts-declaration

Conversation

@camc314

@camc314 camc314 commented May 19, 2026

Copy link
Copy Markdown
Contributor

No description provided.

Copilot AI review requested due to automatic review settings May 19, 2026 09:08
@camc314 camc314 self-assigned this May 19, 2026
@github-actions github-actions Bot added the A-linter Area - Linter label May 19, 2026
@camc314 camc314 force-pushed the codex/refactor-ambient-ts-declaration branch 2 times, most recently from 41193ce to 0c15ef9 Compare May 19, 2026 09:12
@camc314 camc314 added the 0-merge Merge with Graphite Merge Queue label May 19, 2026

camc314 commented May 19, 2026

Copy link
Copy Markdown
Contributor Author

Merge activity

Copilot AI left a comment

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.

Pull request overview

This PR refactors the linter’s TypeScript-related logic by extracting a shared helper for detecting whether an AST node is inside an ambient TypeScript declaration context (e.g. declare module, declare namespace, declare global), and reusing it across multiple rules.

Changes:

  • Added utils::has_ambient_typescript_ancestor as a shared utility.
  • Replaced per-rule ambient-context checks in no_namespace, vars_on_top, and no_var with the shared helper.
  • Extended init_declarations tests to cover global {} nested within an ambient module.

Reviewed changes

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

Show a summary per file
File Description
crates/oxc_linter/src/utils/typescript.rs Adds shared ambient TypeScript ancestor detection helper.
crates/oxc_linter/src/rules/typescript/no_namespace.rs Replaces local ambient-ancestor check with shared helper.
crates/oxc_linter/src/rules/eslint/vars_on_top.rs Uses shared helper to skip ambient TS contexts.
crates/oxc_linter/src/rules/eslint/no_var.rs Uses shared helper to skip ambient TS contexts.
crates/oxc_linter/src/rules/eslint/init_declarations.rs Uses shared helper and adds a regression test for nested global {}.

Comment thread crates/oxc_linter/src/utils/typescript.rs
@codspeed-hq

codspeed-hq Bot commented May 19, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 4 untouched benchmarks
⏩ 47 skipped benchmarks1


Comparing codex/refactor-ambient-ts-declaration (0c15ef9) with main (702b14e)2

Open in CodSpeed

Footnotes

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

@graphite-app graphite-app Bot force-pushed the codex/refactor-ambient-ts-declaration branch from 0c15ef9 to 6dba588 Compare May 19, 2026 09:24
@graphite-app graphite-app Bot merged commit 6dba588 into main May 19, 2026
29 checks passed
@graphite-app graphite-app Bot removed the 0-merge Merge with Graphite Merge Queue label May 19, 2026
@graphite-app graphite-app Bot deleted the codex/refactor-ambient-ts-declaration branch May 19, 2026 09:29
graphite-app Bot pushed a commit that referenced this pull request May 19, 2026
…ypescript_ancestor` (#22577)

Follow-up to #22572 to handle ambient `global {}` declarations without requiring an explicit `declare global`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-linter Area - Linter

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants