Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR TYPESCRIPT

ts async function type

// async anonymous  function always returns a Promise
const dramaticWelcome: Promise<void> = async () => {
    console.log("Hello");

    for (let i = 0; i < 5; i++) {
        // await is converting Promise<number> into number
        const count: number = await delay(500, i);
        console.log(count);
    }

    console.log("World!");
}
 
PREVIOUS NEXT
Tagged: #ts #async #function #type
ADD COMMENT
Topic
Name
5+3 =