From b9bf4d740338f5eca3934bb5b37cbf54fa498b99 Mon Sep 17 00:00:00 2001 From: Robin Malfait Date: Fri, 25 Nov 2022 15:26:14 +0100 Subject: [PATCH 1/2] improve return value of `resolveConfig`, unwrap `ResolvableTo` --- resolveConfig.d.ts | 13 +++++++++++-- types/config.d.ts | 2 +- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/resolveConfig.d.ts b/resolveConfig.d.ts index e2f5f0f9f3f0..2402a267e8cd 100644 --- a/resolveConfig.d.ts +++ b/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 = { + [K in keyof T]: T[K] extends ResolvableTo ? R : T[K] +} + +type ResolvedConfig = Omit & { + theme: UnwrapResolvables +} + +declare function resolveConfig(config: T): ResolvedConfig export = resolveConfig diff --git a/types/config.d.ts b/types/config.d.ts index 34e1621cf069..b4b24a4a0809 100644 --- a/types/config.d.ts +++ b/types/config.d.ts @@ -11,7 +11,7 @@ type KeyValuePair = Record interface RecursiveKeyValuePair { [key: string]: V | RecursiveKeyValuePair } -type ResolvableTo = T | ((utils: PluginUtils) => T) +export type ResolvableTo = T | ((utils: PluginUtils) => T) type CSSRuleObject = RecursiveKeyValuePair interface PluginUtils { From 660761731ba14ec7e2396dfb3b8e7ff279dbcfd9 Mon Sep 17 00:00:00 2001 From: Robin Malfait Date: Wed, 30 Nov 2022 13:47:39 +0100 Subject: [PATCH 2/2] update changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3f1a3a96f39e..a450dc6b7200 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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