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?
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
🙁 Actual behavior
It's parsed as if it was
thus it reports a few errors (
numberis used in a value position, andifis a reserved word).🙂 Expected behavior
I would expect ASI to kick in, and to parse the code as if it was
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?