Skip to content

fix(pstack): satisfy strict typecheck in statechart run.ts and CLI tests - #1148

Open
surlymochan wants to merge 1 commit into
cursor:mainfrom
surlymochan:fix/1141-statechart-typecheck
Open

surlymochan wants to merge 1 commit into
cursor:mainfrom
surlymochan:fix/1141-statechart-typecheck

Conversation

@surlymochan

Copy link
Copy Markdown
Contributor

Fixes #1141

Why

tsc -p tsconfig.json in pstack/skills/statechart/scripts (strict config, TypeScript 7.0.2, @types/node 26.1.2) reports four errors:

  • run.ts(455) and run.ts(471): the exit in the shared common object is inferred as number, which is not assignable to CheckResult.exit (0 | 1 | 2).
  • test/cli.test.ts(430) and test/cli.test.ts(453): two test callbacks return signalWhile(...), whose promise resolves to the phase object; Node's TestFn requires void | Promise<void>.

CI does not run tsc, so nothing flags this today; anyone typechecking the package locally hits it immediately.

What changed

  • run.ts: annotate exitClass with the return type CheckResult["exit"]. The ternary already only ever produces 0, 1, or 2; the annotation stops the literal union from widening to number at the source, so both check() return sites typecheck.
  • test/cli.test.ts: the two callbacks now await signalWhile(...) in an async block body instead of returning its promise — the same shape the neighbouring signal test in this file already uses.
  • Regenerated harness/pstack/ with scripts/generate-pstack-harness-trees.mjs; the two generated copies carry the same edits.

Scope

Type-level only. No runtime behaviour changes: exitClass computes the same values as before, and the test callbacks still await the same signalWhile promise — only its resolution value is no longer returned to the test runner. No other files touched; plugin.json untouched.

Blast Radius

Confined to the statechart skill's scripts and their generated harness copies. The only consumers of exitClass are its two call sites inside run.ts, both internal to check().

Verification

One combined run on this branch:

  • node scripts/generate-pstack-harness-trees.mjs --check — "harness/pstack is up to date"
  • node scripts/validate-plugins.mjs — all plugins validated successfully
  • tsc -p tsconfig.json in pstack/skills/statechart/scripts (typescript@7.0.2 and @types/node@26.1.2 installed as in pstack statechart: strict typecheck reports four errors in run.ts and CLI tests #1141's repro) — exits 0; before this change it reported exactly the four errors listed above
  • node --disable-warning=ExperimentalWarning --test pstack/skills/*/scripts/test/*.test.ts — 334 tests: 267 pass, 0 fail, 67 skipped (the skipped ones shell out to TLC and self-skip when TLA2TOOLS is unset)

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

1 participant