Petar Ivcec
Petar Ivcec

Reputation: 756

React + TypeScript error: No overload matches this call

I am receiving a massive error when mapping through an array like:

// Home.tsx

  render() {
    const { inputs, outputs, expectedOutputs } = this.state;
    return (
        <ContentContainer>
          {inputs.map((input, i) => {
            return (
              <TestRow
                key={i}
                rowNumber={i}
                xml={inputs[i].xml}
                desc={inputs[i].desc}
                output={outputs[i]}
                expectedOutput={expectedOutputs[i]}
                handleTextAreaUpdate={this.handleTextAreaUpdate}
              />
            );
          })}
        </ContentContainer>
    );
// TestRow.tsx

interface TestRowProps {
  xml: string;
  desc: string;
  output: string;
  expectedOutput: string;
  rowNumber: number;
}

class TestRow extends Component<TestRowProps, {}> {
  textArea: any;

the error is:

No overload matches this call. Overload 1 of 2, '(props: Readonly): TestRow', gave the following error.

    Type '{ key: number; rowNumber: number; xml: string; desc: string; output: never; expectedOutput: string; handleTextAreaUpdate: (e: { target: { value: string; }; }, column: number, rowNumber: number) => void; }' is not assignable to type 'IntrinsicAttributes & IntrinsicClassAttributes<TestRow> & Readonly<TestRowProps> & Readonly<{ children?: ReactNode; }>'.
      Property 'handleTextAreaUpdate' does not exist on type 'IntrinsicAttributes & IntrinsicClassAttributes<TestRow> & Readonly<TestRowProps> & Readonly<{ children?: ReactNode; }>'.
  Overload 2 of 2, '(props: TestRowProps, context?: any): TestRow', gave the following error.
    Type '{ key: number; rowNumber: number; xml: string; desc: string; output: never; expectedOutput: string; handleTextAreaUpdate: (e: { target: { value: string; }; }, column: number, rowNumber: number) => void; }' is not assignable to type 'IntrinsicAttributes & IntrinsicClassAttributes<TestRow> & Readonly<TestRowProps> & Readonly<{ children?: ReactNode; }>'.
      Property 'handleTextAreaUpdate' does not exist on type 'IntrinsicAttributes & IntrinsicClassAttributes<TestRow> & Readonly<DiagramProps> & Readonly<{ children?: ReactNode; }>'

. TS2769

Upvotes: 32

Views: 187350

Answers (2)

Jijo Nair
Jijo Nair

Reputation: 838

You are probably missing the return inside the function. I had the same issue, but realized the export function didn't have any return.

Upvotes: 0

Arash Kadkhodaei
Arash Kadkhodaei

Reputation: 485

in the error message, you can find the problem. Property 'handleTextAreaUpdate' does not exist on type means that you should define a property for handleTextAreaUpdate in the TestRowProps interface.

Upvotes: 26

Related Questions