Skip to content

Commit 9fdc590

Browse files
authored
Merge pull request #348 from dcastil/feature/331/add-class-validator-type-to-lib-exports
Add `ClassValidator` type to pacakge exports
2 parents 552d019 + b86b0df commit 9fdc590

File tree

3 files changed

+17
-1
lines changed

3 files changed

+17
-1
lines changed

docs/api-reference.md

+8
Original file line numberDiff line numberDiff line change
@@ -382,6 +382,14 @@ function myWrappedTwMerge(...args: ClassNameValue[]) {
382382
}
383383
```
384384
385+
## `ClassValidator`
386+
387+
```ts
388+
type ClassValidator = (value: string) => boolean
389+
```
390+
391+
TypeScript type for class validators accepted in class definitions within [`extendTailwindMerge`](#extendtailwindmerge) and [`createTailwindMerge`](#createtailwindmerge).
392+
385393
---
386394
387395
Next: [Writing plugins](./writing-plugins.md)

src/index.ts

+6-1
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,10 @@ export { fromTheme } from './lib/from-theme'
55
export { mergeConfigs } from './lib/merge-configs'
66
export { twJoin, type ClassNameValue } from './lib/tw-join'
77
export { twMerge } from './lib/tw-merge'
8-
export { type Config, type DefaultClassGroupIds, type DefaultThemeGroupIds } from './lib/types'
8+
export {
9+
type ClassValidator,
10+
type Config,
11+
type DefaultClassGroupIds,
12+
type DefaultThemeGroupIds,
13+
} from './lib/types'
914
export * as validators from './lib/validators'

tests/public-api.test.ts

+3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import {
22
ClassNameValue,
3+
ClassValidator,
34
Config,
45
DefaultClassGroupIds,
56
DefaultThemeGroupIds,
@@ -40,12 +41,14 @@ test('has correct export types', () => {
4041
const noRun = () => {
4142
const config: Config<DefaultClassGroupIds, DefaultThemeGroupIds> = getDefaultConfig()
4243
const classNameValue: ClassNameValue = 'some-class'
44+
const classValidator: ClassValidator = (value: string) => false
4345

4446
twMerge(classNameValue, classNameValue, classNameValue)
4547
twJoin(classNameValue, classNameValue, classNameValue)
4648

4749
return {
4850
config,
51+
classValidator,
4952
}
5053
}
5154
})

0 commit comments

Comments
 (0)