Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Record.get() with optional NSV (TypeScript) #1463

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

Closed
dinony opened this issue Dec 19, 2017 · 4 comments
Closed

Record.get() with optional NSV (TypeScript) #1463

dinony opened this issue Dec 19, 2017 · 4 comments

Comments

@dinony
Copy link

dinony commented Dec 19, 2017

I'm using v4.0.0-rc.9 with TypeScript.
I wonder why there is no get method in the Record interface without the NSV value.
It results in a lot of .get('..', null) calls. Since I know that there is already a value, given that a record factory already enforces that a value is always present for all keys, it seems unnecessary.

@remi-blaise
Copy link

I encounter the same issue.

remi-blaise added a commit to remi-blaise/immutable-js that referenced this issue Dec 31, 2017
* Make NSV optional in Record.get method

Fixes immutable-js#1463

* Update documentation
remi-blaise added a commit to remi-blaise/immutable-js that referenced this issue Dec 31, 2017
* Make NSV optional in Record.get method

Fixes immutable-js#1463

* Update documentation
@develra
Copy link

develra commented Feb 5, 2018

Woo! I could also use this.

@leidegre
Copy link
Contributor

leidegre commented Mar 18, 2018

It's probably a typo, the get function is quite redundant if you have a record type. You would do record.prop or record[prop] over record.get('prop', undefined). Maybe there are some optimizations I'm not aware of with respect to the Record type that makes this necessary but other than that, a Record is like a specialized Map so, the interface shouldn't really be different.

**Edit: ** of course I was wrong, see #1135

@lawrencezemour
Copy link

I'm glad that this was merged, ideally could you please release a new version with this fix? That would be awesome!

Also, it seems that the type for Record should allow direct access to properties, right?

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

No branches or pull requests

6 participants