Skip to content

Support Flow's indexed access type #13052

@sosukesuzuki

Description

@sosukesuzuki

Bug Report

  • I would like to work on a fix!

Current behavior

Current babel-parser cannot parse Flow's indexed access types with Syntax Error Unexpected token, expected "]" (1:15)

Input Code

type Foo = Bar['foo'];

Expected behavior

Returns the AST like below:

interface IndexedAccessType {
  objectType: Type;
  indexType: LiteralType;
}

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

Use parser directly.

Environment

  • Babel version(s): current main

Possible Solution

Additional context

I could not find the feature from changelog on Flow repo but it seems to be supported by current Flow. See prettier/prettier#10594.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions