Skip to content

import<T> is valid syntax in nightly #48759

@evanw

Description

@evanw

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 and 4.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.

Metadata

Metadata

Assignees

Labels

BugA bug in TypeScriptFix AvailableA PR has been opened for this issueHelp WantedYou can do this

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions