Property 'allSettled' does not exist on type 'PromiseConstructor'.ts(2339)

后端 未结 3 1284
慢半拍i
慢半拍i 2020-12-16 11:14

I\'m trying to use the Promise.allSettled API with TypeScript. Code here:

server.test.ts:

it(\'shou         


        
3条回答
  •  南笙
    南笙 (楼主)
    2020-12-16 11:54

    The types for Promise.allSettled() were only merged in January, and will apparently be released in TypeScript 3.8.

    As an interim solution, you can declare a mock-ish type for the function yourself:

    declare interface PromiseConstructor {
        allSettled(promises: Array>): Promise>;
    }
    

提交回复
热议问题