Skip to content

Remove declare to clean up global scope #354

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

Merged
merged 6 commits into from
Jul 31, 2025

Conversation

drake-nathan
Copy link
Contributor

@drake-nathan drake-nathan commented Mar 14, 2025

Description

As described in the issue I filed, this declare statement is polluting the global scope. It's providing autocomplete in prettier.config.js files, but offers no real type safety. For instance, if you install the plugin but never add it to your plugins, the tailwind options will appear and cause a config error.

Importing the types like this is far safer.

/** @type {import('prettier').Config & import('prettier-plugin-tailwindcss').PluginOptions} */

You might consider this a breaking change, but I don't think a major is necessary. Since there's no actual type-checking in .js files, this shouldn't cause any errors. You'd just lose out on intellisense until you imported the type above. Users with a .json config won't notice anything at all.

Closes #339

@thecrypticace
Copy link
Contributor

This was done intentionally before but yeah I think we can do this. Can always bring it back if people complain. I do think this should be in a 0.7.0 release though.

@thecrypticace thecrypticace added this to the 0.7.0 milestone Jul 23, 2025
@thecrypticace thecrypticace merged commit 2c0965b into tailwindlabs:main Jul 31, 2025
1 check passed
@thecrypticace
Copy link
Contributor

I'm planning on releasing 0.7.x late next week or sometime the week after. Just getting ahead of things. 👍

mattiamalonni added a commit to mattiamalonni/prettier-plugin-tailwindcss that referenced this pull request Jul 31, 2025
* tailwind-main:
  Add support for callable template literals when using custom JSX parser (tailwindlabs#367)
  Handle quotes in `@plugin`, `@config`, and `@source` (tailwindlabs#387)
  Drop support for `prettier-plugin-import-sort` (tailwindlabs#385)
  Remove `declare` to clean up global scope (tailwindlabs#354)
@drake-nathan drake-nathan deleted the remove-declares branch July 31, 2025 15:02
@drake-nathan
Copy link
Contributor Author

I'm planning on releasing 0.7.x late next week or sometime the week after. Just getting ahead of things. 👍

Excellent, thank you!

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.

Tailwind PluginOptions polluting Prettier types in global scope
2 participants