我正在开发一个使用React、Redux和TypeScript的应用程序。我遇到了一个奇怪的情况,就是在进行了一些更改后,其中一个模块停止导出其成员。
文件夹结构如下:
src
|---- components
|---- containers
'components'文件夹包含.tsx文件,而封装的.ts文件位于'containers'文件夹中。
模块NodeList.tsx如下所示:
import * as React from "react";
export const NodeList = (props) => (
<div id="NodeList">
<ul>
{props.items.map((item, i) => (
<li key={i} >
<span id={"Item_"+i}>{item}</span>
</li>
)
)}
</ul>
</div>
)
包装容器 NodeListContainer 是:
import { connect } from "react-redux";
import { Provider } from "react-redux";
import { Nodelist } from "../components/NodeList"
const nodesAsArrayOfType = (state, nodeType: string) => {
console.log("Going for nodes of type ", nodeType)
let a = state.data.model.nodes
let k = Object.keys(a);
let sub = k.filter((e) => {
return a[e].nodeType == nodeType
}).map((e) => a[e])
console.log("Got nodes ", sub)
return sub
}
const mapStateToProps = (state) => {
var list = nodesAsArrayOfType(state, state.UIstate.focusNodeType).map((e) => {return JSON.stringify(e)})
console.log("Returning ", list, list.length)
return {
items: list
}
}
const mapDispatchToProps = (dispatch) => {
return {
newTextValue: (e) => {dispatch({type: "ON_CHANGE", text: e.target.value})}
}
}
export const NodeListContainer = connect(
mapStateToProps,
mapDispatchToProps
)(NodeList)
以上的 NodeList 导入正在被标记为错误消息。
ERROR in ./src/containers/NodeListContainer.ts
(4,10): error TS2305: Module '"MyProject/src/components/NodeList"' has no exported member 'Nodelist'.
有人能提供一些关于这里可能发生了什么的见解吗?