adelsz/pgtyped

pgTyped - Typesafe SQL in TypeScript

View on GitHub ↗Jump to charts ↓

adelsz/pgtyped has 3k+ stars and 100+ forks on GitHub, is written in TypeScript, and was last pushed on Oct 15, 2026. Data as of . Signed-in members get hourly updates — create a free account.

Summary Information

Updated 1 hour ago
Added to GitGenius on September 21st, 2026
Created on September 23rd, 2019
Open Issues & Pull Requests: 98 (+0)
GitHub issues: Enabled
Number of forks: 119
Total Stargazers: 3,284 (+0)
Total Subscribers: 13 (+0)

Repository Insights (GitGenius)

Median issue/PR response: 18.7 days
Mean response time: 111.9 days
90th percentile: 349.4 days
Tracked items: 21

Charts & Analytics

Fetching additional details & charts...

Issue Activity (beta)

Open issues: 26
New in 7 days: 1
Closed in 7 days: 0
Avg open age: 926 days
Stale 30+ days: 24
Stale 90+ days: 21

Recent activity

Opened in 7 days: 1
Closed in 7 days: 0
Comments in 7 days: 0
Events in 7 days: 0

Top labels

  • bug (14)
  • feature request (11)

Most active issues this week

Sign in to see which issues are moving.
Sign in

Detailed Description

PgTyped is a code generator that enables typesafe SQL queries in TypeScript by automatically inferring types from a running PostgreSQL database.

The tool solves the problem of maintaining type safety when writing raw SQL in TypeScript applications. Rather than requiring developers to manually map database schemas to TypeScript types or use an ORM, PgTyped connects to a live Postgres instance and analyzes the actual schema to generate strictly typed query interfaces. It extracts SQL queries from both dedicated SQL files and TypeScript files, then produces corresponding TypeScript types and interfaces that guarantee parameter and result types match the database schema. The approach prevents SQL injection by sending queries and parameters separately to the database driver, allowing PostgreSQL itself to handle parameter substitution safely.

Developers should choose this tool if they prefer writing raw SQL while maintaining full type safety, and if their project uses PostgreSQL as the database. It suits teams that want to avoid the overhead of ORMs or schema definition layers but still need compile-time guarantees about query correctness. The tool supports watch mode for regenerating types as queries are written, works with both CommonJS and ESM, and provides helper utilities for complex parameter interpolation with arrays and objects.

The project maintains active development with ongoing API refinement. The maintainers welcome issue reports, feature requests, and pull contributions from the community.