fix(compiler): generate inputs with aliases properly (#26774)
PR Close #26774
This commit is contained in:

committed by
Matias Niemelä

parent
c048358cf9
commit
19fcfc3d00
@ -86,7 +86,7 @@ export interface R3DirectiveMetadata {
|
||||
/**
|
||||
* A mapping of input field names to the property names.
|
||||
*/
|
||||
inputs: {[field: string]: string};
|
||||
inputs: {[field: string]: string | string[]};
|
||||
|
||||
/**
|
||||
* A mapping of output field names to the property names.
|
||||
|
@ -532,12 +532,15 @@ function stringAsType(str: string): o.Type {
|
||||
return o.expressionType(o.literal(str));
|
||||
}
|
||||
|
||||
function stringMapAsType(map: {[key: string]: string}): o.Type {
|
||||
const mapValues = Object.keys(map).map(key => ({
|
||||
key,
|
||||
value: o.literal(map[key]),
|
||||
quoted: true,
|
||||
}));
|
||||
function stringMapAsType(map: {[key: string]: string | string[]}): o.Type {
|
||||
const mapValues = Object.keys(map).map(key => {
|
||||
const value = Array.isArray(map[key]) ? map[key][0] : map[key];
|
||||
return {
|
||||
key,
|
||||
value: o.literal(value),
|
||||
quoted: true,
|
||||
};
|
||||
});
|
||||
return o.expressionType(o.literalMap(mapValues));
|
||||
}
|
||||
|
||||
|
@ -44,7 +44,7 @@ export interface DirectiveMeta {
|
||||
*
|
||||
* Goes from property names to field names.
|
||||
*/
|
||||
inputs: {[property: string]: string};
|
||||
inputs: {[property: string]: string | string[]};
|
||||
|
||||
/**
|
||||
* Set of outputs which this directive claims.
|
||||
|
@ -67,8 +67,8 @@ export function asLiteral(value: any): o.Expression {
|
||||
return o.literal(value, o.INFERRED_TYPE);
|
||||
}
|
||||
|
||||
export function conditionallyCreateMapObjectLiteral(keys: {[key: string]: string}): o.Expression|
|
||||
null {
|
||||
export function conditionallyCreateMapObjectLiteral(keys: {[key: string]: string | string[]}):
|
||||
o.Expression|null {
|
||||
if (Object.getOwnPropertyNames(keys).length > 0) {
|
||||
return mapToExpression(keys);
|
||||
}
|
||||
|
Reference in New Issue
Block a user