Online TypeScript Editor
Write, refactor, and download TypeScript source in the browser with completions, find, and format helpers.
Completions appear as you type; press Ctrl+Space to open the list. Tab expands snippets where available. Find: Ctrl+F (Cmd+F on Mac). Format: toolbar button or Ctrl+Shift+B for supported languages.
Choose editor font size in pixels
Write, refactor, and download TypeScript source in the browser with completions, find, and format helpers.
Related technologies: Node.js, React, Angular, tsc — see also JavaScript Editor, TSX Editor, JSON Editor.
Starter snippet
type User = { id: string; roles: readonly string[] };
function hasRole(user: User, role: string): boolean {
return user.roles.includes(role);
}Fetch + JSON guard
export async function getJson(url) {
const res = await fetch(url, { headers: { Accept: 'application/json' } });
if (!res.ok) throw new Error(`HTTP ${res.status}`);
return res.json();
}Immutable update
const next = {
...state,
items: state.items.map((it) =>
it.id === id ? { ...it, done: true } : it
),
}; Variables
const port = 3000; let cache: Map<string, User> = new Map();Loops
for (const [k, v] of cache) { }Functions / methods
function pick<T, K extends keyof T>(obj: T, key: K): T[K] { return obj[key]; }Comments
// line /* block */Bindings
const limit = 25;
let cursor = 0;
var legacy = true; // avoid in new codeLoops
for (const item of list) {
work(item);
}
while (cursor < limit) { cursor++; } Parse → transform → emit
// TypeScript pipeline sketch
const input = readLines();
const output = input
.map(line => line.trim())
.filter(Boolean)
.map(transform);
writeLines(output);Error handling wrapper
// TypeScript
function runSafely(task) {
try {
return { ok: true, value: task() };
} catch (err) {
return { ok: false, error: String(err) };
}
} - Is TypeScript compiled here?
- You edit TypeScript with syntax support; compilation happens in your project toolchain.