From 4d9c38ea9f22867d23b23f9ad585f965bedc5c1c Mon Sep 17 00:00:00 2001 From: Matthew Griffith Date: Fri, 24 Sep 2021 09:36:16 -0400 Subject: [PATCH] use regex instead of replaceAll --- src/transforms/recordUpdate.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/transforms/recordUpdate.ts b/src/transforms/recordUpdate.ts index 9d42108..a12c365 100644 --- a/src/transforms/recordUpdate.ts +++ b/src/transforms/recordUpdate.ts @@ -135,7 +135,8 @@ function isUpdateExpression(node: ts.Node): ts.CallExpression | null { } function generateCodeForReusableUpdate(objName: string, shape: string, objectProperties: Array): ts.Node { - const updateFnName = `$$update__${shape.replaceAll(',', '__')}`; + + const updateFnName = `$$update__${shape.replace(/,/g, '__')}`; const initialArgs: Array = [ ts.createIdentifier(objName) ]; const newValues = objectProperties.map((it) => (it as ts.PropertyAssignment).initializer); @@ -279,7 +280,8 @@ function createReusableUpdateStatements(updateSet: Map): ts.Node } function createReusableUpdateStatement(shape: string): string { - const updateFnName = `$$update__${shape.replaceAll(',', '__')}`; + + const updateFnName = `$$update__${shape.replace(/,/g, '__')}`; const props = shape.split(','); const propSetters = props.