Skip to content

Commit

Permalink
Improve return value of resolveConfig, unwrap ResolvableTo (#9972)
Browse files Browse the repository at this point in the history
* improve return value of `resolveConfig`, unwrap `ResolvableTo`

* update changelog
  • Loading branch information
RobinMalfait committed Nov 30, 2022
1 parent cac5a28 commit 4f92e2f
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -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

Expand Down
13 changes: 11 additions & 2 deletions resolveConfig.d.ts
@@ -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 changes: 1 addition & 1 deletion types/config.d.ts
Expand Up @@ -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 {
Expand Down

0 comments on commit 4f92e2f

Please sign in to comment.