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
The code doesn't give TypeScript error but fails at runtime because ShellError is undefined.
What is the feature you are proposing to solve the problem?
Expose ShellError class, just like $ is available. This way I would be able to use instanceof on it.
What alternatives have you considered?
I tried two workarounds neither which I liked:
Intentionally make Bun shell throw error once so I could grab an actual instance
import{$,typeShellError}from'bun'letclassCtor: Functiontry{await$`a-command-that-will-surely-fail^#^#`}catch(err: any){classCtor=err.constructor}exportconstisShellError=(err: any): err is ShellError=>{returnerrinstanceofclassCtor}
Check if properties match, and declare the error as ShellError
import{typeShellError}from'bun'exportconstisShellError=(err: any): err is ShellError=>{if(err===null)returnfalseif(typeoferr!=='object')returnfalsereturn(err.constructor?.name==='ShellError'&&typeoferr.json==='function'&&typeoferr.exitCode==='number')}
The text was updated successfully, but these errors were encountered:
What is the problem this feature would solve?
Right now when I install
@types/bun
and write:The code doesn't give TypeScript error but fails at runtime because ShellError is undefined.
What is the feature you are proposing to solve the problem?
Expose ShellError class, just like
$
is available. This way I would be able to use instanceof on it.What alternatives have you considered?
I tried two workarounds neither which I liked:
The text was updated successfully, but these errors were encountered: