-
Notifications
You must be signed in to change notification settings - Fork 653
Description
Is this a feature or a bug?
- Feature
- Bug
Please describe the actual behavior.
TypeScript does not define the output order of the constituents of a union type. As a result of this, the output from API-extractor is inconsistent between fresh builds and incremental builds. From discussion with the TypeScript team, this is related to the order of loading of types and whether or not certain types need to be instantiated to type check the set of files that were built during the compilation.
The default sort order for union type constituents is based on the internal debug id, which is assigned when the type is instantiated.
If the issue is a bug, how can we reproduce it? Please provide detailed steps and include a GitHub branch if applicable. Your issue will get resolved faster if you can make it easy to investigate.
https://github.com/dmichon-msft/union-type-order-demo
Repro steps:
- Increment value of
incrementStep1inindex.ts. Runnpm run build. Observe order ofexport const testdeclaration. - Increment value of
incrementStep2inB.ts. Runnpm run build. Observe order ofexport const testdeclaration. - Repeat (1) if necessary.
The order will change depending on which files needed recompilation.
The order directly matches that which is output in lib/index.d.ts, which is what changes.
What is the expected behavior?
Since API extractor is concerned with substantive changes, it should define a standard (potentially configurable, but not required) sort order for the constituents of union types, regardless of the order output by TypeScript. This should be similar to the sorting of interface members that api-extractor already performs.
If this is a bug, please provide the tool version, Node.js version, and OS.
- Tool: api-extractor
- Tool Version: 7.8.12, with TypeScript 3.7.5
- Node Version: 10.19.0
- Is this a LTS version? Yes
- Have you tested on a LTS version? Yes
- OS: Windows 10
Edited 6/23@1:29 PM: simplified repro.
Metadata
Metadata
Assignees
Labels
Type
Projects
Status