-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
feat: add action failure helper #12878
Conversation
🦋 Changeset detectedLatest commit: ac9a325 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
packages/kit/types/index.d.ts
Outdated
* Checks whether this is an action failure thrown by {@link fail}. | ||
* @param e The object to check. | ||
* */ | ||
export function isActionFailure(e: unknown): e is ActionFailure_1<undefined>; |
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.
Through this I'm realizing just now that we're not returning "is this interface" but rather "is this class" from that. We should definitely change it for the new function to refer to the interface instead, not sure if it's seen as a breaking change to change it for the others, too
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.
Do you mean we should change them to not use instanceof
for the check? Or simply changing the return type to use the interface:
/**
* Checks whether this is an action failure thrown by {@link fail}.
* @param {unknown} e The object to check.
- * @return {e is ActionFailure}
+ * @return {e is import('./public.js').ActionFailure}
*/
export function isActionFailure(e) {
return e instanceof ActionFailure;
}
It would be a breaking change for the other helpers I think.
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.
If there's a breaking change we want to eventually make for the others, can you file an issue and add it to the 3.0 milestone so that we don't forget?
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've created one here #12986
closes #12611
Exposes a helper method to check if a variable is an instanceof
ActionFailure
Please don't delete this checklist! Before submitting the PR, please make sure you do the following:
Tests
pnpm test
and lint the project withpnpm lint
andpnpm check
Changesets
pnpm changeset
and following the prompts. Changesets that add features should beminor
and those that fix bugs should bepatch
. Please prefix changeset messages withfeat:
,fix:
, orchore:
.Edits