【发布时间】:2020-02-10 06:08:13
【问题描述】:
我在 typescript 中使用 react。
我遇到了导出问题。我正在制作一个包含Material-ui 的界面。
例如,
Wrapping.tsx
import { default as Component, ComponentProps as MProps
}from '@material-ui/core/SomeComponent;
export interface MyPorps extends MProps {}
export default MyComponent: React.FC<MyPorps> = props => {
some of render code
}
index.ts
import MyComponent from './wrapping'
import MyProps from './wrapping'
export default MyComponent;
export MyProps;
Usage.tsx
import MyComponent, { MyProps }from '@wrapping;
// waring: 'MyProps' has declared, but not use.
export default Myusage: React.FC<MyPorps> = props => {
let data: MyProps = {
// MyProps has got error MyProps is any type
// error code: 'MyProps ' refers to a value, but is being used as a type here.ts(2749)
}
}
我不知道为什么MyProps 识别any 类型
MyProps 和 let data 和 import { MyProps } 都不同
我的代码有问题吗?
【问题讨论】:
标签: typescript import export material-ui