Skip to content
Myr

Fix produce test for TypeScript 3.7 and add a test for ReadonlyMap and ReadonlySet.

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

authored by Dave Townsend · committed by Dave Townsend · parent 2fba3f8 · Browse files · 1 file+18 added−2 removed
This commit

State

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

Diff stats

1 file+18 added−2 removed

  • tests:+18 added−2 removed

1 file+18 added−2 removed

modified:__tests__/produce.ts+18 added-2 removed
436 unmodified lines
437 const m = new Map<string, S>([["a", {x: 1}]])438 const s = new Set<S>([{x: 2}])439440 const res1 = produce(m, (draft: Draft<Map<string, S>>) => {441 assert(draft, _ as Map<string, {readonly x: number}>) // TODO: drop readonly in TS 3.7441 assert(draft, _ as Map<string, {x: number}>)442 })443 assert(res1, _ as Map<string, {readonly x: number}>)444445 const res2 = produce(s, (draft: Draft<Set<S>>) => {446 assert(draft, _ as Set<{readonly x: number}>) // TODO: drop readonly in TS 3.7446 assert(draft, _ as Set<{x: number}>)447 })448 assert(res2, _ as Set<{readonly x: number}>)449})450451it("works with ReadonlyMap and ReadonlySet", () => {452 type S = {readonly x: number}453 const m: ReadonlyMap<string, S> = new Map([["a", {x: 1}]])454 const s: ReadonlySet<S> = new Set([{x: 2}])455456 const res1 = produce(m, (draft: Draft<Map<string, S>>) => {457 assert(draft, _ as Map<string, {x: number}>)458 })459 assert(res1, _ as ReadonlyMap<string, {readonly x: number}>)460461 const res2 = produce(s, (draft: Draft<Set<S>>) => {462 assert(draft, _ as Set<{x: number}>)463 })464 assert(res2, _ as ReadonlySet<{readonly x: number}>)465})