我正在将用TypeScript(tsx)编写的新组件添加到由vanilla ES6 react组件(jsx)组成的现有代码库中 . 将现有的jsx-components导入tsx-component时,我正在为jsx-components添加类型定义 .
My issue is how do I add a type definition for a jsx-component that is connected to redux using connect
假设我有一个现有的jsx组件:
class DateField extends React.Component {
...
}
function mapStateToProps(state) {
return {
locale: state.systemUser.language.langKey
};
}
export default connect(mapStateToProps) (DateField);
How would a typedefintion look like for this component?
注意:没有连接我会写typedefinition,如:
import * as React from 'react';
import * as moment from "moment";
export type IonDateFieldChange = (value: string | Date | moment.Moment) => void;
export interface IDateFieldProps {
value: string | Date | moment.Moment
onChange?: IonDateFieldChange
placeholder?: string
}
declare class DateField extends React.Component<IDateFieldProps,any> {}