From 9c6ee5fcd0b25ff121bccc87abef7909bcbcec47 Mon Sep 17 00:00:00 2001 From: Pete Bacon Darwin Date: Wed, 13 Nov 2019 08:33:22 +0000 Subject: [PATCH] refactor(ngcc): move `stripParentheses` to `Esm5ReflectionHost` for re-use (#33777) PR Close #33777 --- packages/compiler-cli/ngcc/src/host/esm5_host.ts | 6 ++++-- packages/compiler-cli/ngcc/src/host/umd_host.ts | 6 +----- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/packages/compiler-cli/ngcc/src/host/esm5_host.ts b/packages/compiler-cli/ngcc/src/host/esm5_host.ts index 92c424ba1c..03ad05b0f9 100644 --- a/packages/compiler-cli/ngcc/src/host/esm5_host.ts +++ b/packages/compiler-cli/ngcc/src/host/esm5_host.ts @@ -14,8 +14,6 @@ import {getNameText, hasNameIdentifier, stripDollarSuffix} from '../utils'; import {Esm2015ReflectionHost, ParamInfo, getPropertyValueFromSymbol, isAssignmentStatement} from './esm2015_host'; import {NgccClassSymbol} from './ngcc_host'; - - /** * ESM5 packages contain ECMAScript IIFE functions that act like classes. For example: * @@ -834,3 +832,7 @@ function isUndefinedComparison(expression: ts.Expression): expression is ts.Expr expression.operatorToken.kind === ts.SyntaxKind.EqualsEqualsEqualsToken && ts.isVoidExpression(expression.right) && ts.isIdentifier(expression.left); } + +export function stripParentheses(node: ts.Node): ts.Node { + return ts.isParenthesizedExpression(node) ? node.expression : node; +} diff --git a/packages/compiler-cli/ngcc/src/host/umd_host.ts b/packages/compiler-cli/ngcc/src/host/umd_host.ts index 30a6c65b57..e5dc0b2674 100644 --- a/packages/compiler-cli/ngcc/src/host/umd_host.ts +++ b/packages/compiler-cli/ngcc/src/host/umd_host.ts @@ -12,7 +12,7 @@ import {absoluteFrom} from '../../../src/ngtsc/file_system'; import {Declaration, Import} from '../../../src/ngtsc/reflection'; import {Logger} from '../logging/logger'; import {BundleProgram} from '../packages/bundle_program'; -import {Esm5ReflectionHost} from './esm5_host'; +import {Esm5ReflectionHost, stripParentheses} from './esm5_host'; export class UmdReflectionHost extends Esm5ReflectionHost { protected umdModules = new Map(); @@ -279,7 +279,3 @@ function findNamespaceOfIdentifier(id: ts.Identifier): ts.Identifier|null { id.parent.expression : null; } - -export function stripParentheses(node: ts.Node): ts.Node { - return ts.isParenthesizedExpression(node) ? node.expression : node; -}