When I call this, the type solver appears to ignore that this function terminates the running thread:
const some_function = () => { FATAL(ErrorCode.FATAL_BAD_SERVER_RESPONSE); print('asdfgghjlk') // not marked unreachable}const some_function = () => { const [ok, data] = // call remote function, if ok = true data is not unknown if (!ok) FATAL(...); print(data.some_key); // data is of type 'unknown'}
const some_function = () => { FATAL(ErrorCode.FATAL_BAD_SERVER_RESPONSE); print('asdfgghjlk') // not marked unreachable}const some_function = () => { const [ok, data] = // call remote function, if ok = true data is not unknown if (!ok) FATAL(...); print(data.some_key); // data is of type 'unknown'}
This function has no condition for calling
error()
error()
, so calling it should be effectively the same as calling
error()
error()
, which does work:
const some_function = () => { const [ok, data] = // call remote function if (!ok) error(); print(data.some_key); // no error}
const some_function = () => { const [ok, data] = // call remote function if (!ok) error(); print(data.some_key); // no error}
Solution
function FATAL(code: ErrorCode): never { error("Fatal error occured: " + code);}
function FATAL(code: ErrorCode): never { error("Fatal error occured: " + code);}