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

Convert the PropTypes compatible to TypeScript

$
0
0

What I'm trying to do is to pass a props and be compatible with both PropTypes and TypeScript.

I have this Props inputGroupAddon:

<TextField        value={value}        inputGroupAddon={{          prepend: {            icon: 'First',            class: ''          },          append: {            icon: 'Last',            class: ''          }        }}      />

Which should be compatible to propTypes:

TextField.propTypes = {  inputGroupAddon: PropTypes.objectOf(    PropTypes.shape({      icon: PropTypes.oneOfType([PropTypes.string, PropTypes.element]),      class: PropTypes.string    })  )}

How can I make this compatible with TypeScript?

type inputGroup = {  icon: Element | string  class: string}export type TextFieldType = {  value: string | any  inputGroupAddon: inputGroup | null}

Viewing all articles
Browse latest Browse all 6287

Trending Articles



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