title: Cannot invoke an expression whose type lacks a call signature in union type
body: <p>I have the following union type written in TypeScript:</p>
  
  <pre><code>interface SingleLineTextFieldPropTypes {
    multiLine: false;
    value: string;
    disabled?: boolean;
    placeholder?: string;
    readOnly?: boolean;
    type?: string;
    className?: string;
  
    onChange: (value: string) =&gt; void;
  }
  
  interface MultiLineTextFieldPropTypes {
    multiLine: true;
    readOnly?: boolean;
    disabled?: boolean;
    placeholder?: string;
    editorState: EditorState;
  
    onChange: (editorState: EditorState) =&gt; void;
  }
  
  type PropTypes =
    SingleLineTextFieldPropTypes |
    MultiLineTextFieldPropTypes;
  </code></pre>
  
  <p>(The only relevant member of those interfaces is the <code>onChange</code> function)</p>
  
  <p>I am using them in a React component as follows:</p>
  
  <pre><code>class Component extends React.Component&lt;PropTypes&gt; {
    render() {
      if (this.props.multiLine === false) {
        return (
          &lt;input
            type={this.props.type}
            readOnly={this.props.readOnly}
            disabled={this.props.disabled}
            placeholder={this.props.placeholder}
            value={this.props.value}
            onChange={(e: React.FormEvent&lt;HTMLInputElement&gt;) =&gt; {
              this.props.onChange((e.target as HTMLInputElement).value as string);
           // ^^^^^^^^^^^^^^^^^^^ here is the error
            }}
            className={classnames('ui-textfield', this.props.className)}
          /&gt;
        );
      }
      else { /* ... */ }
    }
  }
  </code></pre>
  
  <p>Now I am getting an error about the <code>onChange</code> call:</p>
  
  <pre><code>TS2349: Cannot invoke an expression whose type lacks a call signature. Type '((value: string) =&gt; void) | ((editorState: EditorState) =&gt; void)' has no compatible call signatures.
  </code></pre>
  
  <p>What should I do about it? I saw some other questions on StackOverflow about this topic, but <strong>none of them illustrates my situation</strong>. Thank you!</p>