Leon Gaban
Leon Gaban

Reputation: 39018

How to rename a variable coming into a Function in Typescript?

Trying to rename this variable: assetPayoutType to just payType, however because I'm working in TypeScript there is a problem. TypeScript thinks there is a type called payType.

const { title, assetPayoutType } = this.props;

mapDailyAssets(assetPayoutType: string)

IE: This won't work:

mapDailyAssets(assetPayoutType: payType: string)

I searched on StackOverflow and found two answers that did not answer this question.

Answer describes a non-typescript / regular Javascript simple rename:

Renaming remaining properties variable when object destructuring in TypeScript

This answer is about VSCode refactoring:

TypeScript rename variable

Upvotes: 8

Views: 10637

Answers (1)

paulinhorocha
paulinhorocha

Reputation: 470

type is protected word (keyword) in Typescript

also:

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

Upvotes: 11

Related Questions