如何重命名进入 Typescript 函数的变量?

Leo*_*ban 2 javascript variables renaming typescript

尝试将此变量重命名assetPayoutType为 just payType,但是因为我在使用 TypeScript,所以出现了问题。TypeScript 认为有一种类型叫做payType.

const { title, assetPayoutType } = this.props;

mapDailyAssets(assetPayoutType: string)
Run Code Online (Sandbox Code Playgroud)

IE:这行不通:

mapDailyAssets(assetPayoutType: payType: string)
Run Code Online (Sandbox Code Playgroud)

我在 StackOverflow 上搜索,找到了两个没有回答这个问题的答案。

答案描述了非打字稿/常规 Javascript 简单重命名:

在 TypeScript 中解构对象时重命名剩余属性变量

这个答案是关于 VSCode 重构的:

TypeScript 重命名变量

pau*_*cha 5

type 是 Typescript 中的受保护词(关键字)

还:

const { title, assetPayoutType: payoutType } = this.props;