microsoft / microsoft/TypeScript

Unexpected ASI after `declare` (regression since version 4.4)

Open
#54,602 1 comment 1 reaction 1 assignee View on GitHub

@rbuckton is already working on this.

Since Jun 12, 2023.

Bug Domain: Parser Rescheduled
Dominant language
Go
Stars
111k
Forks
14.3k
Avg merge
1d 19h
Merged PRs (30d)
117

Description

Bug Report

🔎 Search Terms

declare asi semicolon

🕗 Version & Regression Information
⏯ Playground Link

Playground link for version 4.3.5 (fine)
Playground link for version 4.4.4 (problematic)

💻 Code

Some random examples that TS 5.1 considers valid syntax (not exhaustive):

declare let declare: any, foo: any
declare foo
declare let declare: any, foo: any
declare foo()
declare let declare: any, foo: any
declare {foo}
🙁 Actual behavior

TypeScript silently does automatic semicolon insertion after declare in all of these cases without generating any syntax errors.

🙂 Expected behavior

I expected these to be syntax errors. I did not expect TypeScript to silently be doing automatic semicolon insertion after declare here as if this is valid syntax.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.