That helps, thanks! I did not suspected an immutability to be a problem, since I never reassigned the let updateSW
. I suspected the type system to be a cause, as it encountered a cycle while resolving the expression and it generally don’t handle that without rec
keyword which only works for function declaration - that is why I used the term “recursion” in the title.
Using ref(ignore)
is another interesting trick, I would assume that the type of the ref
would be locked to ignore
but it later allows storing a function there, so ref(ignore)
is like a void assignment that just prepares the mutable variable. I tried assign the updateSW
to the ref
without the ref(ignore)
preparation but it did not work, apparently for the same reason mentioned above - that the type system was unable tho resolve a type of the function which points to its own result in it’s argument.
Long story short, this surprised me and it is worth documenting! I will make a PR to documentation when I will find some spare time! Meantime, please help me understand what is going on when you assign ref(ignore)
, this part is still little bit blurry to me.