An Interest In:
Web News this Week
- April 2, 2024
- April 1, 2024
- March 31, 2024
- March 30, 2024
- March 29, 2024
- March 28, 2024
- March 27, 2024
June 22, 2022 03:50 pm GMT
Original Link: https://dev.to/jarvispact/til-how-to-get-a-live-preview-of-a-inferred-type-in-typescript-592
TIL: How to get a live preview of a inferred type in typescript
Hi , i am @Jarvispact. Todays blog post is going to be a quick one. I am writing typescript for 3+ years already and just right now stumbled upon a really neat feature, which i want to share with you.
TIL: that you can use a special comment format to get a live preview of the inferred type without the need of hovering over a variable.
const identity = <T>(x: T) => x;const val = identity('change-me');// ^?
Notice the comment in the last line. As long as the ^
character points to a variable it will render a live preview of the inferred type on the right side of the question mark.
Here is a TS Playground to play around with the feature yourself.
Thats it, i promised that it will be a short one . If you are interested in a more detailled blog post about typescript, check it out: Typescript - beyond the basics.
Ok
Original Link: https://dev.to/jarvispact/til-how-to-get-a-live-preview-of-a-inferred-type-in-typescript-592
Share this article:
Tweet
View Full Article
Dev To
An online community for sharing and discovering great ideas, having debates, and making friendsMore About this Source Visit Dev To