Quantcast
Channel: Active questions tagged visual-studio-code - Stack Overflow
Viewing all articles
Browse latest Browse all 97445

Typescript: rename string literal type in VScode

$
0
0

Given some string literal type:

declare type Test = "hello" | "world";

const test: Test = "hello";

I want to rename "hello", and I want the change will take effect also in the usage, but VScode doesn't let me to rename "hello" and just give me an error: you cannot rename this element.

Is there any tool or extension that will allow me to do this kind of refactor? I know I can use enum, but I want a solution for string literal types specifically.

UPDATE I'v also found this open issue in typescript: https://github.com/microsoft/TypeScript/issues/5602

UPDATE2: I'v found out that Intellij supports doing exactly this- when you rename a string literal type, it will rename all the usages as well.


Viewing all articles
Browse latest Browse all 97445

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>