Description
Bug Report
Context: I'm trying to figure out how to update esbuild to handle the latest ASI-related behavior changes that just landed (#48755 and #48659). In the process, I discovered this weird TypeScript behavior that I believe was an oversight. I assume #47607 introduced the regression since it landed around the same time.
I tried to dig through code history to understand this better. It looks like isStartOfLeftHandSideExpression
allows <
after import
due to #16544, although no tests were added for import
followed by <
in that PR. So I'm assuming TypeScript only allows <
after import
for parser recovery, which I don't need to support in esbuild.
🔎 Search Terms
regression import expression type parameters missing arguments
🕗 Version & Regression Information
- This changed between versions
4.7.0-dev.20220216
and4.7.0-dev.20220217
⏯ Playground Link
Playground link with relevant code
💻 Code
import<T>;
let foo = import<foo, bar>;
🙁 Actual behavior
The nightly TypeScript compiler converts the above TypeScript code into the following JavaScript without any errors:
"use strict";
import;
let foo = (import);
🙂 Expected behavior
I either expected the TypeScript compiler to consider this invalid syntax, or if it's valid syntax I expected it to give type errors for the missing type names.
Activity
fatcerberus commentedon Apr 19, 2022
4.6.2 produces this error for a dynamic import with type arguments:
let foo = import;
is also not valid JS, so this definitely looks like an oversight.DanielRosenwasser commentedon Apr 29, 2022
Thanks @a-tarasyuk!