Home / Companies / LogRocket / Blog / Post Details
Content Deep Dive

Kanel tutorial: Generating TypeScript types from PostgreSQL

Blog post from LogRocket

Post Details
Company
Date Published
Author
Agustinus Theodorus
Word Count
2,513
Language
-
Hacker News Points
-
Summary

Synchronizing database types with source code is crucial for creating secure and maintainable software, as mismatches can cause runtime errors, particularly in dynamic languages like JavaScript. TypeScript offers a solution by catching type errors at compile time, but it does not automatically generate type definitions from a database. Tools like Kanel address this gap by generating TypeScript types from PostgreSQL databases, facilitating database-driven development where the database schema serves as the primary source of truth for applications. Unlike ORMs, Kanel focuses solely on type generation and requires additional tools for database interaction, supporting multiple SQL query builders like Kysely and Knex. The text describes how to use Kanel along with a tutorial on creating a to-do list app using Vue.js, NestJS, Kanel, and Kysely in a monorepo setup, emphasizing the advantages of Kanel in ensuring type safety and reducing manual type declaration efforts.