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

Add ifEqual type guard #792

Conversation

harsh-srivastava44
Copy link

@harsh-srivastava44 harsh-srivastava44 commented Jan 7, 2024

Added new type IfEqual type guard, to improve on the issue raised #788

@harsh-srivastava44
Copy link
Author

@sindresorhus @Emiyaaaaa can you guys please review this ?

@harsh-srivastava44 harsh-srivastava44 changed the title Add ifEqual type Add ifEqual type guard Jan 7, 2024
@Emiyaaaaa
Copy link
Collaborator

Could you add this type to README.md?

@sindresorhus
Copy link
Owner

@harsh-srivastava44
Copy link
Author

@Emiyaaaaa this is updated and added doc for all available IfT utilities

@harsh-srivastava44 harsh-srivastava44 changed the title Add ifEqual type guard Add ifEqual type guard Jan 8, 2024
@harsh-srivastava44
Copy link
Author

@sindresorhus is it good to be merged ?

@sindresorhus
Copy link
Owner

#792 (comment)

Go through each point and make sure you follow it.

@harsh-srivastava44
Copy link
Author

@sindresorhus I have just started with contribution journey , It would be helpful to let me know what missing in the PR?

@@ -217,6 +217,13 @@ type ShouldBeNever = IfAny<'not any', 'not never', 'never'>;
- [`IsNever`](source/is-never.d.ts) - Returns a boolean for whether the given type is `never`. (Conditional version: [`IfNever`](source/if-never.d.ts).)
- [`IsUnknown`](source/is-unknown.d.ts) - Returns a boolean for whether the given type is `unknown`. (Conditional version: [`IfUnknown`](source/if-unknown.d.ts).)

Currently, `IfType` guards are available for the following checks:

- [`IfAny`](source/if-any.d.ts) - Determines if a type is `any`, and returns `TypeIfAny` if true, otherwise `TypeIfNotAny`.
Copy link
Owner

Choose a reason for hiding this comment

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

I think it's enough to do this so we don't have to duplicate the description:

Suggested change
- [`IfAny`](source/if-any.d.ts) - Determines if a type is `any`, and returns `TypeIfAny` if true, otherwise `TypeIfNotAny`.
- [`IfAny`](source/if-any.d.ts) - Conditional version of [`IsAny`](source/is-any.d.ts).

* An if-else-like type that resolves depending on whether the two given types are equal.
*
* @see {@link IsEqual}
*
Copy link
Owner

Choose a reason for hiding this comment

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

Doc comments should not be prefixed by *

@sindresorhus
Copy link
Owner

I have just started with contribution journey , It would be helpful to let me know what missing in the PR?

Reviewing PRs is a lot of work. That's why we have the contribution guidelines. It points out common issues so you can fix it yourself before taking a maintainers time to point out obvious things. Just go through it point by point.

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.

None yet

4 participants