我在重新选择包时遇到问题。它在包内有类型,所以如果我理解正确,typeScript 应该自己处理它。但是每当我尝试导入它时,我都会看到(5,32): error TS2307: Cannot find module 'reselect'
.
代码很简单:
/// <reference path="../../../../node_modules/reselect/src/reselect.d.ts"/>
import { connect } from 'react-redux';
import Actions from '../../redux/actions';
import { createSelector } from 'reselect';
import { MapDispatchToPropsObject } from 'react-redux';
import { SearchCity } from './index';
const mapStateToProps = (state) => ({
places: state.searchPlaces,
});
const mapDispatchToProps: MapDispatchToPropsObject = {
search: Actions.searchPlaces.searchPlace,
};
export default connect(mapStateToProps, mapDispatchToProps)(SearchCity);
在这里我手动添加了参考,但它无论如何都不起作用。我将 webpack 与 ts-loader 一起使用。谢谢!