TS7009

error TS7009: ‘new’ expression, whose target lacks a construct signature, implicitly has an ‘any’ type.

Broken Code ❌

1
2
3
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:

1
2
3
export function getPromise(): Promise<void> {
return Promise.resolve();
}

Alternatively, you can make use of the constructor:

1
2
3
4
5
export function getPromise(): Promise<void> {
return new Promise((resolve) => {
resolve();
});
}