Native TypeScript Support
One of Bun's standout features is native TypeScript support. You can run .ts files directly without any configuration or build step.
Running TypeScript Directly
In Bun, TypeScript just works:
Loading Bun Playground...
Interfaces and Types
Define and use TypeScript interfaces:
Loading Bun Playground...
Type Aliases and Union Types
Loading Bun Playground...
Generic Types
Use generics for reusable, type-safe code:
Loading Bun Playground...
Async TypeScript
TypeScript with async/await:
Loading Bun Playground...
Exercise: Type-Safe Function
Create a type-safe function to validate user input:
Loading Bun Exercise...
Exercise: Generic Array Utility
Create a generic function to get the last element of an array:
Loading Bun Exercise...
Exercise: Interface Implementation
Create an interface and a function that uses it:
Loading Bun Exercise...

