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(ngcc): ensure that "inline exports" can be interpreted correctly #39267
Closed
petebacondarwin
wants to merge
3
commits into
angular:master
from
petebacondarwin:ngcc-inline-exports-commonjs
Closed
fix(ngcc): ensure that "inline exports" can be interpreted correctly #39267
petebacondarwin
wants to merge
3
commits into
angular:master
from
petebacondarwin:ngcc-inline-exports-commonjs
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
…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
petebacondarwin
added
type: bug/fix
comp: ngcc
target: minor
This PR is targeted for the next minor release
P3
An issue that is relevant to core functions, but does not impede progress. Important, but not urgent
labels
Oct 14, 2020
I've targeted this PR at |
petebacondarwin
added
the
action: review
The PR is still awaiting reviews from at least one requested reviewer
label
Oct 14, 2020
gkalpak
changed the title
@petebacondarwin fix(ngcc): ensure that "inline exports" can be interpreted correctly
fix(ngcc): ensure that "inline exports" can be interpreted correctly
Oct 14, 2020
gkalpak
approved these changes
Oct 14, 2020
This was referenced Oct 14, 2020
JoostK
approved these changes
Oct 14, 2020
petebacondarwin
added
action: merge
The PR is ready for merge by the caretaker
action: presubmit
The PR is in need of a google3 presubmit
and removed
action: review
The PR is still awaiting reviews from at least one requested reviewer
labels
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. |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Labels
action: merge
The PR is ready for merge by the caretaker
action: presubmit
The PR is in need of a google3 presubmit
cla: yes
P3
An issue that is relevant to core functions, but does not impede progress. Important, but not urgent
target: minor
This PR is targeted for the next minor release
type: bug/fix
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
) asReference
objects.This is not what is desired since it prevents the value of the export
from being unpacked, such as when analyzing
NgModule
declarations: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