@@ -18,7 +18,7 @@ import { generateUUID } from './utils/uuid';
18
18
import baseCss from './index.scss' ;
19
19
import { generateTooltipStyle } from './decorators/styler' ;
20
20
import { BodyModeListener , CustomColor } from './types' ;
21
- import { ReactTooltipProps } from './ReactTooltipProps' ;
21
+ import { Effect , Offset , Place , TooltipProps , Wrapper } from './ReactTooltipProps' ;
22
22
import { checkStatus } from './decorators/customEvent' ;
23
23
24
24
const dispatchGlobalEvent = ( eventName , opts ) => {
@@ -61,14 +61,14 @@ const customListeners = {
61
61
62
62
type TooltipState = {
63
63
uuid : string ;
64
- place : string ;
65
- desiredPlace : string ;
64
+ place : Place ;
65
+ desiredPlace : Place ;
66
66
type : string ;
67
- effect : string ;
67
+ effect : Effect ;
68
68
show : boolean ;
69
69
border : boolean ;
70
70
customColors : CustomColor ;
71
- offset : string | object ;
71
+ offset : Offset ;
72
72
padding : string ;
73
73
extraClass : string ;
74
74
html : boolean ;
@@ -94,7 +94,7 @@ type GetContentFn = {
94
94
95
95
export type GetContentTypes = GetContentFn | string ;
96
96
97
- class ReactTooltip extends React . Component < ReactTooltipProps , TooltipState > {
97
+ class ReactTooltip extends React . Component < TooltipProps , TooltipState > {
98
98
mount : boolean ;
99
99
delayShowLoop ?: NodeJS . Timeout ;
100
100
delayHideLoop ?: NodeJS . Timeout ;
@@ -149,15 +149,15 @@ class ReactTooltip extends React.Component<ReactTooltipProps, TooltipState> {
149
149
static defaultProps = {
150
150
insecure : true ,
151
151
resizeHide : true ,
152
- wrapper : 'div' ,
152
+ wrapper : 'div' as Wrapper ,
153
153
clickable : false
154
154
} ;
155
155
156
156
static supportedWrappers = [ 'div' , 'span' ] ;
157
157
158
158
static displayName = 'ReactTooltip' ;
159
159
160
- constructor ( props : ReactTooltipProps ) {
160
+ constructor ( props : TooltipProps ) {
161
161
super ( props ) ;
162
162
163
163
this . state = {
@@ -319,8 +319,8 @@ class ReactTooltip extends React.Component<ReactTooltipProps, TooltipState> {
319
319
}
320
320
}
321
321
322
- getEffect ( currentTarget : HTMLElement ) {
323
- const dataEffect = currentTarget . getAttribute ( 'data-effect' ) ;
322
+ getEffect ( currentTarget : HTMLElement ) : Effect {
323
+ const dataEffect = currentTarget . getAttribute ( 'data-effect' ) as Effect ;
324
324
return dataEffect || this . props . effect || 'float' ;
325
325
}
326
326
@@ -707,11 +707,11 @@ class ReactTooltip extends React.Component<ReactTooltipProps, TooltipState> {
707
707
708
708
// Make sure the correct place is set
709
709
const desiredPlace =
710
- e . currentTarget . getAttribute ( 'data-place' ) || this . props . place || 'top' ;
711
- const effect =
712
- ( switchToSolid && 'solid' ) || this . getEffect ( e . currentTarget ) ;
710
+ e . currentTarget . getAttribute ( 'data-place' ) as Place || this . props . place || 'top' ;
711
+ const effect : Effect =
712
+ ( switchToSolid && 'solid' ) as Effect || this . getEffect ( e . currentTarget ) as Effect ;
713
713
const offset =
714
- e . currentTarget . getAttribute ( 'data-offset' ) || this . props . offset || { } ;
714
+ e . currentTarget . getAttribute ( 'data-offset' ) as Offset || this . props . offset || { } ;
715
715
const result = getPosition (
716
716
e ,
717
717
e . currentTarget ,
0 commit comments