Quantcast
Channel: Active questions tagged react-native+typescript - Stack Overflow
Viewing all articles
Browse latest Browse all 6287

How to use generics defined in @types for a react native library

$
0
0

I have been trying to use the Agenda component from react-native-calendars library in Typescript. The issue I have been facing is that the type definition makes heavy use of generics mainly TItem to define types for various parameters. When I need to call functions that makes use of this generic the Typescript compiler in VSCode complains that the parameter is defined as any due to which I cannot use all the goodness of TS and I do not know how to incorporate these generics in my code.

<Agenda  items={state.items}  loadItemsForMonth={loadItems.bind(this)}  selected={'2017-05-16'}  renderItem={renderItem.bind(this)}  renderEmptyDate={renderEmptyDate.bind(this)}  rowHasChanged={rowHasChanged.bind(this)}  showClosingKnob={true}/>function renderItem(item) {  return (<TouchableOpacity      onPress={() => Alert.alert(item.name)}><Text>{item.name}</Text></TouchableOpacity>  );}

The compiler complains Parameter 'item' implicitly has an 'any' type. The item parameter in renderItem is supposed to be a TItem but how do I tell the compiler this?


Viewing all articles
Browse latest Browse all 6287

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>