diff --git a/docs/api-reference.md b/docs/api-reference.md index f2b90803..9738396e 100644 --- a/docs/api-reference.md +++ b/docs/api-reference.md @@ -382,6 +382,14 @@ function myWrappedTwMerge(...args: ClassNameValue[]) { } ``` +## `ClassValidator` + +```ts +type ClassValidator = (value: string) => boolean +``` + +TypeScript type for class validators accepted in class definitions within [`extendTailwindMerge`](#extendtailwindmerge) and [`createTailwindMerge`](#createtailwindmerge). + --- Next: [Writing plugins](./writing-plugins.md) diff --git a/src/index.ts b/src/index.ts index 1e043fe6..25d16cb2 100644 --- a/src/index.ts +++ b/src/index.ts @@ -5,5 +5,10 @@ export { fromTheme } from './lib/from-theme' export { mergeConfigs } from './lib/merge-configs' export { twJoin, type ClassNameValue } from './lib/tw-join' export { twMerge } from './lib/tw-merge' -export { type Config, type DefaultClassGroupIds, type DefaultThemeGroupIds } from './lib/types' +export { + type ClassValidator, + type Config, + type DefaultClassGroupIds, + type DefaultThemeGroupIds, +} from './lib/types' export * as validators from './lib/validators' diff --git a/tests/public-api.test.ts b/tests/public-api.test.ts index 12deb896..2fa33cad 100644 --- a/tests/public-api.test.ts +++ b/tests/public-api.test.ts @@ -1,5 +1,6 @@ import { ClassNameValue, + ClassValidator, Config, DefaultClassGroupIds, DefaultThemeGroupIds, @@ -40,12 +41,14 @@ test('has correct export types', () => { const noRun = () => { const config: Config = getDefaultConfig() const classNameValue: ClassNameValue = 'some-class' + const classValidator: ClassValidator = (value: string) => false twMerge(classNameValue, classNameValue, classNameValue) twJoin(classNameValue, classNameValue, classNameValue) return { config, + classValidator, } } })