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 List.insert and upgrade Immutable.js #29

Merged
merged 4 commits into from
Jul 29, 2016
Merged

Conversation

lukesneeringer
Copy link
Contributor

This commit upgrades Immutable to 3.8.1, and sets it to >= in
package.json.

It also adds a List.insert() method to typed-immutable lists.

FIxes #20.

This commit upgrades Immutable to 3.8.1, and sets it to `>=` in
`package.json`.

It also adds a `List.insert()` method to typed-immutable lists.

FIxes #20.
@@ -130,7 +130,7 @@ class TypeInferedList extends BaseImmutableList {
}

get(index, notSetValue) {
return this[$store] ? this[$store].get(index, notSetValue) :
return this[$store] ? this[$store].get(parseInt(index), notSetValue) :
Copy link
Member

Choose a reason for hiding this comment

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

Isn't the point of this library to not automatically type convert? Should it error here?

Copy link
Contributor Author

@lukesneeringer lukesneeringer Jul 27, 2016

Choose a reason for hiding this comment

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

So, apparently Immutable.List auto-converts strings to ints on List.get, which I did not know (and I thought was really strange). So, List.of('a', 'b', 'c', 'd').get('1') would return 'b' rather than undefined.

However, Immutable.js 3.8.1 has a bug in it where it does not auto-convert negative number strings (e.g. '-3'), only positive number ones, while 3.7.0 converted both. That was making two of the tests fail.

I could be talked into just removing that test (it is test/list.js, line 426-434) and just letting the Immutable behavior stand. It is not clear to me why this test is even there, since it did not seem to be testing anything in typed-immutable at all.

Without the parseInt, the assertion on line 431 passes, but the assertions on 432 and 433 fail.

Copy link
Member

Choose a reason for hiding this comment

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

Oh my. This one's strange, we're either working around a bug or undefined behavior.

I think we should error if you try to list.get('1a2b3c'), but I'm also ok with merging as it is. @udnisap @davecoates any opinions?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I guess my feeling is, when in doubt, keep the behavior we had already. If this was a from-scratch thing, I would want it to be an error.

Copy link
Member

Choose a reason for hiding this comment

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

We should keep it as it was and match Immutable.js - this is actually an intended change, see:

immutable-js/immutable-js@7acd81b

The original test cases were based on the immutable.js test cases

Copy link
Contributor

Choose a reason for hiding this comment

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

If immutable has that behaviour I think we should go with it.

@lukesneeringer
Copy link
Contributor Author

I think we have consensus, but leaving this for a day or two, just in case.

@lukesneeringer lukesneeringer mentioned this pull request Jul 27, 2016
@lukesneeringer lukesneeringer merged commit cd43268 into master Jul 29, 2016
@lukesneeringer lukesneeringer deleted the upgrade-immutable branch July 29, 2016 00:51
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