-
Notifications
You must be signed in to change notification settings - Fork 97
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
JSDoc type cast parens are removed #218
Labels
bug
Something isn't working
Comments
This is a tricky one .. Prettier's JS printer/parser respects that parentheses. We use the typescript parser though for the script tags, which does not preserve these, because in a TS file these JSDoc hints don't have meaning. So we probably need to switch the parser according to the script language. |
dummdidumm
pushed a commit
to dummdidumm/prettier-plugin-svelte
that referenced
this issue
May 10, 2021
If a script tag is assumed to be JS, use babel-ts now to format the contents. The formatter prints a little different, keeping parantheses in more places, which fixes sveltejs#218 . The change is not perfect because it would be better to know for sure that the language is JS, which we cannot know because of the possible language defaults.
dummdidumm
added a commit
that referenced
this issue
May 10, 2021
If a script tag is assumed to be JS, use babel-ts now to format the contents. The formatter prints a little different, keeping parantheses in more places, which fixes #218 . The change is not perfect because it would be better to know for sure that the language is JS, which we cannot know because of the possible language defaults.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
When using JSDoc, it's common to do this sort of thing:
This tells TypeScript that
a.b
is of typeFoo
. Prettier will preserve those parentheses when processing JS files, but for whatever reason it fails to do so inside.svelte
files, instead turning it into this:The text was updated successfully, but these errors were encountered: