Skip to content

@prisma-next/extension-postgis@0.16.0: declaration emit fails with TS2742/TS2883 due to private Geometry module #1040

Description

@rubenferreira97

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingneeds-triageAwaiting maintainer triage

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions