TypeScript Master (50 Qs)•Part 1: Basic & Foundational TypeScript (Junior / Entry-Level)
How do Function Signatures and Return Types (`void` vs `never`) work?
junior LevelCode ExampleTypeScript
In Simple Words:
void: Indicates a function completes execution without returning a value (returnsundefinedimplicitly).never: Indicates a function never finishes successfully—either it throws an uncaught exception or enters an infinite loop (while(true)).
typescript
function logMessage(msg: string): void {
console.log(msg);
}
function fail(msg: string): never {
throw new Error(msg);
}