-
Notifications
You must be signed in to change notification settings - Fork 9
Code health improvement: Replace many uses of any + other stricter types
#1211
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR improves type safety by replacing many uses of any with unknown or stricter types, introducing generics for utility functions, and swapping ad-hoc typeof value === "object" checks for the new isRecord/isObject predicates.
- Replace
anyand broad object checks withunknown,isRecord, and type parameters. - Add
JSONValueimports and type annotations to core functions. - Introduce generics to
mergeObjectsand other utilities to enable stronger typing.
Reviewed Changes
Copilot reviewed 18 out of 18 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/toolshed/routes/ai/spell/handlers/fulfill.ts | Swap raw object checks for isRecord in sanitization |
| packages/runner/test/utils.test.ts | Update test schema literals with as const and add generics to mergeObjects |
| packages/runner/src/utils.ts | Strengthen extractDefaultValues and mergeObjects signatures and replace object checks |
| packages/runner/src/storage.ts | Replace deep typeof checks with isRecord in storage serialization |
| packages/runner/src/schema.ts | Add stricter types and use isRecord for JSON schema validation |
| packages/runner/src/runner.ts | Introduce generics and tighten types in runner logic |
| packages/runner/src/query-result-proxy.ts | Use isRecord in proxy guards |
| packages/runner/src/doc.ts | Harden isDoc check with isRecord |
| packages/runner/src/doc-map.ts | Use isRecord when traversing document maps |
| packages/runner/src/cell.ts | Switch to isRecord and isObject for cell updates |
| packages/memory/traverse.ts | Cast to JSONValue and narrow types in traversers |
| packages/js-runtime/interface.ts | Narrow runtime interface methods to unknown args/returns |
| packages/js-runtime/deno.json | Expand Deno permissions for environment variables |
| packages/builder/src/utils.ts | Use isRecord in value traversal |
| packages/builder/src/types.ts | Replace any with unknown in core builder types |
| packages/builder/src/recipe.ts | Use isRecord when naming recipe outputs |
| packages/builder/src/opaque-ref.ts | Guard external value mapping with isRecord |
| packages/builder/src/built-in.ts | Narrow LLM error fields to unknown |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cubic found 16 issues across 17 files. Review them in cubic.dev
React with 👍 or 👎 to teach cubic. Tag @cubic-dev-ai to give specific feedback.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cubic found 16 issues across 17 files. Review them in cubic.dev
React with 👍 or 👎 to teach cubic. Tag @cubic-dev-ai to give specific feedback.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few places where I agree with cubic, but otherwise, lgtm. Would also be ok to merge as is.
Replace `any` types with `unknown` throughout builder, js-runtime, memory, and runner packages to improve type safety and maintainability. Add proper type guards and assertions where needed. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
- tightened deepCopy and mergeObjects
402eff2 to
e76bcc6
Compare
Summary by cubic
Replaced most uses of the any type with unknown and added isRecord and isObject type guards for stricter type safety across builder, runner, js-runtime, and memory packages.