@@ -6,26 +6,25 @@ import { ArrayStore } from 'devextreme-react/common/data';
66
77import Item from './Item.tsx' ;
88import Tag from './Tag.tsx' ;
9- import {
10- simpleProducts , products , productLabel , Product ,
11- } from './data.ts' ;
9+ import { simpleProducts , products , productLabel } from './data.ts' ;
10+ import type { Product } from './types.ts' ;
1211
13- const disabledValue = [ simpleProducts [ 0 ] ] ;
14- const value = [ 1 , 2 ] ;
12+ const disabledValue : string [ ] = [ simpleProducts [ 0 ] ] ;
13+ const value : number [ ] = [ 1 , 2 ] ;
1514const dataSource = new ArrayStore ( {
1615 data : products ,
1716 key : 'Id' ,
1817} ) ;
1918
2019function App ( ) {
21- const [ editableProducts , setEditableProducts ] = useState ( [ ...simpleProducts ] ) ;
22- const [ target , setTarget ] = useState ( null ) ;
23- const [ product , setProduct ] = useState < Product > ( { } ) ;
20+ const [ editableProducts , setEditableProducts ] = useState < string [ ] > ( [ ...simpleProducts ] ) ;
21+ const [ target , setTarget ] = useState < HTMLElement | null > ( null ) ;
22+ const [ product , setProduct ] = useState < Product | null > ( null ) ;
2423
2524 const onCustomItemCreating = useCallback (
26- ( args : TagBoxTypes . CustomItemCreatingEvent ) => {
25+ ( args : TagBoxTypes . CustomItemCreatingEvent ) : void => {
2726 const newValue = args . text ;
28- const isItemInDataSource = editableProducts . some ( ( item ) => item === newValue ) ;
27+ const isItemInDataSource = editableProducts . some ( ( item : string ) : boolean => item === newValue ) ;
2928 if ( ! isItemInDataSource ) {
3029 setEditableProducts ( [ newValue , ...editableProducts ] ) ;
3130 }
@@ -34,15 +33,15 @@ function App() {
3433 [ editableProducts ] ,
3534 ) ;
3635
37- const onMouseEnter = useCallback ( ( e : { currentTarget : any } , newProduct ) => {
36+ const onMouseEnter = useCallback ( ( e : React . MouseEvent < HTMLElement > , newProduct : Product ) : void => {
3837 setTarget ( e . currentTarget ) ;
3938 setProduct ( newProduct ) ;
4039 } , [ ] ) ;
4140
42- const getAltText = useCallback ( ( text : String ) => `${ text } . Picture` , [ ] ) ;
41+ const getAltText = useCallback ( ( text : string ) : string => `${ text } . Picture` , [ ] ) ;
4342
4443 return (
45- < React . Fragment >
44+ < >
4645 < div className = "dx-fieldset" >
4746 < div className = "dx-field" >
4847 < div className = "dx-field-label" > Default mode</ div >
@@ -168,25 +167,25 @@ function App() {
168167 >
169168 < p >
170169 < b > Name: </ b >
171- < span > { product . Name } </ span >
170+ < span > { product ? .Name } </ span >
172171 </ p >
173172 < p >
174173 < b > Price: </ b >
175- < span > { product . Price } </ span >
174+ < span > { product ? .Price } </ span >
176175 </ p >
177176 < p >
178177 < b > In-stock: </ b >
179- < span > { product . Current_Inventory } </ span >
178+ < span > { product ? .Current_Inventory } </ span >
180179 </ p >
181180 < p >
182181 < b > Category: </ b >
183- < span > { product . Category } </ span >
182+ < span > { product ? .Category } </ span >
184183 </ p >
185184 </ Popover >
186185 </ div >
187186 </ div >
188187 </ div >
189- </ React . Fragment >
188+ </ >
190189 ) ;
191190}
192191
0 commit comments