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
declarefunctiongetUser(): {user: string};try{var{ user }=getUser();}catch{console.error("error");}console.info(user.toUpperCase());
🙁 Actual behavior
Code above compiles without errors, but crashes at runtime if getUser throws since user will be undefined -- see TS playground for easy reproduction.
⚠️ Additionally, the behaviour is the same for array destructuring.
🙂 Expected behavior
I'd expect the following error on the last line:
Variable 'user' is used before being assigned. (2454)
As shown in the playground, this error is correctly raised if the variable (r) is initialized using "regular assigment" instead of destructuring assignment (user).