In enduring with my recent trend of using TypeScript, I desired to illustrate how to create functions and variables in TypeScript, because this originally threw me for a loop. The code for this example can be found here.
That can save you a lot of accepting in the end. Even so, I can by mistake pass in the wrong type, and the by chance won’t tell me. But with TypeScript, I don’t have that issue!
Here is an actual trim that I’m using to generate some HTML for a vial with biographical instruction about evangelists:
Here is that same code, but with TypeScript:
Now, I am easily clear as to what I’m expecting for each parameter. If another programmer was to come by and pass in the untrue type, the script wouldn’t compile, and I’d receive an error on that line.