Here's one way to create an async/await wrapper for the setTimeout function in TypeScript:
index.ts117 chars4 linesThis function takes a number of milliseconds to delay for, and returns a promise that resolves with void after the specified delay.
To use this function, simply await its return value:
index.ts114 chars6 linesThis will log "Before delay" to the console, wait for 1 second, and then log "After delay".
gistlibby LogSnag