Let’s check out more Typescript ! These will still be very beginner friendly Typescript code samples, but hopefully we will end up with a general overview of what typescript brings to the table.
Not much to it, we can now add types to our functions by adding a type declaration to the function…
Speaking of functions, so what would happen if you gave a function more parameters than it’s function definition had ? well, you would get an error in Typescript like this one:
In order to better deal with this sort of situation, Typescript provides support for both Optional Function parameters and default parameters, let’s check them both:
More on functions… There are a few other things involving functions and Typescript (This, overloading for instance), check out the official docs for more… Typescript- HandBook: Functions
An enum is a way to organize a collection of related values (like an array with internal operations), check out:Typescript Deep Dive - Enums for more.
you can write
And that’s it for now, I’ll come back for a final overview on Typescript and how to organize your files, I hope this code samples help you getting started with Typescript…