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

fix: import of Prettier TypeScript plugin #133

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

AlCalzone
Copy link

While migrating a project that depends on ts-pegjs to ESM, I ran into a runtime error related to the Prettier TS plugin.

In
https://github.com/prettier/prettier/blob/6b582a061992ee614631b0ff196d92faad86c6c3/src/plugins/typescript.js#L1
the plugin is exported as a named export parsers.

This is accessed later in
https://github.com/prettier/prettier/blob/6b582a061992ee614631b0ff196d92faad86c6c3/src/plugins/builtin-plugins-proxy.js#L34
which expects to be able to access the parsers property of the plugin

By importing the plugin with * as ..., an additional wrapper object is added, resulting in prettierPluginTypescript to have the shape

{ default: { parsers: { typescript: [Object] } } }

instead of the expected

{ parsers: { typescript: [Object] } }

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

Successfully merging this pull request may close these issues.

1 participant