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

🚀 Feature: Add type guard for the error type #226

Closed
3 tasks done
RebeccaStevens opened this issue Jun 16, 2023 · 1 comment · Fixed by #229
Closed
3 tasks done

🚀 Feature: Add type guard for the error type #226

RebeccaStevens opened this issue Jun 16, 2023 · 1 comment · Fixed by #229
Labels
status: accepting prs Please, send a pull request to resolve this! 🙏 type: feature New enhancement or request 🚀

Comments

@RebeccaStevens
Copy link
Collaborator

Bug Report Checklist

  • I have tried restarting my IDE and the issue persists.
  • I have pulled the latest main branch of the repository.
  • I have searched for related issues and found none that matched my issue.

Overview

Essentially a function that returns isIntrinsicType(type) && type.intrinsicName === "error".

Additional Info

I'm not sure what the best name for the function would be. Possible names:

  • isErrorType
    • + short and simple
    • - users may confuse with the JS Error object's type
  • isTypeError
    • + short and simple
    • - inconsistent with other type type guards (other ones always end with "Type")
  • isIntrinsicErrorType
    • + consistent with other intrinsic type guards
    • - users may think "Intrinsic Error" is a subtype of error
@RebeccaStevens RebeccaStevens added the type: feature New enhancement or request 🚀 label Jun 16, 2023
@JoshuaKGoldberg
Copy link
Owner

Hmm good question. I do like consistency - isIntrinsicErrorType makes the most sense to me... and the downside seems much smaller than the other two options'. Voting for isIntrinsicErrorType!

@JoshuaKGoldberg JoshuaKGoldberg added the status: accepting prs Please, send a pull request to resolve this! 🙏 label Jun 16, 2023
RebeccaStevens added a commit that referenced this issue Jun 18, 2023
JoshuaKGoldberg pushed a commit that referenced this issue Jun 18, 2023
fix #226

<!-- 👋 Hi, thanks for sending a PR to ts-api-utils! 💖.
Please fill out all fields below and make sure each item is true and [x]
checked.
Otherwise we may not be able to review your PR. -->

## PR Checklist

- [x] Addresses an existing open issue: fixes #226
- [x] That issue was marked as [`status: accepting
prs`](https://github.com/JoshuaKGoldberg/ts-api-utils/issues?q=is%3Aopen+is%3Aissue+label%3A%22status%3A+accepting+prs%22)
- [x] Steps in
[CONTRIBUTING.md](https://github.com/JoshuaKGoldberg/ts-api-utils/blob/main/.github/CONTRIBUTING.md)
were taken

## Overview

adds `isIntrinsicErrorType`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: accepting prs Please, send a pull request to resolve this! 🙏 type: feature New enhancement or request 🚀
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants