Skip to content

Incorrect ASI inside 'declare type' #54760

Closed
@strager

Description

@strager

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.

Metadata

Metadata

Assignees

Labels

Fix AvailableA PR has been opened for this issueNeeds InvestigationThis issue needs a team member to investigate its status.

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions