title: Cannot invoke an object which is possibly 'undefined' in children component
body: <p>In my expo typescript app, I have a function in a root component:</p>
  <pre><code>  const getCardType = (type = ECardType.WOOD) =&gt; {
      setCardType(type);
    };
  </code></pre>
  <p>and pass it in my first child component:</p>
  <pre><code>  &lt;Slider data={slideData} autoPlay={false} getCardType={getCardType} /&gt;
  </code></pre>
  <p>Here is my first child component where I pass the function, and it types declaration:</p>
  <pre><code>  readonly getCardType?: (type: ECardType) =&gt; void;
  
  
  
    const Slider: React.FunctionComponent&lt;ISliderProps&gt; = ({
      data,
      autoPlay,
      getCardType,
   })
  </code></pre>
  <p>After that I pass it into a second child component:</p>
  <pre><code>&lt;SliderCardItem cardItem={item} index={index} getCardType={getCardType} /&gt;
  </code></pre>
  <p>And in this <strong>SliderItem</strong> component, I use this function:</p>
  <pre><code>  useEffect(() =&gt; {
      getCardType(cardType);
    }, [cardType]);
  </code></pre>
  <p>But Have a TS error:  <strong>Cannot invoke an object which is possibly 'undefined' in children component</strong></p>
  <p>I set the <strong>cardType</strong> below in an <strong>onPress()</strong><br />
  I have this error only in this component<br />
  An idea to fix this error?</p>