@@ -12,6 +12,8 @@ import ViewOptions from './ViewOptions';
12
12
13
13
import './Test.css' ;
14
14
15
+ import type { Detail , LooseValue } from './shared/types' ;
16
+
15
17
const now = new Date ( ) ;
16
18
17
19
const ariaLabelProps = {
@@ -29,26 +31,28 @@ const placeholderProps = {
29
31
yearPlaceholder : 'yyyy' ,
30
32
} ;
31
33
32
- /* eslint-disable no-console */
33
-
34
34
const nineteenNinetyFive = new Date ( 1995 , now . getUTCMonth ( ) + 1 , 15 , 12 ) ;
35
35
const fifteenthOfNextMonth = new Date ( now . getUTCFullYear ( ) , now . getUTCMonth ( ) + 1 , 15 , 12 ) ;
36
36
37
+ /* eslint-disable no-console */
38
+
39
+ type ReturnValue = 'start' | 'end' | 'range' ;
40
+
37
41
export default function Test ( ) {
38
- const portalContainer = useRef ( ) ;
42
+ const portalContainer = useRef < HTMLDivElement > ( null ) ;
39
43
const [ disabled , setDisabled ] = useState ( false ) ;
40
- const [ locale , setLocale ] = useState ( null ) ;
41
- const [ maxDate , setMaxDate ] = useState ( fifteenthOfNextMonth ) ;
42
- const [ maxDetail , setMaxDetail ] = useState ( 'month' ) ;
43
- const [ minDate , setMinDate ] = useState ( nineteenNinetyFive ) ;
44
- const [ minDetail , setMinDetail ] = useState ( 'century' ) ;
44
+ const [ locale , setLocale ] = useState < string > ( ) ;
45
+ const [ maxDate , setMaxDate ] = useState < Date | undefined > ( fifteenthOfNextMonth ) ;
46
+ const [ maxDetail , setMaxDetail ] = useState < Detail > ( 'month' ) ;
47
+ const [ minDate , setMinDate ] = useState < Date | undefined > ( nineteenNinetyFive ) ;
48
+ const [ minDetail , setMinDetail ] = useState < Detail > ( 'century' ) ;
45
49
const [ renderInPortal , setRenderInPortal ] = useState ( false ) ;
46
- const [ returnValue /* , setReturnValue */ ] = useState ( 'start' ) ;
50
+ const [ returnValue /* , setReturnValue */ ] = useState < ReturnValue > ( 'start' ) ;
47
51
const [ required , setRequired ] = useState ( true ) ;
48
52
const [ showLeadingZeros , setShowLeadingZeros ] = useState ( true ) ;
49
53
const [ showNeighboringMonth , setShowNeighboringMonth ] = useState ( false ) ;
50
54
const [ showWeekNumbers , setShowWeekNumbers ] = useState ( false ) ;
51
- const [ value , setValue ] = useState ( now ) ;
55
+ const [ value , setValue ] = useState < LooseValue > ( now ) ;
52
56
53
57
return (
54
58
< div className = "Test" >
0 commit comments