immutable.ts
This file
Path
__tests__/immutable.ts
56 lines · 1.2 KiB · TypeScript
Last changed by
test(ts): use spec.tsAlec Larsonbefore adoptionb5abaed
History of this fileTake it
test(ts): use spec.tsAlec Larsonbefore adoptionb5abaed
line 1why, one step back1import {assert, _} from "spec.ts"fix(ts): ensure produce returns an immutable typealeclarsonbefore adoptiondd25143
lines 2–5why, one step back2import {Immutable} from "../dist/immer.js"34// array in tuple5{test(ts): use spec.tsAlec Larsonbefore adoptionb5abaed
lines 6–7why, one step back6 let val = _ as Immutable<[string[], 1]>7 assert(val, _ as readonly [ReadonlyArray<string>, 1])fix(ts): ensure produce returns an immutable typealeclarsonbefore adoptiondd25143
lines 8–11why, one step back8}910// tuple in array11{test(ts): use spec.tsAlec Larsonbefore adoptionb5abaed
lines 12–13why, one step back12 let val = _ as Immutable<[string, 1][]>13 assert(val, _ as ReadonlyArray<readonly [string, 1]>)fix(ts): ensure produce returns an immutable typealeclarsonbefore adoptiondd25143
lines 14–17why, one step back14}1516// tuple in tuple17{test(ts): use spec.tsAlec Larsonbefore adoptionb5abaed
lines 18–19why, one step back18 let val = _ as Immutable<[[string, 1], 1]>19 assert(val, _ as readonly [readonly [string, 1], 1])fix(ts): ensure produce returns an immutable typealeclarsonbefore adoptiondd25143
lines 20–23why, one step back20}2122// array in array23{test(ts): use spec.tsAlec Larsonbefore adoptionb5abaed
lines 24–25why, one step back24 let val = _ as Immutable<string[][]>25 assert(val, _ as ReadonlyArray<ReadonlyArray<string>>)fix(ts): ensure produce returns an immutable typealeclarsonbefore adoptiondd25143
lines 26–29why, one step back26}2728// tuple in object29{test(ts): use spec.tsAlec Larsonbefore adoptionb5abaed
lines 30–31why, one step back30 let val = _ as Immutable<{a: [string, 1]}>31 assert(val, _ as {readonly a: readonly [string, 1]})fix(ts): ensure produce returns an immutable typealeclarsonbefore adoptiondd25143
lines 32–35why, one step back32}3334// object in tuple35{test(ts): use spec.tsAlec Larsonbefore adoptionb5abaed
lines 36–37why, one step back36 let val = _ as Immutable<[{a: string}, 1]>37 assert(val, _ as readonly [{readonly a: string}, 1])fix(ts): ensure produce returns an immutable typealeclarsonbefore adoptiondd25143
lines 38–41why, one step back38}3940// array in object41{test(ts): use spec.tsAlec Larsonbefore adoptionb5abaed
lines 42–43why, one step back42 let val = _ as Immutable<{a: string[]}>43 assert(val, _ as {readonly a: ReadonlyArray<string>})fix(ts): ensure produce returns an immutable typealeclarsonbefore adoptiondd25143
lines 44–47why, one step back44}4546// object in array47{test(ts): use spec.tsAlec Larsonbefore adoptionb5abaed
lines 48–49why, one step back48 let val = _ as Immutable<Array<{a: string}>>49 assert(val, _ as ReadonlyArray<{readonly a: string}>)fix(ts): ensure produce returns an immutable typealeclarsonbefore adoptiondd25143
lines 50–53why, one step back50}5152// object in object53{test(ts): use spec.tsAlec Larsonbefore adoptionb5abaed
lines 54–55why, one step back54 let val = _ as Immutable<{a: {b: string}}>55 assert(val, _ as {readonly a: {readonly b: string}})fix(ts): ensure produce returns an immutable typealeclarsonbefore adoptiondd25143
line 56why, one step back56}