Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Provide default type to first() and last() #1676

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

Merged
merged 1 commit into from
Jan 17, 2020

Conversation

johanblumenberg
Copy link
Contributor

Before

new OrderedSet().first() gives a compiler error, because the NSV type is not known.
new OrderedSet<V>('a string').first() returns type V | string

You need to explicitly provide the type to first().

Intuitively you would pass type V:

new OrderedSet().first<V>() returns type V, although it can return undefined

The correct way would be:

new OrderedSet().first<undefined>() or new OrderedSet().first(undefined), which would return type V | undefined

After

new OrderedSet<V>().first() returns type V | undefined
new OrderedSet<V>('a string').first() returns type V | string

Less likely to make misstakes.
Less typing in the common case when you want undefined when there is no first value.

@facebook-github-bot
Copy link

Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. In order for us to review and merge your code, please sign up at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need the corporate CLA signed.

If you have received this in error or have any questions, please contact us at cla@fb.com. Thanks!

@rgbkrk
Copy link
Contributor

rgbkrk commented Jun 13, 2019

If I could merge this, I would.

@leebyron leebyron merged commit 91c7c1e into immutable-js:master Jan 17, 2020
@leebyron
Copy link
Collaborator

This is the right thing. thanks!

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.

4 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.