mirror of
https://github.com/tailwindlabs/tailwindcss.git
synced 2025-12-08 21:36:08 +00:00
Improve types of the tailwindcss/plugin (#8400)
* improve types of the `tailwindcss/plugin` This also exposes/types the `plugin.withOptions` as described here: https://tailwindcss.com/docs/plugins#exposing-options * update changelog
This commit is contained in:
parent
81641859cd
commit
83b4811c60
@ -24,6 +24,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
- Error when registering an invalid custom variant ([#8345](https://github.com/tailwindlabs/tailwindcss/pull/8345))
|
||||
- Create tailwind.config.cjs file in ESM package when running init ([#8363](https://github.com/tailwindlabs/tailwindcss/pull/8363))
|
||||
- Fix `matchVariants` that use at-rules and placeholders ([#8392](https://github.com/tailwindlabs/tailwindcss/pull/8392))
|
||||
- Improve types of the `tailwindcss/plugin` ([#8400](https://github.com/tailwindlabs/tailwindcss/pull/8400))
|
||||
|
||||
### Changed
|
||||
|
||||
|
||||
15
plugin.d.ts
vendored
15
plugin.d.ts
vendored
@ -1,6 +1,11 @@
|
||||
import type { Config, PluginCreator } from './types/config'
|
||||
declare function createPlugin(
|
||||
plugin: PluginCreator,
|
||||
config?: Config
|
||||
): { handler: PluginCreator; config?: Config }
|
||||
export = createPlugin
|
||||
type Plugin = {
|
||||
withOptions<T>(
|
||||
plugin: (options: T) => PluginCreator,
|
||||
config?: (options: T) => Config
|
||||
): { (options: T): { handler: PluginCreator; config?: Config }; __isOptionsFunction: true }
|
||||
(plugin: PluginCreator, config?: Config): { handler: PluginCreator; config?: Config }
|
||||
}
|
||||
|
||||
declare const plugin: Plugin
|
||||
export = plugin
|
||||
|
||||
6
types/config.d.ts
vendored
6
types/config.d.ts
vendored
@ -297,7 +297,11 @@ export interface PluginAPI {
|
||||
e: (className: string) => string
|
||||
}
|
||||
export type PluginCreator = (api: PluginAPI) => void
|
||||
export type PluginsConfig = (PluginCreator | { handler: PluginCreator; config?: Config })[]
|
||||
export type PluginsConfig = (
|
||||
| PluginCreator
|
||||
| { handler: PluginCreator; config?: Config }
|
||||
| { (options: any): { handler: PluginCreator; config?: Config }; __isOptionsFunction: true }
|
||||
)[]
|
||||
|
||||
// Top level config related
|
||||
interface RequiredConfig {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user