void
The return type of a function whose result has no meaning and should be ignored.
In more detail
A callback typed as returning void may still return a value; it is simply ignored, which is why forEach accepts functions that return something. A function declared to return undefined, in contrast, must actually return undefined.
Related terms
- undefined — The JavaScript value meaning not set: a variable with no value yet, a missing property or a function that returned nothing.
- callback — A function you pass to other code so it can call you back later, for example when an event happens or a timer fires.
- array methods — Built-in functions on every array, such as map, filter and forEach, that run a callback for each element.
Taught in
- Why TypeScript: Contracts, Erased Types And Soundness — Production TypeScript
- Literal Types: String, Number, Boolean Literals And const — Production TypeScript
- any Versus unknown: Defensive Typing In Practice — Production TypeScript
- void, undefined And null: Exact Optional Property Types — Production TypeScript
- Type Aliases Versus Interfaces: Declaration Merging — Production TypeScript
- Optional Properties, Readonly And Index Signatures — Production TypeScript
- Union Types, Intersections And Property Conflicts — Production TypeScript
- Tuples: Fixed Length, Labeled Elements And Variadic Tuples — Production TypeScript
- Assertion Signatures: asserts condition And Invariants — Production TypeScript
- Generic Interfaces, Classes And Type Aliases — Production TypeScript
- Mapped Types, Key Remapping With as And Template Literals — Production TypeScript