Adding Types to function definitions makes your code easier to read and easier to use… and eliminates an entire category of runtime errors.
By defining the Types of the input and output precisely, you clearly communicate to future programmers -- and to IDEs like VSCode -- what they can expect from the function. Type information combines with the function and argument name to provide a more complete picture of what the purpose and inner workings of the function are, before even looking at what code is inside.
This video uses the Functions section of the TypeScript Handbook as a rough guide, but changes the emphasis significantly based on the needs of Vue developers. We also look at some real-world code from the Vuetify codebase, to see what we’re learning in action!