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 documentation of IterableElement type & add tests for using with Set #894

Merged
merged 10 commits into from
Jun 22, 2024

Conversation

xeho91
Copy link
Contributor

@xeho91 xeho91 commented Jun 20, 2024

Added a new type SetKeys which is a helper to quickly infer the type of keys from a strongly typed Set or ReadonlySet.

@sindresorhus
Copy link
Owner

I think you can already use the IterableElement type for this.

@xeho91
Copy link
Contributor Author

xeho91 commented Jun 20, 2024

I think you can already use the IterableElement type for this.

Oh! I feel dumb missing this one. You're right, IterableElement gives same result.

Least I can do is update examples of IterableElement and mention keywords of the common Iterable instances (Set, Map) in the readme.md next to this type.

Especially this mention:

Many types in JavaScript/TypeScript are iterables. This type works on all types that implement those interfaces. For example, `Array`, `Set`, `Map`, `stream.Readable`, etc.

Because I think is too hidden, at least for people like me. Hopefully not too many 😅

@sindresorhus
Copy link
Owner

sindresorhus commented Jun 21, 2024

👍

And also here: https://github.com/sindresorhus/type-fest?tab=readme-ov-file#alternative-type-names Should probably add SetValues there too, as that's a more correct term for it.

@xeho91 xeho91 changed the title Add SetKeys type Improve documentation of IterableElement type & add tests for using with Set Jun 22, 2024
@sindresorhus sindresorhus merged commit 0e46755 into sindresorhus:main Jun 22, 2024
8 checks passed
@xeho91 xeho91 deleted the set-keys branch June 22, 2024 11:40
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.

2 participants