From f86c467fc47da399c7206d787437cfe3a9e3e11f Mon Sep 17 00:00:00 2001 From: Sam Sussman Date: Thu, 28 Jul 2022 13:50:31 -0500 Subject: [PATCH] chore: remove unused code --- src/declaration.ts | 8 -------- src/expression.ts | 12 ------------ src/visit.ts | 26 -------------------------- 3 files changed, 46 deletions(-) diff --git a/src/declaration.ts b/src/declaration.ts index 75c7c5c3..d0d32112 100644 --- a/src/declaration.ts +++ b/src/declaration.ts @@ -267,10 +267,6 @@ export class ObjectBinding extends BaseNode<"ObjectBinding", VariableDecl> { public clone(): this { return new ObjectBinding(this.bindings.map((b) => b.clone())) as this; } - - public getName(): never { - throw new Error(`an ObjectBinding does not have a name`); - } } /** @@ -303,10 +299,6 @@ export class ArrayBinding extends BaseNode<"ArrayBinding", VariableDecl> { public clone(): this { return new ArrayBinding(this.bindings.map((b) => b?.clone())) as this; } - - public getName(): never { - throw new Error(`an ArrayBinding does not have a name`); - } } export type VariableDeclParent = diff --git a/src/expression.ts b/src/expression.ts index 3aad2822..6b15e63f 100644 --- a/src/expression.ts +++ b/src/expression.ts @@ -439,18 +439,6 @@ export class PropAssignExpr extends BaseExpr< super("PropAssignExpr", arguments); } - /** - * @returns the name of this property if it is statically known (an Identifier or StringLiteralExpr). - */ - public tryGetName(): string | undefined { - if (isIdentifier(this.name)) { - return this.name.name; - } else if (isStringLiteralExpr(this.name)) { - return this.name.value; - } - return undefined; - } - public clone(): this { return new PropAssignExpr(this.name.clone(), this.expr.clone()) as this; } diff --git a/src/visit.ts b/src/visit.ts index 4c9d9e88..47ead2ee 100644 --- a/src/visit.ts +++ b/src/visit.ts @@ -824,31 +824,5 @@ export function visitSpecificChildren( }); } -/** - * Rename all {@link PropAssignExpr} expressions within the {@link obj} where the - * name is statically known and matches a property in the {@link rename} map. - */ -export function renameObjectProperties( - obj: ObjectLiteralExpr, - rename: Record -) { - const newObj = visitEachChild(obj, (node) => { - if (isPropAssignExpr(node)) { - const propName = node.tryGetName(); - if (propName !== undefined && propName in rename) { - const substituteName = rename[propName]; - - return new PropAssignExpr( - new Identifier(substituteName), - node.expr.clone() - ); - } - } - return node; - }); - newObj.parent = obj.parent; - return newObj; -} - // to prevent the closure serializer from trying to import all of functionless. export const deploymentOnlyModule = true;