TypeScript Playground
See type diagnostics beside runtime output. No Node.js APIs or external models are available here.
TypeScript Lab
Playground 1 · Add a type to a task object
Predict whether the title or undefined will print. Then describe the task fields and let the editor catch titel.
正在加载 TypeScript 编辑器…
Diagnostics 0
运行后显示诊断。
Output
等待执行。
Need a hint?
Create ReviewTask with a string title, number priority, and optional assignee.
Expected diagnostics: First task is implicitly any. After adding ReviewTask, the editor reports that titel does not exist and suggests title.
Expected output: Before: [1] undefined; after: [1] Check login
Show solution
type ReviewTask = {
title: string;
priority: number;
assignee?: string;
};
function formatTask(task: ReviewTask): string {
return `[${task.priority}] ${task.title}`;
}
console.log(formatTask({ title: "Check login", priority: 1 }));