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.
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
Enjoying the course? Follow Jon Meyers on Twitter and subscribe to the YouTube channel.