Rescript + react somewhere wanted array

Hi all,

I am getting the following error:

mru_1  |   We've found a bug for you!
mru_1  |   /usr/src/app/src/App.re:22:23-24
mru_1  |
mru_1  |   20 ┆         onEdit={(_i,_s) => Js.log("edit")}
mru_1  |   21 ┆         editId=0
mru_1  |   22 ┆         items=[]>
mru_1  |   23 ┆     </TodoList>
mru_1  |   24 ┆ </div>
mru_1  |
mru_1  |   This has type: list('a)
mru_1  |   Somewhere wanted: array(string)
mru_1  |
mru_1  | FAILED: cannot make progress due to previous errors.

I was wondering why are empty square brackets considered a list rather than an empty string array?

You’re still using an older version of the ReScript language with .re files. In there [] stands for an empty singly linked list. In the old .re language you need to write [||] or [|1, 2, 3|] to denote arrays.

All files ending with the extension .res use the current version of the language syntax. In there [ ] means an empty array as you would expect.

2 Likes