feat(ivy): accept multiple values for exportAs in the compiler (#28001)

exportAs in @Directive metadata supports multiple values, separated by
commas. Previously it was treated as a single value string.

This commit modifies the compiler to understand that exportAs is a
string[]. It stops short of carrying the multiple values through to the
runtime. Instead, it only emits the first one. A future commit will modify
the runtime to accept all the values.

PR Close #28001
This commit is contained in:
Alex Rickabaugh
2019-01-08 16:30:57 -08:00
committed by Andrew Kushnir
parent 6003145422
commit 142553abc6
10 changed files with 27 additions and 13 deletions

View File

@ -177,7 +177,7 @@ export function extractDirectiveMetadata(
member.name === 'ngOnChanges');
// Parse exportAs.
let exportAs: string|null = null;
let exportAs: string[]|null = null;
if (directive.has('exportAs')) {
const expr = directive.get('exportAs') !;
const resolved = evaluator.evaluate(expr);
@ -185,7 +185,7 @@ export function extractDirectiveMetadata(
throw new FatalDiagnosticError(
ErrorCode.VALUE_HAS_WRONG_TYPE, expr, `exportAs must be a string`);
}
exportAs = resolved;
exportAs = resolved.split(',').map(part => part.trim());
}
// Detect if the component inherits from another class

View File

@ -366,7 +366,7 @@ export class SelectorScopeRegistry {
name: clazz.name !.text,
directive: ref,
isComponent: def.name === 'ngComponentDef', selector,
exportAs: readStringType(def.type.typeArguments[2]),
exportAs: readStringArrayType(def.type.typeArguments[2]),
inputs: readStringMapType(def.type.typeArguments[3]),
outputs: readStringMapType(def.type.typeArguments[4]),
queries: readStringArrayType(def.type.typeArguments[5]),