Skip to content

Commit

Permalink
Fix Plugin type issue (#14668)
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
mrmckeb and philipp-spiess authored Nov 28, 2024
1 parent 6069a81 commit 2702cfc
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
7 changes: 5 additions & 2 deletions types/config.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
)[]
Expand Down

0 comments on commit 2702cfc

Please sign in to comment.