microsoft / rushstack

Monorepo for tools developed by the Rush Stack community
https://rushstack.io/
Other
5.91k stars 595 forks source link

[api-extractor] can't link to native API with @link in a @throws tag #4181

Open Ragnar-Oock opened 1 year ago

Ragnar-Oock commented 1 year ago

Summary

@link when used in a @throws section with a native error, will lead api-extractor to print a warning in the console.

Repro steps

When writing

// index.ts
/**
* @throws {@link TypeError} param is expected to be a string, something else was passed
*/
function myFunction(param: string) {
  if (typeof param !== 'string') {
    throw TypeError('param is expected to be a string')
}

api-extractor will output the following warning :

Warning: index.ts:2:5 - (ae-unresolved-link) The @link reference could not be resolved: The package "[packageName]" does not have an export "TypeError"

Standard questions

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

Question Answer
@microsoft/api-extractor version? 7.34.7
Operating system? Windows 10
API Extractor scenario? rollups (.d.ts)
Would you consider contributing a PR? No
TypeScript compiler version? 4.8.4
Node.js version (node -v)? 18.12.1
derekdon commented 1 year ago

Same here.

Ragnar-Oock commented 9 months ago

Actually it looks like AE doesn't resolve links to native API at all. I'm not sure if it did when I first opened this issue.

sample code :

interface NotAnArray {
  /**
  * Same as {@link Array.prototype.flatMap}
  */
  flatMap<returnType>(callback: (resource: resource) => returnType | returnType[]): returnType[];

(ae-unresolved-link) The @โ€‹link reference could not be resolved: The package "[package name]" does not have an export "Array"

Ragnar-Oock commented 7 months ago

update on affected setup :

Question Answer
@microsoft/api-extractor version? 7.42.3
Operating system? Windows 10 and Ubuntu 22.04 WSL
API Extractor scenario? rollups (.d.ts)
Would you consider contributing a PR? No
TypeScript compiler version? 5.4.2 and 5.3.3
Node.js version (node -v)? 20.11.0