Skip to content

Commit d4f1f15

Browse files
Allows fallback values in plugin API helpers (#8762)
* Update types to allow for fallback property values in add/matchUtilities/Components/etc… * Update changelog
1 parent c47e666 commit d4f1f15

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

CHANGELOG.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10-
- Nothing yet!
10+
### Fixed
11+
12+
- Allows fallback values in plugin API helpers ([#8762](https://github.com/tailwindlabs/tailwindcss/pull/8762))
1113

1214
## [3.1.4] - 2022-06-21
1315

types/config.d.ts

+6-5
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ interface RecursiveKeyValuePair<K extends keyof any = string, V = string> {
1212
[key: string]: V | RecursiveKeyValuePair<K, V>
1313
}
1414
type ResolvableTo<T> = T | ((utils: PluginUtils) => T)
15+
type CSSRuleObject = RecursiveKeyValuePair<string, string | string[]>
1516

1617
interface PluginUtils {
1718
colors: DefaultColors
@@ -242,15 +243,15 @@ type ValueType =
242243
export interface PluginAPI {
243244
// for registering new static utility styles
244245
addUtilities(
245-
utilities: RecursiveKeyValuePair | RecursiveKeyValuePair[],
246+
utilities: CSSRuleObject | CSSRuleObject[],
246247
options?: Partial<{
247248
respectPrefix: boolean
248249
respectImportant: boolean
249250
}>
250251
): void
251252
// for registering new dynamic utility styles
252253
matchUtilities<T>(
253-
utilities: KeyValuePair<string, (value: T) => RecursiveKeyValuePair>,
254+
utilities: KeyValuePair<string, (value: T) => CSSRuleObject>,
254255
options?: Partial<{
255256
respectPrefix: boolean
256257
respectImportant: boolean
@@ -261,15 +262,15 @@ export interface PluginAPI {
261262
): void
262263
// for registering new static component styles
263264
addComponents(
264-
components: RecursiveKeyValuePair | RecursiveKeyValuePair[],
265+
components: CSSRuleObject | CSSRuleObject[],
265266
options?: Partial<{
266267
respectPrefix: boolean
267268
respectImportant: boolean
268269
}>
269270
): void
270271
// for registering new dynamic component styles
271272
matchComponents<T>(
272-
components: KeyValuePair<string, (value: T) => RecursiveKeyValuePair>,
273+
components: KeyValuePair<string, (value: T) => CSSRuleObject>,
273274
options?: Partial<{
274275
respectPrefix: boolean
275276
respectImportant: boolean
@@ -279,7 +280,7 @@ export interface PluginAPI {
279280
}>
280281
): void
281282
// for registering new base styles
282-
addBase(base: RecursiveKeyValuePair | RecursiveKeyValuePair[]): void
283+
addBase(base: CSSRuleObject | CSSRuleObject[]): void
283284
// for registering custom variants
284285
addVariant(name: string, definition: string | string[] | (() => string) | (() => string)[]): void
285286
// for looking up values in the user’s theme configuration

0 commit comments

Comments
 (0)