【发布时间】:2016-09-27 02:48:38
【问题描述】:
我有一个定义了 proptypes 的 React 组件库,我正在考虑改用 Typescript。是否有任何工具可以帮助移植代码?这是一个简单组件的一组示例道具:
static propTypes = {
active: PropTypes.bool,
children: PropTypes.node,
disabled: PropTypes.bool,
icon: Icon.propTypes.kind,
tabIndex: PropTypes.number
};
我正在想象一个工具可以将它转换成类似的东西:
interface IButtonProps {
active: boolean,
children: node,
disabled: boolean,
icon: Icon,
tabIndex: number
}
写起来不难,但如果已经存在就更好了。
【问题讨论】:
-
在您选择的 IDE 中进行简单的正则表达式替换怎么样?
-
我的回答有帮助吗?
标签: javascript reactjs typescript transformation porting