Conversation
`yarn lint` exits non-zero on master with 4 errors and 2 warnings. CI only runs
`yarn test`, so nothing has been enforcing it.
* createModelSchema.ts — deletes `const x: Clazz<any> = Object;`, dead
module-scope debris sitting after the function body.
* utils.ts — `ar.filter((x) => true)` becomes `ar.filter(() => true)`. Same
behaviour, including the sparse-array counting the comment refers to, since
`filter` still skips holes.
* deserialize.ts — two missing semicolons, via `eslint --fix`.
* serialize.ts — drops an `as Serialized<T>[]` that the compiler already
infers.
* serialize.ts — replaces `Function` in `FunctionKeys<T>`.
That last one is not the obvious substitution, so it is worth stating why.
The usual replacement for a banned `Function` is `(...args: any[]) => any`,
but that is NOT equivalent in a conditional type: it does not match class
constructors, whereas `Function` does. Verified with tsc — for a class `C`,
`typeof C extends Function` is true while `typeof C extends (...args: any[]) =>
any` is false. Since `FunctionKeys<T>` exists to exclude function-valued
properties from `Serialized<T>`, the naive fix would silently start including
constructor-valued properties and recursing into them. The introduced
`AnyFunction` unions a call signature with a construct signature, preserving
the original breadth.
serialize.ts is not prettier-clean on master (tabs in that block, and a
signature past printWidth). Left alone rather than reformatted, so this diff
stays reviewable; the four files I did touch are prettier-clean.
Verified: `yarn lint` exits 0, `tsc -p tsconfig.json` and
`tsc -p test/typescript/tsconfig.json` both clean, `yarn build` clean, and
`yarn test` passes 70/70.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This branch has not been deployed
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.
yarn lintexits non-zero onmaster— 4 errors, 2 warnings. CI runs onlyyarn test, so nothing has been enforcing it.The five easy ones
createModelSchema.ts— deletesconst x: Clazz<any> = Object;, dead module-scope debris sitting after the function's closing brace.utils.ts—ar.filter((x) => true)→ar.filter(() => true). Identical behaviour, including the sparse-array counting the adjacent comment refers to, sincefilterstill skips holes.deserialize.ts— two missing semicolons, applied witheslint --fix.serialize.ts— drops anas Serialized<T>[]the compiler already infers.The one that isn't obvious
Replacing
FunctioninFunctionKeys<T>. The usual substitution is(...args: any[]) => any, but that is not equivalent inside a conditional type — it doesn't match class constructors, whereasFunctiondoes. Verified with tsc:FunctionKeys<T>exists to exclude function-valued properties fromSerialized<T>, so the naive fix would silently start including constructor-valued properties and recursing into them as objects. Since this is type-level only, no runtime test would have caught it.So the PR introduces
AnyFunction, unioning a call signature with a construct signature to preserve the original breadth:One thing deliberately not done
serialize.tsis not prettier-clean on master — tabs in theFunctionKeysblock, and the implementation signature runs pastprintWidth: 100. I matched the file's local style instead of reformatting, so this diff stays two lines rather than a whole-file churn that buries the actual change. The four files I did touch are prettier-clean. Happy to send the reformat separately if you'd like it.Verified
yarn lintexits 0.tsc -p tsconfig.jsonandtsc -p test/typescript/tsconfig.jsonboth clean — the second matters, since it's what exercisesSerialized<T>against real usage.yarn buildclean.yarn test70/70.🤖 Generated with Claude Code