benjamn / benjamn/recast

`recast.print` does not appear to respect some `Options`

Open
#997 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
5.3k
Forks
363
Avg merge
3d 8h
Merged PRs (30d)
3

Description

In `main.d.ts`, we see:

```ts
export declare function print(node: types.ASTNode, options?: Options): import("./lib/printer").PrintResultType;
```

This suggests to me that all `Options` values will be respected. However, when I set values like `quote`, `trailingComma`, or `tabWidth`, it doesn't do anything:

```
# Node console
> recast.print(recast.parse(`const s = 'asdf'`), {quote: 'double'}).code
"const s = 'asdf'"
```

If I change `print` to `prettyPrint`, then it works.

Is this intentional? What options to `print` are actually used?

Thanks for making this project! It's very useful to me. 😄

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with the print declaration in main.d.ts and reproduce the Node console examples using print and prettyPrint with quote, trailingComma, and tabWidth. Trace how these Options reach the printer and identify which options print actually uses; done means the behavior is confirmed and the API or documentation clearly reflects it.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, typescript
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.