`quote: 'single'` is broken in 0.15.2
- Dominant language
- TypeScript
- Stars
- 1.2k
- Forks
- 194
- Avg merge
- 22h 43m
- Merged PRs (30d)
- 10
Description
After merging #678, `builders.stringLiteral` generates a `node.extra` object with `extra.raw` having double quotes due to `JSON.stringify`:

`recast.print` has [this](https://github.com/benjamn/recast/blob/master/lib/printer.ts#L935) code that doesn't reformat any quotes if `extra.raw` is present:
```ts
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.
Contributor guide
No contributing guide indexed for this repository
Research direction
Trace builders.stringLiteral and the change from #678, then inspect the recast.print handling at lib/printer.ts:935, especially getPossibleRaw, nodeStr, and options.quote. Done means quote: 'single' is respected when printing string literals even when node.extra.raw is present.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100