Skip to content

Unexpected ASI after declare (regression since version 4.4)Β #54602

Description

@evanw

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.

Metadata

Metadata

Assignees

Labels

BugA bug in TypeScriptDomain: ParserThe parser didn't handle the syntax correctlyRescheduledThis issue was previously scheduled to an earlier milestone

Type

No type
No fields configured for issues without a type.

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions