fallow icon indicating copy to clipboard operation
fallow copied to clipboard

A type re-exported from an entry point through an `export *` barrel isn't credited

Open mattlewis92 opened this issue 3 weeks ago • 1 comments

What happened?

When an entry file re-exports a type by name from a barrel, and the barrel gets the type through export *, the declaring file's export is reported as an unused type. The same chain using a named re-export instead of export * is credited.

Reproduction

package.json:

{ "name": "repro", "private": true }

.fallowrc.json:

{ "entry": ["src/index.ts"] }

src/index.ts:

export type { ViaStar } from './kit';
export type { ViaNamed } from './kit/named';

src/kit/index.ts:

export * from './types';

src/kit/types.ts:

export type ViaStar = { a: string };

src/kit/named.ts:

export type { ViaNamed } from './named-types';

src/kit/named-types.ts:

export type ViaNamed = { b: string };

Run fallow dead-code --unused-types. It reports ViaStar in src/kit/types.ts. ViaNamed is not reported.

Expected behavior

ViaStar is part of the entry point's public API through index.ts → kit/index.ts (export *) → kit/types.ts, so it should be credited like ViaNamed. fallow dead-code --trace src/kit/types.ts:ViaStar on the real case says "Re-exported through 2 barrel(s) … 0 ref(s)", even though the last barrel is a configured entry.

Fallow version

3.36.0

Operating system

macOS

Context

This may be related to #2391 (namespace and star re-export crediting gaps), which is closed. This case still reproduces on 3.36.0.

mattlewis92 avatar Nov 13 '26 18:11 mattlewis92

Fixed in v3.43.1.

A type or value that an entry file re-exports by name from an export * barrel now gets entry-point credit. Fallow no longer reports the source declaration as unused. Each namespace of a merged declaration, type and value, gets its own credit.

Thanks, @mattlewis92.

BartWaardenburg avatar Nov 15 '26 07:11 BartWaardenburg