forked from microsoft/rushstack
-
Notifications
You must be signed in to change notification settings - Fork 0
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
Compare fwienber/api-extractor-fix-3593-reference-alias with zelliott/refs + /exported #1
Draft
fwienber
wants to merge
6
commits into
zelliott/integrate
Choose a base branch
from
fwienber/api-extractor-fix-3593-reference-alias-rebased
base: zelliott/integrate
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Maybe newlineKind: 'os' should be the default for api-extractor config (ExtractorConfig.ts) anyway, but for now, let's make it explicit in the test configuration. Another possible scenario is that the tests are run under Windows, but git has been configured to used 'lf'. Then, using 'os' line endings would still lead to a git diff. But detecting the git setting is probably beyond what the test runner should do.
"Incorrect canonical reference to aliased class in .api.json" microsoft#3593 Fix first scenario from microsoft#3593. Added test scenario "docReferencesAlias", inspired by the test repo referenced in the GitHub issue: `Item` and `Options` are default exports of two separate source files, and `index` re-exports both, renaming `Options` to `renamed_Options` (preserving the "namespacing" information of the directory). `DeclarationReferenceGenerator` now receives a function to resolve a Symbol to its emit name. `ApiModelGenerator` fetches this function from `Collector`, which now maintains another map from symbol to `CollectorEntity`. If for a given symbol, there is a `CollectorEntity`, then its `emitName` is returned, the symbol's name otherwise. While this change fixes the `export { __ as __ }` scenario, for _some_ reason, it changes the output of one other test scenario, namely "ambientNameConflict". In its `*.api.json` file, some reference to the class re-exported as `MyPromise`, the name clash of localFile's `Promise` and the global `Promise` now leads to `Promise_2` being used instead of `Promise`, the old expected result that was also wrong, because it should have been `MyPromise`, and `MyPromise` should appear in `*.api.json`, but that is something completely different, so I'll ignore the problem for now and check in the changed expected `*.api.json` of "ambientNameConflict".
"Incorrect canonical reference to aliased class in .api.json" microsoft#3593 This fixes the other aliasing, namely through (nested) namespaces. Added a test scenario "docReferencesNamespaceAlias", which consists of nested namespaces that have their own index.d.ts, re-exporting the default export of each sibling file and their respective sub-namespace (top-level -> 'renamed' -> 'sub'). The *.api.json canonicalReferences now correctly use the nested namespace "fully-qualified name". Again, another test result changed unexpectedly, maybe revealing an existing bug / wrong expected result. The scenario is "exportImportStarAs2", where some 'ForgottenClass' is now referenced via its 'forgottenNs'. I hope that this is an improvement, but I am not sure how "illegal" references to non-exported items are supposed to behave. Implementation: --------------- When DeclarationReferenceGenerator#_getParentReference() finds a parent symbol via the symbol tree, it must also resolve namespace parent symbols the Collector derived from 'import * as ___'. To that end, Collector now has a method getParentSymbols() that pulls namespace imports from the CollectorEntities of a namespace symbol (if present). This must happen in a loop for nested namespaces. Namespace imports are now also registered in the _entitiesBySymbol Map, but I did not find the API to access the symbol of the AstNamespaceImport astEntity (ugly type assertion 'as unknown as ts.Type', which is probably not even the right type to access 'symbol'). I found the reference while debugging, but could not find it in any meaningful subtype.
Extract complex inline expression to apply several navigation steps to a DeclarationReference into a utility method, adequately called `_addNavigationSteps()`. On the fly changed that when in `_getParentReference()`, `parentRef` is undefined, instead of immediately returning undefined, continue with the fallback logic.
e7e6f28
to
d1bc27b
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This PR just serves to see the diff to two PRs of @zelliott.