rushstack icon indicating copy to clipboard operation
rushstack copied to clipboard

[api-extractor]: produces invalid dts if `@internal` identifiers are part of public API typings chain

Open Hotell opened this issue 3 years ago • 0 comments

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

Link to whole repro

Steps:

  1. uncomment lines below this comment // uncomment next line - https://github.com/microsoft/rushstack/issues/3445 within packages/one/src/index.ts
  2. run yarn build
  3. check output in packages/one/dist/untrimmed.ts and packages/one/dist/public.ts

Actual result:

image

Expected result:

one of:

  1. inline @internal types 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';
}
  1. 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;
}
  1. throw error to notify user that he is doing something wrong - exposing public API's that contain @internal types 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

Hotell avatar Jun 03 '22 16:06 Hotell