Calls nobody wrote: implicitly called methods must not fail; an override must not ask for more #125
Loading…
Reference in a new issue
No description provided.
Delete branch "implicit-calls"
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
borrow-escapes(#122), the top of the chain (#119, #120, #121, #123, #116, #122); the diff shown is this piece alone. It does not depend on theMutchange and can be moved below #116 if a non-breaking release should carry it.Two holes of one family: code runs that no call in the source names, so the rules that follow calls never see it. Both passed
tscstrict,safe-ts check --deny-warningsand oxlint.implicit-propagation(error)A method the language calls for you must not be able to fail. It is reported where the method is written, because the places that call it (
String(x), a template,JSON.stringify,for...of,await) are everywhere and mostly untyped, so following them could never be complete, while the definition is one place.toString,valueOf,[Symbol.toPrimitive],toLocaleStringString(x),+x,x < y,jointoJSONJSON.stringify, at any depth[Symbol.iterator],[Symbol.asyncIterator], an iterator'snextfor...of, spread, destructuring,Array.from,for await[Symbol.dispose],[Symbol.asyncDispose]usingat block endthenon a non-promiseawait,Promise.resolve[Symbol.hasInstance]and the other well-known symbols,Proxytraps, an object literal's getters and settersWhat to write instead: handle the failure inside and return a value that says so, or offer a named method. For iteration that is a named generator (
for (const row of table.rows())), which is followed where it is stepped, also through spread andArray.from.override-parameter(error)TypeScript compares a class method's parameters both ways against the method it overrides or implements, so an override may ask for more than its base promises. The rule reports exactly the cells
tscleaves unchecked (the table is on the rule's page): a narrower parameter, a required parameter where the base's is optional or a rest, a writable list where the base takes areadonlyone; on base methods, abstract methods, statics, and an arrow property over a method. An earlier change (no-method-signature) closed the interface half; this is the class half.With no type checker, "narrower" is not decidable in general, so each pair of written types gets one of three answers and only a proven "no" is reported. Proven fine: the same type after opening aliases,
unknown, a union containing the base's type, an object type asking for a subset,readonlyover the writable form, and a wider class. "Wider" is known for the program's classes and interfaces, and for the platform's from data: 406 class-to-parent pairs generated from the DOM library and checked in Chromium, Firefox and WebKit, the language'sErrorfamily, and Node's maps. Sooverride on(event: Event)over a base takingMouseEventis silent. A package's class nobody describes, under a different name, is unknown and silent.Evidence
toStringthat fails through a call and an inheritedtoJSON; a method that catches inside or handles aResultis silent. For overrides: generics bound throughextends Box<Dog>, two levels of inheritance, statics, the arity shapes, and the wider forms in both directions.Proxytraps in tests); all were read and none can fail. None of its classes overrides a method of another of its own classes.implicit-toPrimitive-throwis closed, and four classes were added and closed (iteration,toJSON,valueOf, the override). 2 of 58 escape: division by zero and one documentedMuthole.What turns red on upgrade
A destructured getter, a tagged template's tag and a decorator are now followed, so a failure that reaches a caller only through one of them is reported as
uncaught-propagationorunhandled-failurewhere it was silent.What stays unseen
defineProperty; one inherited from a package's class; aProxyhandler not written at thenew Proxycall.unhandled-failure).Created with Claude Opus 5.5 (implementation) and Claude Fable 5.2 (review and acceptance tests) in Claude Code.