What is TypeScript? How can it be useful to a person learning web development? I was asked this question on a Slack dicussion recently, and came up with the following example which seemed to be enough for my friends to grasp it.
Here’s an example using the browser’s console:
I assigned the var a to a number , the number 1, then I assigned the next var, b, to a string, 'two' ... and then I added them together.
When writing code
TypeScript can also be useful when using certain code editors.
For example, I've typed something that doesn't exist in the data structure here, and my compiler can warn me about it, meaning I don't have to see an error in the browser, then switch back to my code editor:
I can also get useful tools like this, so I have confidence even when I'm typing, that my code is going to be correct.
These two features are great timesavers, and claw back a lot of time you might have spent setting up TypeScript and debugging issues you might have as a result.