TS7009
'new' expression, whose target lacks a construct signature, implicitly has an 'any' type.
Broken Code ❌
export function getPromise(): Promise<void> {
return new Promise.resolve();
}Fixed Code ✔️
The resolve function of a Promise is not a constructor. You can use the new keyword only with constructors, so the new keyword has to be removed in order to fix the code:
export function getPromise(): Promise<void> {
return Promise.resolve();
}Alternatively, you can make use of the constructor:
export function getPromise(): Promise<void> {
return new Promise((resolve) => {
resolve();
});
}