Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 0 additions & 8 deletions src/declaration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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`);
}
}

/**
Expand Down Expand Up @@ -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 =
Expand Down
12 changes: 0 additions & 12 deletions src/expression.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
26 changes: 0 additions & 26 deletions src/visit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -824,31 +824,5 @@ export function visitSpecificChildren<T extends FunctionlessNode>(
});
}

/**
* 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<string, string>
) {
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;