Skip to main content
๐Ÿ› Bug HuntTS TypeScript Hardโšก+35 XP

Missing Return in Union

TypeScript reports not all code paths return a value.

๐Ÿ› Find the bug
1function parse(val: string | number): string {
2 if (typeof val === "string") return val;
3}
๐Ÿ› The bug is on line 3

๐Ÿ”ง Select the correct fix: