Skip to content
Myr

fix(ts): avoid mapping more built-in types

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Promise, Map, WeakMap, Set, & WeakSet instances are never mapped by TypeScript

authored by aleclarson · committed by aleclarson · parent 1941e80 · Browse files · 2 files+41 added−1 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+41 added−1 removed

  • tests:+29 added−0 removed
  • other:+12 added−1 removed

2 files+41 added−1 removed

modified:__tests__/types.ts+29 added
187 unmodified lines
188 val = fromDraft(toDraft(val))189 let draft: typeof val = toDraft(val)190}191192// Map instance193{194 let val: Map<any, any>195 val = fromDraft(toDraft(val))196 let draft: typeof val = toDraft(val)197198 let weak: WeakMap<any, any>199 weak = fromDraft(toDraft(weak))200 let weakDraft: typeof weak = toDraft(weak)201}202203// Set instance204{205 let val: Set<any>206 val = fromDraft(toDraft(val))207 let draft: typeof val = toDraft(val)208209 let weak: WeakSet<any>210 weak = fromDraft(toDraft(weak))211 let weakDraft: typeof weak = toDraft(weak)212}213214// Promise object215{216 let val: Promise<any>217 val = fromDraft(toDraft(val))218 let draft: typeof val = toDraft(val)219}220221// Date instance222{223 let val: Date224 val = fromDraft(toDraft(val))
58 unmodified lines
modified:src/immer.d.ts+12 added-1 removed