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
try{
...
}catch(ex){// Adding an annotation here gives ERROR TS1196: Catch clause variable cannot have a type annotationif(exinstanceofFooError){ex;// ex is of type anyex.message;// OKex.iDontExist;// typechecks OK, but doesn't exist}elseif(isBarError(ex)){ex;// ex is of type anyex.foo();// typechecks OK, but runtime error}else{
...
}}
I guess this is expected behaviour not a bug. But I was not previously aware that the catch clasue variable cannot be annotated. Due to #1426, this means we can't narrow ex inside the catch clause, so all the cases dealing with specific error types get no type checking (since ex remains as any).
I guess this is expected behaviour not a bug. But I was not previously aware that the catch clasue variable cannot be annotated. Due to #1426, this means we can't narrow
exinside the catch clause, so all the cases dealing with specific error types get no type checking (sinceexremains asany).