Skip to content

fix: strip TypeScript before export discovery - #297

Open
tayfuryldz wants to merge 2 commits into
nodejs:mainfrom
tayfuryldz:fix/296-typescript-generic-cast
Open

tayfuryldz wants to merge 2 commits into
nodejs:mainfrom
tayfuryldz:fix/296-typescript-generic-cast

Conversation

@tayfuryldz

Copy link
Copy Markdown

Closes #296

TypeScript module formats are now stripped before runtime export discovery, preventing type arguments from being misidentified as value exports.

Regression coverage adds two generic-cast exports with the same trailing type argument; current main fails with a duplicate phantom export, while the patched path loads and instruments the module correctly.

Validation:

  • Node.js v24.21.0 baseline: duplicate export of unknown
  • patched regression: pass
  • npm run lint: pass
  • npm test: pass (129 tests)
  • git diff --check: clean

Signed-off-by: TayfurYldz <238304586+TayfurYldz@users.noreply.github.com>
@tayfuryldz
tayfuryldz force-pushed the fix/296-typescript-generic-cast branch from 9531ac5 to e75cb45 Compare September 18, 2026 22:30

@BridgeAR BridgeAR left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A new es-module-lexer was just published that should fix the issues and it will automatically be pulled in for new installs, since we use a open range in iitm.

Mind trying that and just updating the minimum version here afterwards? That way we can keep the speedups.

Signed-off-by: TayfurYldz <238304586+TayfurYldz@users.noreply.github.com>
@tayfuryldz

Copy link
Copy Markdown
Author

Tried es-module-lexer 3.0.3 as suggested, raised the minimum to ^3.0.3, and removed the ESM TypeScript stripping workaround to retain the faster lexer path. Added a runtime-independent regression asserting the fixture’s six value exports and three type-only exports. That regression and ESLint pass locally. The full test suite hits ERR_NO_TYPESCRIPT because the locally installed Node 24.15.0 build lacks TypeScript support, so the .mts integration suite still needs normal CI verification.

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.

export const x = expr as Generic<A, B> produces a phantom export named after B, colliding when 2+ such casts share a last type arg

2 participants