38 Commits
Author SHA1 Message Date
58d2e737d7 Fix Plugin type issue (#14668)
This is a quick fix to an issue where the types for PluginsConfig don't
match those used in plugins like
[`@tailwindcss/container-queries`](https://github.com/tailwindlabs/tailwindcss-container-queries).

This was caught by TypeScript with [`exactOptionalPropertyTypes`](
https://www.typescriptlang.org/tsconfig/exactOptionalPropertyTypes.html)
enabled, where TypeScript checks if `undefined` can be supplied as a
value for optional types.

I felt that it made more sense to fix this here, as it makes the core
types more flexible, as opposed to each plugin needing to fix this
when/if they hit it.

---------

Co-authored-by: Philipp Spiess <[email protected]>
2024-11-28 11:12:08 +01:00
014eac8bf4 Fix config types for boxShadow (#14856)
`boxShadow` accepts multiple shadows just like `dropShadow` does. This
patch fixes the TS typings to reflect that.

See demo showing that multiple shadows are supported (complete with it
incorrectly complaining that the config is bad) here:
https://play.tailwindcss.com/VHqWbbEIrz?file=config

---------

Co-authored-by: Philipp Spiess <[email protected]>
2024-11-07 12:22:05 +01:00
Jordan PittmanandAdam Wathan 701d95e2af Restore old behavior for class dark mode, add new selector and variant options for dark mode (#12717)
* Add dark mode variant option

* Tweak warning messages

* Add legacy dark mode option

* wip

* Use `class` for legacy behavior, `selector` for new behavior

* Add simplified failing apply/where test case

* Switch to `where` list, apply changes to `dir` variants

* Don’t let `:where`, `:is:`, or `:has` be attached to pseudo elements

* Updating tests...

* Finish updating tests

* Remove `variant` dark mode strategy

* Update types

* Update comments

* Update changelog

* Revert "Remove `variant` dark mode strategy"

This reverts commit 185250438ccb2f61ba876d4676823c1807891122.

* Add variant back to types

* wip

* Update comments

* Update tests

* Rename variable

* Update changelog

* Update changelog

* Update changelog

* Fix CS

---------

Co-authored-by: Adam Wathan <[email protected]>
2024-01-05 15:20:11 -05:00
48ede64ccf Improve resolveConfig return type: merge themes (#12272)
* Generate types: do not intersect with Config theme type when generating DefaultTheme

* Merge default theme in ResolvedConfig

* UnwrapResolvables on theme.extend as well

* Apply extend to overrides and default theme

* Omit extend from DefaultTheme

* Relax generic constraints, better generic variable names

* Fall back to ThemeConfig if key not in DefaultTheme

* Split out ThemeConfigCustomizable to avoid anys in ThemeConfigResolved

* Allow custom theme properties

* handle TypeScript error

* apply prettier formatting

* update changelog

* change type name

---------

Co-authored-by: Nikita Gaidakov <[email protected]>
Co-authored-by: Robin Malfait <[email protected]>
2023-10-30 14:55:42 -04:00
Jordan Pittman 1aa10b0c67 Update types to work with Node16 module resolution (#12097)
* Update types to work with Node16 module resolution

* Update changelog
2023-10-23 15:38:23 -04:00
4372375e0f Make content optional for presets in TypeScript types (#11730)
* Update config.d.ts, Make array members partial in Config

Instead of `Partial<Array<Thing>>` have `Array<Partial<Thing>>`

* simplify types further

* update changelog

---------

Co-authored-by: Robin Malfait <[email protected]>
2023-10-23 15:25:26 -04:00
54242394d5 Update the types for the safelist config (#10901)
* Revert prepare of v3.3

* Revert "Revert prepare of v3.3"

This reverts commit 14d5a0a7c6d457a9b73fa1a9aca6ed41c46b27ad.

* update SafelistConfig type

I think this type was meant to be like this?

* format types

* update changelog

---------

Co-authored-by: Robin Malfait <[email protected]>
2023-03-29 22:54:57 +02:00
Robin Malfait 91dae9da0f Revert "Prepare for the v3.2.6"
This reverts commit 9e1409ade8.
2023-02-08 17:39:43 +01:00
Robin Malfait 9e1409ade8 Prepare for the v3.2.6 2023-02-08 17:35:09 +01:00
Robin Malfait 8b7f2966ef Revert "Prepare for the v3.2.5 release (#10531)"
This reverts commit 309bfc50a9.
2023-02-08 16:37:50 +01:00
Robin MalfaitandGitHub 309bfc50a9 Prepare for the v3.2.5 release (#10531)
* Revert "add caption-side utilities (#10470)"

This reverts commit 19f05892e9.

* Revert "Add support for configuring default `font-variation-settings` for a `font-family` (#10515)"

This reverts commit 314c1920d9.

* Revert "feat: add hyphens (#10071)"

This reverts commit 82709bed66.

* Revert "Add logical properties support for inline direction"

* Revert "Add `delay-0` and `duration-0` by default"

* Revert "Support using variables as arbitrary values without `var()`"

* Revert "Add `line-height` modifier support to `font-size` utilities"
2023-02-08 15:53:00 +01:00
314c1920d9 Add support for configuring default font-variation-settings for a font-family (#10515)
* Add support for configuring default `font-variation-settings` for a `font-family`

* update changelog

---------

Co-authored-by: Nikolai Grushkovsky <[email protected]>
2023-02-07 15:06:59 +01:00
Justin WongandGitHub 6f38ee64ee Fix missing blocklist type (#10239)
* Fix missing `blocklist` type

* Update changelog
2023-01-04 11:53:07 +01:00
bd37d452cb Fix missing string[] in the dropShadow type (#10072)
* Fix missing `string[]` in the `dropShadow` type

* Update changelog

Co-authored-by: Jordan Pittman <[email protected]>
2022-12-14 09:48:49 -05:00
95b8a291b1 Add data key to theme types (#10023)
* Add "data" type in tailwind.config

* Update changelog

Co-authored-by: Jordan Pittman <[email protected]>
2022-12-09 10:37:42 -05:00
Robin MalfaitandGitHub 82512479aa Improve return value of resolveConfig, unwrap ResolvableTo (#9972)
* improve return value of `resolveConfig`, unwrap `ResolvableTo`

* update changelog
2022-11-30 14:26:15 +01:00
Robin MalfaitandGitHub b951074ee8 Fix missing supports in types (#9616)
* add `supports` to types

* update changelog
2022-10-20 14:29:00 +02:00
Jordan PittmanandGitHub c66a7bba9a Add generalized modifier support to matchUtilities (#9541)
* Change `matchVariant` API to use positional arguments

* Fix CS

wip

* Change match variant wrap modifier in an object

Needed for compat w/ some group and peer plugins

* Add modifier support to matchUtilities

* refactor

* Hoist utility modifier splitting

* Rename fn

* refactor

* Add support for generic utility modifiers

* Fix CS

* wip

* update types

* Warn when using modifiers without the option

* Allow modifiers to be a config object

* Make sure we can return null from matchUtilities to omit rules

* Feature flag generalized modifiers

We’re putting a flag for modifiers in front of matchVariant and matchUtilities

* cleanup

* Update changelog

* Properly flag variants using modifiers

* Fix test
2022-10-13 14:01:17 -04:00
Jordan PittmanandGitHub 38298101c6 Fix content key plugin types mismatch (#9545)
* Fix plugin types

* Update changelog
2022-10-13 13:46:50 -04:00
776ba137be Prepare for container queries setup (#9526)
* setup for container queries

* remove container query implementation itself

This will be moved to its own plugin.

* update changelog

Co-authored-by: Jordan Pittman <[email protected]>
2022-10-12 12:24:46 +02:00
Jordan PittmanandGitHub 5c8e676293 Allow resolving content paths relative to the config file (#9396)
* Update lockfile

* Tweak formatting

* Refactor content path parsing

* Allow resolving content paths relative to the config file

* Include resolved symlinks as additional content paths

* Update changelog

* Work on suite of tests for content resolution

* reformat integration test list

* Move content resolution tests to integration

* Update future and experimental types
2022-09-23 08:09:02 -04:00
Robin MalfaitandGitHub c698d75c6a Polish matchVariant API (#9313)
* convert the `matchVariant` to look more like `addVariant`

With the biggest difference that the `matchVariant` will have a callback
function that receives the current value of the variant.

* use object as argument for `matchVariant` callback

This will allow us to add more properties in the future if needed
without breaking changes.

- This is a breaking change: `(value) => ...` -> `({ value, other }) => ...`
- This is **not** a breaking change: `({ value }) => ...` -> `({ value, other }) => ...`

* add types for `matchVariant`
2022-09-16 15:37:35 +02:00
Brad CornesandGitHub fb77b87739 Fix fontFamily config types (#9214) 2022-08-30 12:22:15 +01:00
Augustine CalvinoandGitHub 0857d2adc6 fix safelist variant key required by typings (#9200) 2022-08-28 19:00:22 +02:00
0697acd4b0 Support font-weight in font-size utilities (#8763)
* Support font-weight in font-size utilities

* WIP update tests

* Update changelog

Co-authored-by: Jordan Pittman <[email protected]>
2022-07-04 17:01:06 -04:00
Jordan PittmanandGitHub 31a64f6940 Allows fallback values in plugin API helpers (#8762)
* Update types to allow for fallback property values in add/matchUtilities/Components/etc…

* Update changelog
2022-07-01 16:48:28 -04:00
bdc5732bb3 Fix casing of import of corePluginList type definition (#8587)
* Fix: Wrong import of CorePluginList type file

* Update changelog

Co-authored-by: Jordan Pittman <[email protected]>
2022-06-10 09:56:15 -04:00
Jordan PittmanandGitHub 62c2bf8008 Fix postcss plugin type (#8564)
* Fix postcss plugin type

* Update changelog
2022-06-09 16:38:45 -04:00
Robin MalfaitandGitHub d4e828a97a Add type annotations to the tailwind.config.js file (#8493)
* add type annotation to the config by default

* use `@type {import('tailwindcss').Config}` instead
2022-06-02 16:44:12 +02:00
Brad CornesandGitHub d16ea90480 Use single-line syntax for private types comments (#8420)
This prevents the comments from appearing in editors
2022-05-25 10:49:20 +01:00
Brad CornesandGitHub 850aa8eedd Improve theme.extend types (#8419) 2022-05-24 13:26:26 +01:00
Robin MalfaitandGitHub dfc5e905af Improve types of the tailwindcss/plugin (#8400)
* improve types of the `tailwindcss/plugin`

This also exposes/types the `plugin.withOptions` as described here: https://tailwindcss.com/docs/plugins#exposing-options

* update changelog
2022-05-23 12:35:19 +02:00
Brad CornesandGitHub 7b5ff8472b Update screens types (#8042) 2022-04-05 11:46:50 +01:00
Brad CornesandGitHub 4fc8fba24c Update theme.fontSize types (#8040) 2022-04-04 14:35:33 +01:00
Robin MalfaitandGitHub 936f359b5c Types: allow for arbitrary theme values (for 3rd party plugins) (#7926)
* allow for arbitrary configuration in the `theme` section

This is useful for third party plugins otherwise you will get an error.

* WIP: `theme()` utility function code completion

This will give you code completion in the `theme()` function. The reason
it is still a WIP is that this only works with the default config right
now and not 100% sure if it is possible to define generics in JSDoc.

The idea would be to:
- Provide types from the default config
- Provide types from the custom config (e.g.: 3rd party plugin)
- Override default config types with the overrides of the user's config

Right now this only provides types for the defaultConfig which might
result in dropping all of this in favor of a much simpler:

```ts
theme<D = any>(path: string, defaultValue: D) => D
```

But this sadly doesn't give you "nice" auto completion. However, the
default might be good enough if we don't error on for example
`theme('customPlugin')` which is currently not the case.

* update changelog

* undo all `theme` types, and type it as `theme(path: string): any`

Since currently we don't want to investigate time to make the code
completion *perfect* (because it might be even impossible to do it
properly due to resolving of overrides, extend and deeply nested presets)

For now we will provide a way simpler type, which is better than
incorrect types. So far we only had types for the default config theme
*only*.
2022-03-31 23:58:31 +02:00
Robin MalfaitandGitHub 4de990c3d3 fix types nesting (#7914)
`Partial` is only 1 level deep. We don't want it to be recursively deep,
that's for the plugin itself to decide. But the parts under `theme`
should all be optional.
2022-03-22 11:53:40 +01:00
Robin Malfait bf2ed8d1b0 ensure generated types are published as well
In my testing, I was publishing using a node 16 install, but on CI we
are using Node 12. It seems that the NPM that shipped with Node 12
ignores all files for publishing if they are mentioned in `.gitignore`
which I could reproduce locally.

Doing a bit of testing, I used this solution which I think we also used
in v2 when generating `dist/` files. The `npm publish --dry-run` now
_does_ include the generated types as well and they are still ignored
for version control.
2022-03-22 10:46:38 +01:00
Robin MalfaitandGitHub 352689548d Add TypeScript types for the tailwind.config.js file (#7891)
* add generate-types script

This script will generate the full list of core plugins, which will
allow you to get code completion for the `corePlugins` section.

It will also generate all the colors (and deprecated colors) which is
used in multiple places in the config.

* add types for the `tailwind.config.js` config file

* annotate stubs with a JSDoc pointing to the types

* add types to package.json

- Updated the files to make sure that the types are being published
- Add a `types` section in the `package.json`, otherwise your editor by
  default will look for the `DefinitelyTyped` types which got me really
  confused for a second.
- Added some scripts to make sure that the generation of types happens
  when needed (before tests and before building). This way you never
  ever have to think about generating them when working on Tailwind CSS
  internals.

* re-export types top-level

Having a `colors.d.ts` next to the `colors.js` file allows us to type
the `colors.js` file and your editor will pickup the types from
`colors.d.ts`.

* also publish generated types

* update changelog

* enable TypeScript only when using `init --types` for now

* update tests to verify that `--types` works
2022-03-22 10:24:28 +01:00