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

Typescript does not throw an error when wrong type of prop is passed

$
0
0

I'm just trying out typescript to see what's all the fuss is about, but I'm having some problems with type checking.

I'm intentionally passing wrong props to functional component to see if an error is thrown, but its not and cant seem to find the reasson.

Button component

interface Props {  label: string;}const Button: React.FC<Props> = ({ label }) => {  return (<TouchableOpacity      style={tailwind("rounded-full border-2 rounded-lg py-2 px-4 bg-blue-100 border-blue-600"      )}><Text style={tailwind("text-xl")}>{label}</Text></TouchableOpacity>  );};

Button used

<View style={tailwind("w-full h-full flex justify-start")}><View style={tailwind("w-full")}><Button text={true} /></View></View>

tsconfig.json

"compilerOptions": {"allowSyntheticDefaultImports": true,"jsx": "react-native","lib": ["dom", "esnext"],"moduleResolution": "node","noEmit": true,"skipLibCheck": true,"resolveJsonModule": true,"strict": true  }}

Viewing all articles
Browse latest Browse all 6212

Trending Articles



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