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

@ -119,7 +119,7 @@ export interface R3DirectiveMetadataFacade {
inputs: string[];
outputs: string[];
usesInheritance: boolean;
exportAs: string|null;
exportAs: string[]|null;
providers: Provider[]|null;
}

View File

@ -150,7 +150,7 @@ function directiveMetadata(type: Type<any>, metadata: Directive): R3DirectiveMet
},
typeSourceSpan: null !,
usesInheritance: !extendsDirectlyFromObject(type),
exportAs: metadata.exportAs || null,
exportAs: extractExportAs(metadata.exportAs),
providers: metadata.providers || null,
};
}
@ -189,6 +189,14 @@ function extractQueriesMetadata(
return queriesMeta;
}
function extractExportAs(exportAs: string | undefined): string[]|null {
if (exportAs === undefined) {
return null;
}
return exportAs.split(',').map(part => part.trim());
}
function isContentQuery(value: any): value is Query {
const name = value.ngMetadataName;
return name === 'ContentChild' || name === 'ContentChildren';