Skip to content

New formatting producing syntax errors #496

Closed
@remitbri

Description

@remitbri

Hello

I'm on a project using rescript 9.1.4, and I've been using the extension v1.3.0 for quite a while, with formatting on save enabled and without problems :) .
Since upgrading automatically to 1.4.0, I've noticed some minor new formatting (e.g {...someRecord, foobar: foobar} becoming {...someRecord, foobar}), which is surprising as I haven't migrated to a new rescript version. Painpoint: potentially having to reformat all my codebase without any "good reason" (quotes, quotes)? Hmm.

But much much more importantly, code like

  @val
  external \"import": (
    @as("../SomeModule.mjs") _,
    unit,
  ) => Js.Promise.t<'a> = "import"
  let make = ReactLazy.make(() =>
    \"import"() |> Js.Promise.then_((module(SomeModule: SomeModuleType)) =>
      Js.Promise.resolve({"default": SomeModule.make})
    )
  )

is changed to

 @val
  external import: (
    @as("../SomeModule.mjs") _,
    unit,
  ) => Js.Promise.t<'a> = "import"
  let make = ReactLazy.make(() =>
    import() |> Js.Promise.then_((module(SomeModule: SomeModuleType)) =>
      Js.Promise.resolve({"default": SomeModule.make})
    )
  )

and produces syntax errors
1)

 `import` is a reserved keyword. Keywords need to be escaped: \"import"

(for the declaration of import)

I'm not sure what to parse here when looking at "import". (for the use of import)

(Happy to help if more details needed, beta testing, etc)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions