Skip to content

fix(barrel-policy): skip export statements inside ambient module declarations - #3

Merged
Mearman merged 1 commit into
mainfrom
fix/barrel-policy-ambient-module-declarations
Sep 3, 2026
Merged

fix(barrel-policy): skip export statements inside ambient module declarations#3
Mearman merged 1 commit into
mainfrom
fix/barrel-policy-ambient-module-declarations

Conversation

@Mearman

@Mearman Mearman commented Sep 3, 2026

Copy link
Copy Markdown
Member

Summary

  • `export * from`/`export { x } from` written purely inside a `declare module "..." { ... }` (a TSModuleDeclaration) describes an external package's or namespace's types -- no real runtime import chain exists at that location
  • barrel-policy was matching this syntax the same as a genuine re-export, flagging the routine pattern of typing an otherwise-untyped npm package by re-exporting another package's types under a declared module name (e.g. `declare module "untyped-pkg" { export * from "typed-pkg"; }`)
  • New `isInsideAmbientModuleDeclaration` helper walks the parent chain generically (not asserting a specific parser's node types) and both `ExportNamedDeclaration`/`ExportAllDeclaration` handlers in barrel-policy now skip nodes inside one
  • Confirmed live migrating a real consumer onto this package: a `.d.ts` ambient shim for an untyped plotting library was flagged as a barrel-policy violation; zero once this fix is applied

Test plan

  • `pnpm lint` / `pnpm typecheck` / `pnpm test` (346/346, one clean full run plus a second confirming no flakiness) / `pnpm build` all green
  • New valid-case tests: a re-export inside `declare module "pkg" { ... }` and inside `declare module Namespace { ... }`, both in the strictest (`banned`) mode

…arations

export * from/export { x } from written purely inside a `declare module
"..." { ... }` (a TSModuleDeclaration) describes an external package's
or namespace's types -- it produces no real runtime import chain, since
nothing is actually imported or re-exported at that location. The rule
was matching this syntax the same as a genuine re-export, flagging the
routine pattern of typing an otherwise-untyped package by re-exporting
another package's types under a declared module name.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 3, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
🔒 Security Review Completed 2026-09-03T04:45:59.478588Z 9cc56ea PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@Mearman
Mearman merged commit 8047629 into main Sep 3, 2026
5 checks passed
@Mearman
Mearman deleted the fix/barrel-policy-ambient-module-declarations branch September 3, 2026 04:44
@github-actions

github-actions Bot commented Sep 3, 2026

Copy link
Copy Markdown

🎉 This PR is included in version 2.10.4 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant