-
-
Notifications
You must be signed in to change notification settings - Fork 63
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
Make types of available keys more strict and configurable through generics #279
Conversation
Hey @kachkaev! 👋 Thanks for the PR (and the reviews haha 😁). The partial support for theme collections is really a pain in tailwind-merge, sorry for the energy you had to spend on this. However, narrowing the type of possible keys in the config would be a breaking change, I'm afraid we can't merge this as-is. It is currently possible to expand the available theme keys yourself and use those in the config which is important in the context of plugins. It's not so well documented at the moment, but you'll find the info here: https://github.com/dcastil/tailwind-merge/blob/v1.14.0/docs/api-reference.md#fromtheme E.g. you can define your font-size scale like this: import { extendTailwindMerge, fromTheme } from 'tailwind-merge'
const mergeTailwindClasses = extendTailwindMerge({
theme: {
// …rest of definition
fontSize: ['tiny', 'okay-ish', 'enormous']
},
classGroups: {
'font-size': [{ text: [fromTheme('fontSize')] }],
},
}); It's a really tricky problem:
I think the only option available at the moment is to improve the documentation and make it easier to understand how to configure it (less reading, get to results quicker). |
Hi @dcastil, thanks for sharing the details of this problem, it’s quite deep indeed! I can see the flaws in the proposed solution now. The docs of With the potential use of type CustomThemeKey = 'fontSize' | 'somethingElse';
const mergeTailwindClasses = extendTailwindMerge<ExtraThemeKey>({
theme: {
// …rest of definition
fontSize: ['tiny', 'okay-ish', 'enormous'], // works
somethingElse: ['foo', 'bar'], // works
oops: ['hello'], // typescript error
},
classGroups: {
'font-size': [{ text: [fromTheme<CustomThemeKey>('fontSize')] }],
},
}); It will be a breaking change indeed, but only in the TS land. I have seen other libraries releasing tighter typings in minor versions, so that’s a potential option too. For those who do want to upgrade but have no time to configure new typings, all they’d need to do is: - const mergeTailwindClasses = extendTailwindMerge({
+ const mergeTailwindClasses = extendTailwindMerge<string>({ Making
WDYT? |
Oh I never considered to use generics. This is a really nice idea! This could also be useful to make the classGroup keys more strict to prevent accidental use of non-existent class groups and to make finding class group keys easier. E.g. the API could look like this: extendTailwindMerge<ThemeKeys, ClassGroupKeys>(…)
// This would enable the same behavior as currently
extendTailwindMerge<string, string>(…)
Lots of tailwind-merge users are using TypeScript and it would break a lot of build pipelines when a breaking change in types only would be introduced. I think this would be unexpected to most of those people in a minor version change, so I'd only ship this in a major version. But I'm already looking at a potential v2 release (you can check the list of changes I want to make in the v2 milestone). Introducing the generic defaulting to Would you want to do the non-breaking change in this PR? Then you could solve this problem in your team right away and I could solve this for everyone else in v2. This would also give me some time to learn whether there is a way to make the API even better. |
Great, thanks! Feel free to close this PR if needed 👍 |
6d10f33
to
45b4e80
Compare
This turned out to be quite the change with a bit of more involved TypeScripting. I hope it'll all work as expected. 😅 |
Adding size info since the bot for it didn't run here: size-limit report 📦
|
This was addressed in release v2.0.0. |
[![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | [tailwind-merge](https://togithub.com/dcastil/tailwind-merge) | [`1.14.0` -> `2.0.0`](https://renovatebot.com/diffs/npm/tailwind-merge/1.14.0/2.0.0) | [![age](https://developer.mend.io/api/mc/badges/age/npm/tailwind-merge/2.0.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://developer.mend.io/api/mc/badges/adoption/npm/tailwind-merge/2.0.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://developer.mend.io/api/mc/badges/compatibility/npm/tailwind-merge/1.14.0/2.0.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/tailwind-merge/1.14.0/2.0.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | --- ### Release Notes <details> <summary>dcastil/tailwind-merge (tailwind-merge)</summary> ### [`v2.0.0`](https://togithub.com/dcastil/tailwind-merge/releases/tag/v2.0.0) [Compare Source](https://togithub.com/dcastil/tailwind-merge/compare/v1.14.0...v2.0.0) The tailwind-merge v2 release has been sitting here almost finished for 2 months already. But the timing was never quite right, especially thinking about the increased support needed after the release. In the meantime, the product of the company I work at [launched in public beta](https://medium.com/@​risecal/meet-rise-the-calendar-that-works-for-you-were-launching-the-public-beta-today-bc07555a2191) and I married. Thank you for your patience. This release focuses on making it easier to configure the library for new users. Check out the [migration guide](./v1-to-v2-migration.md) and if you have any questions, feel free to [create an issue](https://togithub.com/dcastil/tailwind-merge/issues/new/choose). ##### Breaking Changes - Fix `background-image` and `background-position` being merged incorrectly by [@​dcastil](https://togithub.com/dcastil) in [https://github.com/dcastil/tailwind-merge/pull/300](https://togithub.com/dcastil/tailwind-merge/pull/300) - Values for `background-position` and `background-size` can look very similar and Tailwind CSS uses the same `bg-` prefix for both groups. This results in some [limitations](../limitations.md) for tailwind-merge. - Make types of available keys more strict and configurable through generics by [@​kachkaev](https://togithub.com/kachkaev) in [https://github.com/dcastil/tailwind-merge/pull/279](https://togithub.com/dcastil/tailwind-merge/pull/279) - Make it possible to override elements with `extendTailwindMerge` by [@​dcastil](https://togithub.com/dcastil) in [https://github.com/dcastil/tailwind-merge/pull/294](https://togithub.com/dcastil/tailwind-merge/pull/294) - Separate validators better by [@​dcastil](https://togithub.com/dcastil) in [https://github.com/dcastil/tailwind-merge/pull/292](https://togithub.com/dcastil/tailwind-merge/pull/292) - Make `conflictingClassGroupModifiers` in config non-optional by [@​dcastil](https://togithub.com/dcastil) in [https://github.com/dcastil/tailwind-merge/pull/291](https://togithub.com/dcastil/tailwind-merge/pull/291) - Move separator to config by [@​dcastil](https://togithub.com/dcastil) in [https://github.com/dcastil/tailwind-merge/pull/290](https://togithub.com/dcastil/tailwind-merge/pull/290) - Remove `module` field from package.json by [@​dcastil](https://togithub.com/dcastil) in [https://github.com/dcastil/tailwind-merge/pull/289](https://togithub.com/dcastil/tailwind-merge/pull/289) - Remove deprecated exports by [@​dcastil](https://togithub.com/dcastil) in [https://github.com/dcastil/tailwind-merge/pull/288](https://togithub.com/dcastil/tailwind-merge/pull/288) - Transpile lib to more modern JS by [@​dcastil](https://togithub.com/dcastil) in [https://github.com/dcastil/tailwind-merge/pull/287](https://togithub.com/dcastil/tailwind-merge/pull/287) ##### New Features - Make types of available keys more strict and configurable through generics by [@​kachkaev](https://togithub.com/kachkaev) in [https://github.com/dcastil/tailwind-merge/pull/279](https://togithub.com/dcastil/tailwind-merge/pull/279) - Make it possible to override elements with `extendTailwindMerge` by [@​dcastil](https://togithub.com/dcastil) in [https://github.com/dcastil/tailwind-merge/pull/294](https://togithub.com/dcastil/tailwind-merge/pull/294) - Separate validators better by [@​dcastil](https://togithub.com/dcastil) in [https://github.com/dcastil/tailwind-merge/pull/292](https://togithub.com/dcastil/tailwind-merge/pull/292) - Make `conflictingClassGroupModifiers` in config non-optional by [@​dcastil](https://togithub.com/dcastil) in [https://github.com/dcastil/tailwind-merge/pull/291](https://togithub.com/dcastil/tailwind-merge/pull/291) - Move separator to config by [@​dcastil](https://togithub.com/dcastil) in [https://github.com/dcastil/tailwind-merge/pull/290](https://togithub.com/dcastil/tailwind-merge/pull/290) - Remove `module` field from package.json by [@​dcastil](https://togithub.com/dcastil) in [https://github.com/dcastil/tailwind-merge/pull/289](https://togithub.com/dcastil/tailwind-merge/pull/289) - Remove deprecated exports by [@​dcastil](https://togithub.com/dcastil) in [https://github.com/dcastil/tailwind-merge/pull/288](https://togithub.com/dcastil/tailwind-merge/pull/288) - Transpile lib to more modern JS by [@​dcastil](https://togithub.com/dcastil) in [https://github.com/dcastil/tailwind-merge/pull/287](https://togithub.com/dcastil/tailwind-merge/pull/287) - Add ES5 bundle by [@​dcastil](https://togithub.com/dcastil) in [https://github.com/dcastil/tailwind-merge/pull/286](https://togithub.com/dcastil/tailwind-merge/pull/286) ##### Bug Fixes - Fix touch action classes overriding each other incorrectly by [@​dcastil](https://togithub.com/dcastil) in [https://github.com/dcastil/tailwind-merge/pull/313](https://togithub.com/dcastil/tailwind-merge/pull/313) - Fix `background-image` and `background-position` being merged incorrectly by [@​dcastil](https://togithub.com/dcastil) in [https://github.com/dcastil/tailwind-merge/pull/300](https://togithub.com/dcastil/tailwind-merge/pull/300) - Fix number validators accidentally returning `true` for empty strings by [@​dcastil](https://togithub.com/dcastil) in [https://github.com/dcastil/tailwind-merge/pull/295](https://togithub.com/dcastil/tailwind-merge/pull/295) - Rename lazy-initializaton.test.ts to lazy-initialization.test.ts by [@​CrutchTheClutch](https://togithub.com/CrutchTheClutch) in [https://github.com/dcastil/tailwind-merge/pull/284](https://togithub.com/dcastil/tailwind-merge/pull/284) ##### Documentation - Explain limitations of arbitrary values in `bg-size` and `bg-position` class groups in docs by [@​dcastil](https://togithub.com/dcastil) in [https://github.com/dcastil/tailwind-merge/pull/328](https://togithub.com/dcastil/tailwind-merge/pull/328) **Full Changelog**: dcastil/tailwind-merge@v1.14.0...v2.0.0 </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://developer.mend.io/github/ariakit/ariakit). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy4zMS41IiwidXBkYXRlZEluVmVyIjoiMzcuMzEuNSIsInRhcmdldEJyYW5jaCI6Im1haW4ifQ==--> Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
[![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | [tailwind-merge](https://togithub.com/dcastil/tailwind-merge) | [`1.14.0` -> `2.0.0`](https://renovatebot.com/diffs/npm/tailwind-merge/1.14.0/2.0.0) | [![age](https://developer.mend.io/api/mc/badges/age/npm/tailwind-merge/2.0.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://developer.mend.io/api/mc/badges/adoption/npm/tailwind-merge/2.0.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://developer.mend.io/api/mc/badges/compatibility/npm/tailwind-merge/1.14.0/2.0.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/tailwind-merge/1.14.0/2.0.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | --- ### Release Notes <details> <summary>dcastil/tailwind-merge (tailwind-merge)</summary> ### [`v2.0.0`](https://togithub.com/dcastil/tailwind-merge/releases/tag/v2.0.0) [Compare Source](https://togithub.com/dcastil/tailwind-merge/compare/v1.14.0...v2.0.0) The tailwind-merge v2 release has been sitting here almost finished for 2 months already. But the timing was never quite right, especially thinking about the increased support needed after the release. In the meantime, the product of the company I work at [launched in public beta](https://medium.com/@​risecal/meet-rise-the-calendar-that-works-for-you-were-launching-the-public-beta-today-bc07555a2191) and I married. Thank you for your patience. This release focuses on making it easier to configure the library for new users. Check out the [migration guide](https://togithub.com/dcastil/tailwind-merge/blob/v2.0.0/docs/changelog/v1-to-v2-migration.md) and if you have any questions, feel free to [create an issue](https://togithub.com/dcastil/tailwind-merge/issues/new/choose). ##### Breaking Changes - Fix `background-image` and `background-position` being merged incorrectly by [@​dcastil](https://togithub.com/dcastil) in [https://github.com/dcastil/tailwind-merge/pull/300](https://togithub.com/dcastil/tailwind-merge/pull/300) - Values for `background-position` and `background-size` can look very similar and Tailwind CSS uses the same `bg-` prefix for both groups. This results in some [limitations](https://togithub.com/dcastil/tailwind-merge/blob/v2.0.0/docs/limitations.md) for tailwind-merge. If you use background position or background size with arbitrary values, please read [this section](https://togithub.com/dcastil/tailwind-merge/blob/v2.0.0/docs/limitations.md#you-need-to-use-label-in-arbitrary-background-position-and-background-size-classes) about how to use them. - Make types of available keys more strict and configurable through generics by [@​kachkaev](https://togithub.com/kachkaev) in [https://github.com/dcastil/tailwind-merge/pull/279](https://togithub.com/dcastil/tailwind-merge/pull/279) - Make it possible to override elements with `extendTailwindMerge` by [@​dcastil](https://togithub.com/dcastil) in [https://github.com/dcastil/tailwind-merge/pull/294](https://togithub.com/dcastil/tailwind-merge/pull/294) - Separate validators better by [@​dcastil](https://togithub.com/dcastil) in [https://github.com/dcastil/tailwind-merge/pull/292](https://togithub.com/dcastil/tailwind-merge/pull/292) - Make `conflictingClassGroupModifiers` in config non-optional by [@​dcastil](https://togithub.com/dcastil) in [https://github.com/dcastil/tailwind-merge/pull/291](https://togithub.com/dcastil/tailwind-merge/pull/291) - Move separator to config by [@​dcastil](https://togithub.com/dcastil) in [https://github.com/dcastil/tailwind-merge/pull/290](https://togithub.com/dcastil/tailwind-merge/pull/290) - Remove `module` field from package.json by [@​dcastil](https://togithub.com/dcastil) in [https://github.com/dcastil/tailwind-merge/pull/289](https://togithub.com/dcastil/tailwind-merge/pull/289) - Remove deprecated exports by [@​dcastil](https://togithub.com/dcastil) in [https://github.com/dcastil/tailwind-merge/pull/288](https://togithub.com/dcastil/tailwind-merge/pull/288) - Transpile lib to more modern JS by [@​dcastil](https://togithub.com/dcastil) in [https://github.com/dcastil/tailwind-merge/pull/287](https://togithub.com/dcastil/tailwind-merge/pull/287) ##### New Features - Make types of available keys more strict and configurable through generics by [@​kachkaev](https://togithub.com/kachkaev) in [https://github.com/dcastil/tailwind-merge/pull/279](https://togithub.com/dcastil/tailwind-merge/pull/279) - Make it possible to override elements with `extendTailwindMerge` by [@​dcastil](https://togithub.com/dcastil) in [https://github.com/dcastil/tailwind-merge/pull/294](https://togithub.com/dcastil/tailwind-merge/pull/294) - Separate validators better by [@​dcastil](https://togithub.com/dcastil) in [https://github.com/dcastil/tailwind-merge/pull/292](https://togithub.com/dcastil/tailwind-merge/pull/292) - Make `conflictingClassGroupModifiers` in config non-optional by [@​dcastil](https://togithub.com/dcastil) in [https://github.com/dcastil/tailwind-merge/pull/291](https://togithub.com/dcastil/tailwind-merge/pull/291) - Move separator to config by [@​dcastil](https://togithub.com/dcastil) in [https://github.com/dcastil/tailwind-merge/pull/290](https://togithub.com/dcastil/tailwind-merge/pull/290) - Remove `module` field from package.json by [@​dcastil](https://togithub.com/dcastil) in [https://github.com/dcastil/tailwind-merge/pull/289](https://togithub.com/dcastil/tailwind-merge/pull/289) - Remove deprecated exports by [@​dcastil](https://togithub.com/dcastil) in [https://github.com/dcastil/tailwind-merge/pull/288](https://togithub.com/dcastil/tailwind-merge/pull/288) - Transpile lib to more modern JS by [@​dcastil](https://togithub.com/dcastil) in [https://github.com/dcastil/tailwind-merge/pull/287](https://togithub.com/dcastil/tailwind-merge/pull/287) - Add ES5 bundle by [@​dcastil](https://togithub.com/dcastil) in [https://github.com/dcastil/tailwind-merge/pull/286](https://togithub.com/dcastil/tailwind-merge/pull/286) ##### Bug Fixes - Fix touch action classes overriding each other incorrectly by [@​dcastil](https://togithub.com/dcastil) in [https://github.com/dcastil/tailwind-merge/pull/313](https://togithub.com/dcastil/tailwind-merge/pull/313) - Fix `background-image` and `background-position` being merged incorrectly by [@​dcastil](https://togithub.com/dcastil) in [https://github.com/dcastil/tailwind-merge/pull/300](https://togithub.com/dcastil/tailwind-merge/pull/300) - Fix number validators accidentally returning `true` for empty strings by [@​dcastil](https://togithub.com/dcastil) in [https://github.com/dcastil/tailwind-merge/pull/295](https://togithub.com/dcastil/tailwind-merge/pull/295) - Rename lazy-initializaton.test.ts to lazy-initialization.test.ts by [@​CrutchTheClutch](https://togithub.com/CrutchTheClutch) in [https://github.com/dcastil/tailwind-merge/pull/284](https://togithub.com/dcastil/tailwind-merge/pull/284) ##### Documentation - Explain limitations of arbitrary values in `bg-size` and `bg-position` class groups in docs by [@​dcastil](https://togithub.com/dcastil) in [https://github.com/dcastil/tailwind-merge/pull/328](https://togithub.com/dcastil/tailwind-merge/pull/328) **Full Changelog**: dcastil/tailwind-merge@v1.14.0...v2.0.0 Thanks to [@​quezlatch](https://togithub.com/quezlatch), [@​brandonmcconnell](https://togithub.com/brandonmcconnell), [@​manavm1990](https://togithub.com/manavm1990) and [@​ErwinAI](https://togithub.com/ErwinAI) for sponsoring tailwind-merge! ❤️ </details> --- ### Configuration 📅 **Schedule**: Branch creation - "before 4am on the first day of the month" (UTC), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR is behind base branch, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://developer.mend.io/github/sebald/pattern-analyzer). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy40Ni4wIiwidXBkYXRlZEluVmVyIjoiMzcuNDYuMCIsInRhcmdldEJyYW5jaCI6Im1haW4ifQ==--> Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
[![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | [tailwind-merge](https://togithub.com/dcastil/tailwind-merge) | [`^1.14.0` -> `^2.0.0`](https://renovatebot.com/diffs/npm/tailwind-merge/1.14.0/2.0.0) | [![age](https://developer.mend.io/api/mc/badges/age/npm/tailwind-merge/2.0.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://developer.mend.io/api/mc/badges/adoption/npm/tailwind-merge/2.0.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://developer.mend.io/api/mc/badges/compatibility/npm/tailwind-merge/1.14.0/2.0.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/tailwind-merge/1.14.0/2.0.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | --- ### Release Notes <details> <summary>dcastil/tailwind-merge (tailwind-merge)</summary> ### [`v2.0.0`](https://togithub.com/dcastil/tailwind-merge/releases/tag/v2.0.0) [Compare Source](https://togithub.com/dcastil/tailwind-merge/compare/v1.14.0...v2.0.0) The tailwind-merge v2 release has been sitting here almost finished for 2 months already. But the timing was never quite right, especially thinking about the increased support needed after the release. In the meantime, the product of the company I work at [launched in public beta](https://medium.com/@​risecal/meet-rise-the-calendar-that-works-for-you-were-launching-the-public-beta-today-bc07555a2191) and I married. Thank you for your patience. This release focuses on making it easier to configure the library for new users. Check out the [migration guide](https://togithub.com/dcastil/tailwind-merge/blob/v2.0.0/docs/changelog/v1-to-v2-migration.md) and if you have any questions, feel free to [create an issue](https://togithub.com/dcastil/tailwind-merge/issues/new/choose). ##### Breaking Changes - Fix `background-image` and `background-position` being merged incorrectly by [@​dcastil](https://togithub.com/dcastil) in [https://github.com/dcastil/tailwind-merge/pull/300](https://togithub.com/dcastil/tailwind-merge/pull/300) - Values for `background-position` and `background-size` can look very similar and Tailwind CSS uses the same `bg-` prefix for both groups. This results in some [limitations](https://togithub.com/dcastil/tailwind-merge/blob/v2.0.0/docs/limitations.md) for tailwind-merge. If you use background position or background size with arbitrary values, please read [this section](https://togithub.com/dcastil/tailwind-merge/blob/v2.0.0/docs/limitations.md#you-need-to-use-label-in-arbitrary-background-position-and-background-size-classes) about how to use them. - Make types of available keys more strict and configurable through generics by [@​kachkaev](https://togithub.com/kachkaev) in [https://github.com/dcastil/tailwind-merge/pull/279](https://togithub.com/dcastil/tailwind-merge/pull/279) - Make it possible to override elements with `extendTailwindMerge` by [@​dcastil](https://togithub.com/dcastil) in [https://github.com/dcastil/tailwind-merge/pull/294](https://togithub.com/dcastil/tailwind-merge/pull/294) - Separate validators better by [@​dcastil](https://togithub.com/dcastil) in [https://github.com/dcastil/tailwind-merge/pull/292](https://togithub.com/dcastil/tailwind-merge/pull/292) - Make `conflictingClassGroupModifiers` in config non-optional by [@​dcastil](https://togithub.com/dcastil) in [https://github.com/dcastil/tailwind-merge/pull/291](https://togithub.com/dcastil/tailwind-merge/pull/291) - Move separator to config by [@​dcastil](https://togithub.com/dcastil) in [https://github.com/dcastil/tailwind-merge/pull/290](https://togithub.com/dcastil/tailwind-merge/pull/290) - Remove `module` field from package.json by [@​dcastil](https://togithub.com/dcastil) in [https://github.com/dcastil/tailwind-merge/pull/289](https://togithub.com/dcastil/tailwind-merge/pull/289) - Remove deprecated exports by [@​dcastil](https://togithub.com/dcastil) in [https://github.com/dcastil/tailwind-merge/pull/288](https://togithub.com/dcastil/tailwind-merge/pull/288) - Transpile lib to more modern JS by [@​dcastil](https://togithub.com/dcastil) in [https://github.com/dcastil/tailwind-merge/pull/287](https://togithub.com/dcastil/tailwind-merge/pull/287) ##### New Features - Make types of available keys more strict and configurable through generics by [@​kachkaev](https://togithub.com/kachkaev) in [https://github.com/dcastil/tailwind-merge/pull/279](https://togithub.com/dcastil/tailwind-merge/pull/279) - Make it possible to override elements with `extendTailwindMerge` by [@​dcastil](https://togithub.com/dcastil) in [https://github.com/dcastil/tailwind-merge/pull/294](https://togithub.com/dcastil/tailwind-merge/pull/294) - Separate validators better by [@​dcastil](https://togithub.com/dcastil) in [https://github.com/dcastil/tailwind-merge/pull/292](https://togithub.com/dcastil/tailwind-merge/pull/292) - Make `conflictingClassGroupModifiers` in config non-optional by [@​dcastil](https://togithub.com/dcastil) in [https://github.com/dcastil/tailwind-merge/pull/291](https://togithub.com/dcastil/tailwind-merge/pull/291) - Move separator to config by [@​dcastil](https://togithub.com/dcastil) in [https://github.com/dcastil/tailwind-merge/pull/290](https://togithub.com/dcastil/tailwind-merge/pull/290) - Remove `module` field from package.json by [@​dcastil](https://togithub.com/dcastil) in [https://github.com/dcastil/tailwind-merge/pull/289](https://togithub.com/dcastil/tailwind-merge/pull/289) - Remove deprecated exports by [@​dcastil](https://togithub.com/dcastil) in [https://github.com/dcastil/tailwind-merge/pull/288](https://togithub.com/dcastil/tailwind-merge/pull/288) - Transpile lib to more modern JS by [@​dcastil](https://togithub.com/dcastil) in [https://github.com/dcastil/tailwind-merge/pull/287](https://togithub.com/dcastil/tailwind-merge/pull/287) - Add ES5 bundle by [@​dcastil](https://togithub.com/dcastil) in [https://github.com/dcastil/tailwind-merge/pull/286](https://togithub.com/dcastil/tailwind-merge/pull/286) ##### Bug Fixes - Fix touch action classes overriding each other incorrectly by [@​dcastil](https://togithub.com/dcastil) in [https://github.com/dcastil/tailwind-merge/pull/313](https://togithub.com/dcastil/tailwind-merge/pull/313) - Fix `background-image` and `background-position` being merged incorrectly by [@​dcastil](https://togithub.com/dcastil) in [https://github.com/dcastil/tailwind-merge/pull/300](https://togithub.com/dcastil/tailwind-merge/pull/300) - Fix number validators accidentally returning `true` for empty strings by [@​dcastil](https://togithub.com/dcastil) in [https://github.com/dcastil/tailwind-merge/pull/295](https://togithub.com/dcastil/tailwind-merge/pull/295) - Rename lazy-initializaton.test.ts to lazy-initialization.test.ts by [@​CrutchTheClutch](https://togithub.com/CrutchTheClutch) in [https://github.com/dcastil/tailwind-merge/pull/284](https://togithub.com/dcastil/tailwind-merge/pull/284) ##### Documentation - Explain limitations of arbitrary values in `bg-size` and `bg-position` class groups in docs by [@​dcastil](https://togithub.com/dcastil) in [https://github.com/dcastil/tailwind-merge/pull/328](https://togithub.com/dcastil/tailwind-merge/pull/328) **Full Changelog**: dcastil/tailwind-merge@v1.14.0...v2.0.0 Thanks to [@​quezlatch](https://togithub.com/quezlatch), [@​brandonmcconnell](https://togithub.com/brandonmcconnell), [@​manavm1990](https://togithub.com/manavm1990) and [@​ErwinAI](https://togithub.com/ErwinAI) for sponsoring tailwind-merge! ❤️ </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Enabled. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://developer.mend.io/github/dotkom/monoweb). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy4zMS41IiwidXBkYXRlZEluVmVyIjoiMzcuNDYuMCIsInRhcmdldEJyYW5jaCI6Im1haW4ifQ==--> Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
[![Mend Renovate logo banner](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | [tailwind-merge](https://togithub.com/dcastil/tailwind-merge) | [`^1.13.2` -> `^2.0.0`](https://renovatebot.com/diffs/npm/tailwind-merge/1.14.0/2.0.0) | [![age](https://developer.mend.io/api/mc/badges/age/npm/tailwind-merge/2.0.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://developer.mend.io/api/mc/badges/adoption/npm/tailwind-merge/2.0.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://developer.mend.io/api/mc/badges/compatibility/npm/tailwind-merge/1.14.0/2.0.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/tailwind-merge/1.14.0/2.0.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | --- ### Release Notes <details> <summary>dcastil/tailwind-merge (tailwind-merge)</summary> ### [`v2.0.0`](https://togithub.com/dcastil/tailwind-merge/releases/tag/v2.0.0) [Compare Source](https://togithub.com/dcastil/tailwind-merge/compare/v1.14.0...v2.0.0) The tailwind-merge v2 release has been sitting here almost finished for 2 months already. But the timing was never quite right, especially thinking about the increased support needed after the release. In the meantime, the product of the company I work at [launched in public beta](https://medium.com/@​risecal/meet-rise-the-calendar-that-works-for-you-were-launching-the-public-beta-today-bc07555a2191) and I married. Thank you for your patience. This release focuses on making it easier to configure the library for new users. Check out the [migration guide](https://togithub.com/dcastil/tailwind-merge/blob/v2.0.0/docs/changelog/v1-to-v2-migration.md) and if you have any questions, feel free to [create an issue](https://togithub.com/dcastil/tailwind-merge/issues/new/choose). ##### Breaking Changes - Fix `background-image` and `background-position` being merged incorrectly by [@​dcastil](https://togithub.com/dcastil) in [https://github.com/dcastil/tailwind-merge/pull/300](https://togithub.com/dcastil/tailwind-merge/pull/300) - Values for `background-position` and `background-size` can look very similar and Tailwind CSS uses the same `bg-` prefix for both groups. This results in some [limitations](https://togithub.com/dcastil/tailwind-merge/blob/v2.0.0/docs/limitations.md) for tailwind-merge. If you use background position or background size with arbitrary values, please read [this section](https://togithub.com/dcastil/tailwind-merge/blob/v2.0.0/docs/limitations.md#you-need-to-use-label-in-arbitrary-background-position-and-background-size-classes) about how to use them. - Make types of available keys more strict and configurable through generics by [@​kachkaev](https://togithub.com/kachkaev) in [https://github.com/dcastil/tailwind-merge/pull/279](https://togithub.com/dcastil/tailwind-merge/pull/279) - Make it possible to override elements with `extendTailwindMerge` by [@​dcastil](https://togithub.com/dcastil) in [https://github.com/dcastil/tailwind-merge/pull/294](https://togithub.com/dcastil/tailwind-merge/pull/294) - Separate validators better by [@​dcastil](https://togithub.com/dcastil) in [https://github.com/dcastil/tailwind-merge/pull/292](https://togithub.com/dcastil/tailwind-merge/pull/292) - Make `conflictingClassGroupModifiers` in config non-optional by [@​dcastil](https://togithub.com/dcastil) in [https://github.com/dcastil/tailwind-merge/pull/291](https://togithub.com/dcastil/tailwind-merge/pull/291) - Move separator to config by [@​dcastil](https://togithub.com/dcastil) in [https://github.com/dcastil/tailwind-merge/pull/290](https://togithub.com/dcastil/tailwind-merge/pull/290) - Remove `module` field from package.json by [@​dcastil](https://togithub.com/dcastil) in [https://github.com/dcastil/tailwind-merge/pull/289](https://togithub.com/dcastil/tailwind-merge/pull/289) - Remove deprecated exports by [@​dcastil](https://togithub.com/dcastil) in [https://github.com/dcastil/tailwind-merge/pull/288](https://togithub.com/dcastil/tailwind-merge/pull/288) - Transpile lib to more modern JS by [@​dcastil](https://togithub.com/dcastil) in [https://github.com/dcastil/tailwind-merge/pull/287](https://togithub.com/dcastil/tailwind-merge/pull/287) ##### New Features - Make types of available keys more strict and configurable through generics by [@​kachkaev](https://togithub.com/kachkaev) in [https://github.com/dcastil/tailwind-merge/pull/279](https://togithub.com/dcastil/tailwind-merge/pull/279) - Make it possible to override elements with `extendTailwindMerge` by [@​dcastil](https://togithub.com/dcastil) in [https://github.com/dcastil/tailwind-merge/pull/294](https://togithub.com/dcastil/tailwind-merge/pull/294) - Separate validators better by [@​dcastil](https://togithub.com/dcastil) in [https://github.com/dcastil/tailwind-merge/pull/292](https://togithub.com/dcastil/tailwind-merge/pull/292) - Make `conflictingClassGroupModifiers` in config non-optional by [@​dcastil](https://togithub.com/dcastil) in [https://github.com/dcastil/tailwind-merge/pull/291](https://togithub.com/dcastil/tailwind-merge/pull/291) - Move separator to config by [@​dcastil](https://togithub.com/dcastil) in [https://github.com/dcastil/tailwind-merge/pull/290](https://togithub.com/dcastil/tailwind-merge/pull/290) - Remove `module` field from package.json by [@​dcastil](https://togithub.com/dcastil) in [https://github.com/dcastil/tailwind-merge/pull/289](https://togithub.com/dcastil/tailwind-merge/pull/289) - Remove deprecated exports by [@​dcastil](https://togithub.com/dcastil) in [https://github.com/dcastil/tailwind-merge/pull/288](https://togithub.com/dcastil/tailwind-merge/pull/288) - Transpile lib to more modern JS by [@​dcastil](https://togithub.com/dcastil) in [https://github.com/dcastil/tailwind-merge/pull/287](https://togithub.com/dcastil/tailwind-merge/pull/287) - Add ES5 bundle by [@​dcastil](https://togithub.com/dcastil) in [https://github.com/dcastil/tailwind-merge/pull/286](https://togithub.com/dcastil/tailwind-merge/pull/286) ##### Bug Fixes - Fix touch action classes overriding each other incorrectly by [@​dcastil](https://togithub.com/dcastil) in [https://github.com/dcastil/tailwind-merge/pull/313](https://togithub.com/dcastil/tailwind-merge/pull/313) - Fix `background-image` and `background-position` being merged incorrectly by [@​dcastil](https://togithub.com/dcastil) in [https://github.com/dcastil/tailwind-merge/pull/300](https://togithub.com/dcastil/tailwind-merge/pull/300) - Fix number validators accidentally returning `true` for empty strings by [@​dcastil](https://togithub.com/dcastil) in [https://github.com/dcastil/tailwind-merge/pull/295](https://togithub.com/dcastil/tailwind-merge/pull/295) - Rename lazy-initializaton.test.ts to lazy-initialization.test.ts by [@​CrutchTheClutch](https://togithub.com/CrutchTheClutch) in [https://github.com/dcastil/tailwind-merge/pull/284](https://togithub.com/dcastil/tailwind-merge/pull/284) ##### Documentation - Explain limitations of arbitrary values in `bg-size` and `bg-position` class groups in docs by [@​dcastil](https://togithub.com/dcastil) in [https://github.com/dcastil/tailwind-merge/pull/328](https://togithub.com/dcastil/tailwind-merge/pull/328) **Full Changelog**: dcastil/tailwind-merge@v1.14.0...v2.0.0 Thanks to [@​quezlatch](https://togithub.com/quezlatch), [@​brandonmcconnell](https://togithub.com/brandonmcconnell), [@​manavm1990](https://togithub.com/manavm1990) and [@​ErwinAI](https://togithub.com/ErwinAI) for sponsoring tailwind-merge! ❤️ </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Enabled. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://developer.mend.io/github/xkrishguptaa/study-web3). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy4zMS41IiwidXBkYXRlZEluVmVyIjoiMzcuNTkuOCIsInRhcmdldEJyYW5jaCI6Im1haW4ifQ==--> Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Edit from @dcastil:
Closes #293
A couple of weeks ago I happily configured font sizes inside
extendTailwindMerge
:As it turned out,
fontSize
was not supported by the theme object which was not obvious from the start. Discovering this was a bit painful and took our team some energy and time. After searching for similar issues withfontSize
, I found a few folks falling into the same trap: #274, #250, etc.This PR slightly improves the DX by flagging the trap I have fallen into:
Stricter typings will hopefully make it easier for other teams to configure
tailwind-merge
faster and with fewer errors. They also enable autocompletion:For those who are here from search, the right config for
fontSize
in my case was this:PS: Great lib @dcastil 💯
PPS: Apologies for unexpected reviews – I shared this PR with colleagues and they thought it was against our repo 😅