In the project, there are multiple props that components could be. How to resolve this situation?
We can use | to resolve.
Firstly:
import { QuestionInputPropsType } from "./QuestionInput";
import { QuestionTitlePropsType } from "./QuestionTitle";
export type ComponentPropsType =
| QuestionInputPropsType
| QuestionTitlePropsType;
It means ComponentPropsType can either be QuestionInputPropsType or QuestionTitlePropsType
Then, we can use it in the type we want to define:
import { ComponentPropsType } from "../../components/QuestionComponents";
export type ComponentInfoType = {
fe_id: string;
type: string;
title: string;
props: ComponentPropsType;
};
Comments
Post a Comment