Idea: forbid grabbing non draftables in strict mode
維護者通常 4 天內回覆
評估
- 難度
- 5/5
- 預估耗時
- 一週以上
- 新手友好度
- 25/100
- Issue 類型
- 功能
- 描述清晰度
- 需要釐清
- 活躍度
- 停滯
- 技術堆疊
- javascript
研究方向
先檢視所參照的 issue #674,以及 Immer 目前對無法轉換為 draft 的類別實例的行為。此提案尚未決定要在 mutableRef、unsafe、original 和 enableStrictMode 之間選擇哪一個作為 API;要完成這項工作,需要確定設計,並實作 strict mode 與向後相容性所對應的行為。
由索引模型根據 Issue 內容生成。
描述
🚀 Feature Proposal
See #674 and many other issues where people are surprised that Immer by default totally ignores their class instances.
The idea is that if a field contains a non-draftable object, it becomes unreadable. E.g.: produce(state, draft => { draft.buffer; }) would throw. To still use the buffer inside a draft, a explicit signal needs to be given, e.g. produce(state, draft => { mutableRef(draft.buffer).push(17); ).
Not sure about the name: mutableRef, unsafe could all work. Or maybe we could even reuse the existing original method for this purpose, although that might be confusing.
For easy backward compatibility an option enableStrictMode(boolean) could be used, by default off in the current version, and enabled in the next major.
Can this be solved in user-land code?
No
- 主要語言
- JavaScript
- 星號
- 29k
- 分支
- 905
- 平均合併
- 3 天 16 小時
- 30 天內合併 PR
- 22
環境準備
這個專案沒有提供開發容器、Dockerfile 或貢獻指南,環境需要你自己搭建:先看它的 README,通用步驟見我們的新手貢獻指南。
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
immerjs/immer 的其他 Issue
-
Shrinking an array with `length =` and growing it back loses the patches for the truncated indices可能已有人在做 @RClaudiuM 今天認領。 未關閉
難度 2/5 1-3 小時 新手友好度 75/100
維護者通常 4 天內回覆
-
難度 3/5 1-2 天 新手友好度 35/100
維護者通常 4 天內回覆
-
Docs: Chinese (zh-CN) website translation is outdated vs English docs可能重新可做 @lijiayou0728 於 91 天前認領,目前沒有進行中的 PR。 未關閉
難度 4/5 3-5 天 新手友好度 55/100
維護者通常 4 天內回覆
-
question
難度 5/5 一週以上 新手友好度 35/100
維護者通常 4 天內回覆
-
難度 5/5 一週以上 新手友好度 35/100
維護者通常 4 天內回覆
相似的 Issue
-
難度 2/5 1-3 小時 新手友好度 76/100
Automattic/node-canvas#2633 ·
-
難度 2/5 1-3 小時 新手友好度 78/100
capricorn86/happy-dom#2594 ·
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 78/100
-
難度 2/5 1-3 小時 新手友好度 79/100
microsoft/monaco-editor#5575 ·
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 84/100
維護者通常 1 天內回覆