Open this example in the interactive library
Source code
type Task = (name: string, attempt?: number) => string;
const task: Task = (name, attempt = 1) => name + " #" + attempt;
console.log(
(() => {
interface Format {
(n: number): string;
}
const format: Format = (n) => n.toFixed(2);
return format(3);
})(),
);
Sample output
3.00
