-
Notifications
You must be signed in to change notification settings - Fork 24.8k
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
fix(compiler-cli): identify aliased initializer functions #54480
Conversation
c7e27bd
to
8f55367
Compare
* Tracks which symbols are imported in specific files and under what names. | ||
* Allows for efficient querying for references to those symbols. | ||
*/ | ||
export class ImportedSymbolsTracker { |
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.
In the future I think we'll also need methods like hasImportsFor(symbol, moduleName)
and hasNamespaceImportFor(moduleName)
which will allow us to skip traversing the entire file even earlier. I skipped them for now since we don't need them yet, but all the information is already there.
0911967
to
1132572
Compare
1132572
to
7e8a3c5
Compare
packages/compiler-cli/src/ngtsc/imports/src/imported_symbols_tracker.ts
Outdated
Show resolved
Hide resolved
packages/compiler-cli/src/ngtsc/imports/src/imported_symbols_tracker.ts
Outdated
Show resolved
Hide resolved
packages/compiler-cli/src/ngtsc/imports/src/imported_symbols_tracker.ts
Outdated
Show resolved
Hide resolved
const transformers: ts.CustomTransformers = { | ||
before: [ | ||
getInitializerApiJitTransform(reflectionHost, /* isCore */ false), | ||
getInitializerApiJitTransform(reflectionHost, importTracker, /* isCore */ false), |
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.
At this point we have so many trackers 😄 local compilation, deferred etc
Fixes that initializer functions weren't being recognized if they are aliased (e.g. `import {model as alias} from '@angular/core';`). To do this efficiently, I had to introduce the `ImportedSymbolsTracker` which scans the top-level imports of a file and allows them to be checked quickly, without having to go through the type checker. It will be useful in the future when verifying that that initializer APIs aren't used in unexpected places. I've also introduced tests specifically for the `tryParseInitializerApiMember` function so that we can test it in isolation instead of going through the various functions that call into it.
7e8a3c5
to
096bbd2
Compare
This PR was merged into the repository by commit f04ecc0. |
Fixes that initializer functions weren't being recognized if they are aliased (e.g. `import {model as alias} from '@angular/core';`). To do this efficiently, I had to introduce the `ImportedSymbolsTracker` which scans the top-level imports of a file and allows them to be checked quickly, without having to go through the type checker. It will be useful in the future when verifying that that initializer APIs aren't used in unexpected places. I've also introduced tests specifically for the `tryParseInitializerApiMember` function so that we can test it in isolation instead of going through the various functions that call into it. PR Close #54480
…gular#54480)" This reverts commit f04ecc0.
Rolled back due to breakage in g3. In summary,
|
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Fixes that initializer functions weren't being recognized if they are aliased (e.g.
import {model as alias} from '@angular/core';
).To do this efficiently, I had to introduce the
ImportedSymbolsTracker
which scans the top-level imports of a file and allows them to be checked quickly, without having to go through the type checker. It will also be useful in the future when verifying that that initializer APIs aren't used in unexpected places.I've also introduced tests specifically for the
tryParseInitializerApiMember
function so that we can test it in isolation instead of going through the various functions that call into it.