I had a opportunity to define like this type hoge_hoge_1
which last character changes of number as string.
How to do
1. define hoge_hoge
in the string.
this is easy, just add type of
with template literal
${typeof 'hoge_hoge'}
2. define number which change as string.
number can define like this
type Number = number
in this time I need to define number as string, so just add template literal
type Number = `${number}`
▼ This is final code
const PREFIX_ITEM_NAME = "hoge_hoge"
type NumericString = `${number}`
type HogeItemName =
`${typeof PREFIX_ITEM_NAME}_${NumericString}`
Problem
On my editor (webstorm), some errors appeared
I found that it is supported starting from TypeScript 4.1.
So I just fixed my setting of my editor and everything changed fine 😀
Top comments (0)