Declaring Types in Untyped Code

This lesson delves into how to declare types on a JavaScript code that does not have a type.

The keyword declare can be used before one of the previous three declaration types (var, let, const). As the name suggests, it declares to TypeScript that the variable is somewhere but not saying where. This is not used frequently but can be useful if you need to tell the transpiler that the variable is present, just not in the current project (or loaded module), and may not be visible.

Get hands-on with 1400+ tech skills courses.