Typecheck package test trees and fix the drift they were hiding#941
Conversation
|
Warning Review limit reached
Next review available in: 33 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Path: .coderabbit.yml Review profile: CHILL Plan: Pro Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (42)
📝 WalkthroughWalkthroughThis PR expands multiple package tsconfig includes to compile test sources and updates parser, printer, mongo emitter, and sql test fixtures to match revised helper types, storage hashes, relation references, and generated type expectations. ChangesTest infrastructure and fixture updates
Estimated code review effort: 4 (Complex) | ~60 minutes Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
@prisma-next/extension-author-tools
@prisma-next/mongo-runtime
@prisma-next/family-mongo
@prisma-next/sql-runtime
@prisma-next/family-sql
@prisma-next/extension-arktype-json
@prisma-next/middleware-cache
@prisma-next/mongo
@prisma-next/extension-paradedb
@prisma-next/extension-pgvector
@prisma-next/extension-postgis
@prisma-next/postgres
@prisma-next/sql-orm-client
@prisma-next/sqlite
@prisma-next/extension-supabase
@prisma-next/target-mongo
@prisma-next/adapter-mongo
@prisma-next/driver-mongo
@prisma-next/contract
@prisma-next/utils
@prisma-next/config
@prisma-next/errors
@prisma-next/framework-components
@prisma-next/operations
@prisma-next/ts-render
@prisma-next/contract-authoring
@prisma-next/ids
@prisma-next/psl-parser
@prisma-next/psl-printer
@prisma-next/cli
@prisma-next/cli-telemetry
@prisma-next/config-loader
@prisma-next/emitter
@prisma-next/language-server
@prisma-next/migration-tools
prisma-next
@prisma-next/vite-plugin-contract-emit
@prisma-next/mongo-codec
@prisma-next/mongo-contract
@prisma-next/mongo-value
@prisma-next/mongo-contract-psl
@prisma-next/mongo-contract-ts
@prisma-next/mongo-emitter
@prisma-next/mongo-schema-ir
@prisma-next/mongo-query-ast
@prisma-next/mongo-orm
@prisma-next/mongo-query-builder
@prisma-next/mongo-lowering
@prisma-next/mongo-wire
@prisma-next/sql-contract
@prisma-next/sql-errors
@prisma-next/sql-operations
@prisma-next/sql-schema-ir
@prisma-next/sql-contract-psl
@prisma-next/sql-contract-ts
@prisma-next/sql-contract-emitter
@prisma-next/sql-lane-query-builder
@prisma-next/sql-relational-core
@prisma-next/sql-builder
@prisma-next/target-postgres
@prisma-next/target-sqlite
@prisma-next/adapter-postgres
@prisma-next/adapter-sqlite
@prisma-next/driver-postgres
@prisma-next/driver-sqlite
commit: |
size-limit report 📦
|
f279f3c to
0a4a5df
Compare
There was a problem hiding this comment.
🧹 Nitpick comments (2)
packages/2-mongo-family/3-tooling/emitter/test/generate-orm-fixture.ts (1)
17-38: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winRedundant whole-object
as Contractcast undercuts the narrowerblindCastfix.The variable is already declared
const contract: Contract = {...}, anddomainis already narrow-cast viablindCast. The trailing} as Contract;casts the entire object anyway, which can silently mask type errors on any other field (e.g.,roots,storage) that the narrower casts were specifically introduced to avoid.♻️ Proposed fix
meta: {}, -} as Contract; +};If this still fails to typecheck without the cast, that likely indicates an actual mismatch worth narrowing further (similar to how
domainwas handled) rather than casting the whole object.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/2-mongo-family/3-tooling/emitter/test/generate-orm-fixture.ts` around lines 17 - 38, The trailing whole-object cast on the contract fixture undermines the narrower `blindCast` workaround and can hide real type issues in `roots`, `storage`, or other fields. Remove the final `as Contract` from the `contract` object in `generate-orm-fixture.ts`, keep the explicit `const contract: Contract` annotation, and if typechecking breaks, narrow the specific mismatching field instead of casting the entire object.packages/2-mongo-family/3-tooling/emitter/test/fixtures/create-mongo-contract.ts (1)
34-51: 🗄️ Data Integrity & Integration | 🔵 Trivial | ⚡ Quick winSibling
profileHashliteral left unconverted.
storageHashwas just migrated tocoreHash(...), butprofileHash: 'sha256:test' as const(line 49) in the same function remains a raw string, unlikegenerate-orm-fixture.tsin this cohort which usesprofileHash('sha256:orm-profile')for the equivalent field. The trailing} as Contract;on line 51 likely hides any type mismatch here.♻️ Proposed fix
+import { coreHash, profileHash } from '`@prisma-next/contract/types`'; ... - profileHash: 'sha256:test' as const, + profileHash: profileHash('sha256:test'),Please confirm whether
Contract['profileHash']is a branded type requiring theprofileHash(...)constructor (asstorageHashrequirescoreHash(...)).🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/2-mongo-family/3-tooling/emitter/test/fixtures/create-mongo-contract.ts` around lines 34 - 51, The create-mongo-contract fixture still sets profileHash as a raw string, unlike the migrated storageHash and the equivalent generate-orm-fixture helper. Update the createMongoContract fixture to construct profileHash with the proper profileHash(...) branded constructor (or otherwise confirm the Contract['profileHash'] type and align with its required factory) so the returned Contract matches the expected branded type instead of relying on the final cast.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In
`@packages/2-mongo-family/3-tooling/emitter/test/fixtures/create-mongo-contract.ts`:
- Around line 34-51: The create-mongo-contract fixture still sets profileHash as
a raw string, unlike the migrated storageHash and the equivalent
generate-orm-fixture helper. Update the createMongoContract fixture to construct
profileHash with the proper profileHash(...) branded constructor (or otherwise
confirm the Contract['profileHash'] type and align with its required factory) so
the returned Contract matches the expected branded type instead of relying on
the final cast.
In `@packages/2-mongo-family/3-tooling/emitter/test/generate-orm-fixture.ts`:
- Around line 17-38: The trailing whole-object cast on the contract fixture
undermines the narrower `blindCast` workaround and can hide real type issues in
`roots`, `storage`, or other fields. Remove the final `as Contract` from the
`contract` object in `generate-orm-fixture.ts`, keep the explicit `const
contract: Contract` annotation, and if typechecking breaks, narrow the specific
mismatching field instead of casting the entire object.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yml
Review profile: CHILL
Plan: Pro
Run ID: 177e96ea-e77e-4da0-a84f-abfd0067b423
⛔ Files ignored due to path filters (1)
pnpm-lock.yamlis excluded by!**/pnpm-lock.yaml
📒 Files selected for processing (42)
packages/1-framework/2-authoring/contract/tsconfig.jsonpackages/1-framework/2-authoring/ids/tsconfig.jsonpackages/1-framework/2-authoring/psl-parser/test/attribute-helpers.test.tspackages/1-framework/2-authoring/psl-parser/test/attribute-spec-combinators.test.tspackages/1-framework/2-authoring/psl-parser/test/attribute-spec.test-d.tspackages/1-framework/2-authoring/psl-parser/test/attribute-spec.test.tspackages/1-framework/2-authoring/psl-parser/test/named-type-declaration.test-d.tspackages/1-framework/2-authoring/psl-parser/test/symbol-table.test.tspackages/1-framework/2-authoring/psl-parser/test/syntax/navigation.test.tspackages/1-framework/2-authoring/psl-parser/tsconfig.jsonpackages/1-framework/2-authoring/psl-printer/package.jsonpackages/1-framework/2-authoring/psl-printer/test/fixtures/declarative-policy-select-extension.tspackages/1-framework/2-authoring/psl-printer/test/generic-extension-block-printer.test.tspackages/1-framework/2-authoring/psl-printer/test/print-psl-from-ast.test.tspackages/1-framework/2-authoring/psl-printer/tsconfig.jsonpackages/1-framework/3-tooling/cli/tsconfig.jsonpackages/1-framework/3-tooling/vite-plugin-contract-emit/tsconfig.jsonpackages/2-mongo-family/3-tooling/emitter/test/emitter-hook.generation.test.tspackages/2-mongo-family/3-tooling/emitter/test/emitter-hook.resolve-field-value-set.test.tspackages/2-mongo-family/3-tooling/emitter/test/emitter-hook.structure.test.tspackages/2-mongo-family/3-tooling/emitter/test/emitter-hook.value-set-codec-path.test.tspackages/2-mongo-family/3-tooling/emitter/test/fixtures/blog-contract.tspackages/2-mongo-family/3-tooling/emitter/test/fixtures/create-mongo-contract.tspackages/2-mongo-family/3-tooling/emitter/test/generate-orm-fixture.tspackages/2-mongo-family/3-tooling/emitter/tsconfig.jsonpackages/2-sql/1-core/contract/test/contract-typemaps-shape.test.tspackages/2-sql/1-core/contract/test/domain-types.test.tspackages/2-sql/1-core/contract/test/foreign-key-cross-space.test.tspackages/2-sql/1-core/contract/test/resolve-storage-table.test.tspackages/2-sql/1-core/contract/test/sql-storage.test.tspackages/2-sql/1-core/contract/test/storage-column-many.test.tspackages/2-sql/1-core/contract/test/test-support.tspackages/2-sql/1-core/contract/test/validators.test.tspackages/2-sql/1-core/contract/tsconfig.jsonpackages/2-sql/3-tooling/emitter/test/create-emitter-test-contract.tspackages/2-sql/3-tooling/emitter/test/emitter-hook.generation.advanced.test.tspackages/2-sql/3-tooling/emitter/test/emitter-hook.generation.basic.test.tspackages/2-sql/3-tooling/emitter/test/emitter-hook.parameterized-types.test.tspackages/2-sql/3-tooling/emitter/test/emitter-hook.structure.test.tspackages/2-sql/3-tooling/emitter/test/emitter-hook.types.test.tspackages/2-sql/3-tooling/emitter/test/sql-storage-fixture.tspackages/2-sql/3-tooling/emitter/tsconfig.json
💤 Files with no reviewable changes (1)
- packages/2-sql/3-tooling/emitter/test/emitter-hook.types.test.ts
Ten packages had a tsconfig that only included src/, so their test files
were never typechecked. Errors in the tests therefore accumulated
silently — the trigger was psl-printer tests constructing
PslExtensionBlock literals without the now-required blockAttributes field.
Align every package tsconfig with the repo convention of including
test/**/*.ts, then fix the ~400 pre-existing type errors this surfaced.
The errors were entirely test-side drift from current IR shapes: storage
fixtures using the removed {tables} shape instead of
namespaces.<id>.entries.table, missing required storageHash, plain
strings where branded NamespaceId/hash types are now required, and
property access on index-signature maps. Fixes use the repo factories and
hash constructors (coreHash/profileHash, crossRef) rather than hand-forced
literals; assertions are unchanged.
cli was config-only: dropped an over-tight rootDir (its test fixtures
import a shared helper across a package boundary by relative path, an
established pattern here) and bumped lib to ES2024 for Promise.withResolvers.
Two genuine test-code bugs surfaced and were fixed: a stray [] argument
in generateContractDts call sites (sql + mongo emitters) and a dev
fixture script with a stale call signature.
No production src/ changed. Verified: repo-root pnpm typecheck (143 tasks)
and each package pnpm test are green.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Signed-off-by: willbot <w.a.madden+machine@gmail.com>
Signed-off-by: Will Madden <madden@prisma.io>
0a4a5df to
6d4cc78
Compare
…ge fix) The native-enum PRs (#941/#944/#946) added infer-psl-contract.enum-adoption.test.ts, which constructs a PostgresTableSchemaNode; this slice made rlsEnabled a required field, so the merged tree failed the (now stricter, per #941) typecheck. Supply rlsEnabled: false at the one construction site — the same mechanical ripple every other construction site in this slice already carries. Signed-off-by: willbot <w.a.madden+machine@gmail.com> Signed-off-by: Will Madden <madden@prisma.io>
Ten workspace packages had a
tsconfig.jsonwhoseincludewas["src/**/*.ts"], so theirtest/trees were never typechecked. Type errors in those tests accumulated silently over time. The concrete trigger:psl-printertests constructPslExtensionBlockliterals without the now-requiredblockAttributesfield, and nothing caught it.What this does
Aligns every one of those package tsconfigs with the repo convention (the other 30 packages already include
test/**/*.ts), then fixes the type errors that surfaced — roughly 400 across five packages, all pre-existing test-side drift.The drift that was hidden
The tests had fallen out of sync with the current IR shapes:
{ tables: {...} }shape instead of{ storageHash, namespaces: { <id>: { entries: { table: {...} } } } }, and omitted the now-requiredstorageHash.stringpassed whereNamespaceId/StorageHashBaseare now required.obj.FoowherenoPropertyAccessFromIndexSignaturerequiresobj["Foo"].PslExtensionBlock,ContractModelBase,PslAttribute, etc.Fixes build objects through the repo’s factories and hash constructors (
coreHash/profileHash,crossRef) rather than hand-forced literals or casts, per theuse-contract-ir-factories,use-hash-constructors, andno-contract-data-patching-in-testsrules. No test assertion was weakened.Two genuine bugs in test/dev code turned up and were fixed: a stray
[]argument shiftinggenerateContractDtscall sites (sql + mongo emitters), and a dev fixture script with a stale call signature.cliwas config-only: its test fixtures import a shared helper across a package boundary by relative path (an established pattern here), which conflicted with an over-tightrootDir; droppedrootDirand bumpedlibtoES2024forPromise.withResolvers.Scope
No production
src/changed — every fix is in test files, test-only fixtures/helpers, or tsconfig.Verification
pnpm typecheck— green (143 tasks).pnpm test— green.pnpm lint:depsand per-package biome lint — green.Note: 3 failing tests in
@prisma-next/config-loader(test/load.test.ts, c12 path resolution) are pre-existing onmainand unrelated to this change — verified by running that suite on a clean checkout ofHEAD. Not addressed here.🤖 Generated with Claude Code
Summary by CodeRabbit
readonlytype expectations, and safer token/model assertions).tsconfigcompilation scope to includetest/**/*.ts(instead of onlysrc/**/*.ts) across multiple packages.