-
-
Notifications
You must be signed in to change notification settings - Fork 13
fix(type-check): try improving type checking performance #475
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
|
Note Other AI code review bot(s) detectedCodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review. WalkthroughSwitched many public array types to readonly, removed delegate-model branching in ORM result types, updated $transaction overloads to return ZenStackPromise, refactored the TypeScript schema generator to emit a generated SchemaType class and exported instance, and updated many generated schema files to use the class-based export. Changes
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes
Possibly related PRs
Poem
Pre-merge checks and finishing touches❌ Failed checks (2 warnings)
✅ Passed checks (1 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 |
|
Claude finished @ymc9's task —— View job PR Review: Type Checking Performance ImprovementsThis PR implements several strategic optimizations to improve TypeScript type checking performance. Based on my analysis of the changes across 31 files, here's my comprehensive review: ✅ Positive Changes1. ZenStackPromise EliminationImpact: Significant type checking performance improvement
2. Schema Generation RefactoringImpact: Faster compilation and cleaner generated code
3. Delegate Model Type SimplificationImpact: Reduced type complexity
4. Import Optimization
|
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.
Actionable comments posted: 0
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
packages/orm/src/client/contract.ts (1)
273-277: This is a breaking change requiring migration documentation or a major version bump.
ZenStackPromiseis not a simple type alias—it exposes acbcallback property that's part of the public API. The codebase validates this property in transaction operations (client-impl.ts:154):input.every((p) => p.then && p.cb). ReplacingZenStackPromisewith nativePromisewill break code that passes these promises to$transaction()because nativePromisedoesn't have acbproperty. Consumers relying on lazy evaluation (queries only execute when awaited) may also experience unexpected behavior changes.
♻️ Duplicate comments (1)
tests/e2e/orm/schemas/delegate/typecheck.ts (1)
54-64: Same TODO pattern for relation queries.This is the same discriminated union type narrowing test as lines 19-29, but for relation queries. Both tests are critical for validating type coverage in different query contexts.
See the comment on lines 19-29 for the detailed concern about tracking these TODOs.
🧹 Nitpick comments (5)
packages/orm/src/client/crud-types.ts (3)
62-83: Consider removing commented-out code or adding a TODO explaining why it's preserved.The commented-out delegate model branching logic spans ~20 lines. If this is intentionally disabled for type-checking performance improvements, consider either:
- Removing it entirely if it's no longer needed
- Adding a brief comment explaining why it's preserved (e.g.,
// TODO: Re-enable after performance optimization)Leaving substantial blocks of commented-out code without explanation can lead to maintenance confusion.
125-133: Same consideration forDelegateUnionResult- clean up or document intent.This type appears to be disabled in tandem with the
DefaultModelResultchange above. Consider the same cleanup approach for consistency.
2014-2016: Commented-outProviderSupportsDistinctcorresponds toFindArgssimplification.Same cleanup consideration as the other commented-out sections. If this type is no longer needed, removing it would reduce dead code.
tests/e2e/orm/schemas/delegate/typecheck.ts (1)
19-29: Track the TODO for discriminated union type narrowing.This commented-out test validates a critical TypeScript feature: discriminated union type narrowing based on the
assetTypediscriminator. Without this test, you're not validating that TypeScript correctly narrows the union type to allow accessing sub-model fields after a runtime check.Please verify:
- Is discriminated union narrowing for delegate models planned for implementation?
- Should this TODO be tracked in an issue to ensure it's not forgotten?
As per coding guidelines, type checking tests should validate TypeScript inference and type coverage. Consider either:
- Re-enabling this test if the feature works
- Creating an issue to track this missing type coverage
- Documenting why this behavior isn't supported
Would you like me to open an issue to track this feature?
packages/sdk/src/ts-schema-generator.ts (1)
182-291: Consider explicitreadonlymodifiers for class properties.The class properties rely on
as constfor type-level immutability, but lack runtimereadonlyprotection. While this works, explicitreadonlymodifiers would:
- Make immutability intent clearer
- Prevent accidental runtime mutations
- Align with best practices for schema definitions
The
pluginsproperty is appropriately left mutable (noas const), which seems intentional for runtime modifications.Example for immutable properties:
private createSchemaClass(model: Model, lite: boolean) { const members: ts.ClassElement[] = [ // provider ts.factory.createPropertyDeclaration( - undefined, + [ts.factory.createModifier(ts.SyntaxKind.ReadonlyKeyword)], 'provider', undefined, undefined, this.createAsConst(this.createProviderObject(model)), ),Apply similar changes to other immutable properties (
models,typeDefs,enums,authType,procedures), but notplugins.
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (31)
packages/common-helpers/src/zip.ts(1 hunks)packages/orm/src/client/contract.ts(22 hunks)packages/orm/src/client/crud-types.ts(6 hunks)packages/orm/src/client/crud/operations/base.ts(5 hunks)packages/orm/src/client/crud/validator/index.ts(1 hunks)packages/orm/src/client/crud/validator/utils.ts(6 hunks)packages/orm/src/client/helpers/schema-db-pusher.ts(1 hunks)packages/orm/src/utils/object-utils.ts(1 hunks)packages/schema/src/schema.ts(8 hunks)packages/sdk/src/ts-schema-generator.ts(4 hunks)samples/next.js/zenstack/schema-lite.ts(2 hunks)samples/next.js/zenstack/schema.ts(2 hunks)samples/orm/main.ts(1 hunks)samples/orm/zenstack/schema.ts(3 hunks)tests/e2e/apps/rally/zenstack/schema.ts(3 hunks)tests/e2e/github-repos/cal.com/schema.ts(3 hunks)tests/e2e/github-repos/formbricks/schema.ts(3 hunks)tests/e2e/github-repos/trigger.dev/schema.ts(3 hunks)tests/e2e/orm/schemas/auth-type/schema.ts(3 hunks)tests/e2e/orm/schemas/basic/schema.ts(3 hunks)tests/e2e/orm/schemas/default-auth/schema.ts(2 hunks)tests/e2e/orm/schemas/delegate/schema.ts(2 hunks)tests/e2e/orm/schemas/delegate/typecheck.ts(2 hunks)tests/e2e/orm/schemas/json/schema.ts(2 hunks)tests/e2e/orm/schemas/name-mapping/schema.ts(3 hunks)tests/e2e/orm/schemas/omit/schema.ts(2 hunks)tests/e2e/orm/schemas/petstore/schema.ts(2 hunks)tests/e2e/orm/schemas/typed-json/schema.ts(3 hunks)tests/e2e/orm/schemas/typing/schema.ts(4 hunks)tests/runtimes/bun/schemas/schema.ts(2 hunks)tests/runtimes/edge-runtime/schemas/schema.ts(2 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
tests/e2e/**/*.{ts,tsx}
📄 CodeRabbit inference engine (CLAUDE.md)
E2E tests should validate real-world schema compatibility with established projects
Files:
tests/e2e/orm/schemas/delegate/schema.tstests/e2e/orm/schemas/default-auth/schema.tstests/e2e/orm/schemas/basic/schema.tstests/e2e/orm/schemas/petstore/schema.tstests/e2e/orm/schemas/name-mapping/schema.tstests/e2e/github-repos/cal.com/schema.tstests/e2e/orm/schemas/typing/schema.tstests/e2e/orm/schemas/auth-type/schema.tstests/e2e/orm/schemas/delegate/typecheck.tstests/e2e/orm/schemas/typed-json/schema.tstests/e2e/orm/schemas/json/schema.tstests/e2e/orm/schemas/omit/schema.tstests/e2e/apps/rally/zenstack/schema.tstests/e2e/github-repos/formbricks/schema.tstests/e2e/github-repos/trigger.dev/schema.ts
tests/**/type*.{ts,tsx}
📄 CodeRabbit inference engine (CLAUDE.md)
Ensure TypeScript inference and type coverage are validated through type coverage tests
Files:
tests/e2e/orm/schemas/delegate/typecheck.ts
🧠 Learnings (8)
📓 Common learnings
Learnt from: CR
Repo: zenstackhq/zenstack-v3 PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-26T01:55:04.540Z
Learning: Applies to packages/zenstackhq/orm/**/*.{ts,tsx} : Use Kysely as the query builder interface for low-level database queries, avoiding raw SQL when possible
Learnt from: CR
Repo: zenstackhq/zenstack-v3 PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-26T01:55:04.540Z
Learning: Applies to packages/zenstackhq/orm/**/*.{ts,tsx} : Implement plugin hooks at ORM, Kysely, and entity mutation levels for query interception and customization
Learnt from: CR
Repo: zenstackhq/zenstack-v3 PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-26T01:55:04.540Z
Learning: Applies to packages/zenstackhq/orm/**/*.test.{ts,tsx} : ORM package tests should include comprehensive client API tests and policy tests
📚 Learning: 2025-11-26T01:55:04.540Z
Learnt from: CR
Repo: zenstackhq/zenstack-v3 PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-26T01:55:04.540Z
Learning: Applies to tests/e2e/**/*.{ts,tsx} : E2E tests should validate real-world schema compatibility with established projects
Applied to files:
tests/runtimes/edge-runtime/schemas/schema.tssamples/next.js/zenstack/schema.tstests/e2e/orm/schemas/delegate/schema.tstests/e2e/orm/schemas/default-auth/schema.tstests/e2e/orm/schemas/basic/schema.tssamples/orm/zenstack/schema.tstests/e2e/orm/schemas/petstore/schema.tstests/runtimes/bun/schemas/schema.tstests/e2e/orm/schemas/name-mapping/schema.tstests/e2e/github-repos/cal.com/schema.tssamples/next.js/zenstack/schema-lite.tstests/e2e/orm/schemas/typing/schema.tstests/e2e/orm/schemas/auth-type/schema.tstests/e2e/orm/schemas/delegate/typecheck.tstests/e2e/orm/schemas/typed-json/schema.tstests/e2e/orm/schemas/json/schema.tstests/e2e/orm/schemas/omit/schema.tstests/e2e/apps/rally/zenstack/schema.tstests/e2e/github-repos/formbricks/schema.tstests/e2e/github-repos/trigger.dev/schema.ts
📚 Learning: 2025-11-26T01:55:04.540Z
Learnt from: CR
Repo: zenstackhq/zenstack-v3 PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-26T01:55:04.540Z
Learning: Applies to **/*.zmodel : ZModel schema files should define database structure and policies that compile to TypeScript via `zenstack generate`
Applied to files:
tests/runtimes/edge-runtime/schemas/schema.tssamples/next.js/zenstack/schema.tstests/e2e/orm/schemas/delegate/schema.tstests/e2e/orm/schemas/default-auth/schema.tstests/e2e/orm/schemas/basic/schema.tssamples/orm/zenstack/schema.tstests/e2e/orm/schemas/petstore/schema.tstests/runtimes/bun/schemas/schema.tstests/e2e/orm/schemas/name-mapping/schema.tssamples/orm/main.tspackages/orm/src/client/helpers/schema-db-pusher.tstests/e2e/github-repos/cal.com/schema.tssamples/next.js/zenstack/schema-lite.tstests/e2e/orm/schemas/typing/schema.tstests/e2e/orm/schemas/auth-type/schema.tstests/e2e/orm/schemas/delegate/typecheck.tspackages/orm/src/client/contract.tstests/e2e/orm/schemas/typed-json/schema.tspackages/sdk/src/ts-schema-generator.tstests/e2e/orm/schemas/json/schema.tstests/e2e/orm/schemas/omit/schema.tstests/e2e/apps/rally/zenstack/schema.tstests/e2e/github-repos/formbricks/schema.tstests/e2e/github-repos/trigger.dev/schema.ts
📚 Learning: 2025-10-21T16:09:31.218Z
Learnt from: ymc9
Repo: zenstackhq/zenstack-v3 PR: 319
File: packages/runtime/src/client/executor/zenstack-query-executor.ts:63-72
Timestamp: 2025-10-21T16:09:31.218Z
Learning: In ZenStack, TypeDefs can be inherited by models. When a TypeDef contains fields with `map` attributes, those mapped field names need to be processed by the QueryNameMapper since they become part of the inheriting model's schema. Therefore, when checking if a schema has mapped names (e.g., in `schemaHasMappedNames`), both `schema.models` and `schema.typeDefs` must be inspected for `@map` and `map` attributes.
Applied to files:
tests/runtimes/edge-runtime/schemas/schema.tssamples/next.js/zenstack/schema.tstests/e2e/orm/schemas/delegate/schema.tstests/e2e/orm/schemas/default-auth/schema.tstests/e2e/orm/schemas/basic/schema.tssamples/orm/zenstack/schema.tstests/e2e/orm/schemas/petstore/schema.tstests/runtimes/bun/schemas/schema.tstests/e2e/orm/schemas/name-mapping/schema.tstests/e2e/github-repos/cal.com/schema.tssamples/next.js/zenstack/schema-lite.tstests/e2e/orm/schemas/typing/schema.tstests/e2e/orm/schemas/auth-type/schema.tstests/e2e/orm/schemas/typed-json/schema.tstests/e2e/orm/schemas/json/schema.tstests/e2e/orm/schemas/omit/schema.tstests/e2e/apps/rally/zenstack/schema.tstests/e2e/github-repos/formbricks/schema.tstests/e2e/github-repos/trigger.dev/schema.ts
📚 Learning: 2025-11-26T01:55:04.540Z
Learnt from: CR
Repo: zenstackhq/zenstack-v3 PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-26T01:55:04.540Z
Learning: Applies to packages/zenstackhq/orm/**/*.{ts,tsx} : Implement plugin hooks at ORM, Kysely, and entity mutation levels for query interception and customization
Applied to files:
samples/orm/zenstack/schema.tssamples/orm/main.tspackages/orm/src/client/helpers/schema-db-pusher.tssamples/next.js/zenstack/schema-lite.tspackages/orm/src/client/crud-types.tstests/e2e/orm/schemas/auth-type/schema.tspackages/orm/src/client/contract.tspackages/orm/src/client/crud/operations/base.ts
📚 Learning: 2025-11-26T01:55:04.540Z
Learnt from: CR
Repo: zenstackhq/zenstack-v3 PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-26T01:55:04.540Z
Learning: Applies to packages/zenstackhq/orm/**/*.{ts,tsx} : Use Kysely as the query builder interface for low-level database queries, avoiding raw SQL when possible
Applied to files:
samples/orm/zenstack/schema.tssamples/orm/main.tssamples/next.js/zenstack/schema-lite.tspackages/orm/src/client/crud-types.tspackages/orm/src/client/contract.tspackages/orm/src/client/crud/operations/base.ts
📚 Learning: 2025-11-26T01:55:04.540Z
Learnt from: CR
Repo: zenstackhq/zenstack-v3 PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-26T01:55:04.540Z
Learning: Applies to packages/zenstackhq/orm/**/*.test.{ts,tsx} : ORM package tests should include comprehensive client API tests and policy tests
Applied to files:
samples/orm/zenstack/schema.tssamples/orm/main.tstests/e2e/orm/schemas/delegate/typecheck.tspackages/orm/src/client/contract.ts
📚 Learning: 2025-11-26T01:55:04.540Z
Learnt from: CR
Repo: zenstackhq/zenstack-v3 PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-26T01:55:04.540Z
Learning: Applies to tests/**/type*.{ts,tsx} : Ensure TypeScript inference and type coverage are validated through type coverage tests
Applied to files:
tests/e2e/orm/schemas/delegate/typecheck.ts
🧬 Code graph analysis (4)
tests/e2e/github-repos/cal.com/schema.ts (3)
tests/e2e/orm/schemas/typed-json/schema.ts (2)
SchemaType(9-105)schema(106-106)tests/e2e/orm/schemas/typing/schema.ts (1)
SchemaType(9-346)packages/schema/src/schema.ts (1)
SchemaDef(11-19)
packages/orm/src/client/crud/validator/index.ts (1)
packages/schema/src/schema.ts (1)
AttributeApplication(40-43)
packages/orm/src/client/contract.ts (1)
packages/orm/src/client/crud-types.ts (5)
SimplifiedModelResult(248-255)BatchResult(283-283)CountResult(1594-1602)AggregateResult(1681-1722)GroupByResult(1800-1849)
packages/sdk/src/ts-schema-generator.ts (2)
packages/language/src/generated/ast.ts (1)
isEnum(432-434)packages/plugins/policy/src/expression-transformer.ts (1)
authType(138-143)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
- GitHub Check: Agent
- GitHub Check: claude-review
- GitHub Check: build-test (20.x, postgresql)
- GitHub Check: build-test (20.x, sqlite)
🔇 Additional comments (58)
packages/orm/src/client/helpers/schema-db-pusher.ts (1)
116-122: LGTM - Type casts necessary for Kysely interface compatibility.The
as string[]casts are appropriate here sinceidFieldsis nowreadonly string[]but Kysely'saddForeignKeyConstraintexpects mutablestring[]. Since the array is only read (not mutated) by the constraint builder, this is safe.packages/common-helpers/src/zip.ts (1)
4-10: LGTM - Readonly input parameters correctly allow broader usage.The
readonlymodifier on input arrays is appropriate since the function only reads from the arrays. The non-null assertions on line 8 are safe given the loop bound isMath.min(arr1.length, arr2.length).packages/schema/src/schema.ts (6)
25-37: LGTM - ModelDef fields correctly marked as readonly.Making
attributes,idFields, andsubModelsreadonly appropriately reflects that these schema definition arrays should not be mutated after creation.
54-55: LGTM - RelationInfo arrays marked readonly.The
fieldsandreferencesarrays in relation definitions are correctly marked as readonly since they represent static schema metadata.
70-74: LGTM - FieldDef arrays properly immutable.The
attributes,default(supportingreadonly unknown[]), andforeignKeyForare appropriately marked readonly.
296-300: Good defensive typing forIsDelegateModel.The
string extends Model ? false : ...guard prevents incorrect inference whenModelresolves to the basestringtype (e.g., in generic contexts), ensuring the type utility returnsfalserather than potentiallytruein ambiguous cases.
127-132: LGTM - GetSubModels updated for readonly check.The type guard correctly checks for
readonly string[]to match the updatedsubModelstype inModelDef.
189-213: LGTM - ScalarFields and ForeignKeyFields updated for readonly arrays.The type utilities correctly check against
readonly string[]forforeignKeyFor, maintaining consistency with the updatedFieldDeftype.packages/orm/src/client/crud/validator/index.ts (1)
300-337: LGTM - Parameter type aligned with schema definition.The
readonly AttributeApplication[]parameter type correctly matches the updatedFieldDef.attributestype fromschema.ts, ensuring type consistency across the codebase.packages/orm/src/utils/object-utils.ts (2)
4-6: LGTM - Readonly parameter appropriate for read-only usage.The
readonly string[]type correctly reflects thatextractFieldsonly reads from the array viaincludes().
11-12: LGTM - Readonly parameter appropriate for read-only usage.The
readonly string[]type correctly reflects thatfieldsToSelectObjectonly reads from the array viamap().packages/orm/src/client/crud/operations/base.ts (5)
253-253: Good type covariance improvement forreturnFieldsparameter.Changing to
readonly string[]allows callers to pass readonly arrays without casting, which aligns well with the broader readonly typing updates across the codebase.
665-666: Consistent readonly typing forfieldsToReturn.Same beneficial change as in other methods, maintaining consistency across the CRUD operations.
904-905: LGTM - readonly parameter for update operation.
1210-1211: LGTM - readonly parameter for updateMany operation.
1926-1927: LGTM - readonly parameter for delete operation.packages/orm/src/client/crud/validator/utils.ts (6)
25-28: Appropriate readonly constraint forattributesparameter.The function only reads and iterates over attributes, so
readonlyis semantically correct and improves type safety for callers.
92-95: LGTM - consistent readonly typing.
123-126: LGTM - consistent readonly typing.
155-159: LGTM - consistent readonly typing for decimal validation.
234-237: LGTM - consistent readonly typing for list validation.
260-263: LGTM - consistent readonly typing for custom validation.packages/orm/src/client/crud-types.ts (3)
1034-1034: Good readonly constraint forOppositeRelationFields.Changing
Opposite['fields'] extends string[]toOpposite['fields'] extends readonly string[]aligns with the schema's readonly field definitions.
1088-1097: SimplifiedFindArgstype - verify SQLite distinct behavior.The simplified type now always includes
distinctwhenCollectionis true, removing the previousProviderSupportsDistinctconditional. This is cleaner for type-checking.Ensure that runtime behavior for SQLite (which may handle
distinctdifferently) is not affected. If SQLite support for distinct is handled at the query-building layer rather than the type layer, this change is fine.
2000-2006: Appropriate readonly constraint forNonOwnedRelationFields.Using
readonly unknown[]correctly reflects that references arrays from the schema are immutable.packages/orm/src/client/contract.ts (7)
80-80: LGTM! Simplified return types for raw query methods.Replacing
ZenStackPromise<Schema, T>with nativePromise<T>should improve type checking performance by reducing type instantiation complexity. The Schema parameter is not needed for these raw query operations since the return types don't depend on schema structure.Also applies to: 90-90, 99-99, 109-109
159-162: Consistent with Promise migration.The sequential transaction signature correctly accepts
Promise<any>[]and usesUnwrapTuplePromisesto extract the resolved types.
359-361: LGTM! Find operations migrated to native Promise.All find operations (
findMany,findUnique,findUniqueOrThrow,findFirst,findFirstOrThrow) consistently returnPromise<SimplifiedModelResult<...>>, maintaining proper type inference while simplifying the Promise wrapper.Also applies to: 369-371, 379-381, 389-391, 399-401
455-457: LGTM! Create operations migrated to native Promise.The
create,createMany, andcreateManyAndReturnmethods correctly returnPromise<SimplifiedModelResult<...>>andPromise<BatchResult>respectively.Also applies to: 484-486, 506-508
627-629: LGTM! Update and upsert operations migrated to native Promise.The
update,updateMany,updateManyAndReturn, andupsertmethods maintain correct return types with the simplified Promise wrapper.Also applies to: 651-653, 677-679, 701-703
724-726: LGTM! Delete operations migrated to native Promise.Both
deleteanddeleteManymethods correctly returnPromise<SimplifiedModelResult<...>>andPromise<BatchResult>.Also applies to: 747-749
769-771: LGTM! Aggregation operations migrated to native Promise.The
count,aggregate, andgroupBymethods maintain their complex return type inference (CountResult,AggregateResult,GroupByResult) while simplifying the Promise wrapper.Also applies to: 790-792, 827-829
packages/sdk/src/ts-schema-generator.ts (3)
118-118: LGTM: Method refactoring aligns with class-based approach.The rename from
createSchemaObjecttocreateSchemaClassaccurately reflects the architectural shift to class-based schema generation.
125-125: LGTM: Idiomatic use ofundefinedfor optional parameter.Using
undefinedinstead offalsefor theisTypeOnlyparameter is more idiomatic and functionally equivalent.
153-170: LGTM: Clean class-based schema export pattern.The new pattern exports both the
SchemaTypeclass definition and aschemainstance, providing better type safety and potentially improved type-checking performance (per PR objectives).samples/orm/main.ts (1)
1-2: Import reordering is safeOnly the
PolicyPluginimport position changed; no side-effectful imports involved, so behavior of the sample remains unchanged.tests/runtimes/edge-runtime/schemas/schema.ts (1)
9-100: Class-based schema wrapper looks consistent and safeWrapping the generated schema in a
SchemaTypeclass that implementsSchemaDefand exportingschema = new SchemaType()preserves the previous object shape (provider/models/authType/plugins) while enabling the new class-based pattern. Nothing here suggests behavioral or type-level regressions for the edge-runtime tests.tests/e2e/github-repos/trigger.dev/schema.ts (1)
9-6344: Migration to class-basedSchemaTypemaintains schema semanticsThe trigger.dev schema is now exposed via a
SchemaTypeclass instance withprovider,models, andenumsall definedas const, plusauthType = "User"and an emptypluginsmap. This aligns with the new class-based schema pattern and should keep the e2e schema semantically identical to the prior object-literal form while supporting the type-checking improvements targeted by the PR.tests/e2e/github-repos/cal.com/schema.ts (2)
9-13: SchemaType wrapper and provider/models structure look correctWrapping the existing schema into
export class SchemaType implements SchemaDefwithproviderandmodelsas... as constmatches the shared pattern from other schema files and keeps the cal.com schema structure intact. No issues from a typing or E2E-compatibility perspective.
9185-9643: Enums, authType, plugins, and exported instance are consistent with SchemaDef
enums = { ... } as constfollows the same shape and literal-typing approach as other generated schemas.authType = "User" as constaligns with the presence of aUsermodel and the established pattern inSchemaTypeimplementations.plugins = {}satisfies theRecord<string, unknown>contract.export const schema = new SchemaType();cleanly exposes the schema instance for the E2E cal.com tests.All of this is consistent with the broader refactor and should continue to validate real-world schema compatibility.
samples/orm/zenstack/schema.ts (1)
9-244: Class-based schema pattern looks correct.The refactoring from a plain object to a class-based
SchemaTypeimplementingSchemaDefis well-structured. Theas constassertions onprovider,models,typeDefs,enums, andauthTypecorrectly preserve literal types for TypeScript inference.tests/e2e/github-repos/formbricks/schema.ts (1)
9-3025: E2E schema follows the class-based pattern correctly.This large real-world schema from formbricks validates that the class-based
SchemaTypepattern works correctly for complex schemas with many models and enums. The structure is consistent with other schema files in this PR.tests/runtimes/bun/schemas/schema.ts (1)
9-100: LGTM!The class-based schema pattern is correctly applied for Bun runtime testing. The access control policies using
ExpressionUtilsare properly preserved.samples/next.js/zenstack/schema-lite.ts (1)
9-106: LGTM!The lite schema variant correctly implements the class-based
SchemaTypepattern with minimal model definitions suitable for the Next.js sample.tests/e2e/orm/schemas/typed-json/schema.ts (1)
9-106: LGTM!The typed JSON test schema correctly implements the class-based pattern with
typeDefsfor nested JSON structures. This validates the pattern works well for typed JSON field scenarios.samples/next.js/zenstack/schema.ts (1)
9-115: LGTM — class-based schema generation looks correct.The migration from object literal to class-based
SchemaTypeimplementingSchemaDefis well-structured. Theas constassertions onprovider,models, andauthTypeensure proper literal type inference, which should help TypeScript's type checker cache and reuse type information more efficiently.tests/e2e/orm/schemas/name-mapping/schema.ts (1)
9-123: LGTM — validates name mapping compatibility.The schema correctly tests
@mapand@@mapattributes for field and model name mapping, which is a common real-world requirement for matching existing database naming conventions. The class-based structure is consistent with other schema files in this PR.tests/e2e/orm/schemas/basic/schema.ts (1)
9-287: LGTM — comprehensive E2E test schema.This schema provides solid coverage of common ORM features including relations, access policies (
@@allow,@@deny), type definitions for inheritance (CommonFields), enums, and various field configurations. The class-based structure correctly implementsSchemaDef.tests/e2e/orm/schemas/typing/schema.ts (1)
9-347: LGTM — thorough type system test coverage.The schema effectively tests advanced typing scenarios: computed fields with
OperandExpression, composite primary keys (Region), JSON type definitions (Identity,IdentityProvider), and enum arrays. The computed field stub implementation (throwing an error) is appropriate since these are resolved at runtime by the ORM.tests/e2e/orm/schemas/omit/schema.ts (1)
9-138: LGTM — validates@omitand delegate model patterns.The schema correctly tests the
@omitattribute for sensitive fields (password,content) and the delegate model pattern with discriminator inheritance (Base→Sub). These are important real-world patterns for data privacy and polymorphic models.tests/e2e/orm/schemas/delegate/schema.ts (1)
9-465: Class-based schema generation looks correct for delegate model hierarchy.The generated
SchemaTypeclass properly implementsSchemaDefwith the delegate model inheritance chain (Asset → Video → RatedVideo, Asset → Image). Theas constassertions onprovider,models, andauthTypepreserve literal type inference while the class-based approach should reduce TypeScript's type instantiation depth. As per coding guidelines, this E2E test schema validates real-world delegate model compatibility.tests/e2e/orm/schemas/default-auth/schema.ts (1)
9-122: LGTM - Default auth schema correctly generated.The class-based schema properly captures the default auth pattern with
ExpressionUtils.member(ExpressionUtils.call("auth"), ["id"])for the defaultuserIdvalue and the correspondinghasDefault: trueon the relation. Structure aligns with the broader PR pattern.tests/e2e/orm/schemas/json/schema.ts (1)
9-42: LGTM - JSON schema correctly generated without auth type.The schema correctly omits
authTypesince no auth model is defined. The JSON field definitions (type: "Json") are properly represented with optional modifier where applicable.tests/e2e/orm/schemas/petstore/schema.ts (1)
9-157: Petstore schema with access policies correctly generated.The class-based schema properly represents the access control rules using
ExpressionUtilsexpressions. The complex policy conditions (e.g., Line 94-96 with nested binary expressions for Pet read access) are correctly structured. This validates real-world schema compatibility with access control patterns as per coding guidelines.tests/e2e/orm/schemas/auth-type/schema.ts (1)
9-70: Custom auth type schema via typeDefs correctly generated.The schema properly defines
Authas a typedef with@@authattribute rather than as a model, andauthType = "Auth" as constcorrectly references this typedef. ThetypeDefsproperty structure withPermissionandAuthtypes is well-formed.tests/e2e/apps/rally/zenstack/schema.ts (3)
9-13: LGTM - Class-based schema structure is correct.The class declaration properly implements
SchemaDef, and theas constassertion onproviderensures correct type inference. This pattern aligns with the PR objective of improving type-checking performance.
2391-2521: LGTM - Proper const assertions and class field definitions.The
as constassertions onmodelsandenumsensure TypeScript infers exact literal types, which is essential for the type-checking performance improvements this PR targets. TheauthTypecorrectly references theUsermodel.
2522-2523: LGTM - Singleton export pattern is appropriate.Exporting a single schema instance allows consistent usage across the codebase. This E2E test validates real-world schema compatibility with a comprehensive Rally application schema containing 28 models and 15 enums.
|
Claude finished @ymc9's task —— View job PR Review: Type Checking Performance ImprovementsComprehensive review of architectural changes across 32 files to improve TypeScript type checking performance. 🚨 CRITICAL ISSUES1. Breaking Change: ZenStackPromise RemovalLocation: invariant(
typeof input === 'function' || (Array.isArray(input) && input.every((p) => p.then && p.cb)),
'Invalid transaction input, expected a function or an array of ZenStackPromise',
);The Problem: Sequential transactions (
Impact: Breaking change - existing user code using sequential transactions will break. Recommendation: Either maintain backward compatibility or document as breaking change requiring major version bump. 2. Delegate Model Functionality Potentially BrokenLocation: Large blocks of commented-out delegate model logic suggest this feature may be temporarily disabled: // IsDelegateModel<Schema, Model> extends true
// ? DelegateUnionResult<Schema, Model, Options, GetSubModels<Schema, Model>, Omit>Evidence: ✅ EXCELLENT IMPROVEMENTS1. Schema Generation Refactoring ⭐Architectural improvement from object literals to class-based approach: Before: const _schema = { ... } as const satisfies SchemaDef;
type Schema = typeof _schema & { __brand?: 'schema' };
export const schema: Schema = _schema;After: export class SchemaType implements SchemaDef {
readonly provider = { ... } as const;
readonly models = { ... } as const;
}
export const schema = new SchemaType();Benefits:
2. Readonly Array Conversions ⭐Comprehensive migration to immutable arrays improves type safety:
Benefits: Better immutability guarantees + potential TypeScript caching improvements. 3. Type Simplification
📊 PERFORMANCE ASSESSMENTExpected Benefits:
Validation Needed: Can't run test suite due to environment limitations - recommend running full test suite locally to validate:
🔒 SECURITYStatus: ✅ No security concerns identified
💡 RECOMMENDATIONSImmediate Actions Required:
Code Quality:
📋 SUMMARYRecommendation: ✅ Approve with critical fixes required This is a well-executed performance optimization with sound architectural decisions. The schema generation refactoring and readonly conversions should significantly improve TypeScript compilation times. However, the ZenStackPromise removal introduces a breaking change that must be addressed before merging. Key Action Items:
--- • Branch: fix/tsc-perf |
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 aims to improve TypeScript type-checking performance by refactoring how schemas are generated and represented. The changes shift from object literals with complex type manipulations to a simpler class-based approach, convert array types to readonly for better immutability, and simplify promise handling by planning to remove ZenStackPromise wrappers.
Key Changes:
- Refactored schema generation to use class instances implementing
SchemaDefinstead of object literals with branded types - Changed schema type definitions to use
readonlyarrays for improved immutability and type inference - Updated return types in contract from
ZenStackPromiseto plainPromise(though implementation still uses ZenStackPromise) - Temporarily disabled delegate model discrimination and provider-specific distinct field type checking
Reviewed changes
Copilot reviewed 32 out of 32 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/sdk/src/ts-schema-generator.ts | Refactored to generate schema classes instead of object literals, replacing _schema object with SchemaType class |
| packages/schema/src/schema.ts | Updated type definitions to use readonly arrays for attributes, idFields, subModels, etc.; added guard to IsDelegateModel |
| packages/orm/src/client/contract.ts | Changed method return types from ZenStackPromise to plain Promise |
| packages/orm/src/client/crud-types.ts | Commented out delegate model discrimination logic and ProviderSupportsDistinct type check |
| packages/orm/src/client/helpers/schema-db-pusher.ts | Added type casts to convert readonly string[] to string[] for Kysely API compatibility |
| packages/orm/src/client/crud/validator/*.ts | Updated validation functions to accept readonly AttributeApplication[] |
| packages/orm/src/client/crud/operations/base.ts | Updated method signatures to accept readonly string[] for field parameters |
| packages/common-helpers/src/zip.ts | Updated to accept readonly arrays |
| tests/e2e/orm/schemas/delegate/typecheck.ts | Commented out type checks for discriminated sub-model fields |
| samples/orm/main.ts | Reordered imports (minor change) |
| All generated schema files | Regenerated using new class-based schema format |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Claude finished @ymc9's task —— View job PR Review: Type Checking Performance ImprovementsThis PR implements strategic optimizations to improve TypeScript type checking performance through several architectural changes. Here's my comprehensive analysis: 🚨 Critical Issue: Breaking Change in Transaction APIProblem: The removal of Root Cause: // From client-impl.ts:154
input.every((p) => p.then && p.cb)Impact: Sequential transactions Recommendation: Either maintain ✅ Excellent Changes1. Schema Generation RefactoringImpact: Significant type checking performance improvement Before: Complex object literals with branded types const _schema = { ... } as const satisfies SchemaDef;
type Schema = typeof _schema & { __brand?: 'schema' };
export const schema: Schema = _schema;After: Clean class-based approach export class SchemaType implements SchemaDef {
readonly provider = { ... } as const;
readonly models = { ... } as const;
}
export const schema = new SchemaType();Benefits: Eliminates complex type intersections and branded types that slow TypeScript compilation. 2. Readonly Array ConversionsImpact: Better type safety and potentially faster type inference All array types properly converted to
This improves immutability guarantees while helping TypeScript cache type information more efficiently.
|
|
Claude finished @ymc9's task —— View job PR Review: Type Checking Performance ImprovementsComprehensive review of architectural changes across 32 files to improve TypeScript type checking performance. 🚨 CRITICAL ISSUES1. Breaking Change: ZenStackPromise RemovalLocation: invariant(
typeof input === 'function' || (Array.isArray(input) && input.every((p) => p.then && p.cb)),
'Invalid transaction input, expected a function or an array of ZenStackPromise',
);The Problem: Sequential transactions (
Impact: Breaking change - existing user code using sequential transactions will break. Recommendation: Either maintain backward compatibility or document as breaking change requiring major version bump. 2. Delegate Model Functionality Potentially BrokenLocation: Large blocks of commented-out delegate model logic suggest this feature may be temporarily disabled: // IsDelegateModel<Schema, Model> extends true
// ? DelegateUnionResult<Schema, Model, Options, GetSubModels<Schema, Model>, Omit>Evidence: ✅ EXCELLENT IMPROVEMENTS1. Schema Generation Refactoring ⭐Architectural improvement from object literals to class-based approach: Before: const _schema = { ... } as const satisfies SchemaDef;
type Schema = typeof _schema & { __brand?: 'schema' };
export const schema: Schema = _schema;After: export class SchemaType implements SchemaDef {
readonly provider = { ... } as const;
readonly models = { ... } as const;
}
export const schema = new SchemaType();Benefits:
2. Readonly Array Conversions ⭐Comprehensive migration to immutable arrays improves type safety:
Benefits: Better immutability guarantees + potential TypeScript caching improvements. 3. Type Simplification
📊 PERFORMANCE ASSESSMENTExpected Benefits:
Validation Needed: Can't run test suite due to environment limitations - recommend running full test suite locally to validate:
🔒 SECURITYStatus: ✅ No security concerns identified
💡 RECOMMENDATIONSImmediate Actions Required:
Code Quality:
📋 SUMMARYRecommendation: ✅ Approve with critical fixes required This is a well-executed performance optimization with sound architectural decisions. The schema generation refactoring and readonly conversions should significantly improve TypeScript compilation times. However, the ZenStackPromise removal introduces a breaking change that must be addressed before merging. Key Action Items:
--- • Branch: fix/tsc-perf |
|
Claude finished @ymc9's task —— View job PR Review: Type Checking Performance ImprovementsComprehensive review of architectural changes across 32 files to improve TypeScript type checking performance. Todo List
🚨 CRITICAL ISSUES1. Breaking Change: ZenStackPromise RemovalLocation: invariant(
typeof input === 'function' || (Array.isArray(input) && input.every((p) => p.then && p.cb)),
'Invalid transaction input, expected a function or an array of ZenStackPromise',
);The Problem: Sequential transactions (
Impact: Breaking change - existing user code using sequential transactions will break. Recommendation: Either maintain backward compatibility or document as breaking change requiring major version bump. 2. Delegate Model Functionality Potentially BrokenLocation: Large blocks of commented-out delegate model logic suggest this feature may be temporarily disabled: // IsDelegateModel<Schema, Model> extends true
// ? DelegateUnionResult<Schema, Model, Options, GetSubModels<Schema, Model>, Omit>Evidence: ✅ EXCELLENT IMPROVEMENTS1. Schema Generation Refactoring ⭐Architectural improvement from object literals to class-based approach: Before: const _schema = { ... } as const satisfies SchemaDef;
type Schema = typeof _schema & { __brand?: 'schema' };
export const schema: Schema = _schema;After: export class SchemaType implements SchemaDef {
readonly provider = { ... } as const;
readonly models = { ... } as const;
}
export const schema = new SchemaType();Benefits:
2. Readonly Array Conversions ⭐Comprehensive migration to immutable arrays improves type safety:
Benefits: Better immutability guarantees + potential TypeScript caching improvements. 3. Type Simplification
📊 PERFORMANCE ASSESSMENTExpected Benefits:
Validation Needed: Can't run test suite due to environment limitations - recommend running full test suite locally to validate:
🔒 SECURITYStatus: ✅ No security concerns identified
💡 RECOMMENDATIONSImmediate Actions Required:
Code Quality:
📋 SUMMARYRecommendation: ✅ Approve with critical fixes required This is a well-executed performance optimization with sound architectural decisions. The schema generation refactoring and readonly conversions should significantly improve TypeScript compilation times. However, the ZenStackPromise removal introduces a breaking change that must be addressed before merging. Key Action Items:
--- • Branch: fix/tsc-perf |
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.
Actionable comments posted: 2
🧹 Nitpick comments (1)
packages/schema/src/schema.ts (1)
62-78:FieldDef.defaultwidening toreadonly unknown[]may be too permissive.
If this is meant to model JSON/list defaults, consider a tighter type (e.g., a JSON value shape or a dedicated “default value” union) so consumers don’t lose useful static guarantees.
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
packages/orm/src/client/contract.ts(1 hunks)packages/schema/src/schema.ts(7 hunks)
🧰 Additional context used
🧠 Learnings (6)
📓 Common learnings
Learnt from: CR
Repo: zenstackhq/zenstack-v3 PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-26T01:55:04.540Z
Learning: Applies to packages/zenstackhq/orm/**/*.{ts,tsx} : Implement plugin hooks at ORM, Kysely, and entity mutation levels for query interception and customization
Learnt from: CR
Repo: zenstackhq/zenstack-v3 PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-26T01:55:04.540Z
Learning: Applies to packages/zenstackhq/orm/**/*.{ts,tsx} : Use Kysely as the query builder interface for low-level database queries, avoiding raw SQL when possible
Learnt from: CR
Repo: zenstackhq/zenstack-v3 PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-26T01:55:04.540Z
Learning: Applies to **/*.zmodel : ZModel schema files should define database structure and policies that compile to TypeScript via `zenstack generate`
Learnt from: CR
Repo: zenstackhq/zenstack-v3 PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-26T01:55:04.540Z
Learning: Applies to packages/zenstackhq/orm/**/*.test.{ts,tsx} : ORM package tests should include comprehensive client API tests and policy tests
Learnt from: CR
Repo: zenstackhq/zenstack-v3 PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-26T01:55:04.540Z
Learning: Database migrations should use Prisma CLI under the hood via ZenStack commands
Learnt from: ymc9
Repo: zenstackhq/zenstack-v3 PR: 319
File: packages/runtime/src/client/executor/zenstack-query-executor.ts:63-72
Timestamp: 2025-10-21T16:09:31.218Z
Learning: In ZenStack, TypeDefs can be inherited by models. When a TypeDef contains fields with `map` attributes, those mapped field names need to be processed by the QueryNameMapper since they become part of the inheriting model's schema. Therefore, when checking if a schema has mapped names (e.g., in `schemaHasMappedNames`), both `schema.models` and `schema.typeDefs` must be inspected for `@map` and `map` attributes.
📚 Learning: 2025-11-26T01:55:04.540Z
Learnt from: CR
Repo: zenstackhq/zenstack-v3 PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-26T01:55:04.540Z
Learning: Applies to packages/zenstackhq/orm/**/*.test.{ts,tsx} : ORM package tests should include comprehensive client API tests and policy tests
Applied to files:
packages/orm/src/client/contract.ts
📚 Learning: 2025-11-26T01:55:04.540Z
Learnt from: CR
Repo: zenstackhq/zenstack-v3 PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-26T01:55:04.540Z
Learning: Applies to packages/zenstackhq/orm/**/*.{ts,tsx} : Implement plugin hooks at ORM, Kysely, and entity mutation levels for query interception and customization
Applied to files:
packages/orm/src/client/contract.ts
📚 Learning: 2025-11-26T01:55:04.540Z
Learnt from: CR
Repo: zenstackhq/zenstack-v3 PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-26T01:55:04.540Z
Learning: Applies to packages/zenstackhq/orm/**/*.{ts,tsx} : Use Kysely as the query builder interface for low-level database queries, avoiding raw SQL when possible
Applied to files:
packages/orm/src/client/contract.ts
📚 Learning: 2025-11-26T01:55:04.540Z
Learnt from: CR
Repo: zenstackhq/zenstack-v3 PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-26T01:55:04.540Z
Learning: Applies to tests/e2e/**/*.{ts,tsx} : E2E tests should validate real-world schema compatibility with established projects
Applied to files:
packages/schema/src/schema.ts
📚 Learning: 2025-11-26T01:55:04.540Z
Learnt from: CR
Repo: zenstackhq/zenstack-v3 PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-26T01:55:04.540Z
Learning: Applies to **/*.zmodel : ZModel schema files should define database structure and policies that compile to TypeScript via `zenstack generate`
Applied to files:
packages/schema/src/schema.ts
🧬 Code graph analysis (1)
packages/orm/src/client/contract.ts (2)
packages/orm/src/client/promise.ts (1)
ZenStackPromise(7-13)packages/orm/src/utils/type-utils.ts (1)
UnwrapTuplePromises(89-91)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
- GitHub Check: build-test (20.x, sqlite)
- GitHub Check: build-test (20.x, postgresql)
- GitHub Check: claude-review
🔇 Additional comments (4)
packages/orm/src/client/contract.ts (1)
160-163: Return type change is consistent and correct.The change from
Promise<UnwrapTuplePromises<P>>toZenStackPromise<Schema, UnwrapTuplePromises<P>>aligns with the updated callback-based overload and maintains API consistency. The parameter type correctly constrains the input toZenStackPromise<Schema, any>[], ensuring the implementation can access thecbproperty.packages/schema/src/schema.ts (3)
21-38: Readonly array shift in public schema types looks consistent (but is a consumer-facing breaking change).
Switchingattributes,idFields, andsubModelstoreadonly ...[]is coherent with “immutable schema metadata” and should help avoid accidental mutation. Just ensure this is communicated as an API typing break for downstream callers that were mutating arrays.
40-43: LGTM: propagate readonly to nested attribute/relation list metadata.
AttributeApplication.args,RelationInfo.fields, andRelationInfo.referencesbecoming readonly is a good follow-through on the immutability story.Also applies to: 52-60
189-213: No action required. TheforeignKeyForclassification logic correctly handles optional fields.foreignKeyFor?: readonly string[]defines the type asreadonly string[] | undefined, and the conditional checks (extends readonly string[]) properly narrow to exclude undefined values. This results in correct field classification: scalar fields include non-array-backed fields, and foreign key fields include only array-backed fields.
|
Claude finished @ymc9's task —— View job PR Review: Type Checking Performance ImprovementsComprehensive review of architectural changes across 32 files to improve TypeScript type checking performance. 🚨 CRITICAL ISSUES1. Breaking Change: Transaction API MismatchLocation: invariant(
typeof input === 'function' || (Array.isArray(input) && input.every((p) => p.then && p.cb)),
'Invalid transaction input, expected a function or an array of ZenStackPromise',
);The Problem: Sequential transactions (
Impact: Breaking change - existing user code using sequential transactions will break. Recommendation: Either maintain ZenStackPromise compatibility or document as breaking change requiring major version bump. 2. Delegate Model Functionality Potentially BrokenLocation: Large blocks of commented-out delegate model logic suggest this feature may be temporarily disabled: // TODO: revisit how to efficiently implement discriminated sub model types
// IsDelegateModel<Schema, Model> extends true
// ? DelegateUnionResult<Schema, Model, Options, GetSubModels<Schema, Model>, Omit>Evidence: ✅ EXCELLENT IMPROVEMENTS1. Schema Generation Refactoring ⭐Architectural improvement from object literals to class-based approach: Before: const _schema = { ... } as const satisfies SchemaDef;
type Schema = typeof _schema & { __brand?: 'schema' };
export const schema: Schema = _schema;After: export class SchemaType implements SchemaDef {
readonly provider = { ... } as const;
readonly models = { ... } as const;
}
export const schema = new SchemaType();Benefits:
2. Readonly Array Conversions ⭐Comprehensive migration to immutable arrays improves type safety:
Benefits: Better immutability guarantees + potential TypeScript caching improvements. 3. Type Simplification
📊 PERFORMANCE ASSESSMENTExpected Benefits:
Validation Needed: Recommend running full test suite locally to validate:
🔒 SECURITYStatus: ✅ No security concerns identified
💡 RECOMMENDATIONSImmediate Actions Required:
Code Quality:
📋 SUMMARYRecommendation: ✅ Approve with critical fixes required This is a well-executed performance optimization with sound architectural decisions. The schema generation refactoring and readonly conversions should significantly improve TypeScript compilation times. However, the transaction API breaking change must be addressed before merging. Key Action Items:
--- • Branch: fix/tsc-perf |
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.