11interface Cash {
2- [ index : number ] : Window & Document & HTMLElement & Element & Node ;
2+ [ index : number ] : Ele ;
33 length : number ;
4- splice ( start : number , deleteCount ?: number ) : any ;
5- splice ( start : number , deleteCount : number , ...items : Ele [ ] ) : any ;
4+ splice ( start : number , deleteCount ?: number ) : Ele [ ] ;
5+ splice ( start : number , deleteCount : number , ...items : Ele [ ] ) : Ele [ ] ;
66}
77interface CashStatic {
88 fn : Cash ;
@@ -12,9 +12,18 @@ declare type plainObject = {
1212} ;
1313declare type falsy = undefined | null | false | 0 | '' ;
1414declare type Ele = Window | Document | HTMLElement | Element | Node ;
15- declare type Selector = falsy | string | Function | HTMLCollection | NodeList | Ele | Ele [ ] | ArrayLike < any > | Cash ;
16- declare type Comparator = string | Function | Ele | Cash ;
15+ declare type Selector = falsy | string | Function | HTMLCollection | NodeList | Ele | Ele [ ] | ArrayLike < Ele > | Cash ;
16+ declare type Comparator = string | Ele | Cash | ( ( this : Ele , index : number , ele : Ele ) => boolean ) ;
1717declare type Context = Document | HTMLElement | Element ;
18+ declare type EventObj = Event & {
19+ __delegate ?: boolean ;
20+ namespace ?: string ;
21+ data ?: any ;
22+ } ;
23+ declare type EventCallback = {
24+ ( event : EventObj , data ?: any ) : any ;
25+ guid ?: number ;
26+ } ;
1827declare class Cash {
1928 constructor ( selector ?: Selector , context ?: Context | Cash ) ;
2029 init ( selector ?: Selector , context ?: Context | Cash ) : Cash ;
@@ -33,20 +42,22 @@ interface Cash {
3342interface Cash {
3443 last ( ) : Cash ;
3544}
45+ declare type MapCallback < T > = ( this : T , index : number , ele : T ) => Ele ;
3646interface Cash {
37- map ( callback : Function ) : Cash ;
47+ map ( callback : MapCallback < Ele > ) : Cash ;
3848}
3949interface Cash {
4050 slice ( start ?: number , end ?: number ) : Cash ;
4151}
4252interface CashStatic {
4353 camelCase ( str : string ) : string ;
4454}
55+ declare type EachCallback < T > = ( this : T , index : number , ele : T ) => any ;
4556interface CashStatic {
46- each ( arr : ArrayLike < any > , callback : Function ) : void ;
57+ each < T > ( arr : ArrayLike < T > , callback : EachCallback < T > ) : void ;
4758}
4859interface Cash {
49- each ( callback : Function ) : this;
60+ each ( callback : EachCallback < Ele > ) : this;
5061}
5162interface Cash {
5263 removeProp ( prop : string ) : this;
@@ -61,9 +72,10 @@ interface CashStatic {
6172 guid : number ;
6273}
6374interface CashStatic {
64- matches ( ele : HTMLElement , selector : string ) : boolean ;
75+ matches ( ele : any , selector : string ) : boolean ;
6576}
6677interface CashStatic {
78+ isWindow ( x : any ) : x is Window ;
6779 isFunction ( x : any ) : x is Function ;
6880 isString ( x : any ) : x is string ;
6981 isNumeric ( x : any ) : boolean ;
@@ -84,8 +96,9 @@ interface Cash {
8496 removeAttr ( attrs : string ) : this;
8597}
8698interface Cash {
87- attr ( attrs : string ) : any ;
88- attr ( attrs : string , value : any ) : this;
99+ attr ( ) : undefined ;
100+ attr ( attrs : string ) : string | null ;
101+ attr ( attrs : string , value : string ) : this;
89102 attr ( attrs : plainObject ) : this;
90103}
91104interface Cash {
@@ -98,7 +111,7 @@ interface Cash {
98111 removeClass ( classes ?: string ) : this;
99112}
100113interface CashStatic {
101- unique ( arr : ArrayLike < any > ) : ArrayLike < any > ;
114+ unique < T > ( arr : ArrayLike < T > ) : ArrayLike < T > ;
102115}
103116interface Cash {
104117 add ( selector : Selector , context ?: Context ) : Cash ;
@@ -107,8 +120,8 @@ interface CashStatic {
107120 prefixedProp ( prop : string , isVariable ?: boolean ) : string ;
108121}
109122interface Cash {
110- css ( prop : string ) : any ;
111- css ( prop : string , value : any ) : this;
123+ css ( prop : string ) : string | undefined ;
124+ css ( prop : string , value : string ) : this;
112125 css ( props : plainObject ) : this;
113126}
114127interface Cash {
@@ -118,8 +131,8 @@ interface Cash {
118131 data ( datas : plainObject ) : this;
119132}
120133interface Cash {
121- innerWidth ( ) : number ;
122- innerHeight ( ) : number ;
134+ innerWidth ( ) : number | undefined ;
135+ innerHeight ( ) : number | undefined ;
123136}
124137interface Cash {
125138 width ( ) : number ;
@@ -143,31 +156,31 @@ interface Cash {
143156interface Cash {
144157 off ( ) : this;
145158 off ( events : string ) : this;
146- off ( events : string , callback : Function ) : this;
147- off ( events : string , selector : string , callback : Function ) : this;
159+ off ( events : string , callback : EventCallback ) : this;
160+ off ( events : string , selector : string , callback : EventCallback ) : this;
148161}
149162interface Cash {
150163 on ( events : plainObject ) : this;
151- on ( events : string , callback : Function , _one ?: boolean ) : this;
152- on ( events : string , selector : string | Function , callback : Function , _one ?: boolean ) : this;
164+ on ( events : string , callback : EventCallback , _one ?: boolean ) : this;
165+ on ( events : string , selector : string | EventCallback , callback : EventCallback , _one ?: boolean ) : this;
153166}
154167interface Cash {
155168 one ( events : plainObject ) : this;
156- one ( events : string , callback : Function ) : this;
157- one ( events : string , selector : string | Function , callback : Function ) : this;
169+ one ( events : string , callback : EventCallback ) : this;
170+ one ( events : string , selector : string | EventCallback , callback : EventCallback ) : this;
158171}
159172interface Cash {
160173 ready ( callback : Function ) : this;
161174}
162175interface Cash {
163- trigger ( event : string | Event , data ?: any ) : this;
176+ trigger ( event : Event | string , data ?: any ) : this;
164177}
165178interface Cash {
166179 serialize ( ) : string ;
167180}
168181interface Cash {
169182 val ( ) : string | string [ ] ;
170- val ( value : any ) : this;
183+ val ( value : string | string [ ] ) : this;
171184}
172185interface Cash {
173186 clone ( ) : this;
0 commit comments