Skip to content

Plain JS files don't issue error on await inside non-async function #49483

@sandersn

Description

@sandersn

The following file should have an error in any JS file that isn't explicitly opted out of JS checking:

function f() {
  await new Promise(undefined);
}

Expected: "await expressions are only allowed within async functions"
Actual: no error.

Note that other plain JS errors work fine; function f() { break } and const x = 1; const x = 2 both error as expected.

Metadata

Metadata

Assignees

Labels

BugA bug in TypeScriptFix AvailableA PR has been opened for this issuecheckJsRelates to checking JavaScript using TypeScript

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions