Skip to content

[Bug]: missing support for auto accessors with TypeScript annotations #15205

@bradzacher

Description

@bradzacher

💻

  • Would you like to work on a fix?

How are you using Babel?

Programmatic API (babel.transform, babel.parse)

Input code

class Foo {
    accessor prop: string = 1;
}

Configuration file name

No response

Configuration

https://babeljs.io/repl#?browsers=&build=&builtIns=false&corejs=3.6&spec=false&loose=false&code_lz=MYGwhgzhAEBiD29oG8BQ0PTMYBTK8ATtAA6HwkBc0EALoQJYB2A5tALzQCMA3KgL6ogA&debug=false&forceAllTransforms=false&shippedProposals=false&circleciRepo=&evaluate=true&fileSize=true&timeTravel=false&sourceType=module&lineWrap=true&presets=stage-2%2Cstage-3%2Ctypescript&prettier=true&targets=&version=7.20.4&assumptions=%7B%7D

Current and expected behavior

Current:

/repl.ts: Missing semicolon. (2:17)

  1 | class Foo {
> 2 |     accessor prop: string = 1;
    |                  ^
  3 | }
  4 |

Expected:
parses fine as it's valid TS syntax

Environment

Website

Possible solution

Add support for type annotations on auto-accessors when parsing TS

Additional context

It looks like there is support for TS modifiers including abstract, but type annotations are not allowed

Metadata

Metadata

Assignees

No one assigned

    Labels

    outdatedA closed issue/PR that is archived due to age. Recommended to make a new issuepkg: parser

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions