Fix TypeScript declarations to support currying and immutable state#98
Fix TypeScript declarations to support currying and immutable state#98olavim wants to merge 4 commits intoimmerjs:masterfrom
Conversation
|
thanks for the PR @tilastokeskus! Not sure if this PR really solves the issue. If I understand the typings correctly, I think this will just make the top level type mutable, but not things that are marked as readonly in any subtypes? |
|
@mweststrate You're right, it didn't work properly after all. And apparently there are some other problems too with what I did: microsoft/TypeScript#13723 From what I gather, recursively removing the readonly-ness from a type properly is not possible at the moment. I pushed a hacky change that makes the state mutable, and at least on my IDE (WebStorm 2018) still gives me correct suggestions when accessing the draft's data. See if you can find glaring issues with it. |
|
I have a simpler fix than this one that also fixes some bugs in the typings. I'm about to create a pull request. Edit: see #109 |
|
@tilastokeskus thanks for the effort! I think #109 is a cleaner solution though, so closing this one in favor of that one. N.b. note that you can always use |
The TypeScript declarations prevent modying the produced draft if it was produced from an object that has a readonly interface:
Also calling
producewith only one argument is not allowed, so currying is impossible:This PR solves both of these cases.
Fixes #97