prisma-generator-typescript-interfaces is a Prisma generator designed to create entirely standalone, zero-dependency TypeScript interface definitions directly from a Prisma schema. Its primary purpose is to provide type definitions for models, enums, and other schema elements without requiring the full `@prisma/client` package or the generated Prisma client itself. This makes the generated types ideal for use cases such as Data Transfer Objects (DTOs) in API layers, sharing types across different services in a monorepo, or any scenario where a lightweight, independent type declaration is preferred. The package is currently stable at version 3.1.0 and has seen consistent development, including several minor and patch releases, with a recent major version (v3.0.0) introducing notable breaking changes. A key differentiator is its extensive customizability, allowing users to configure types for various Prisma scalar types (like Date, BigInt, Decimal, Bytes) to either maintain compatibility with Prisma client's native types or to match common JSON serialization formats. It also provides granular control over relation handling and enum generation.
npm install prisma-generator-typescript-interfacesVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to configure the generator in `schema.prisma`, run the generation command, and then import and use the generated `User` interface and `Gender` enum in a TypeScript application.
Update your `generator` block in `schema.prisma`. Replace `omitRelations = true` or `optionalRelations = true` with `relations = "none"` or `relations = "optional"` respectively. Use `relations = "required"` for the default behavior.
To replicate the behavior of `BufferObject` or `ArrayObject`, you must now define a custom type. Refer to the 'Custom Types' documentation for guidance on how to define these via the `customTypes` option.
Upgrade your project's TypeScript version to 4.9 or newer. Alternatively, avoid using `enumType = "object"` and choose a different `enumType` setting.
If you are using Prisma v5 and require `Buffer` types for compatibility with your Prisma client, explicitly set `bytesType = "Buffer"` in your generator configuration in `schema.prisma`.
Replace `omitRelations` or `optionalRelations` with the new `relations` option. For example, use `relations = "none"` to omit all relations, or `relations = "optional"`.
Remove `bytesType = "BufferObject"` (or `ArrayObject`) from your generator configuration. If you need this behavior, define a custom type using the `customTypes` option.
Upgrade your TypeScript dependency to version 4.9 or higher, or change the `enumType` option in your generator configuration to a different value.
Explicitly set `bytesType = "Buffer"` in your `generator typescriptInterfaces` block in `schema.prisma` if you are using Prisma v5.
No dependency data recorded yet.