Skip to content
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

Commits on Oct 14, 2020

  1. refactor(compiler-cli): visit inline declarations with implementation…

    …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.
    petebacondarwin committed Oct 14, 2020
    Configuration menu
    Copy the full SHA
    22bd8e9 View commit details
    Browse the repository at this point in the history
  2. fix(ngcc): ensure that "inline exports" can be interpreted correctly

    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 committed Oct 14, 2020
    Configuration menu
    Copy the full SHA
    7036a61 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    08a3e11 View commit details
    Browse the repository at this point in the history