File tree 4 files changed +19
-13
lines changed
4 files changed +19
-13
lines changed Original file line number Diff line number Diff line change 1
1
export type ClassValue = ClassArray | ClassDictionary | string | number | null | boolean | undefined ;
2
+ export type ClassDictionary = Record < string , any > ;
3
+ export type ClassArray = ClassValue [ ] ;
2
4
3
- export interface ClassDictionary {
4
- [ id : string ] : any ;
5
- }
6
-
7
- export interface ClassArray extends Array < ClassValue > { }
8
-
9
- declare const clsx : ( ...classes : ClassValue [ ] ) => string ;
10
-
5
+ export declare function clsx ( ...inputs : ClassValue [ ] ) : string ;
11
6
export default clsx ;
Original file line number Diff line number Diff line change @@ -20,6 +20,8 @@ $ npm install --save clsx
20
20
21
21
``` js
22
22
import clsx from ' clsx' ;
23
+ // or
24
+ import { clsx } from ' clsx' ;
23
25
24
26
// Strings (variadic)
25
27
clsx (' foo' , true && ' bar' , ' baz' );
Original file line number Diff line number Diff line change @@ -26,7 +26,7 @@ function toVal(mix) {
26
26
return str ;
27
27
}
28
28
29
- export default function ( ) {
29
+ export function clsx ( ) {
30
30
var i = 0 , tmp , x , str = '' ;
31
31
while ( i < arguments . length ) {
32
32
if ( tmp = arguments [ i ++ ] ) {
@@ -38,3 +38,5 @@ export default function () {
38
38
}
39
39
return str ;
40
40
}
41
+
42
+ export default clsx ;
Original file line number Diff line number Diff line change 1
1
import test from 'tape' ;
2
- import fn from '../src' ;
2
+ import * as mod from '../src' ;
3
3
4
- test ( 'clsx' , t => {
5
- t . is ( typeof fn , 'function' , 'exports a function' ) ;
6
- t . is ( typeof fn ( ) , 'string' , '~> returns string output' ) ;
4
+ const fn = mod . default ;
5
+
6
+ test ( 'exports' , t => {
7
+ t . is ( typeof mod . default , 'function' , 'exports default function' ) ;
8
+ t . is ( typeof mod . clsx , 'function' , 'exports named function' ) ;
9
+ t . ok ( mod . default === mod . clsx , 'exports are equal' ) ;
10
+
11
+ t . is ( typeof mod . default ( ) , 'string' , '~> returns string output' ) ;
12
+ t . is ( typeof mod . clsx ( ) , 'string' , '~> returns string output' ) ;
13
+
7
14
t . end ( ) ;
8
15
} ) ;
9
16
You can’t perform that action at this time.
0 commit comments