Skip to content

Await in static field initializerΒ #43099

Closed
@Kingwl

Description

@Kingwl

Bug Report

πŸ”Ž Search Terms

πŸ•— Version & Regression Information

  • I was unable to test this on prior versions because _______

⏯ Playground Link

Playground

πŸ’» Code

async function f () {
  class C {
    static a = await (Promise.resolve(1)) // error here
  }
  return C as any
}

f().then(c => {
  console.log(c.a) 
})

πŸ™ Actual behavior

ReferenceError: await is not defined when target below es2020

πŸ™‚ Expected behavior

No error at wait.
Output: 1

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugA bug in TypeScript

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions