no-null: calls on values declared with a package's type go outside; bench without dev checks #46
Loading…
Reference in a new issue
No description provided.
Delete branch "evobug/no-null-package-receivers"
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?
From the TwitchRTS comparison report: the server converts SQLite
NULLs at the row boundary and had to work around Node refusingundefinedas a parameter.no-nullvalidate<Row>(row)turns thenullof an optional field intoundefined, also for SQLite's null-prototype row objects.statement.run({ note: note ?? null })was reported whenever the statement was a class field, a parameter or a local, which is how statements are always held. Only a value that came straight from a package import counted as outside code.thisfields and constructor parameter properties;Option<…>,Mut<…>,Readonly<…>and… | undefined.nullargument.null_package_receivers.Docs
validate<T>, and?? nullin the parameters.no-null.mdlists the new case.Bench
npm run benchnow runs withSAFE_TS_DEV_CHECKS=0.matchmeasured 1.71× a hand-written switch instead of 0.89×: the misleading result the docs already warn about.Verification
npm run build, typecheck, typecheck:emit and the docs build pass.🤖 Generated with Claude Code
Node's SQLite takes null for SQL NULL and refuses undefined, but `statement.run({ note: note ?? null })` was reported when the statement was a class field (`#insert: StatementSync`), a parameter (`db: DatabaseSync`) or a local made from one. Only values that came straight from a package import counted as outside code. Now bindings, `this` fields and constructor parameter properties declared with a package's type (also through Option / Mut / Readonly / `| undefined`), or made from one, are outside receivers. Std types don't count. Docs: the absence guide shows the SQLite pattern (rows through validate<T>, `?? null` in parameters); the no-null page lists the new case. `npm run bench` now runs with SAFE_TS_DEV_CHECKS=0: with the checks on, match measured 1.71x a hand-written switch instead of 0.89x. Co-Authored-By: Claude Opus 5.5 <[email protected]>