ast-types icon indicating copy to clipboard operation
ast-types copied to clipboard

`quote: 'single'` is broken in 0.15.2

Open be9 opened this issue 3 years ago • 0 comments

After merging #678, builders.stringLiteral generates a node.extra object with extra.raw having double quotes due to JSON.stringify:

Screen Shot 2022-08-02 at 12 16 50 PM

recast.print has this code that doesn't reformat any quotes if extra.raw is present:

    case "BooleanLiteral": // Babel 6 Literal split
    case "StringLiteral": // Babel 6 Literal split
    case "Literal":
      return fromString(
        getPossibleRaw(n) ||
          (typeof n.value === "string" ? nodeStr(n.value, options) : n.value),
        options,
      );

getPossibleRaw wins here; nodeStr which respects options.quote is not called.

be9 avatar Aug 02 '22 05:08 be9