Skip to content
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

Incorrect ASI inside 'declare type' #54760

Closed
strager opened this issue Jun 24, 2023 · 2 comments · Fixed by #54761
Closed

Incorrect ASI inside 'declare type' #54760

strager opened this issue Jun 24, 2023 · 2 comments · Fixed by #54761
Assignees
Labels
Fix Available A PR has been opened for this issue Needs Investigation This issue needs a team member to investigate its status.

Comments

@strager
Copy link
Contributor

strager commented Jun 24, 2023

Bug Report

If there is a newline between declare type and T = null;, then as of v4.4.4 the parser behaves as if there was a semicolon between type and T (good) but also a semicolon between declare and type (bug).

declare /*ASI*/ type /*ASI*/
T = null;

I think it's a bug that a semicolon was implicitly inserted between declare and type without any newline in the source code. ASI normally interjects only if a newline is present (or in other special cases which I don't think apply here).

In version v4.3.5, the parser behaved as if there was only a semicolon between type and T (where there's a newline).

🔎 Search Terms

declare type asi

🕗 Version & Regression Information

  • This changed between versions v4.3.5 and v4.4.4

⏯ Playground Link

Playground link with relevant code

💻 Code

var declare, type, T;

declare type
T = null;

🙁 Actual behavior

No diagnostic.

🙂 Expected behavior

Diagnostic: "';' expected." referring to after the declare token on line 3.

@evanw
Copy link
Contributor

evanw commented Jun 24, 2023

See also #54602

@RyanCavanaugh RyanCavanaugh added the Needs Investigation This issue needs a team member to investigate its status. label Jun 26, 2023
@RyanCavanaugh RyanCavanaugh added this to the TypeScript 5.3.0 milestone Jun 26, 2023
@typescript-bot typescript-bot added the Fix Available A PR has been opened for this issue label Jun 27, 2023
@jakebailey
Copy link
Member

FWIW this (and #54602) bisects to #43005.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Fix Available A PR has been opened for this issue Needs Investigation This issue needs a team member to investigate its status.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants