Mazout Mazout
Mazout Mazout

Reputation: 13

IntrinsicAttributes : Type Error with a type = ComponentType, [TS2322] TypeScript

This is my second question here so be indulgent please :).

Context : Got one Component who receive as props this , focus on resultType:

type Props = {
    //Array of an Interface populate by an import json on parent 
    arraySource: Array<{}>,

    resultType: ComponentType,

    resultStyleName: string;
    Callback: (tagsChecked : Array<string>) => void;
 };

ComponentType is a Type from React to define a Component include in framework.

So i use this to pass a type as ComponentType and use this to dynamically create component which is send to the generic component.

Then i do this and got an error on className line:

  _props.arraySource.map((propsItem) => {
      arrayTarget.push(
        <_props.resultType
          className={_props.resultStyleName}
          item={propsItem}
          Callback={propsItem}
          getCallback={getCallBackFromChild}
          >
</_props.resultType>
      );
    });

The Error is : Unable to assign type '{ className: string; item: {}; Callback: {}; getCallback: (value: any, name: string) => Promise; }' to type 'IntrinsicAttributes'. The 'className' property does not exist on the 'IntrinsicAttributes' type.ts(2322)

Was reading about Intrinsic Attributes, and understand it was a problem if we didn't define good types in Props but actually my type is define and result is good there is only this error pending

If anyone has an idea? Code is actually working and i don't want to make huge impact

Upvotes: 0

Views: 368

Answers (0)

Related Questions