TypeScript code examples · runnable

20 runnable TypeScript code examples.

Open any TypeScript example to explore the code and run it online. No setup, no signup.

TypeScript

How to convert a string to a number in TypeScriptHow to use getters and setters in TypeScriptHow to create a dictionary in TypeScriptHow to convert a string to an enum in TypeScriptHow to type a callback function in TypeScriptHow to extend a type in TypeScriptHow to remove an item from an array in TypeScriptHow to check for null or undefined in TypeScriptHow to loop through an enum in TypeScriptHow to check a type at runtime in TypeScriptHow to define class constants in TypeScriptHow to parse JSON into a typed object in TypeScriptHow to overload a function in TypeScriptHow to use async/await with Array.map in TypeScriptHow to check if a value exists in an enum in TypeScriptHow to omit a property from a type in TypeScriptHow to loop through an object in TypeScriptHow to get the return type of a function in TypeScriptHow to create a union type from an array in TypeScriptHow to check a switch is exhaustive in TypeScript
Questions & answers

TypeScript examples, explained

Can I run these TypeScript code examples?

Yes. Open any TypeScript example to edit and run its code on the CompileBytes engine without installing anything.

Is this free? Do I need an account?

Every example is free to read, run, edit, and copy. No account is required.

Can I copy these into my own projects?

Yes. These examples are designed to be copied and adapted to your own code.

Where can I run my own code?

Open the TypeScript compiler from the main playground catalog, then paste or write any code you want to run.