You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
functionerrorHandler2(error:unknown){return;if(errorinstanceofError){console.log(error.message);//Error: Object is of type 'unknown'.}}functionerrorHandler3(error:unknown){throwerrorif(errorinstanceofError){console.log(error.message);//Error: Object is of type 'unknown'.}}
π Actual behavior
I've put return or throw statement just for debugging purpose to end function earlier. And I got compiler error in later code.
π Expected behavior
No error because I have allowUnreachableCode: true in tsconfig (default) and the unreachable code is valid (but compiler says it is not).
Small bug IMO, nothing serious, but it's something I didn't expect.
The text was updated successfully, but these errors were encountered:
allowUnreachableCode causes unreachable code itself to not error. But due to the linked bug the type checking does not work as expected within unreachable code, resulting in a type error.
Bug Report
π Search Terms
unknown allowUnreachableCode
π Version & Regression Information
4.5.4 and 4.6.0-dev.20220107
β― Playground Link
Playground link with relevant code
π» Code
π Actual behavior
I've put
return
orthrow
statement just for debugging purpose to end function earlier. And I got compiler error in later code.π Expected behavior
No error because I have
allowUnreachableCode: true
in tsconfig (default) and the unreachable code is valid (but compiler says it is not).Small bug IMO, nothing serious, but it's something I didn't expect.
The text was updated successfully, but these errors were encountered: