⬅️ FEM TypeScript Fundamentals
Promises
- TypeScript needs to statically type promises, just like it does for other code.
- All promises have the type
Promise<T>, whereTis the type of the value inside the promise - It’s easy to forget to give functions a
Promisereturn type.
//👎
const promise: number = Promise.resolve(100);
promise;
//Async Result:
type error: Type 'Promise<number>' is not assignable to type 'number'.