rushstack icon indicating copy to clipboard operation
rushstack copied to clipboard

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

Open Ragnar-Oock opened this issue 2 years ago • 3 comments

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

Ragnar-Oock avatar Jun 08 '23 15:06 Ragnar-Oock

Same here.

derekdon avatar Aug 14 '23 09:08 derekdon

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 avatar Jan 03 '24 14:01 Ragnar-Oock

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

Ragnar-Oock avatar Mar 18 '24 12:03 Ragnar-Oock