Fix Plugin type issue (#14668)

This is a quick fix to an issue where the types for PluginsConfig don't
match those used in plugins like
[`@tailwindcss/container-queries`](https://github.com/tailwindlabs/tailwindcss-container-queries).

This was caught by TypeScript with [`exactOptionalPropertyTypes`](
https://www.typescriptlang.org/tsconfig/exactOptionalPropertyTypes.html)
enabled, where TypeScript checks if `undefined` can be supplied as a
value for optional types.

I felt that it made more sense to fix this here, as it makes the core
types more flexible, as opposed to each plugin needing to fix this
when/if they hit it.

---------

Co-authored-by: Philipp Spiess <hello@philippspiess.com>
This commit is contained in:
Brody McKee 2024-11-28 21:12:08 +11:00 • committed by GitHub
parent 6069a81187
commit 2702cfcc2c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 8 additions and 3 deletions

View file

@ -7,7 +7,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]
- Nothing yet!
### Fixed
- Ensure the TypeScript types for `PluginsConfig` allow `undefined` values ([#14668](https://github.com/tailwindlabs/tailwindcss/pull/14668))
## [3.4.15] - 2024-11-14

7
types/config.d.ts vendored
View file

@ -344,9 +344,12 @@ export interface PluginAPI {
export type PluginCreator = (api: PluginAPI) => void
export type PluginsConfig = (
| PluginCreator
| { handler: PluginCreator; config?: Partial<Config> }
| { handler: PluginCreator; config?: Partial<Config> | undefined }
| {
(options: any): { handler: PluginCreator; config?: Partial<Config> }
(options: any): {
handler: PluginCreator;
config?: Partial<Config> | undefined;
};
__isOptionsFunction: true
}
)[]