Escape hatches, round two: markers need permission, every spelling of a hatch is counted, declare is a cast #119
Loading…
Reference in a new issue
No description provided.
Delete branch "escape-hatches-2"
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?
Based on
sentinel-values(#118). The open pieces above #118 form one chain, each branch containing the ones below it: #119, #120, #121, #123, then #116 and #122. Merge them in that order. This is the bottom of the chain.An agent aims at "the checker passes", so every way of making it pass without fixing the code gets used. The check already counts its escape hatches and ratchets them against a baseline. Four ways around that were still open. Each passed
tscstrict,safe-ts check --deny-warningsand oxlint with the preset:What changes
File markers need permission.
// @safe-ts stdand// @safe-ts legacyare honoured only in files the project lists under"trustedFiles"/"legacyFiles"in package.json. An unlisted marker is an error (unlisted-marker), and the file is checked, transformed and followed as if the marker were not there, so writing the comment gains nothing. The CLI, editor, oxlint plugin, Vite plugin and Node loader decide through one function. Markers insidenode_modulesstay honoured.Lint suppressions are counted, and the ones that silence SAFE-TS are reported (
no-lint-suppression). Everyeslint-disable*/oxlint-disable*form, in.ts,.tsxand Vue scripts and templates. Reported: a blanket one, one naming asafe-ts/rule, and one naming a rule the preset sets to error (no-eval,no-new-func, ...) without-- reason. vue-tsc's template comments (@vue-ignore,@vue-skip,@vue-expect-error) get the treatment@ts-ignoreand@ts-expect-erroralready have.The same at configuration level. An
.oxlintrc.jsonthat does not extend the preset, turns one of its rules off or down, or leaves files out is listed under "weakened below the defaults" and ratcheted like package.json's settings.Ambient declarations (
no-unchecked-declare). Everydeclareform and the project's own.d.tsfiles are counted. Reported: the forms that assert a value nobody checks, such asdeclare const x: Config,declare function,declare class, a required member added to a built-in or to a package's interface, a bodilessdeclare module "x";, anddeclare value: stringon a class field. Only counted: a declaration typedunknownor admittingundefined, optional members, wildcard asset modules with a body, and new types.Every spelling of a hatch is counted.
trust,unsafe,panicanddefineSanitizerwere counted only when called by their imported name. Now a namespace import, a copy,.call, a computed member, a hatch stored in an object or a field, and a re-export all count; a use the checker cannot follow counts once, so the count can only be too high. A package linked into the workspace is recognised by its package.json name.The ratchet covers all of it. The new counts are in the summary line,
--jsonand the baseline, and a test holds the three together.What turns red on upgrade
safe-ts checkprints, per package.json, the exact"trustedFiles"/"legacyFiles"lines to add, with every marked file it found..d.tsfiles and 12 source files with declarations. A bundler-injected constant typedstring, avirtual:module with a typed default,declare module '*.css';, and two required globals in test support code. The 12 others (optional members, globals typedOption<T>) are counted only.That project gets 8 new findings in all: those 5, and one file whose
stdmarker is no longer honoured until listed, with the cast and the object dictionary it was hiding. Nothing is lost. Its hatch counts are unchanged; it uses no other spelling of a hatch.Review
The implementer's first round counted hatches by imported name only, which my held-out cases showed was the piece's own hole:
r.trust<T>(x)passed the baseline gate with no finding. The second round replaced the per-name counters with one pass over every reference. I also checked mismatched lists (alegacymarker in a file listed as trusted is refused), markers below the header, block and JSDoc forms, and that// safe-ts-ignore unlisted-markerabove a marker gains nothing.Four classes were added to the soundness corpus (a cast behind an unlisted
stdorlegacymarker, behind adeclare, behind a required member on a built-in). All escaped at the starting commit and are rejected now.What stays unseen
declare global, and members brought in byextends.Option<T>before it is set..oxlintrc.json: the files itsextendsnames, nested configs,oxlint -c, and JavaScript configs (one next to the package.json is a setup warning).Created with Claude Opus 5.5 (implementation) and Claude Fable 5.2 (review, acceptance tests and one fix) in Claude Code.
.oxlintrc.json, the file that sets themResultkept in a local #120promise-as-value,floating-promise#121this, parts handed out, kept copies, wider aliases, loans alive at once #122