Fail closed: check counts what it did not see, and any nobody wrote becomes unknown (no-ts-suppression, no-hidden-any, strict-lib) #108
Loading…
Reference in a new issue
No description provided.
Delete branch "fail-closed"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
An agent aims at "the checker passes", so whatever the checker doesn't see gets shipped. I ran about 120 small programs through
safe-ts check --idiomatic,tsc7 (strict) and oxlint with the preset to find what all three accept. Two of the leaks were in the foundations, and this PR closes them. It is the first of a series; the next ones cover calls written another way, receivers the checker can't resolve, and built-ins that throw.1. The gate said "no problems" about code it never looked at
safe-ts check <dir>was refused."rules": { "no-any": "off" }in package.json printed "✓ no problems" and was not counted anywhere.@ts-nocheck,@ts-ignoreand@ts-expect-errorwere neither reported nor counted.--deny-warningslet through.Now
checktakes directories, names the source files its entries don't reach, and names every setting that checks less than the default.--deny-warningsfails on everything the run prints as a warning. A new rule,no-ts-suppression, reports@ts-nocheck,@ts-ignoreand an@ts-expect-errorwithout a reason.--write-baseline/--baselineratchet the escape hatches, weakened settings, files not checked, unresolved imports and warnings per rule.Two bugs found on the way are fixed too: whether a file counted as a test file depended on the checkout's path (a project under a directory named
testshadtest-only-helperoff everywhere), and the directory walker followed symlink loops.2.
anythat nobody wroteno-anybans the keyword, but TypeScript's lib hands outanyon its own. The worst case was our own advice:unsafe(() => JSON.parse(text)), the fixunhandled-failurerecommends, was typedResult<any, unknown>, so afterisErrthe value could be read or assigned as anything. The packs' generated safe versions did the same (json(body)returnedResult<any, unknown>).unsafe/unsafeAsyncgiveunknownfor a function that returnsany. No setup needed.@evobug_com/safe-ts-std/strict-lib, an opt-in types entry, retypesJSON.parse,response.json(),Array.isArray,new Array(n), an untypednew Map(),Object.create,Object.fromEntries,Reflect.getand a promise's rejection reason.checkwarns when the tsconfig doesn't load it.no-hidden-any, covers what types can't retype:event.data, a bareMessageEventor one with a claimed type argument,Function,history.state, Node'sworkerDataand worker messages.unknownwhere lib saysany.What an adopter will notice
These can turn a green build red; the CHANGELOG's Changed section says what to do about each.
--deny-warningsnow fails on unresolved imports, files not checked and setup warnings (a pack enabled but not installed,strict-libnot loaded,noUncheckedIndexedAccessoff).unsafe(() => JSON.parse(...))stops compiling: validate the value, or useparseJson<T>.no-ts-suppressionandno-hidden-any.How it was checked
test:std,typecheck, the docs examples (813 compile),test:viteand the docs site build pass.Array.isArrayon a union, awssocket's typedmessageevent, the project's own typed emitters) stays free of findings.no-hidden-any.process.initgroupswith an unknown user succeeds as root); the third commit gives that test a trigger that fails as either user.Not verified
strict-libdoes to a full adopter build undertscis not measured; the checkout I had could not resolve its workspace packages.event.datapassed straight to a parameter typedunknownthrough a contextually typed callback, which the checker can't see. Annotating the event clears it; the rule page lists this case.Created with Claude Opus subagents (implementation) and Claude Fable 5.2 (review and acceptance tests) in Claude Code.
anynobody wrote becomesunknown: unsafe(), strict-lib, no-hidden-any, the packs' safe versionsThe new test workflow runs as root, where `process.initgroups("no-such-user", 0)` succeeds: Node hands a user name straight to libc, which only fails on the `setgroups` permission. The trigger passed locally through `EPERM`, not through the unknown credential it was written for. It now names a group that doesn't exist, which Node refuses with `ERR_UNKNOWN_CREDENTIAL` before any system call. Co-Authored-By: Claude Fable 5.2 <[email protected]>