refactor(compiler-cli): reformat directive/pipe metadata extraction (#39961)
The prior usage of a ternary expression caused the code to be formatted in a weird way, so this commit replaces the ternary with an `if` statement. PR Close #39961
This commit is contained in:
parent
dd8a31838c
commit
e69288418c
@ -65,42 +65,45 @@ export function toR3ComponentMeta<TExpression>(
|
|||||||
|
|
||||||
let wrapDirectivesAndPipesInClosure = false;
|
let wrapDirectivesAndPipesInClosure = false;
|
||||||
|
|
||||||
const directives: R3UsedDirectiveMetadata[] = metaObj.has('directives') ?
|
let directives: R3UsedDirectiveMetadata[] = [];
|
||||||
metaObj.getArray('directives').map(directive => {
|
if (metaObj.has('directives')) {
|
||||||
const directiveExpr = directive.getObject();
|
directives = metaObj.getArray('directives').map(directive => {
|
||||||
const type = directiveExpr.getValue('type');
|
const directiveExpr = directive.getObject();
|
||||||
const selector = directiveExpr.getString('selector');
|
const type = directiveExpr.getValue('type');
|
||||||
|
const selector = directiveExpr.getString('selector');
|
||||||
|
|
||||||
let typeExpr = type.getOpaque();
|
let typeExpr = type.getOpaque();
|
||||||
if (type.isFunction()) {
|
if (type.isFunction()) {
|
||||||
typeExpr = type.getFunctionReturnValue().getOpaque();
|
typeExpr = type.getFunctionReturnValue().getOpaque();
|
||||||
wrapDirectivesAndPipesInClosure = true;
|
wrapDirectivesAndPipesInClosure = true;
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
type: typeExpr,
|
type: typeExpr,
|
||||||
selector: selector,
|
selector: selector,
|
||||||
inputs: directiveExpr.has('inputs') ?
|
inputs: directiveExpr.has('inputs') ?
|
||||||
directiveExpr.getArray('inputs').map(input => input.getString()) :
|
directiveExpr.getArray('inputs').map(input => input.getString()) :
|
||||||
[],
|
[],
|
||||||
outputs: directiveExpr.has('outputs') ?
|
outputs: directiveExpr.has('outputs') ?
|
||||||
directiveExpr.getArray('outputs').map(input => input.getString()) :
|
directiveExpr.getArray('outputs').map(input => input.getString()) :
|
||||||
[],
|
[],
|
||||||
exportAs: directiveExpr.has('exportAs') ?
|
exportAs: directiveExpr.has('exportAs') ?
|
||||||
directiveExpr.getArray('exportAs').map(exportAs => exportAs.getString()) :
|
directiveExpr.getArray('exportAs').map(exportAs => exportAs.getString()) :
|
||||||
null,
|
null,
|
||||||
};
|
};
|
||||||
}) :
|
});
|
||||||
[];
|
}
|
||||||
|
|
||||||
const pipes = metaObj.has('pipes') ? metaObj.getObject('pipes').toMap(value => {
|
let pipes = new Map<string, o.Expression>();
|
||||||
if (value.isFunction()) {
|
if (metaObj.has('pipes')) {
|
||||||
wrapDirectivesAndPipesInClosure = true;
|
pipes = metaObj.getObject('pipes').toMap(value => {
|
||||||
return value.getFunctionReturnValue().getOpaque();
|
if (value.isFunction()) {
|
||||||
} else {
|
wrapDirectivesAndPipesInClosure = true;
|
||||||
return value.getOpaque();
|
return value.getFunctionReturnValue().getOpaque();
|
||||||
}
|
} else {
|
||||||
}) :
|
return value.getOpaque();
|
||||||
new Map<string, o.Expression>();
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
...toR3DirectiveMeta(metaObj, code, sourceUrl),
|
...toR3DirectiveMeta(metaObj, code, sourceUrl),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user