rushstack
rushstack copied to clipboard
[api-extractor]: produces invalid dts if `@internal` identifiers are part of public API typings chain
Summary
when publicTrimmedFilePath is used and public API surfaces contain type information that are produced from types that contain @internal annotation , api-extractor generates invalid .d.ts rollup file.
Repro steps
Steps:
- uncomment lines below this comment
// uncomment next line - https://github.com/microsoft/rushstack/issues/3445withinpackages/one/src/index.ts - run
yarn build - check output in
packages/one/dist/untrimmed.tsandpackages/one/dist/public.ts
Actual result:

Expected result:
one of:
- inline
@internaltypes to existing definition:
-export declare type WeekDay = WorkDay | WeekendDay;
+export declare type WeekDay = 'monday' | 'tuesday| ' saturday' | 'sunday';
export interface Baseball {
foo: Hello;
- bar: WorkDay;
+ bar: 'monday' | 'tuesday| ' saturday' | 'sunday';
}
- remove parts of public API's that contain
@internal
NOTE: This feels rather wrong so I dont think this is right approach
-export declare type WeekDay = WorkDay | WeekendDay;
export interface Baseball {
foo: Hello;
- bar: WorkDay;
}
- throw error to notify user that he is doing something wrong - exposing public API's that contain
@internaltypes within public API surface
both previous solutions (1 or 2) might be non trivial to implement, so at least providing correct guidance would provide good enough DX
Details
Standard questions
Please answer these questions to help us investigate your issue more quickly:
| Question | Answer |
|---|---|
@microsoft/api-extractor version? |
7.24.2 |
| Operating system? | Linux/Mac |
| API Extractor scenario? | rollups (.d.ts) |
| Would you consider contributing a PR? | Maybe |
| TypeScript compiler version? | 4.6.4 |
Node.js version (node -v)? |
14.8.1 |