๐ Search Terms
parser, async, conditional
๐ Version & Regression Information
- This is the behavior in every version I tried
โฏ Playground Link
No response
๐ป Code
const a = true;
const b = 1;
function async(): number {
return b;
}
const first = a ? async() : 0;
// TS1005: '=>' expected.
const second = a ? async() : x => x;
// TS1005: ':' expected.
๐ Actual behavior
The parser appears to interpret async() as the beginning of an async arrow function and the conditional separator as a return-type annotation.
The first case also produces a syntax diagnostic when parsed as JavaScript after removing the : number annotation. Node accepts and executes that JavaScript equivalent
๐ Expected behavior
Both conditional expressions should parse successfully. async() is a call to the function named async, and the following colon separates the conditionalโs branches.
Additional information about the issue
Oxc fix: https://github.com/oxc-project/oxc/pull/26537/changes
๐ Search Terms
parser, async, conditional
๐ Version & Regression Information
โฏ Playground Link
No response
๐ป Code
๐ Actual behavior
The parser appears to interpret async() as the beginning of an async arrow function and the conditional separator as a return-type annotation.
The first case also produces a syntax diagnostic when parsed as JavaScript after removing the : number annotation. Node accepts and executes that JavaScript equivalent
๐ Expected behavior
Both conditional expressions should parse successfully. async() is a call to the function named async, and the following colon separates the conditionalโs branches.
Additional information about the issue
Oxc fix: https://github.com/oxc-project/oxc/pull/26537/changes