-
Notifications
You must be signed in to change notification settings - Fork 25.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(compiler-cli): set TS original node on imported namespace identif…
…iers (#40711) This commit causes imports added by ngtsc's `ImportManager` to have their TypeScript "original node" set to the generated `ts.ImportDeclaration` statement. In g3, the tsickle transformer runs after the Angular transformer and post- processes Angular's compilation output. One of its post-processing tasks is to transform generated imports and references to imported symbols from the commonjs module system to the g3 module system. Part of this transformation involves recognizing modules with specific metadata and altering references to symbols from those modules accordingly. Normally, tsickle can rely on TypeScript's binding for an imported symbol to find its origin module and thus the correct metadata for the symbol. However the Angular transform generates new synthetic imports which don't have such binding information. Angular's imports are always namespace imports of the form: ``` import * as qualifier 'module/specifier'; ``` References to such an import are then of the form `qualifier.SymbolName`. To process such imports properly, tsickle needs to be able to associate the reference to `qualifier` in the expression `qualifer.SymbolName` with the `ts.ImportDeclaration` statement that defines it. It expects to do this by looking at the `ts.getOriginalNode()` for the `qualifier` reference, which should be the `ts.ImportDeclaration`. This commit changes ngtsc's import generation mechanism to set the original node on `qualifier` identifiers according to this expectation. This commit is not tested in the direct compiler tests, since: 1) there is no observable behavior externally from setting the original node 2) we don't have tests that intercept transformer operations (which could be used to directly assert against the AST nodes) 3) tsickle's published version does not (yet) contain the g3-specific transformations which rely on the original node and would thus allow the behavior to be observed. Instead, we rely on the g3 testing suite to validate the correctness of this fix. Breaking this functionality would cause g3 compilation errors for targets, since tsickle would be unable to transform imports correctly. PR Close #40711
- Loading branch information
1 parent
4c6d557
commit 87ac052
Showing
14 changed files
with
74 additions
and
54 deletions.
There are no files selected for viewing
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
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
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
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
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
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
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
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
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
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
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
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
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
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