Skip to content
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

Merged
merged 1 commit into from
Feb 26, 2024

Conversation

patricklx
Copy link
Contributor

No description provided.

@@ -101,9 +102,11 @@ export class EnvironmentImpl implements Environment {
// Delegate methods and values
public isInteractive: boolean;

isArgumentError: typeof isArgumentError;
Copy link
Contributor

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];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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 {
Copy link
Contributor

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?

Copy link
Contributor

@chancancode chancancode left a 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

@patricklx patricklx force-pushed the patch-2 branch 2 times, most recently from 8517768 to 4e9db94 Compare November 14, 2023 11:28
}


export declare function isArgumentError(arg: unknown): arg is ArgumentError
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this correct?

@patricklx
Copy link
Contributor Author

@NullVoxPopuli can we have another look here?

@NullVoxPopuli NullVoxPopuli merged commit 17ca94f into glimmerjs:main Feb 26, 2024
@patricklx patricklx deleted the patch-2 branch February 26, 2024 13:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants