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

Typescript - Conditional Type / Optional

$
0
0

I have a component, It takes arguments such as :

interface Props {  label: string;  children?: React.ReactNode;  withoutActions?: boolean;  fieldKey?: KeyProperties;  corporate: Corporate;}

The withoutActions and fieldKey are used by a form.If the withoutActions prop is true, then there should not be a provided fieldKey.

However, if my withoutActions is undefined, then i should enforce my fieldLabel to be of type **KeyProperties** which is a specific list of available values for it.

If withoutActions is undefined, the other SHOULD NOT be defined at allIf withoutActions is true, the other SHOULD be defined respecting the specific keyProperties type.

How can i implement that ?


Viewing all articles
Browse latest Browse all 6287

Trending Articles



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