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

TypeScript is not throwing errors when invalid value passed to the Props

$
0
0
const enum ColumnValues {  one = 1,  two = 2,  three = 3,}interface Props {  style?: StyleProp<ViewStyle>;  title?: string;  titleContainerStyle?: StyleProp<ViewStyle>;  titleStyle?: StyleProp<TextStyle>;  textInputStyle?: StyleProp<TextStyle>;  column?: ColumnValues.one | ColumnValues.two | ColumnValues.three;}const DynPut: FC<Props> = Props => {...return(...)

I have imported this DynPut into another component and passed the value 10 to the Column Prop but typescript is not throwing any errors. How to make typescript throw an error when any values greater than 3 is passed to the Column Prop

<DynPut    title="Add Items"    style={{backgroundColor: 'yellow'}}    titleStyle={{backgroundColor: 'green'}}    titleContainerStyle={{backgroundColor: 'green'}}    textInputStyle={{borderWidth: 5}}    column={10}  />

Viewing all articles
Browse latest Browse all 6287

Trending Articles