Search Terms
missing await error refactoring
Suggestion
Missing an await can cause some confusion especially for people who haven't used async/await before. A helpful error message when you have a Promise<T> instead of T that suggests maybe an await is missing might help address this. There are at least a few common cases this comes up:
- Using operators, and T is a primitive type. If T were say an object type, it seems more likely something else is wrong with the code to me.
- Passing to a function, and T is a valid parameter at that position.
- for-of and T is some array type
- The target of a member expression and T has the member (or maybe the property name is not in Promise).
A quick fix could also be considered. When in an async function and an error such as above appears, a quick fix that adds an await before the source of the promise within that function.
Use Cases
It helps people realize when they need an await.
Checklist
My suggestion meets these guidelines:
Search Terms
missing await error refactoring
Suggestion
Missing an
awaitcan cause some confusion especially for people who haven't used async/await before. A helpful error message when you have a Promise<T> instead of T that suggests maybe an await is missing might help address this. There are at least a few common cases this comes up:A quick fix could also be considered. When in an async function and an error such as above appears, a quick fix that adds an await before the source of the promise within that function.
Use Cases
It helps people realize when they need an await.
Checklist
My suggestion meets these guidelines: