[英]Type 'string[] | undefined' is not assignable to type 'string | undefined'
I am new to typescript. I am facing some while declaring Props in typescript as follows:我是typescript的新手,在typescript中声明Props时遇到了一些如下:
Types of property 'd' are incompatible.
Type 'string[] | undefined' is not assignable to type 'string | undefined'.
I have one xyzProps which contains some sting type and one is string[] as given below:我有一个 xyzProps,其中包含一些 sting 类型,一个是 string[],如下所示:
const d1: string[] = [];
type xyzProps = {
a: string;
b: string;
c: string;
d: typeof d1;
};
When I am trying to use the above propes as follows then it gives an error当我尝试按如下方式使用上述属性时,它会出错
export type abcPageProps = RouteComponentProps<Partial<xyzProps>> & ReduxProps;
Any idea why it gives me this error OR any solution for it.知道为什么它会给我这个错误或任何解决方案。
can you try你能试一下吗
type xyzProps = {
a: string;
b: string;
c: string;
d: string[];
};
export type abcPageProps = RouteComponentProps<xyzProps> & ReduxProps;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.