Skip to content

Instantly share code, notes, and snippets.

@netotz
netotz / haltingProblem.ts
Last active April 4, 2025 15:25
Solving the halting problem using TypeScript
type AnyFunction = () => any;
/**
* Returns true if running `func()` reaches a return statement.
* Otherwise, if it loops forever, returns false.
* @author God. This function is always right.
*/
declare function doesReturn(func: AnyFunction): boolean;
function test(): void | never {