From 8176a228b2b6365ea53178f2c998549fcab02268 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=8F=E6=A9=98?= Date: Tue, 2 Jun 2026 02:54:17 +0000 Subject: [PATCH] fix: resolve all TypeScript LSP errors in CLI package MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1. CLI tsconfig: disable composite/declaration/declarationMap, enable noEmit — CLI runs via bun, never compiled by tsc. Eliminates all TS6059/TS6307 rootDir errors. 2. Use conditional spread to filter undefined values before passing to renderAsync/renderDirect/tag — satisfies exactOptionalPropertyTypes. 3. Fix TS2304: schemaHash not in scope in template delete catch block, use schemaInput instead. Fixes #36 --- packages/cli/src/index.ts | 26 +++++++++++++------------- packages/cli/tsconfig.json | 6 ++++-- 2 files changed, 17 insertions(+), 15 deletions(-) diff --git a/packages/cli/src/index.ts b/packages/cli/src/index.ts index 90f0b24..8d9f034 100644 --- a/packages/cli/src/index.ts +++ b/packages/cli/src/index.ts @@ -576,9 +576,9 @@ async function cmdRender(args: string[]): Promise { // Otherwise, use renderDirect for inline rendering of the envelope value. if (typeof envelope.value === "string" && isHash(envelope.value)) { const output = await renderAsync(store, envelope.value as Hash, { - resolution, - decay, - epsilon, + ...(resolution !== undefined && { resolution }), + ...(decay !== undefined && { decay }), + ...(epsilon !== undefined && { epsilon }), varStore, }); process.stdout.write(output + "\n"); @@ -588,9 +588,9 @@ async function cmdRender(args: string[]): Promise { envelope.value, store, { - resolution, - decay, - epsilon, + ...(resolution !== undefined && { resolution }), + ...(decay !== undefined && { decay }), + ...(epsilon !== undefined && { epsilon }), }, ); process.stdout.write(output + "\n"); @@ -598,9 +598,9 @@ async function cmdRender(args: string[]): Promise { } else { const hash = resolveHash(input as string, varStore); const output = await renderAsync(store, hash, { - resolution, - decay, - epsilon, + ...(resolution !== undefined && { resolution }), + ...(decay !== undefined && { decay }), + ...(epsilon !== undefined && { epsilon }), varStore, }); // Output to stdout without JSON wrapping (raw output) @@ -767,9 +767,9 @@ async function cmdVarTag(args: string[]): Promise { const { tags, labels, deleteNames } = parseTagsLabels(tagArgs); const variable = varStore.tag(name, schema, { - add: Object.keys(tags).length > 0 ? tags : undefined, - addLabels: labels.length > 0 ? labels : undefined, - delete: deleteNames.length > 0 ? deleteNames : undefined, + ...(Object.keys(tags).length > 0 && { add: tags }), + ...(labels.length > 0 && { addLabels: labels }), + ...(deleteNames.length > 0 && { delete: deleteNames }), }); await out( @@ -1040,7 +1040,7 @@ async function cmdTemplateDelete(args: string[]): Promise { ); } catch (e) { if (e instanceof VariableNotFoundError) { - die(`Error: Template not found for schema: ${schemaHash}`); + die(`Error: Template not found for schema: ${schemaInput}`); } throw e; } finally { diff --git a/packages/cli/tsconfig.json b/packages/cli/tsconfig.json index 75eba9f..fb5a197 100644 --- a/packages/cli/tsconfig.json +++ b/packages/cli/tsconfig.json @@ -1,8 +1,10 @@ { "extends": "../../tsconfig.json", "compilerOptions": { - "rootDir": "src", - "outDir": "dist" + "composite": false, + "declaration": false, + "declarationMap": false, + "noEmit": true }, "include": ["src"] } -- 2.43.0