From 534039428496bcededc62d2e450d29d7bac42475 Mon Sep 17 00:00:00 2001 From: Kevin Ingersoll Date: Wed, 30 Oct 2024 17:15:54 +0000 Subject: [PATCH] fix(abi-ts): ts output should use as const (#3348) --- .changeset/smart-suns-scream.md | 5 +++++ packages/abi-ts/src/command.ts | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 .changeset/smart-suns-scream.md diff --git a/.changeset/smart-suns-scream.md b/.changeset/smart-suns-scream.md new file mode 100644 index 0000000000..1d33c9985c --- /dev/null +++ b/.changeset/smart-suns-scream.md @@ -0,0 +1,5 @@ +--- +"@latticexyz/abi-ts": patch +--- + +Using a TS extension (rather than DTS) now correctly includes `as const` in the TS output. diff --git a/packages/abi-ts/src/command.ts b/packages/abi-ts/src/command.ts index f4529c757d..d6b8c9679f 100644 --- a/packages/abi-ts/src/command.ts +++ b/packages/abi-ts/src/command.ts @@ -49,7 +49,7 @@ export const command: CommandModule = { const ts = tsExtension.includes(".d.") ? `declare const abi: ${json};\n\nexport default abi;\n` - : `const abi = ${json};\n\nexport default abi;\n`; + : `const abi = ${json} as const;\n\nexport default abi;\n`; debug("Writing", tsFilename); writeFileSync(tsFilename, ts);