Skip to content

TypeScript 3.7 syntax: asserts this #10671

@thorn0

Description

@thorn0

Bug Report

Current Behavior
In #10527, it wasn't taken into account that the asserts keyword can be followed by this, not only by an identifier. Now it's a parser error, Unexpected token. Babel REPL.

Input Code

class Test {
    assertIsTest2(): asserts this is Test2 {
        if (this instanceof Test2) return;
        throw new Error();
    }
}

Expected behavior/code
Should parse. TypeScript playground.

Environment

  • Babel version(s): 7.7.0
  • How you are using Babel: @babel/parser

Metadata

Metadata

Assignees

Labels

Has PRarea: typescriptoutdatedA closed issue/PR that is archived due to age. Recommended to make a new issue

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions