【发布时间】:2016-11-15 21:18:41
【问题描述】:
reselect 包有问题。它在包内有类型,所以如果我理解正确,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 一起使用。 谢谢!
【问题讨论】:
-
你的文件
tsconfig.json在哪里? -
@Paleo 放在项目的根目录下。这个文件放在
src/scripts/components/search-city/ -
文件
reselect.d.ts是目录search-city的后代吗?
标签: typescript typescript-typings