Learn the fundamentals of creating, resolving and rejecting promises using TypeScript. We also cover the fundamentals of a .then
chain.
We will see how the Promise constructor takes an executor callback which will be called at runtime with two arguments (resolve and reject).
Hi! Thanks for the tutorial. I installed Typecript globally, but when I try to run the .ts file in this tutorial, I get the following error: "error TS2693: 'Promise' only refers to a type, but is being used as a value here." What am I missing? I notice you have a tsconfig file — do I need that?
What am I missing? I notice you have a tsconfig file — do I need that?
Yes. Specifically the lib option : https://basarat.gitbooks.io/typescript/content/docs/types/lib.d.ts.html
Is there any difference between throwing an error inside a promise and reject the promise?
@brendan inside a promise chain
: no. there is no difference.
Cool thx