-
Notifications
You must be signed in to change notification settings - Fork 604
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[api-extractor] Linking to overloads generates warnings, but no way to specify which overload #1240
Comments
Distinguishing declarations is generally useful for merged declarations (e.g. overloaded functions, enum+namespace, interface+function, etc). In contrast, namespace+namespace and interface+interface are special cases where the distinction between declarations is NOT very meaningful. If you have two namespaces named "Office", I suppose ideally API Extractor should collapse them into a single namespace. However this can involve nontrivial transformations, for example: // "Oh, TypeScript!" :-D
export namespace N {
export interface A { }
export interface C extends B { }
}
export namespace N {
export interface B { }
export interface C extends A { }
} The collapsed namespace would need a collapsed For the special case of namespace+namespace (and interface+interface), I'm tempted to propose that the declaration reference resolver should arbitrarily select the first one it finds. In practice it doesn't matter much. This would eliminate the error and need for But @AlexJerabek... now I'm wondering how these multiple namespaces appear in your generated docs. Do they get folded together? Do they get separate TOC nodes? Does one of them get silently discarded? If the answer is something bad, then maybe we should go ahead and implement collapsing, at least in the .api.json file if not the .d.ts rollup. (We also absolutely need to implement support for |
Thanks for the quick response @octogonz! The namespaces get folded together today, which is what we'd expect. We can merge the namespaces together in our d.ts (apparently the separation was for historical reasons). That avoids this issue. Because we're not blocked, this isn't an API Extractor feature we need. This issue was more to point out the discrepancy between the warning's advice and actual functionality. |
In #1308 @postspectacular wrote:
|
The short answer is that it's not implemented. (Fixing this is obviously a high priority in general, but embarrassingly it's stagnated because it doesn't affect us much; the Rush Stack project tries to avoid designing APIs with overloads.) There are two versions of the
The new notation was introduced this summer and has not been integrated yet into the TSDoc parser library. That work needs to be completed before API Extractor could adopt it (even though API Extractor is already using it for the Thus, if we want to get this working quickly, we should implement it for the old syntax. It's probably not a lot of work, and much of the implementation should be reusable later when we switch to the new syntax. If I remember right, this needs to be implemented in two places:
Would someone want to help out with this? I'm pretty busy right now, so I'm not sure I could do it right away. But I'd be very happy to provide guidance/help if someone else wants to make the PR. |
Here's a PR: #1648 |
This fix was published with API Extractor 7.7.0 |
@octogonz you're a ⭐️ ! thank you so much & apols for lack of responses. busy times! |
Our d.ts file has two namespaces named "Office". When running API Extractor version 7.1.0, links like this
{@link Office.AsyncResult | AsyncResult}
give warnings like this:I wanted to use the guidance given in this TSDoc spec, but I'm unable to use the labels or index selectors to reference overloaded namespaces.
When using
{@link (Office:2).AsyncResult}
, I get the warning:When using
{@label COMMON_API}
, I get the warning:Is there a workaround until labels or index-references are supported? Thank you.
The text was updated successfully, but these errors were encountered: