fix(ngcc): viaModule should be null for local imports (#36989)

In the CommonJS and UMD reflection hosts, the logic for computing the
`viaModule` property of `Declaration` objects was not correct for some
cases when getting the exports of modules.

In these cases it was setting `viaModule` to the path of the local module
rather than `null`.

PR Close #36989
This commit is contained in:
Pete Bacon Darwin
2020-05-12 08:20:01 +01:00
committed by Kara Erickson
parent 2486db7c2b
commit d268d2ad85
4 changed files with 73 additions and 70 deletions

View File

@ -56,7 +56,7 @@ export interface RequireCall extends ts.CallExpression {
* `ts.Identifier` corresponding to `<namespace>` will be returned). Otherwise return `null`.
*/
export function findNamespaceOfIdentifier(id: ts.Identifier): ts.Identifier|null {
return id.parent && ts.isPropertyAccessExpression(id.parent) &&
return id.parent && ts.isPropertyAccessExpression(id.parent) && id.parent.name === id &&
ts.isIdentifier(id.parent.expression) ?
id.parent.expression :
null;