diff --git a/.changeset/tame-ways-tan.md b/.changeset/tame-ways-tan.md new file mode 100644 index 00000000..22a8d558 --- /dev/null +++ b/.changeset/tame-ways-tan.md @@ -0,0 +1,5 @@ +--- +"@cartesi/cli": patch +--- + +fix the `runNodeCommand` declaration, which a consumer compiling with `exactOptionalPropertyTypes` rejected diff --git a/.github/workflows/cli.yaml b/.github/workflows/cli.yaml index f8438122..038a3543 100644 --- a/.github/workflows/cli.yaml +++ b/.github/workflows/cli.yaml @@ -43,6 +43,9 @@ jobs: - name: Type check run: bun run --cwd apps/cli typecheck:tsc + - name: Type check declarations + run: bun run --cwd apps/cli typecheck:declarations + - name: Test run: bun test apps/cli/ diff --git a/apps/cli/package.json b/apps/cli/package.json index 60b38e25..2b39c0f8 100644 --- a/apps/cli/package.json +++ b/apps/cli/package.json @@ -65,6 +65,7 @@ "posttest": "bun lint", "test": "bun test", "typecheck": "run-s codegen typecheck:tsc", + "typecheck:declarations": "tsc -p tsconfig.declarations.json", "typecheck:tsc": "tsc" }, "engines": { diff --git a/apps/cli/src/exec/node-container.ts b/apps/cli/src/exec/node-container.ts index 3a0502ec..c6836eb4 100644 --- a/apps/cli/src/exec/node-container.ts +++ b/apps/cli/src/exec/node-container.ts @@ -1,4 +1,4 @@ -import { ExecaError, execa } from "execa"; +import { ExecaError, execa, type ResultPromise } from "execa"; import { type Hex, isHex } from "viem"; import type { CartesiEnvironmentVariables } from "../base.js"; @@ -83,7 +83,7 @@ export const runNodeCommand = (options: { env?: Record; projectName: string; stdout?: "stdout" | "stderr"; -}) => +}): ResultPromise => execa( "docker", nodeExecArgs({ ...options, interactive: !!process.stdin.isTTY }), diff --git a/apps/cli/tsconfig.declarations.json b/apps/cli/tsconfig.declarations.json new file mode 100644 index 00000000..0b9c53ca --- /dev/null +++ b/apps/cli/tsconfig.declarations.json @@ -0,0 +1,15 @@ +{ + // type-check the published declarations as a strict consumer would, with + // exact optional types and the library check on: our own build skips both + "compilerOptions": { + "target": "ES2022", + "module": "NodeNext", + "moduleResolution": "NodeNext", + "strict": true, + "exactOptionalPropertyTypes": true, + "skipLibCheck": false, + "noEmit": true, + "types": ["node"] + }, + "files": ["dist/types/lib.d.ts"] +}