Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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] Fix #3593 Incorrect canonical reference to aliased class in .api.json #3602
[api-extractor] Fix #3593 Incorrect canonical reference to aliased class in .api.json #3602
Changes from 5 commits
8a1cbd3
5b2d7ad
6bc0676
b11cc24
ef387a7
97e4593
1e11c5c
b02f81b
844f15b
f423294
6bfbc7a
a2f2485
4df3810
6d975b5
6f1811e
1ba1066
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if a symbol is exported from both a namespace and the entry point? Consider the following:
What should the declaration reference of
SomeClass
be? Today, API Extractor will actually write two items to the doc model forSomeClass
:my-package!SomeClass:class
as a child of theApiEntryPoint
.my-package!i1.SomeClass:class
as a child of theApiNamespace
my-package!i1
.(Note that today API Extractor will actually write only the latter to the doc model, but this is a recent bug from #3552 and relatively trivial to fix. I'm working on it.)
Ideally API Extractor would only write
SomeClass
once to the doc model... so which declaration reference is right? Today, your PR generatesmy-package!i1.SomeClass:class
for reference tokens, in part due to the logic highlighted by this comment.Another situation - suppose a symbol is exported from multiple namespaces, in some convoluted way like this:
What should the declaration reference of
SomeClass
be? Again, today, API Extractor writes two items forSomeClass
:my-package!i1.internal.SomeClass
my-package!i2.internal.SomeClass
And today, your PR is indeterministic in which one it generates for reference tokens.
I think fundamentally this is another instance of #1308. I'm not sure what the right behavior is. But I do think we want the behavior to be somewhat deterministic and robust to shuffling of API items. One idea is to choose the shortest ID, and among IDs of the same length, choose the one that comes first alphabetically. That being said, I'm not sure if this open question should block this PR.
@octogonz - what do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems like a bad idea in the first place to expose the same module under two different names. However, if you want to support this use case, maybe the developer should have some means to specify which alias is the "canonical" one and thus has precedence. Could be a new api-extractor configuration or even a new TSDoc tag.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This sounds good to me. Maybe we could also provide a TSDoc tag that allows the choice to be explicitly specified, similar to suggestions for the other ae-ambiguous-ids issues.