Reactjs 如何从react intl和typescript一起使用injectIntl?
我正在尝试使用Reactjs 如何从react intl和typescript一起使用injectIntl?,reactjs,typescript,react-intl,Reactjs,Typescript,React Intl,我正在尝试使用react intl中的injectIntl和这样的类型脚本(这与我在其他问题的答案中发现的一致): TypeScript版本是3.3.3333似乎,问题不在于react intl。 证书类型不正确的问题。查看证书类型 只需从道具中移除证书,然后检查问题是否消失 看来,问题不在于react intl。 证书类型不正确的问题。查看证书类型 只需从道具中移除证书,然后检查问题是否消失 这没有帮助-如果我从道具中删除证书,那么typescript会抱怨下一个道具,我已经在我的问题中添加了
react intl
中的injectIntl
和这样的类型脚本(这与我在其他问题的答案中发现的一致):
TypeScript版本是3.3.3333似乎,问题不在于
react intl
。
证书类型不正确的问题。查看证书
类型
只需从道具中移除证书
,然后检查问题是否消失 看来,问题不在于react intl
。
证书类型不正确的问题。查看证书
类型
只需从道具中移除证书
,然后检查问题是否消失 这没有帮助-如果我从道具
中删除证书,那么typescript会抱怨下一个道具,我已经在我的问题中添加了错误消息。请在问题中添加TSADED的版本不确定,但是试试看:``Component```HonzaKalfus我建议你打个电话。这没有帮助-如果我从Props
中删除证书,然后typescript抱怨下一个prop,我已经在我的问题中添加了错误消息。请在问题中添加一个版本的TSAdded不确定,但请尝试:``Component``@HonzaKalfus我建议您打个电话。@cwtuan谢谢您的提示。快速更新:我最终使用了一个*.d.ts文件覆盖了这些类型。在我看来,“确定类型”中的定义似乎是错误的。您是如何使用*.d.ts文件覆盖类型的,我对Typescript 3.5也有同样的问题。x@JunQ您可以这样做:@cwtuan谢谢您的提示。快速更新:我最终使用*.d.ts文件覆盖了这些类型。在我看来,“确定类型”中的定义似乎是错误的。您是如何使用*.d.ts文件覆盖类型的,我对Typescript 3.5也有同样的问题。x@JunQ您可以这样做:
import { injectIntl, InjectedIntlProps } from "react-intl";
interface Props {
certificate?: Certificate;
onCancelClick(event: any): void;
onDeleteClick(event: any): void;
onSubmit(certificate: CertificateWritable): Promise<any>;
}
class CertificateForm extends Component<Props & InjectedIntlProps> {
// ... removed for simplicity
}
export default injectIntl<Props>(CertificateForm);
Error:(174, 34) TS2345: Argument of type 'typeof CertificateForm' is not assignable to parameter of type 'ComponentType<Props & InjectedIntlProps>'.
Type 'typeof CertificateForm' is not assignable to type 'ComponentClass<Props & InjectedIntlProps, any>'.
Types of property 'propTypes' are incompatible.
Type '{ certificate: Requireable<InferProps<{ [x: string]: Requireable<string> | Validator<ReactText> | Requireable<boolean>; }>>; onCancelClick: Validator<(...args: any[]) => any>; onDeleteClick: Requireable<...>; onSubmit: Validator<...>; }' is not assignable to type 'WeakValidationMap<Props & InjectedIntlProps>'.
Types of property 'certificate' are incompatible.
Type 'Requireable<InferProps<{ [x: string]: Requireable<string> | Validator<ReactText> | Requireable<boolean>; }>>' is not assignable to type 'Validator<Certificate | null | undefined>'.
Types of property '[nominalTypeHack]' are incompatible.
Type 'InferProps<{ [x: string]: Requireable<string> | Validator<ReactText> | Requireable<boolean>; }> | null | undefined' is not assignable to type 'Certificate | null | undefined'.
Type 'InferProps<{ [x: string]: Requireable<string> | Validator<ReactText> | Requireable<boolean>; }>' is not assignable to type 'Certificate | null | undefined'.
Type 'InferProps<{ [x: string]: Requireable<string> | Validator<ReactText> | Requireable<boolean>; }>' is missing the following properties from type 'Certificate': id, caCertificate, caCertificateKey, domain, and 2 more.
Error:(175, 27) TS2345: Argument of type 'typeof CertificateForm' is not assignable to parameter of type 'ComponentType<Props & InjectedIntlProps>'.
Type 'typeof CertificateForm' is not assignable to type 'ComponentClass<Props & InjectedIntlProps, any>'.
Types of property 'propTypes' are incompatible.
Type '{ certificate: Requireable<InferProps<{ [x: string]: Requireable<string> | Validator<ReactText> | Requireable<boolean>; }>>; onCancelClick: Validator<(...args: any[]) => any>; onDeleteClick: Requireable<...>; onSubmit: Validator<...>; }' is not assignable to type 'WeakValidationMap<Props & InjectedIntlProps>'.
Types of property 'onDeleteClick' are incompatible.
Type 'Requireable<(...args: any[]) => any>' is not assignable to type 'Validator<(event: any) => void>'.
Types of property '[nominalTypeHack]' are incompatible.
Type '((...args: any[]) => any) | null | undefined' is not assignable to type '((event: any) => void) | undefined'.
Type 'null' is not assignable to type '((event: any) => void) | undefined'.