TypeScript

Unhandled promise rejection crashing the app in TypeScript

TypeScriptAsync & PromisesHandling Async Errorsintermediate

What this snippet does

If an awaited promise throws and isn't caught, it becomes an unhandled rejection, which crashes Node.js applications.

Expected output

done
(node:1234) UnhandledPromiseRejectionWarning: Error: crash

Why practise typing this

Typing async & promises code builds muscle memory for the symbols and indentation TypeScript uses most, which prose-based typing tests never cover. DevType measures your words per minute and accuracy on this snippet and tracks the individual characters you mistype, so later lessons can target them.

More TypeScript practice

Browse all TypeScript snippets →