From f117a36a6c57c16f112e53c88a79911795d71b49 Mon Sep 17 00:00:00 2001 From: Rosco Kalis Date: Tue, 3 Dec 2024 14:09:53 +0100 Subject: [PATCH] Fix bug in new --format ts flag --- packages/utils/src/artifact.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/utils/src/artifact.ts b/packages/utils/src/artifact.ts index 14707807..ac2c4aeb 100644 --- a/packages/utils/src/artifact.ts +++ b/packages/utils/src/artifact.ts @@ -63,7 +63,9 @@ export function exportArtifact(artifact: Artifact, targetFile: string, format: ' export function formatArtifact(artifact: Artifact, format: 'json' | 'ts'): string { if (format === 'ts') { - return `export default ${stringifyAsTs(artifact)} as const;\n`; + // We remove any undefined values to make the artifact serializable using stringifyAsTs + const normalisedArtifact = JSON.parse(JSON.stringify(artifact)); + return `export default ${stringifyAsTs(normalisedArtifact)} as const;\n`; } return JSON.stringify(artifact, null, 2);