Skip to content

import<T> is valid syntax in nightly #48759

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
evanw opened this issue Apr 19, 2022 · 2 comments · Fixed by #48787
Closed

import<T> is valid syntax in nightly #48759

evanw opened this issue Apr 19, 2022 · 2 comments · Fixed by #48787
Assignees
Labels
Bug A bug in TypeScript Fix Available A PR has been opened for this issue Help Wanted You can do this

Comments

@evanw
Copy link
Contributor

evanw commented Apr 19, 2022

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.

@fatcerberus
Copy link

fatcerberus commented Apr 19, 2022

4.6.2 produces this error for a dynamic import with type arguments:

Dynamic import cannot have type arguments.

let foo = import; is also not valid JS, so this definitely looks like an oversight.

@RyanCavanaugh RyanCavanaugh added Bug A bug in TypeScript Help Wanted You can do this labels Apr 19, 2022
@RyanCavanaugh RyanCavanaugh added this to the Backlog milestone Apr 19, 2022
@typescript-bot typescript-bot added the Fix Available A PR has been opened for this issue label Apr 29, 2022
@DanielRosenwasser
Copy link
Member

Thanks @a-tarasyuk!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug in TypeScript Fix Available A PR has been opened for this issue Help Wanted You can do this
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants