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:
JoostK 2020-12-05 14:35:25 +01:00 committed by Misko Hevery
parent dd8a31838c
commit e69288418c

View File

@ -65,8 +65,9 @@ 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')) {
directives = metaObj.getArray('directives').map(directive => {
const directiveExpr = directive.getObject(); const directiveExpr = directive.getObject();
const type = directiveExpr.getValue('type'); const type = directiveExpr.getValue('type');
const selector = directiveExpr.getString('selector'); const selector = directiveExpr.getString('selector');
@ -89,18 +90,20 @@ export function toR3ComponentMeta<TExpression>(
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 (metaObj.has('pipes')) {
pipes = metaObj.getObject('pipes').toMap(value => {
if (value.isFunction()) { if (value.isFunction()) {
wrapDirectivesAndPipesInClosure = true; wrapDirectivesAndPipesInClosure = true;
return value.getFunctionReturnValue().getOpaque(); return value.getFunctionReturnValue().getOpaque();
} else { } else {
return value.getOpaque(); return value.getOpaque();
} }
}) : });
new Map<string, o.Expression>(); }
return { return {
...toR3DirectiveMeta(metaObj, code, sourceUrl), ...toR3DirectiveMeta(metaObj, code, sourceUrl),