π Search Terms
- missing await in conditional
- await
- conditional
π Version & Regression Information
Since 4.3.0-dev
β― Playground Link
Playground link with relevant code
π» Code
declareconstcache: Record<string,Promise<string>>declareconstfetchThing: (id: string)=>Promise<string>constgetCachedThing1=(id: string)=>{letthing=cache[id]return!thing// not an error, if the error in getCachedThing3 is valid then why this isn't an error?
? (cache[id]=fetchThing(id))
: thing}constgetCachedThing2=(id: string)=>{letthing=cache[id]returnthing??(cache[id]=fetchThing(id))// not an error}constgetCachedThing3=(id: string)=>{letthing=cache[id]returnthing// error (2801), but it should't be, getCachedThing3 isn't async function
? thing
: (cache[id]=fetchThing(id))}After applying quick fix to getChachedThing3 error:
constgetCachedThing3=(id: string)=>{letthing=cache[id]returnawaitthing// error (2801), but it should't be, getCachedThing3 isn't async function// error (2801), but it should't be, getCachedThing3 isn't async function
? thing
: (cache[id]=fetchThing(id))}Quick fixed code is invalid (await is added to non-async function). Also, comment gets duplicated.
π Actual behavior
- Missing await in conditional errors are inconsistent
- Missing await in conditional errors get reported in non-async functions
- Quick fixing the error in non-async function produces invalid results
π Expected behavior
- Missing await in conditional errors to be consistent
- Missing await in conditional errors to NOT be reported in non-async functions
- No quick fix suggestion in non-async function
As a sidenote, I think the "missing await in conditional error" feature should be under a flag
- It is wildly inconsistent
- This is a job for linters
- Objects are thruthy, so let them be thruthy :)
- This feature breaks existing code
π Search Terms
π Version & Regression Information
Since 4.3.0-dev
β― Playground Link
Playground link with relevant code
π» Code
After applying quick fix to
getChachedThing3error:Quick fixed code is invalid (
awaitis added to non-async function). Also, comment gets duplicated.π Actual behavior
π Expected behavior
As a sidenote, I think the "missing await in conditional error" feature should be under a flag