Skip to content

[Bug]: should parse type A = import("mod", { with: { type: "json" }}); #16276

@sosukesuzuki

Description

@sosukesuzuki

💻

  • Would you like to work on a fix?

How are you using Babel?

Programmatic API (babel.transform, babel.parse)

Input code

type A = import("foo", {with: {type: "json"}})

Configuration file name

No response

Configuration

N/A

Current and expected behavior

Current:

SyntaxError: Unexpected token, expected ")"

Expected:

Success

Environment

const { parse } = require("@babel/parser"); // 7.23.9

const code = `type A = import("foo", { with: { type: "json"} }});`;
const result = parse(code, { plugins: ["typescript", "importAttributes" ]});

Possible solution

Fix the parser

Additional context

context: prettier/prettier#16072

TypeScript compiler can parse it(Playground link)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions