Remove declare to clean up global scope#354
Merged
thecrypticace merged 6 commits intotailwindlabs:mainfrom Jul 31, 2025
Merged
Conversation
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. |
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)
Contributor
Author
Excellent, thank you! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Breaking Change
No longer mutate the global prettier config types
If you're using JSDoc comments or TypeScript for your Prettier config you should augment the options object yourself. The previous setup was not strictly typesafe because you could get suggestions for the options regardless of whether or not this plugin was actually included in your config.
As described in the issue I filed, this
declarestatement is polluting the global scope. It's providing autocomplete inprettier.config.jsfiles, but offers no real type safety. For instance, if you install the plugin but never add it to yourplugins, 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