Β© 2026 LinearBytes Inc.
Search posts, tags, users, and pages
Harshit Jain
Frontend @ Intuit | Ex MakeMyTrip, SAP | Javascript| Typescript | React | React Native | UI
In TypeScript, there are two ways of assigning a type to a variable. Type Declaration Type Assertion If you have ever written typescript code, you most probably would have used both of them at some point in time. So let's dive deep into what type d...
Hanamant k
UI Engineer
Great post..!! In last paragraph of post you mentioned ' Type assertion gives more safety '. is that typo mistake...??
Thanks for pointing that out. I have fixed it.
Krzysztof Szala
Type Assertion can be helpful in unit tests, when you need to create some typed object, but you don't need all its properties. Otherwise, I try to avoid it because it is almost like typing things with any.
any
Yes, that's also a common usecase π
Hanamant k
UI Engineer
Great post..!! In last paragraph of post you mentioned ' Type assertion gives more safety '. is that typo mistake...??