Skip to content

feat(typescript): add internal prop to exclude declarations from barrel exports#375

Open
joheredi wants to merge 3 commits intoalloy-framework:mainfrom
joheredi:joheredi/internal-export-visibility
Open

feat(typescript): add internal prop to exclude declarations from barrel exports#375
joheredi wants to merge 3 commits intoalloy-framework:mainfrom
joheredi:joheredi/internal-export-visibility

Conversation

@joheredi
Copy link
Contributor

@joheredi joheredi commented Mar 8, 2026

Add an internal boolean prop to all declaration components (FunctionDeclaration, VarDeclaration, ClassDeclaration, InterfaceDeclaration, EnumDeclaration, TypeDeclaration). When a declaration has both export and internal, it is
exported from its source module but excluded from:

  • Barrel file re-exports (uses filtered named exports instead of export *)
  • Cross-package public symbol resolution

This enables keeping utility declarations importable within a package while hiding them from the generated public API surface.

Additionally, barrel files now detect and resolve name conflicts when multiple source files export symbols with the same name. Instead of emitting conflicting export * statements that cause TypeScript build errors, the barrel falls back to named
re-exports with deterministic aliases (e.g. export { helper as helper_1 } from "./b.js"). Cross-package reference resolution uses the aliased name so consumer imports match the barrel's exports.

…el exports

Add an `internal` boolean prop to all declaration components
(FunctionDeclaration, VarDeclaration, ClassDeclaration,
InterfaceDeclaration, EnumDeclaration, TypeDeclaration). When a
declaration has both `export` and `internal`, it is exported from its
source module but excluded from:

- Barrel file re-exports (uses filtered named exports instead of
  export *)
- Cross-package public symbol resolution

This enables keeping utility declarations importable within a package
while hiding them from the generated public API surface.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@github-actions
Copy link
Contributor

github-actions bot commented Mar 8, 2026

All changed packages have been documented.

  • @alloy-js/typescript
Show changes

@alloy-js/typescript - fix ✏️

Resolve name conflicts in barrel file exports. When multiple source files export symbols with the same name, the barrel now falls back to named re-exports with deterministic aliases (e.g. export { helper as helper_2 } from "./b.js") instead of emitting conflicting export * statements that produce TypeScript build errors.

@alloy-js/typescript - feature ✏️

Add internal prop to declaration components. Internal declarations are exported from their source module but excluded from barrel file re-exports and public package resolution.

@pkg-pr-new
Copy link

pkg-pr-new bot commented Mar 8, 2026

Open in StackBlitz

npm i https://pkg.pr.new/alloy-framework/alloy/@alloy-js/typescript@375

commit: cfd1b20

joheredi and others added 2 commits March 8, 2026 05:37
When multiple source files in the same directory export symbols with the
same name, the generated barrel file now detects the conflict and falls
back to named re-exports with deterministic aliases instead of emitting
conflicting export * statements that cause TypeScript build errors.

- BarrelFile pre-scans public exports to detect duplicate names
- ExportStatement renders aliased named re-exports for conflicts
- Reference resolution uses barrel-exported symbol for correct imports
- Added 4 regression tests for various conflict scenarios

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Replace manual name conflict detection in BarrelFile with the
SymbolTable's built-in deconfliction. ExportStatement now creates
re-export alias symbols in the barrel module's values SymbolTable,
and the defaultConflictHandler automatically renames duplicates.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant