我有一個定義了proptypes的React組件庫,正在考慮切換到Typescript。有沒有任何工具可以幫助移植代碼?下面是一個簡單的組件設置道具的例子:將jsx轉換爲tsx?
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更換? –