6

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

Erik Philips
  • 53,428
  • 11
  • 128
  • 150
Leon Gaban
  • 36,509
  • 115
  • 332
  • 529
  • 2
    After adding the new name you have to remove the old name as well? – Bergi Sep 24 '18 at 19:31
  • Just realized I could rename the variable higher up in my logic, when it comes through `this.props` I think there is no way to rename a variable this way with Typescript. – Leon Gaban Sep 24 '18 at 19:38

1 Answers1

9

type is protected word (keyword) in Typescript

also:

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

Leon Gaban
  • 36,509
  • 115
  • 332
  • 529
paulinhorocha
  • 412
  • 4
  • 12