rushstack icon indicating copy to clipboard operation
rushstack copied to clipboard

[api-extractor] incorrect name in canonical reference when there are references to types with same names but under different namespaces

Open jeremymeng opened this issue 2 years ago • 1 comments
trafficstars

Summary

We are using a coding pattern that a package exports multiple features at top level. Each of the features are very similar in structures thus they have types with same name or exported with same name (e.g., Client, Responses). api-extractor generates api.json that have incorrect names at some canonical references.

Repro steps

Repro code at https://github.com/jeremymeng/ae-repro-2

just run

yarn install npm run extract-api

then check the output api.json under the temp/ directory

For example, https://github.com/jeremymeng/ae-repro-2/blob/main/temp/ae-model.api.json#L469

There's a _2 suffix in canonicalReference": "ae-model!FeatureB.Client_2.Interface2:interface", while the definition is "Client" wrapped inside FeatureB namespace

https://github.com/jeremymeng/ae-repro-2/blob/main/temp/ae-model.api.json#L450

Other incorrect places:

https://github.com/jeremymeng/ae-repro-2/blob/main/temp/ae-model.api.json#L524

https://github.com/jeremymeng/ae-repro-2/blob/main/temp/ae-model.api.json#L533

Expected result:

No _<number> suffix inside canonical references when they are unique (nested inside different namespaces)

Standard questions

Please answer these questions to help us investigate your issue more quickly:

Question Answer
@microsoft/api-extractor version? 7.34.3
Operating system? Linux
API Extractor scenario? (.api.json)
Would you consider contributing a PR?
TypeScript compiler version? 4.8, 4.9
Node.js version (node -v)? 18.12.0

jeremymeng avatar Feb 07 '23 20:02 jeremymeng