I wish to get the name of a type as shown in the example below.
Can it be achieved ?
type Type = 1
type TypeName <T> = `Type name is ${T & string}`
type NameOfType = TypeName <Type> // never, expected 'Type name is Type'
I wish to get the name of a type as shown in the example below.
Can it be achieved ?
type Type = 1
type TypeName <T> = `Type name is ${T & string}`
type NameOfType = TypeName <Type> // never, expected 'Type name is Type'
You can't do that. TypeScrip is just an extortion of JavaScript. Where are no types and generics in runtime. Types exist only in context of TypeScript.
Your question is similar to this one. How to get Generic class<T> name of typescript?