Skip to content

pstack statechart: strict typecheck reports four errors in run.ts and CLI tests #1141

Open

Description

@freeacger

Summary

The statechart compiler in pstack 0.15.36 produces four TypeScript errors when checked with its existing scripts/tsconfig.json. I reproduced this on an unchanged copy of commit c742dd61706fbacc1b95f1a20b7b988cf096ce6c, using the pinned toolchain below.

There are two causes, each reported at two locations:

  • run.ts: the exit property in common is inferred as number, while CheckResult.exit requires 0 | 1 | 2. Both returns that spread common fail.
  • test/cli.test.ts: two test callbacks return signalWhile(...), whose promise resolves to the phase object. The Node TestFn type requires void | Promise<void>.

Reproduce

git clone --filter=blob:none --sparse https://github.com/cursor/plugins.git pstack-typecheck-repro
cd pstack-typecheck-repro
git sparse-checkout set pstack
git checkout --detach c742dd61706fbacc1b95f1a20b7b988cf096ce6c
cd pstack/skills/statechart/scripts

npm install --ignore-scripts --no-save --package-lock=false --no-audit --no-fund typescript@7.0.2 @types/node@26.1.2
./node_modules/.bin/tsc -p tsconfig.json --pretty false

No changes to source files or tsconfig.json are needed. The package's declared fast-check@4.5.3 dependency is installed along with the two explicit packages.

Environment used:

  • macOS, arm64
  • Node 24.13.0, npm 11.6.2
  • TypeScript 7.0.2, @types/node 26.1.2, fast-check 4.5.3

Actual result

The command exits 1 with these diagnostics, abbreviated:

run.ts(455,9): error TS2322: ... is not assignable to type 'CheckResult'.
  Types of property 'exit' are incompatible.
    Type 'number' is not assignable to type '0 | 1 | 2'.

run.ts(471,5): error TS2322: ... is not assignable to type 'CheckResult'.
  Types of property 'exit' are incompatible.
    Type 'number' is not assignable to type '0 | 1 | 2'.

test/cli.test.ts(430,5): error TS2345: ... is not assignable to parameter of type 'TestFn'.
  Type 'Promise<...phase object...>' is not assignable to type 'void | Promise<void>'.

test/cli.test.ts(453,5): error TS2345: ... is not assignable to parameter of type 'TestFn'.
  Type 'Promise<...phase object...>' is not assignable to type 'void | Promise<void>'.

Expected result and scope

Checking the existing strict TypeScript configuration should exit 0, or the supported compiler and Node type versions should be specified if a different toolchain is intended.

The package currently exposes a runtime test command rather than a typecheck command. I did not observe a CLI failure caused by these type errors: a passing-model smoke test exited 0, and a counterexample smoke test exited 1 with the expected report. This report concerns static checking with the versions above.

A contextual type for common that preserves CheckResult["exit"], and callbacks that await signalWhile without returning its phase object, appear to be the relevant correction points.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions