Skip to content

Unfriendly syntax error for TypeScript readonly parameter #12057

@sosukesuzuki

Description

@sosukesuzuki

Bug Report

  • I would like to work on a fix!

Current behavior

Try it out link

It throws a syntax error Unexpected token, expected "," (2:27)

Input Code

class C {
  not_constructor(readonly foo: string) {}
}

Expected behavior

It throws a syntax error A parameter property is only allowed in a constructor implementation. like TypeScript TypeScript Playground link.

Babel Configuration (babel.config.js, .babelrc, package.json#babel, cli command, .eslintrc)

  • Filename: babel.config.js
{
  "presets": ["@babel/preset-typescript"]
}

Environment

I don't think environment information is needed because this issue is simple, but I will provide it if it is needed for you guys.

Possible Solution

Additional context

Metadata

Metadata

Assignees

No one assigned

    Labels

    Has PRoutdatedA 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