I'm trying to use injectIntl
from react-intl
with typescript like this (which is in accordance with what I found in answers to other questions):
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);
But I'm getting the following error:
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.
I don't get what I'm doing wrong and how to make it work with TS?
None of the suggested solutions from here work: React-intl, use api with Typescript
I've got @types/react-intl
version 2.3.17 installed.
Update:
Here's the error message I get if I remove certificate
from Props
:
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'.
TypeScript version is 3.3.3333