Become a member
to unlock all features

    Work with DOM Elements in TypeScript using Type Assertions

    htmlHTML 5

    The DOM can be a bit tricky when it comes to typing. You never really know exactly what you're going to get, so you have to educate your codebase into what you know you're using. This is done using Type Assertion where TypeScript types know they're a certain type, but you give it additional information so you can access the properties and methods that you know will be available.