[api-extractor] Keep separate d.ts files but filter public API
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 25/100
- Issue type
- Feature
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- node.js, typescript
- Domain
- build-system, tooling
Research direction
Start by reviewing API Extractor's reporting, rollups, and docs scenarios, especially dtsRollup, alongside TypeScript's per-module .d.ts output and the package.json exports mapping. Define how modules are crawled, public exports are filtered, and matching output files are generated. Done means separate non-empty .d.ts files preserve the source hierarchy, with discrepancies reported.
Written by the indexing model from the issue text.
Description
Summary
I'd like to use the API extractor functionalities to track my public API and filter anything non-public from my d.ts files.
At the same time I want to keep separate d.ts files (one for every .mjs just like typescript prints it).
Unfortunately the dtsRollup works in a "bundle/barrel module" mindset where you only have a single library file.
Details
In the era of ESM the practice of "bundling" when publishing packages seem to vanish to support features like tree-shaking better. Same applies for "barrel modules" which contain all exports of your library.
Following this strategy it would be great if api-extractor could do it's magic without expecting a single barrel d.ts.
Imagine a tsc output of .mjs and .d.ts files matching the .ts file hierarchy. I'd expect:
- api-extractor to crawl the modules of my project and build the public API surface.
- Potentially the
exportsproperty of the package.json is consulted to filter what's really public from an NPM perspective (mapping might be tricky though). - api-extractor writes the output
d.tsfiles with the same hierarchy to a given output directory (empty d.ts files are omitted). - Any warnings on discrepancies of exports are reported (e.g. a public api exposes a filtered private one).
Standard questions
Please answer these questions to help us investigate your issue more quickly:
| Question | Answer |
|---|---|
@microsoft/api-extractor version? |
7.53.3 |
| Operating system? | Any |
| API Extractor scenario? | reporting (.api.md) / rollups (.d.ts) / docs (.api.json) |
| Would you consider contributing a PR? | Maybe, depends on the efforts |
| TypeScript compiler version? | 5.9.3 |
Node.js version (node -v)? |
v24.11.0 |
- Dominant language
- TypeScript
- Stars
- 6.5k
- Forks
- 708
- Avg merge
- 4d 13h
- Merged PRs (30d)
- 62
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from microsoft/rushstack
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
-
Difficulty 4/5 3-5 days Newbie friendliness 45/100
All issues in microsoft/rushstack
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
bcgov/bc-wallet-mobile#4761 · 1 comment ·
-
external-issue to-triage
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
area-deployment area-integrations triage:bot-seen
Difficulty 2/5 Half a day Newbie friendliness 86/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
-
refactor
Difficulty 2/5 1-3 hours Newbie friendliness 84/100