fix(ivy): support multiple exportAs (#27996)

Allows for multiple, comma-separated `exportAs` names, similarly to `ViewEngine`.

These changes fix FW-708.

PR Close #27996
This commit is contained in:
Kristiyan Kostadinov
2019-01-10 22:24:32 +01:00
committed by Andrew Kushnir
parent b78351cc7e
commit 9277142d54
14 changed files with 107 additions and 57 deletions

View File

@ -151,7 +151,7 @@ export function defineComponent<T>(componentDefinition: {
*
* See: {@link Directive.exportAs}
*/
exportAs?: string;
exportAs?: string[];
/**
* Template function use for rendering DOM.
@ -605,7 +605,7 @@ export const defineDirective = defineComponent as any as<T>(directiveDefinition:
*
* See: {@link Directive.exportAs}
*/
exportAs?: string;
exportAs?: string[];
}) => never;
/**

View File

@ -1716,7 +1716,11 @@ function saveNameToExportMap(
index: number, def: DirectiveDef<any>| ComponentDef<any>,
exportsMap: {[key: string]: number} | null) {
if (exportsMap) {
if (def.exportAs) exportsMap[def.exportAs] = index;
if (def.exportAs) {
for (let i = 0; i < def.exportAs.length; i++) {
exportsMap[def.exportAs[i]] = index;
}
}
if ((def as ComponentDef<any>).template) exportsMap[''] = index;
}
}

View File

@ -121,7 +121,7 @@ export interface DirectiveDef<T> extends BaseDef<T> {
/**
* Name under which the directive is exported (for use with local references in template)
*/
readonly exportAs: string|null;
readonly exportAs: string[]|null;
/**
* Factory function used to create a new directive instance.
@ -349,4 +349,4 @@ export type PipeTypeList =
// Note: This hack is necessary so we don't erroneously get a circular dependency
// failure based on types.
export const unusedValueExportToPlacateAjd = 1;
export const unusedValueExportToPlacateAjd = 1;