Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[v3] async printer support? #15080

Open
JounQin opened this issue Jul 11, 2023 · 2 comments
Open

[v3] async printer support? #15080

JounQin opened this issue Jul 11, 2023 · 2 comments
Labels
area:api Issues with Prettier's Application Programming Interface status:needs discussion Issues needing discussion and a decision to be made before action can be taken

Comments

@JounQin
Copy link
Member

JounQin commented Jul 11, 2023

Environments:

  • Prettier Version: 3.0.0
  • Running Prettier via:
  • Runtime:
  • Operating System:
  • Prettier plugins (if any):

Steps to reproduce:

Expected behavior:

I noticed it was supported at PR https://github.com/prettier/prettier/pull/13104/files#diff-cddf33c36c5425b14ba32233a483b88230c3c1c65bfa8b256be6c894c4f66d67R10-R18, but unavailable in v3?

prettier/src/index.d.ts

Lines 466 to 471 in 79d8a39

print(
path: AstPath<T>,
options: ParserOptions<T>,
print: (path: AstPath<T>) => Doc,
args?: unknown,
): Doc;

I'm wondering is it as expected? In prettier-plugin-sh I have to use synckit for async printer support.

Actual behavior:

@fisker
Copy link
Member

fisker commented Jul 11, 2023

Expected, unfortunately due to performance issue #13104 has been reverted #13210 and replaced with #13211. Can you share your use case? Maybe I can help.

@fisker
Copy link
Member

fisker commented Jul 11, 2023

I found your plugin, you can

  1. print in your parse function, weird, but doable.
  2. return a Promise in print, this is undocumented feature, only works if plugin don't call print recursively.

@sosukesuzuki sosukesuzuki added status:needs discussion Issues needing discussion and a decision to be made before action can be taken area:api Issues with Prettier's Application Programming Interface labels Jul 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:api Issues with Prettier's Application Programming Interface status:needs discussion Issues needing discussion and a decision to be made before action can be taken
Projects
None yet
Development

No branches or pull requests

3 participants