I'm having trouble understanding the concept of 'as never' in this particular code snippet. I've come across the definition that it signifies something that never occurs or excludes other types, but I can't seem to grasp its usage in the context provided below.
import { View, Button, Text, StyleSheet, FlatList, TouchableOpacity, Image } from 'react-native'
import React from 'react'
import { useNavigation } from '@react-navigation/native'
const data = [
{
id: 1,
title: 'Google Search',
screen: 'MapScreen',
},
{
id: 2,
title: 'I\'m Feeling Lucky',
screen: 'MapScreen',
}
]
const NavOptions = (props: NavProps) => {
const navigation = useNavigation();
return (
<FlatList
data={data}
keyExtractor={(item) => item.id}
horizontal
renderItem={({ item }) => (
<View style={styles.container}>
<TouchableOpacity
onPress={() => props.term && navigation.navigate(item.screen as never, {
term: props.term,
} as never)}
style={styles.button}>
<Text style={styles.text}>{item.title}</Text>
</TouchableOpacity>
</View>
)}
/>
)
}
const styles = StyleSheet.create({
container: {
padding: 10,
},
button: {
backgroundColor: "#f8f9fa",
padding: 10,
},
text: {
color: "black",
textAlign: "center",
},
});
type NavProps = {
term: string;
}
export default NavOptions