Repository navigation
test(unit): drive the runtime refusals from plain-JS specs instead of @ts-expect-error - #93
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
Antony wants every suppression
guardrails.suppressions.jsonallows in this repo brought to zero by fixing the code it hides (ANT-1090). The 56@ts-expect-errorwere all in unit specs that pass a value the types forbid on purpose, to check a runtime refusal. Those refusals exist for callers the type checker never sees: plain-JS modules and version skew. Antony chose to test them the way such a caller reaches them, from plain JavaScript. This PR does that and lowerstsExpectErrorfrom 56 to 0.What
tsconfig.jsonsetsallowJs: true(checkJsstays off) and addssrc/**/*.jstoinclude. The build compiles each*.untyped.spec.jsintodist/test, where mocha andajs module testalready look.*.untyped.spec.jssibling of its TS spec. It keeps itsdescribeandittitles and its assertions. One file per TS spec, 21 in all.pipeline-lambda-idswas all such tests, so it became JS whole.feeds-fixture.ts,selection-fixture.ts,pipeline-fold-fixture.tsandconfig-fixture.ts. They are moved, not rewritten.expression-fixtureorexpression-array-fixture. The tests they came from used a file-local copy of the same context. The fields those tests read (age,name,createdAt) have the same types in both.REFUSED(readonly unknown[]) and one rejection callback parameter (unknown).No production code changes.
flowchart LR subgraph before ts1["*.spec.ts"] -- "@ts-expect-error + bad value" --> guard1[runtime refusal] end subgraph after ts2["*.spec.ts"] --> typed[typed behaviour] js["*.untyped.spec.js<br/>(no type checking, like a JS caller)"] -- bad value --> guard2[runtime refusal] fx["*-fixture.ts"] --> ts2 fx --> js endSAFETY comments added
None.
Proof
pnpm run checks:Checks: 11 passed, 0 failed.Same tests before and after. The unit suite, run as mocha JSON on base and head, compared by full test title and how often each title appears:
The JS specs reach the refusals. The CROSS_INSTANCE refusal in
NormalizeInstanceIdis disabled on purpose, then restored:API: 1 packages, 1 entries unchanged against origin/main (committed HEAD).
API: skipped .agents/skills/verify-module, private.
Runtime API: 1 packages, 1 entries unchanged against origin/main (committed HEAD).
No behavioural probe ran.
Suppressions in authored code files (origin/main and committed HEAD). A lint directive counts once per rule it names;
*is a directive naming none.anti-slop/no-unknown-parameters@ts-expect-error@ts-ignoreSAFETY:comments