COZYHUB
  • Home
  • Disclaimer
  • Privacy Policy
  • About
  • Contact

How to get the name of a type as a string


I wish to get the name of a type as shown in the example below.
Can it be achieved ?

type Type = 1type TypeName <T> = `Type name is ${T & string}`type NameOfType = TypeName <Type> // never, expected 'Type name is Type'

playground link

1

Best Answer


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?

Random Posts

Converting an XML file to string typeWhat does it mean to give a div a style='height:100%'?How to get Google Docs into dark mode when the browser's forced dark flag is enabled?Modifying a file inside a jarVisual Studio: LINK : fatal error LNK1181: cannot open input fileMessage not displaying with PySimpleGUIPocket Sphinx on AndroidWhat's the difference between a CRC and a checksum?Why am I suddenly getting a "Blocked loading mixed active content" issue in Firefox?ffmpeg concat: "Unsafe file name"Econometrics : White Test with Rany open-source/free .NET profanity filter for website?Can I use "Config" object with boto3 resource?How to unset "ENV" in dockerfile?Uncaught syntaxerror: unexpected identifier? [closed]ThreadLocal & Memory LeakCheck if my database instance on SQL server is encrypted by TDE?How to find hidden characters in excelJSON Structure for List of ObjectsDrawing an image from a data URL to a canvas
Designed by COZYHUB