Package and version
@prisma-next/postgres@0.16.0
What happened?
Exporting a TypeScript-authored contract that composes the PostGIS extension prevents TypeScript declaration emission.
Merely adding @prisma-next/extension-postgis/pack to extensionPacks is sufficient to trigger the error. No geometry column or database connection is required.
error TS2883: The inferred type of 'contract' cannot be named without a
reference to 'Geometry' from
'../node_modules/@prisma-next/extension-postgis/dist/geojson-L3qRlIZY.mjs'.
This is likely not portable. A type annotation is necessary.
Removing the PostGIS extension pack allows declaration emission to succeed.
What did you expect to happen?
TypeScript declaration emission should succeed when the PostGIS extension pack is composed into an exported contract.
The emitted declaration should refer only to stable public package exports, such as:
@prisma-next/extension-postgis/geojson
@prisma-next/extension-postgis/codec-types
@prisma-next/extension-postgis/pack
It should not need to reference a private, build-hashed module under the package's dist directory.
Minimal reproduction
Install the dependencies:
bun add '@prisma-next/extension-postgis@0.16.0' '@prisma-next/postgres@0.16.0'
bun add --dev 'typescript@5.9.3'
contract.ts:
import postgis from '@prisma-next/extension-postgis/pack';
import { defineContract } from '@prisma-next/postgres/contract-builder';
export const contract = defineContract(
{
extensionPacks: { postgis },
},
({ field, model }) => ({
models: {
Example: model('Example', {
fields: {
id: field.int().id(),
},
}),
},
}),
);
tsconfig.json:
{
"compilerOptions": {
"declaration": true,
"emitDeclarationOnly": true,
"module": "preserve",
"moduleResolution": "bundler",
"noEmitOnError": true,
"preserveSymlinks": true,
"skipLibCheck": true,
"strict": true,
"target": "ESNext"
},
"files": ["contract.ts"]
}
Run:
tsc --project tsconfig.json
Environment
- Node: 26.3.0
- OS: Windows 11, build 10.0.26200
- Package manager: Bun 1.4.0
- TypeScript: 7.0.1
- Target database: PostgreSQL 18.1
- Database connection required to reproduce: No
Additional context
The published PostGIS pack declaration carries CodecTypes, whose Geometry type resolves through a private generated module similar to:
@prisma-next/extension-postgis/dist/geojson-L3qRlIZY.mjs
The package already exposes stable public GeoJSON and codec type entrypoints, so the inferred public contract type should ideally be nameable through those exports.
A temporary consumer workaround is to widen the exported contract:
import type { Contract } from '@prisma-next/contract/types';
export const contract: Contract = defineContract(/* ... */);
This permits declaration emission, but loses the precise inferred type of the exported contract, so it does not seem like an ideal permanent consumer-side solution.
Package and version
@prisma-next/postgres@0.16.0
What happened?
Exporting a TypeScript-authored contract that composes the PostGIS extension prevents TypeScript declaration emission.
Merely adding
@prisma-next/extension-postgis/packtoextensionPacksis sufficient to trigger the error. No geometry column or database connection is required.Removing the PostGIS extension pack allows declaration emission to succeed.
What did you expect to happen?
TypeScript declaration emission should succeed when the PostGIS extension pack is composed into an exported contract.
The emitted declaration should refer only to stable public package exports, such as:
@prisma-next/extension-postgis/geojson@prisma-next/extension-postgis/codec-types@prisma-next/extension-postgis/packIt should not need to reference a private, build-hashed module under the package's
distdirectory.Minimal reproduction
Install the dependencies:
contract.ts:tsconfig.json:{ "compilerOptions": { "declaration": true, "emitDeclarationOnly": true, "module": "preserve", "moduleResolution": "bundler", "noEmitOnError": true, "preserveSymlinks": true, "skipLibCheck": true, "strict": true, "target": "ESNext" }, "files": ["contract.ts"] }Run:
tsc --project tsconfig.jsonEnvironment
Additional context
The published PostGIS pack declaration carries
CodecTypes, whoseGeometrytype resolves through a private generated module similar to:The package already exposes stable public GeoJSON and codec type entrypoints, so the inferred public contract type should ideally be nameable through those exports.
A temporary consumer workaround is to widen the exported contract:
This permits declaration emission, but loses the precise inferred type of the exported contract, so it does not seem like an ideal permanent consumer-side solution.