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
re: compilerOptions.useUnknownInCatchVariables introduces by #967
Do we:
a) prefer to keep this disabled
b) update our code to correctly handle catch (e: unknown) {
I like (b) ... but it is more work, for example:
TS docs suggest e instanceof Error unfortunately, especially with more then one vmcontext there can be more then one error instance, and more technically today we duct-type these caught variables, changing them to a subclass model may not always be possible / work / etc.
One approach (type guard):
isWhatWeWant(e: unknown) : eis{ code: string}{//... implementation}catch(e){if(isWhatWeWant(e)){if(e.code==='ENOENT'){// do stuff}else{// do other stuff}}else{throwe;// we have no clue what is up}}
Another approach: catch(e: any) { } loose and goosy
There are other approaches, WDYT?
The text was updated successfully, but these errors were encountered:
stefanpenner
changed the title
compilerOptions.useUnknownInCatchVariables introduces by #951
compilerOptions.useUnknownInCatchVariables introduces by #967
Sep 8, 2021
re: compilerOptions.useUnknownInCatchVariables introduces by #967
Do we:
a) prefer to keep this disabled
b) update our code to correctly handle
catch (e: unknown) {
I like (b) ... but it is more work, for example:
TS docs suggest
e instanceof Error
unfortunately, especially with more then one vmcontext there can be more then one error instance, and more technically today we duct-type these caught variables, changing them to a subclass model may not always be possible / work / etc.One approach (type guard):
Another approach:
catch(e: any) { }
loose and goosyThere are other approaches, WDYT?
The text was updated successfully, but these errors were encountered: