我正在开发一个 react、redux Typescript 应用程序。我有一个奇怪的情况,在一些更改后,其中一个module停止导出其成员。
文件夹结构为:
src
|---- components
|---- containers
“components”文件夹包含 .tsx 文件,而包装 .ts 文件位于“containers”文件夹中。
下面列出了module 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'.
任何人都可以对这里可能发生的事情提供任何见解吗?