void and never
void is for functions that return nothing. never is for functions that never return, such as ones that always throw.
Example
function log(m: string): void { console.log(m); }
function fail(m: string): never { throw new Error(m); }
log("ok");
try { fail("x"); } catch (e) { console.log("caught"); }Result
ok caught
Exercise
No return value.
function f(): {}
Quiz Test
These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.