Course lesson
Declare Global Intersection Types for Transformed Supabase Data with Typescript
TypeScript reduces runtime errors and makes code more maintainable. In this lesson, we use the Supabase CLI to introspect our PostgreSQL schema and generate TypeScript definitions.
- Duration
- 4 min
- Access
- Free
- Transcript
- Retained from source evidence
TypeScript reduces runtime errors and makes code more maintainable. In this lesson, we use the Supabase CLI to introspect our PostgreSQL schema and generate TypeScript definitions.
Additionally, we resolve a collection of TypeScript errors and create a custom union type for our transformed tweets - making it globally available throughout our Next.js application.
Code Snippets
Custom type for TweetWithAuthor
type TweetWithAuthor = Tweet & {
author: Profile;
likes: number;
user_has_liked_tweet: boolean;
};Generate TypeScript definitions
npx supabase gen types typescript --project-id your-project-id > lib/database.types.ts