# @prisma-next/ts-render

> TypeScript source-text rendering utilities: JSON-to-TS literal printer and abstract expression base class

Latest version **0.16.0** (published 2026-07-21) · Apache-2.0 license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install @prisma-next/ts-render
pnpm add @prisma-next/ts-render
yarn add @prisma-next/ts-render
bun add @prisma-next/ts-render
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 0.16.0 |
| Published | 2026-07-21 |
| First published | 2026-04-24 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | bundled |
| Module format | ESM |
| Node | >=24 |
| Dependencies | 0 |
| Unpacked size | 60.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 414 |
| Maintainers | sevinf, tylerhogarth, aqrln, wmadden-prisma |

## Links

- npm: https://www.npmjs.com/package/@prisma-next/ts-render
- Repository: https://github.com/prisma/prisma-next
- Homepage: https://github.com/prisma/prisma-next#readme
- Issues: https://github.com/prisma/prisma-next/issues
- npm.io page: https://npm.io/package/@prisma-next/ts-render

## Recent versions

- 0.16.0 (latest) — 2026-07-21
- 0.16.0-dev.35 (dev) — 2026-08-24
- 0.16.0-dev.34 — 2026-07-27
- 0.16.0-dev.33 — 2026-07-27
- 0.16.0-dev.32 — 2026-07-27
- 0.16.0-dev.31 — 2026-07-27
- 0.16.0-dev.30 — 2026-07-27
- 0.16.0-dev.29 — 2026-07-27
- 0.16.0-dev.28 — 2026-07-24
- 0.16.0-dev.27 — 2026-07-24
- 0.16.0-dev.26 — 2026-07-24
- 0.16.0-dev.25 — 2026-07-24
- 0.16.0-dev.24 — 2026-07-24
- 0.16.0-dev.23 — 2026-07-24
- 0.16.0-dev.22 — 2026-07-23
- … 508 more at https://npm.io/package/@prisma-next/ts-render/versions

## README

# @prisma-next/ts-render

> **Internal package.** This package is an implementation detail of [`prisma-next`](https://www.npmjs.com/package/prisma-next)
> and is published only to support its runtime. Its API is unstable and may change
> without notice. Do not depend on this package directly; install `prisma-next` instead.

TypeScript source-text rendering utilities shared by any Prisma Next component that has to emit hand-editable `.ts` files — today the Postgres and Mongo migration-authoring surfaces, later any new target that ships a migration-authoring experience.

## Overview

Two small pieces:

- **`TsExpression`** — abstract base class for any node that renders as a TypeScript expression in a generated source file. Subclasses supply `renderTypeScript(): string` and `importRequirements(): readonly ImportRequirement[]`. Hierarchical so that composite nodes (e.g. a `DataTransformCall` containing slot expressions) can recurse into their children.
- **`jsonToTsSource(value)`** — pure JSON-to-TypeScript-source printer. Accepts `unknown` for ergonomics with structural types whose fields happen to be JSON-compatible, and throws at runtime on anything that is not a JSON primitive / array / object.

## Codec → TS pipeline

`jsonToTsSource` is deliberately the **second** stage of a two-stage pipeline:

```text
jsValue  →  codec.encodeJson  →  JsonValue  →  jsonToTsSource  →  TS source text
```

Stage 1 (`codec.encodeJson`) is a codec responsibility — date serialization, opaque domain types (vector, bigint, uuid), JSON canonicalization. Stage 2 (this module) is a pure printer that must never grow type-specific branches. To render a non-JSON JS value (`Date`, `Vector`, `BigInt`, `Buffer`, …), encode it through the relevant codec's `encodeJson` first.

## Usage

```ts
import { type ImportRequirement, TsExpression, jsonToTsSource } from '@prisma-next/ts-render';

class CreateTableCall extends TsExpression {
  constructor(
    readonly schema: string,
    readonly table: string,
    readonly columns: ReadonlyArray<{ name: string; typeSql: string; nullable: boolean }>,
  ) {
    super();
  }

  override renderTypeScript(): string {
    return `createTable(${jsonToTsSource(this.schema)}, ${jsonToTsSource(this.table)}, ${jsonToTsSource(this.columns)})`;
  }

  override importRequirements(): readonly ImportRequirement[] {
    return [{ moduleSpecifier: '@prisma-next/postgres/migration', symbol: 'createTable' }];
  }
}
```

---
_Source: https://npm.io/package/@prisma-next/ts-render · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
