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:

committed by
Andrew Kushnir

parent
6003145422
commit
142553abc6
@ -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
|
||||
|
@ -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]),
|
||||
|
Reference in New Issue
Block a user