Improve return value of resolveConfig, unwrap ResolvableTo (#9972)

* improve return value of `resolveConfig`, unwrap `ResolvableTo`

* update changelog
This commit is contained in:
Robin Malfait 2022-11-30 14:26:15 +01:00 committed by GitHub
parent cac5a28c41
commit 4f92e2ff5e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 3 deletions

View File

@ -19,6 +19,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Fix `foo-[abc]/[def]` not being handled correctly ([#9866](https://github.com/tailwindlabs/tailwindcss/pull/9866))
- Add container queries plugin to standalone CLI ([#9865](https://github.com/tailwindlabs/tailwindcss/pull/9865))
- Support renaming of output files by `PostCSS` plugin. ([#9944](https://github.com/tailwindlabs/tailwindcss/pull/9944))
- Improve return value of `resolveConfig`, unwrap `ResolvableTo` ([#9972](https://github.com/tailwindlabs/tailwindcss/pull/9972))
## [3.2.4] - 2022-11-11

13
resolveConfig.d.ts vendored
View File

@ -1,3 +1,12 @@
import type { Config } from './types/config'
declare function resolveConfig(config: Config): Config
import type { Config, ResolvableTo } from './types/config'
type UnwrapResolvables<T> = {
[K in keyof T]: T[K] extends ResolvableTo<infer R> ? R : T[K]
}
type ResolvedConfig<T extends Config> = Omit<T, 'theme'> & {
theme: UnwrapResolvables<T['theme']>
}
declare function resolveConfig<T extends Config>(config: T): ResolvedConfig<T>
export = resolveConfig

2
types/config.d.ts vendored
View File

@ -11,7 +11,7 @@ type KeyValuePair<K extends keyof any = string, V = string> = Record<K, V>
interface RecursiveKeyValuePair<K extends keyof any = string, V = string> {
[key: string]: V | RecursiveKeyValuePair<K, V>
}
type ResolvableTo<T> = T | ((utils: PluginUtils) => T)
export type ResolvableTo<T> = T | ((utils: PluginUtils) => T)
type CSSRuleObject = RecursiveKeyValuePair<string, null | string | string[]>
interface PluginUtils {