Skip to content

babel-preset-typescript failed to parse optional async method #10525

@brianle1301

Description

@brianle1301

Bug Report

Current Behavior
Babel throws Unexpected token, expected "(" when encounters this piece of code:

class A extends B {
  async method?(val: string): Promise<void>;
              ^
}

Expected behavior/code
This code should be parsed successfully

Babel Configuration (.babelrc, package.json, cli command)

module.exports = {
  presets: [
    [
      '@babel/preset-env',
      {
        targets: {
          node: 'current',
        },
      },
    ],
    '@babel/preset-typescript',
  ],
  ignore: ['node_modules'],
};

Environment

  • Babel version(s): 7.4.0
  • Node/npm version: 10.16.3
  • OS: Windows 10
  • Monorepo: no
  • How you are using Babel: cli

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: typescriptoutdatedA 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