0
votes

Expected Behavior: Able to use promises in TypeScript.

Observed Behavior: Using promises gives the following type error, 'new' expression, whose target lacks a construct signature, implicitly has an 'any' type.ts(7009)

How to duplicate the problem: 1) Within a create react app using TypeScript try creating a promise.

 const test = new Promise<string>((res, _rej) => {
    res("hi");
  });
1
What is your question? This sounds more like a bug report, which should be filed in the TypeScript bug tracker. - Jörg W Mittag
Thank you Jörg. It is working now without any changes on my end. Can we delete this question? - Olli Tapio
@OlliTapio something changed, you just don't know what ;) - Evert
Ha fair enough! - Olli Tapio

1 Answers

0
votes

You can use Promise.resolve instead like as below:

const test = Promise.resolve<string>("Hi")