let declaration
A variable declared with the let keyword, which can be reassigned later.
In more detail
Because the value may change, TypeScript infers the wider type, such as string rather than "Avery". Prefer const unless you really need to reassign.
Related terms
- const — The JavaScript keyword that declares a variable which cannot be reassigned.
- type widening — The compiler giving a value a broader type than its exact value, such as string instead of "production", because it might change later.
Taught in
- Type Annotations, Type Inference And Contextual Typing — Production TypeScript