其他人在更新到TypeScript 3.4时遇到意外行为吗?
我的组件现在无法识别从connect函数传递的道具。
import React, { SFC } from "react";
import { connect } from "react-redux";
import { Dispatch } from "../../types";
import * as actions from "../actions";
interface IOwnProps {
readonly id: string;
readonly name: string;
readonly className?: string;
}
type DispatchProps = ReturnType<typeof mapDispatchToProps>;
type Props = IOwnProps & DispatchProps;
export const Collapsable: SFC<Props> = (props) => (
<div onClick={props.toggle} className={props.className}>
{props.children}
</div>
);
function mapDispatchToProps(dispatch: Dispatch, ownProps: IOwnProps) {
return {
toggle: () => dispatch(actions.toggle(ownProps.name, ownProps.id)),
};
}
export default connect(
null,
mapDispatchToProps,
)(Collapsable);
使用TypeScript 3.3.4可以正确选择“ id”,“ name”,“ className”,但是使用3.4时,也可以选择“ toggle”