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

[Bug]: docs.source.format doesn't accept "typescript" as a parser #21891

Open
emily-haynes opened this issue Apr 3, 2023 · 0 comments
Open

Comments

@emily-haynes
Copy link

Describe the bug

When setting docs.source.format: "typescript", the following error gets thrown:

Couldn't resolve parser "typescript". Parsers must be explicitly added to the standalone bundle.

From the discussion here, my understanding is that this is due to the prettierTypescript plugin not being loaded.

As a workaround, we're using transformSource (soon to be updated to transform) to pull in the parser manually:

import prettier from "prettier/standalone";
import prettierTypescript from "prettier/parser-typescript";

export const parameters = {
  docs: {
    source: {
      transformSource: (src: string) => 
        prettier.format(src, {
          parser: "typescript",
          plugins: [prettierTypescript]
        }),
      },
    },
};

To Reproduce

No response

System

No response

Additional context

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants