fix(ngcc): ensure that "inline exports" can be interpreted correctly #39267
Closed
petebacondarwin wants to merge 3 commits intoangular:masterfrom
Closed
fix(ngcc): ensure that "inline exports" can be interpreted correctly #39267petebacondarwin wants to merge 3 commits intoangular:masterfrom
petebacondarwin wants to merge 3 commits intoangular:masterfrom
Conversation
…s differently Some inline declarations are of the form: ``` exports.<name> = <implementation>; ``` In this case the declaration `node` is `exports.<name>`. When interpreting such inline declarations we actually want to visit the `implementation` expression rather than visiting the declaration `node`. This commit adds `implementation?: ts.Expression` to the `InlineDeclaration` type and updates the interpreter to visit these expressions as described above.
Previously, inline exports of the form `exports.foo = <implementation>;` were
being interpreted (by the ngtsc `PartialInterpeter`) as `Reference` objects.
This is not what is desired since it prevents the value of the export
from being unpacked, such as when analyzing `NgModule` declarations:
```
exports.directives = [Directive1, Directive2];
@NgImport({declarations: [exports.directives]})
class AppModule {}
```
In this example the interpreter would think that `exports.directives`
was a reference rather than an array that needs to be unpacked.
This bug was picked up by the ngcc-validation repository. See
angular/ngcc-validation#1990 and
https://circleci.com/gh/angular/ngcc-validation/17130
Contributor
Author
|
I've targeted this PR at |
gkalpak
approved these changes
Oct 14, 2020
This was referenced Oct 14, 2020
JoostK
approved these changes
Oct 14, 2020
atscott
pushed a commit
that referenced
this pull request
Oct 14, 2020
…39267) Previously, inline exports of the form `exports.foo = <implementation>;` were being interpreted (by the ngtsc `PartialInterpeter`) as `Reference` objects. This is not what is desired since it prevents the value of the export from being unpacked, such as when analyzing `NgModule` declarations: ``` exports.directives = [Directive1, Directive2]; @NgImport({declarations: [exports.directives]}) class AppModule {} ``` In this example the interpreter would think that `exports.directives` was a reference rather than an array that needs to be unpacked. This bug was picked up by the ngcc-validation repository. See angular/ngcc-validation#1990 and https://circleci.com/gh/angular/ngcc-validation/17130 PR Close #39267
|
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. |
This file contains hidden or 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
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Previously, inline exports of the form
exports.foo = <implementation>;werebeing interpreted (by the ngtsc
PartialInterpeter) asReferenceobjects.This is not what is desired since it prevents the value of the export
from being unpacked, such as when analyzing
NgModuledeclarations:In this example the interpreter would think that
exports.directiveswas a reference rather than an array that needs to be unpacked.
This bug was picked up by the ngcc-validation repository. See
angular/ngcc-validation#1990 and
https://circleci.com/gh/angular/ngcc-validation/17130