fix(ngcc): use the correct identifiers when updating typings files (#34254)

Previously the identifiers used in the typings files were the same as
those used in the source files.

When the typings files and the source files do not match exactly, e.g.
when one of them is flattened, while the other is a deep tree, it is
possible for identifiers to be renamed.

This commit ensures that the correct identifier is used in typings files
when the typings file does not export the same name as the source file.

Fixes https://github.com/angular/ngcc-validation/pull/608

PR Close #34254
This commit is contained in:
Pete Bacon Darwin
2019-12-18 14:03:05 +00:00
committed by Kara Erickson
parent f22a6eb00e
commit 31be29a9f3
14 changed files with 94 additions and 39 deletions

View File

@ -29,7 +29,7 @@ export interface R3NgModuleMetadata {
/**
* An expression representing the module type being compiled.
*/
type: o.Expression;
type: R3Reference;
/**
* An expression representing the module type being compiled, intended for use within a class
@ -160,7 +160,7 @@ export function compileNgModule(meta: R3NgModuleMetadata): R3NgModuleDef {
const expression = o.importExpr(R3.defineNgModule).callFn([mapToMapExpression(definitionMap)]);
const type = new o.ExpressionType(o.importExpr(R3.NgModuleDefWithMeta, [
new o.ExpressionType(moduleType), tupleTypeOf(declarations), tupleTypeOf(imports),
new o.ExpressionType(moduleType.type), tupleTypeOf(declarations), tupleTypeOf(imports),
tupleTypeOf(exports)
]));
@ -228,7 +228,7 @@ export interface R3InjectorDef {
export interface R3InjectorMetadata {
name: string;
type: o.Expression;
type: R3Reference;
internalType: o.Expression;
deps: R3DependencyMetadata[]|null;
providers: o.Expression|null;
@ -259,7 +259,7 @@ export function compileInjector(meta: R3InjectorMetadata): R3InjectorDef {
const expression = o.importExpr(R3.defineInjector).callFn([mapToMapExpression(definitionMap)]);
const type =
new o.ExpressionType(o.importExpr(R3.InjectorDef, [new o.ExpressionType(meta.type)]));
new o.ExpressionType(o.importExpr(R3.InjectorDef, [new o.ExpressionType(meta.type.type)]));
return {expression, type, statements: result.statements};
}