Skip to content

Conversation

@mhodgson
Copy link
Contributor

Fixes #2240

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Sep 11, 2025

📝 Walkthrough

Walkthrough

Removes automatic alias import for runtime.Types in generated model type files and updates JSON optional field typing to use runtime.Types.Skip directly. The statements array now starts empty, and any reference to $Types.Skip is replaced with runtime.Types.Skip.

Changes

Cohort / File(s) Summary of Changes
Enhancer generator import/type handling
packages/schema/src/plugins/enhancer/enhance/index.ts
Removed prepended alias import import $Types = runtime.Types;. Initialized statements as empty array. Replaced optional JSON union from `

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Suggested reviewers

  • ymc9

Pre-merge checks (5 passed)

✅ Passed checks (5 passed)
Check name Status Explanation
Title Check ✅ Passed The title accurately describes a real, important change in the changeset — switching usages of $Types.Skip to runtime.Types.Skip — and is concise and focused; however it does not explicitly mention the companion removal of the generated import alias which is also part of the diff.
Linked Issues Check ✅ Passed The code changes implement the coding objective from issue [#2240] by removing the generated "import $Types = runtime.Types" alias and updating JSON-field typing to use "runtime.Types.Skip" instead of "$Types.Skip", which addresses the TS1380 error caused by a type-only runtime import; these modifications are confined to the enhancer/typegen generation logic and directly map to the linked issue's requested fix.
Out of Scope Changes Check ✅ Passed The changes described in the raw summary are limited to removing the generated $Types import alias and updating type references to runtime.Types.Skip, with no modifications to exported/public signatures or unrelated files, so no out-of-scope changes were detected.
Description Check ✅ Passed The description ("Fixes #2240") directly references the linked issue and is therefore related to the changeset, satisfying this lenient check, though it is minimal and could be expanded with a one- or two-sentence summary of the implemented fix for reviewer clarity.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.

Tip

👮 Agentic pre-merge checks are now available in preview!

Pro plan users can now enable pre-merge checks in their settings to enforce checklists before merging PRs.

  • Built-in checks – Quickly apply ready-made checks to enforce title conventions, require pull request descriptions that follow templates, validate linked issues for compliance, and more.
  • Custom agentic checks – Define your own rules using CodeRabbit’s advanced agentic capabilities to enforce organization-specific policies and workflows. For example, you can instruct CodeRabbit’s agent to verify that API documentation is updated whenever API schema files are modified in a PR. Note: Upto 5 custom checks are currently allowed during the preview period. Pricing for this feature will be announced in a few weeks.

Please see the documentation for more information.

Example:

reviews:
  pre_merge_checks:
    custom_checks:
      - name: "Undocumented Breaking Changes"
        mode: "warning"
        instructions: |
          Pass/fail criteria: All breaking changes to public APIs, CLI flags, environment variables, configuration keys, database schemas, or HTTP/GraphQL endpoints must be documented in the "Breaking Change" section of the PR description and in CHANGELOG.md. Exclude purely internal or private changes (e.g., code not exported from package entry points or explicitly marked as internal).

Please share your feedback with us on this Discord post.

✨ Finishing touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a 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

🧹 Nitpick comments (1)
packages/schema/src/plugins/enhancer/enhance/index.ts (1)

615-630: Guard against missing runtime import in model files.

Relying on the generator’s existing import type * as runtime … is fine, but to make this resilient across Prisma versions, opportunistically add a type-only runtime import if it’s absent.

Apply this diff near the statements initialization:

-            const statements: (string | StatementStructures)[] = [];
+            const statements: (string | StatementStructures)[] = [];
+            // Ensure `runtime` is available for type positions if the generated file doesn't import it
+            const runtimeImport = sf
+                .getImportDeclarations()
+                .find((d) => /\/runtime\/library$/.test(d.getModuleSpecifierValue()) || d.getModuleSpecifierValue().includes('@prisma/client/runtime/library'))
+                ?.getModuleSpecifierValue() ?? undefined;
+            if (!runtimeImport) {
+                statements.push(`import type * as runtime from "@prisma/client/runtime/library";`);
+            }
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8962ad9 and bcbc624.

📒 Files selected for processing (1)
  • packages/schema/src/plugins/enhancer/enhance/index.ts (2 hunks)
⏰ 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). (6)
  • GitHub Check: build-test (20.x)
  • GitHub Check: OSSAR-Scan
  • GitHub Check: Analyze (javascript-typescript)
  • GitHub Check: dependency-review
  • GitHub Check: build-test (20.x)
  • GitHub Check: build-test (20.x)
🔇 Additional comments (4)
packages/schema/src/plugins/enhancer/enhance/index.ts (4)

615-615: Removing $Types alias is the right call to avoid TS1380 with type-only runtime imports.

Initializing statements without injecting import $Types = runtime.Types is correct for Prisma 6.16+ where runtime is imported as type-only.


1035-1035: Switching to runtime.Types.Skip aligns with type-only runtime import.

This avoids aliasing a type-only import and fixes TS1380.


615-615: Resolved — generated models import runtime as type-only

Confirmed: Prisma 6.16.0 "prisma-client" generator emits model files with import type * as runtime from "@prisma/client/runtime/library"; no change required.


1032-1039: Confirmed: runtime.Types.Skip is present in Prisma 6.16.0 for both generators

Prisma 6.16.0 generated clients — both the new "prisma-client" and legacy "prisma-client-js" — import from "@prisma/client/runtime/library" and expose the sentinel as runtime.Types.Skip.

@ymc9 ymc9 merged commit 87083c0 into zenstackhq:dev Sep 11, 2025
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants