diff --git a/src/scripts/object/move_unknown_properties.ts b/src/scripts/object/move_unknown_properties.ts index dc0c7cd..8124992 100644 --- a/src/scripts/object/move_unknown_properties.ts +++ b/src/scripts/object/move_unknown_properties.ts @@ -7,8 +7,6 @@ * file that was distributed with this source code. */ -import { inspect } from 'node:util' - /** * Options accepts by the output script */ @@ -18,6 +16,14 @@ type MovePropertiesOptions = { fieldsToIgnore: string[] } +/** + * Converts an array of strings to a string representation + * like ["foo", "bar"]. Just like node:inspect does. + */ +function arrayToString(arr: string[]) { + return `[${arr.map((str) => `"${str}"`).join(', ')}]` +} + /** * Returns JS fragment for moving properties from the source * to destination @@ -30,5 +36,7 @@ export function defineMoveProperties({ if (!allowUnknownProperties) { return '' } - return `moveProperties(${variableName}.value, ${variableName}_out, ${inspect(fieldsToIgnore)});` + + const serializedFieldsToIgnore = arrayToString(fieldsToIgnore) + return `moveProperties(${variableName}.value, ${variableName}_out, ${serializedFieldsToIgnore});` }