-
Notifications
You must be signed in to change notification settings - Fork 190
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
improve arguments error detection for inspector #1492
Conversation
@@ -101,9 +102,11 @@ export class EnvironmentImpl implements Environment { | |||
// Delegate methods and values | |||
public isInteractive: boolean; | |||
|
|||
isArgumentError: typeof isArgumentError; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know I made up the original name, but since we are now stashing it on a more general object, we probably want to name it something slightly more specific and less likely to collide/confuse with other meaning, like isArgumentCaptureError
, didErrorDuringCapture
or something similar.
const ARGUMENT_ERROR = Symbol("ARGUMENT_ERROR"); | ||
|
||
export function isArgumentError(arg: unknown): arg is ArgumentError { | ||
return arg !== null && typeof arg === "object" && arg[ARGUMENT_ERROR]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return arg !== null && typeof arg === "object" && arg[ARGUMENT_ERROR]; | |
return arg !== null && typeof arg === "object" && (arg as { [ARGUMENT_ERROR]?: unknown })[ARGUMENT_ERROR]`; |
...I think
return arg !== null && typeof arg === "object" && arg[ARGUMENT_ERROR]; | ||
} | ||
|
||
export class ArgumentErrorImpl { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't need to be exported, yeah?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Other than fixing the lint/type stuff this broadly looks good to me, I don't have a strong opinion on whether we merge it now or after the error branch. I'll leave that up to @NullVoxPopuli
8517768
to
4e9db94
Compare
} | ||
|
||
|
||
export declare function isArgumentError(arg: unknown): arg is ArgumentError |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this correct?
@NullVoxPopuli can we have another look here? |
No description provided.