All Articles

TypeScript 5.0 has landed!

Matt Pocock
Matt PocockMatt is a well-regarded TypeScript expert known for his ability to demystify complex TypeScript concepts.

TypeScript 5.0 has made it to Total TypeScript!

It brought a lot of improvements - you can learn all about it in our 5.0 breakdown.

The most exciting feature for Total TypeScript was const type parameters.

It lets you specify a type parameter as const - meaning that everything that gets passed to that parameter gets inferred as if it were as const.

const routes = <const TRoutes>( routes: TRoutes ) => { return routes; }; const myRoutes = routes({ user: "/user", createUser: "/user/create", }); Object.values(myRoutes); // ['/user', '/user/create'] // Before 5.0, myRoutes would be inferred as string[] 

Before 5.0, you needed to use a hack in TypeScript to get this behaviour - the F.Narrow type helper from ts-toolbelt. I even taught this in Total TypeScript!

No longer - I've re-recorded 3 exercises in TT's Advanced Patterns workshop to take advantage of const type annotations.

I can't wait to see what you build with them!

Matt's signature

TypeScript 5.0 has landed!

Cursor Rules for Better AI Development

Finding existing community .cursor/rules for TypeScript lacking, I'm sharing my own set to hopefully kickstart a discussion on what makes effective AI coding guidance. These rules focus purely on TypeScript language features, documentation, structure (like Result types), teaching the AI specific nuances (like noUncheckedIndexedAccess), and practical habits, rather than specific frameworks. I also distinguish between shareable, project-specific Workspace Rules (versioned in Git) and personalized Global Rules (living in your IDE) to tailor the AI to your individual style and workflow. You can download my current ruleset using the link in the original post.

Matt Pocock
Matt Pocock

Should You Declare Return Types?

Here's a quick .cursor/rules addition you can make for handling return types in TypeScript.

# Return Types

When declaring functions on the top-level of a module,
declare their return types. This will help future AI
assistants understand the function's purpose.

```ts
const myFunc = (): string => {
  return "hello";
};
```

One exception to this is components which return JSX.
No need to
Matt Pocock
Matt Pocock

TypeScript Announces Go Rewrite, Achieves 10x Speedup

TypeScript announced a full rewrite of TypeScript in Go. In testing, this rewrite has achieved a 10x speedup in some repositories - and up to 15x in others.

Matt Pocock
Matt Pocock

TypeScript 5.8 Ships --erasableSyntaxOnly To Disable Enums

TypeScript 5.8's new erasableSyntaxOnly flag enforces pure type annotations by disabling enums, namespaces, and parameter properties.

Matt Pocock
Matt Pocock