DEV Community

Discussion on: async/await Crash Course

Collapse
 
patarapolw profile image
Pacharapol Withayasakpunt • Edited

I wonder if "starting with semicolons" is a new standard after ASI and no-semicolon.

But mine is a little different async IIFE.

;(async () => {
  // code
})().catch(console.error)

Other special cases.

;[
  ...
].forEach

;(a as any).key

Also, there is a rule in ESLint called no-return-await, so

async function foo () {
  return await fetch('/api')
}

// is same as

async function foo () {
  return fetch('/api')
}

// is same as

function foo () {
  return fetch('/api')
}

Yes, you can await sync functions as well, as long as it returns a Promise.

Collapse
 
kumareth profile image
Kumar Abhirup

Yes. I have an ESLint rule enforcing those rules... Those are nice!