local str: "state1" | "state2" = "state1"
local function ObserveState() :number
if str == "state1" then
return 1
elseif str == "state2" then
return 2
end
-- "Not all codepaths in this function return 'number'"
end
str can ONLY be state1 or state2, so the typechecker should be smart enough to know that nothing needs to be returned outside of the if statement