AI-powered
podcast player
Listen to all your favourite podcasts with AI-powered features
TypeScript Tools and Tricks - Const Diverse?
The const assertion is when you're creating an object in JavaScript. You can tack on as const onto the end of it and what that will do is It will do extreme type narrowing meaning that the The type of an object if you don't specify the type inIn the case of mine was title string descriptionstring number of episodes number right so string string number. What as const will do is it will narrow it down from not just any string but literally the string of syntax FM the description goes from a broad string any string to the string of Whatever description we put in there. That's really cool becauseyou have now just created a type in TypeScript From the actual data that has been