Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve return value of resolveConfig, unwrap ResolvableTo #9972

Merged
merged 2 commits into from Nov 30, 2022

Conversation

RobinMalfait
Copy link
Contributor

@RobinMalfait RobinMalfait commented Nov 30, 2022

This PR improves the return type fo the resolveConfig a little bit.

In the config, a lot of values can be written in various forms (and most of it is optional). We also allow for dynamic "runtime" presets, so generating the perfect TypeScript types are almost impossible.

However, some of the parts in the config accept a function that resolves to type T, this improvement gets rid of the callback function and results in T directly (because calling resolveConfig should resolve this).

Fixes: #9929

Copy link
Contributor

@thecrypticace thecrypticace left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

General approach looks good sans the change for handling theme.extend unwrapping and merging.

@justinh-kairos
Copy link

I'm still seeing this with tailwind 3.3.2:

Property 'colors' does not exist on type 'UnwrapResolvables<{ container: { center: true; padding: string; screens: { "2xl": string; }; }; extend: { fontFamily: { sans: [string, ...string[]]; display: [string, ...string[]]; }; colors: { input: string; ring: { DEFAULT: string; offset: string; }; ... 10 more ...; card: { ...; }; }; borderRadius: { ...; }; keyf...'.ts(2339)

@stefusilviu
Copy link

stefusilviu commented Jan 19, 2024

@justinh-kairos This seems to be solved in 3.4.1

@theocerutti
Copy link

theocerutti commented Feb 9, 2024

No it still doesn't work:

const config = resolveConfig(tailwindConfig);

const mycolor = config.theme.colors.neutral['750']; // Element implicitly has an 'any' type because expression of type '750' can't be used to index type ...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

resolveConfig returns wrong TypeScript type for theme keys
5 participants