One of TypeScript’s great features is the level of specificity you can achieve when typing variables. You can define an array to be a collection of strings, or numbers, or a mix of them, but you can also establish that an element is either an HTMLInputElement or an HTMLSelectElement. However, the ease to designate the granularity of your variable types can lead to much confusion when you are starting out.
One of the fields where I have seen programmers being more inconsistent is when typing HTML elements, especially while working with React. To be fair, it’s a little disconcerting when you consider the vast range of possibilities you have, particularly when you are starting to work with TypeScript.
#reactjs #typescript #react #programming #javascript