From 2702cfcc2c04f0615f0d53846850cbe769d57262 Mon Sep 17 00:00:00 2001 From: Brody McKee Date: Thu, 28 Nov 2024 21:12:08 +1100 Subject: [PATCH] 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 --- CHANGELOG.md | 4 +++- types/config.d.ts | 7 +++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c6c0fa7f4f84..e0958ba4c655 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/types/config.d.ts b/types/config.d.ts index 2c95a6dec67f..64fbf63c4878 100644 --- a/types/config.d.ts +++ b/types/config.d.ts @@ -344,9 +344,12 @@ export interface PluginAPI { export type PluginCreator = (api: PluginAPI) => void export type PluginsConfig = ( | PluginCreator - | { handler: PluginCreator; config?: Partial } + | { handler: PluginCreator; config?: Partial | undefined } | { - (options: any): { handler: PluginCreator; config?: Partial } + (options: any): { + handler: PluginCreator; + config?: Partial | undefined; + }; __isOptionsFunction: true } )[]