/** * Some predefined delay values (in milliseconds). */ export enum Delays { Short = 500, Medium = 2000, Long = 5000, } /** * Returns a Promise that resolves after a given time. * * @param {string} name - A name. * @param {number=} [delay=Delays.Medium] - A number of milliseconds to delay resolution of the Promise. * @returns {Promise} */ function delayedHello( name: string, delay: number = Delays.Medium, ): Promise { return new Promise((resolve: (value?: string) => void) => setTimeout(() => resolve(`Hello, ${name}`), delay), ) } // Please see the comment in the .eslintrc.json file about the suppressed rule! // Below is an example of how to use ESLint errors suppression. You can read more // at https://eslint.org/docs/latest/user-guide/configuring/rules#disabling-rules // eslint-disable-next-line @typescript-eslint/explicit-function-return-type export async function greeter(name: any) { // eslint-disable-line @typescript-eslint/no-explicit-any // The name parameter should be of type string. Any is used only to trigger the rule. return await delayedHello(name, Delays.Medium) } await greeter('world').then(console.log)