immutable-js / immutable-js/immutable-js

Issue with "remove" and plain array

Open
#2,106 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
33k
Forks
1.9k
Avg merge
6d 7h
Merged PRs (30d)
1

Description

```ts
const originalArray = List([ 'a', '2', '3' ])
remove(originalArray, 1)
// ['a', '3']
```
works as expected : https://immutable-js.com/play/#Y29uc3Qgb3JpZ2luYWxBcnJheSA9IExpc3QoWyAnYScsICcyJywgJzMnIF0pCnJlbW92ZShvcmlnaW5hbEFycmF5LCAxKQ==

If we have a plain array, then the output is a weird concatenation of the rest of the array as string : https://immutable-js.com/play/#Y29uc3Qgb3JpZ2luYWxBcnJheSA9IFsgJ2EnLCAnMicsICdiJywgJzQnIF0KcmVtb3ZlKG9yaWdpbmFsQXJyYXksIDEp

If the array is full of numbers, then it does work fine : https://immutable-js.com/play/#Y29uc3Qgb3JpZ2luYWxBcnJheSA9IFsgMSwgMiwgMywgNCBdCnJlbW92ZShvcmlnaW5hbEFycmF5LCAxKQ==

The weirdest case is is the first string contains a number in a string, then the remove function does crash ! https://immutable-js.com/play/#Y29uc3Qgb3JpZ2luYWxBcnJheSA9IFsgJzEnLCAnYScsICdiJywgJ2MnIF0KcmVtb3ZlKG9yaWdpbmFsQXJyYXksIDEp

### Set

The same applies for "set": https://immutable-js.com/play/#Y29uc3Qgb3JpZ2luYWxBcnJheSA9IFsgJ2RvZycsICdmcm9nJywgJ2NhdCcsICdmb29kJyBdCnNldChvcmlnaW5hbEFycmF5LCAxLCAnY293JykgLy8gWyAnZG9nJywgJ2NvdycsICdjYXQnLCAnZm9vZCcgXQ==

### Update

Same for update: https://immutable-js.com/play/#Y29uc3Qgb3JpZ2luYWxBcnJheSA9IFsnZG9nJywgJ2Zyb2cnLCAnY2F0J107CnVwZGF0ZShvcmlnaW5hbEFycmF5LCAxLCAodmFsKSA9PiB2YWwudG9VcHBlckNhc2UoKSk7IC8vIFsgJ2RvZycsICdGUk9HJywgJ2NhdCcgXQ==

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the plain-array examples for remove, set, and update, then inspect those entry points to compare their handling of arrays containing strings and numbers. Done means these calls return the expected array values without concatenating elements or throwing; add regression coverage for the reported cases.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, typescript
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.