-
Notifications
You must be signed in to change notification settings - Fork 140
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
Typescript type annotations being removed #338
Comments
I have the same problem, I tried with other version but still get same problem. |
@Spoertm @yogiprsetya I think I've seen this once or twice in a project even without any plugins installed but this isn't the first report of this and I have no idea why or how this would happen. Can either of you provide a reproduction alongside details about how you're using Prettier (like in VSCode, Zed, command line, etc…)? |
@thecrypticace Mysteriously, when I now reinstall and use it, the bug isn't happening anymore 😅 Here's how to get to the same point at least:I'm using VSCode with these (relevant) extensions:
"prettier": {
"plugins": ["prettier-plugin-tailwindcss"]
}
const handleFileUpload = async (e: React.ChangeEvent<HTMLInputElement>) => {
// ...
};
I'd really like to know if you can reproduce it. |
I have never been able to use this plugin with typescript. Always deletes my types. Are you guys using it with typescript? |
@slythespacecat yeah I use it with TypeScript quite a lot |
@thecrypticace very interesting, I have no idea why it happens, but would love to be able to use it I tried creating a new Nextjs app (npx create-next-app) no ESLint to try and isolate it. Disabled all my VS Code extensions but Prettier. added .prettierrc.js like so:
and prettier.config.js like so:
Then added this to the page.tsx file:
Ran the formatter and it just gobbled the (edit: added spaces) < HTMLInputElement > part. Maybe a VS Code config thing? I have no idea. I've tried disabling everything I can find. Sorry I couldn't be of much help. It's a great plugin |
I've been able to set it up in a way that doesn't delete the type in the following example (and many like it, essentially, everytime there's a < Type > type declaration):
Changed the prettier parser from typescript to babel-ts. I have no idea why it worked, but figured it might help someone smarter than me |
I've been able to replicate it, sort of. I noticed changing the parser to babel-ts on .prettier.config.js does nothing helpful, just deletes the type as previously. Changing the parser to babel-ts on .prettierrc.js file fixes the issue. Is there anything I can do to help? I could upload the repo to my account, but I don't know if that'd help - it's really just the most create-next-app blank app imaginable. So I'm thinking it might be a VS Code thing, that in my case is fixed by changing the parser. But I don't know. Here's what works, and what doesn't work, in my case: WORKS: // .prettierrc.js
// .prettier.config.js
DOESN'T WORK: // .prettierrc.js
// .prettier.config.js
And then all I'm doing is hitting save to format it, or "Format Document With...", and it always works with the first setup, never works (deletes types) with the second setup. I wish I could be more helpful. Let me know if I can help in any way! I'm very happy I can use it again eheh EDIT: Sorry I forgot, these are all the latest versions of everything i believe. Here's the package.json: { |
What version of
prettier-plugin-tailwindcss
are you using?v0.6.9
What version of Tailwind CSS are you using?
v3.4.17
What version of Node.js are you using?
v21.5.0
What package manager are you using?
npm
What operating system are you using?
Windows
Describe your issue
The type annotations in Typescript are being removed. So the above code snippet is converted to:
The text was updated successfully, but these errors were encountered: