Skip to content

Formatter deconstructs tagged template literals to arrays when followed by an arrow expression #8011

@nkrkv

Description

@nkrkv

I found the formatter gets rid of tagged template literals when they are followed by an arrow expression. It does not happen if the tagged literal is the last expression in the chain.

Happens with 11.1.4 and 12.0.0-rc.3 at least.

Original

sql
->SQL.query`INSERT INTO my_table (a, b, c) VALUES ${a}, ${b}, ${c}`
->Promise.thenResolve(Console.log)

Expected

No change

Actual

sql
->(
  SQL.query(
    [`INSERT INTO my_table (a, b, c) VALUES `, `, `, `, `, ``],
    [a, b, c],
  )
)
->Promise.thenResolve(Console.log)

Playground

https://rescript-lang.org/try?version=v12.0.0-rc.3&module=esmodule&code=M4RwNgUAtAfAygRQDIDoQFcCmAnAngAwEkA5OAUQCUAVAAhKoHkaBbXAfQBcBDAIzExoAKLgBoaPMQGMAlDQBqAQSQBVMnBoASAN5cAvmO099mrZN35oMAArYA9swCWwTCg4ALTADsKmYLbAAbpiCAMK2nn78KGC2AObSQA

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