-
Notifications
You must be signed in to change notification settings - Fork 13k
Closed
Labels
BugA bug in TypeScriptA bug in TypeScriptFix AvailableA PR has been opened for this issueA PR has been opened for this issue
Milestone
Description
Bug Report
🔎 Search Terms
asi new expression type arguments
🕗 Version & Regression Information
TypeScript 4.7 Nightly (tested with the playground). This syntax has never been valid before TS 4.7.
new X<T>;
is valid syntax since #47607 (cc @ahejlsberg)
⏯ Playground Link
Playground link with relevant code
💻 Code
class A<T> {}
new A<number>
if (0) {}
🙁 Actual behavior
It's parsed as if it was
class A<T> {}
new A<number> if (0) {}
thus it reports a few errors (number
is used in a value position, and if
is a reserved word).
🙂 Expected behavior
I would expect ASI to kick in, and to parse the code as if it was
class A<T> {}
new A<number>;
if (0) {}
Context
I'm implementing this in Babel. If it's expected that ASI does not work here, what are the rules to differentiate between a new expression with only type arguments, and a relational comparison?
Metadata
Metadata
Assignees
Labels
BugA bug in TypeScriptA bug in TypeScriptFix AvailableA PR has been opened for this issueA PR has been opened for this issue