Skip to content
Myr

Reformat all TypeScript code with new prettier version

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

authored by Stefan Wille · committed by Stefan Wille · parent d0d2b86 · Browse files · 3 files+124 added−103 removed
This commit

State

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

Diff stats

3 files+124 added−103 removed

  • tests:+88 added−85 removed
  • other:+36 added−18 removed

3 files+124 added−103 removed

modified:__tests__/flow/ts.ts+4 added-4 removed
modified:__tests__/types.ts+84 added-81 removed
modified:src/immer.d.ts+36 added-18 removed
1// Mapped type to remove readonly modifiers from state2// Based on https://github.com/Microsoft/TypeScript/blob/d4dc67aab233f5a8834dff16531baf99b16fea78/tests/cases/conformance/types/conditional/conditionalTypes1.ts#L120-L1293export type DraftObject<T> = {4 -readonly [P in keyof T]: Draft<T[P]>;5};6export interface DraftArray<T> extends Array<Draft<T>> { }7export type Draft<T> =8 T extends any[] ? DraftArray<T[number]> :9 T extends ReadonlyArray<any> ? DraftArray<T[number]> :10 T extends object ? DraftObject<T> :11 T;3export type DraftObject<T> = {-readonly [P in keyof T]: Draft<T[P]>}4export interface DraftArray<T> extends Array<Draft<T>> {}5export type Draft<T> = T extends any[]6 ? DraftArray<T[number]>7 : T extends ReadonlyArray<any>8 ? DraftArray<T[number]>9 : T extends object ? DraftObject<T> : T1011export interface Patch {14 op: "replace" | "remove" | "add",15 path: (string|number)[]12 op: "replace" | "remove" | "add"13 path: (string | number)[]14 value?: any15}1617export type PatchListener = (patches: Patch[], inversePatches: Patch[]) => void
35 unmodified lines
53 initialState: S54 ): (currentState: S | undefined, a: A, b: B) => S55 // 3 additional arguments of types A, B and C56 <S = any, A = any, B = any, C = any>(59 recipe: (this: Draft<S>, draftState: Draft<S>, a: A, b: B, c: C) => void | S,57 recipe: (58 this: Draft<S>,59 draftState: Draft<S>,60 a: A,61 b: B,62 c: C63 ) => void | S,64 initialState: S65 ): (currentState: S | undefined, a: A, b: B, c: C) => S66 // any number of additional arguments, but with loss of type safety67 // this may be alleviated if "variadic kinds" makes it into Typescript:68 // https://github.com/Microsoft/TypeScript/issues/545369 <S = any>(66 recipe: (this: Draft<S>, draftState: Draft<S>, ...extraArgs: any[]) => void | S,70 recipe: (71 this: Draft<S>,72 draftState: Draft<S>,73 ...extraArgs: any[]74 ) => void | S,75 initialState: S76 ): (currentState: S | undefined, ...extraArgs: any[]) => S7778 // curried invocations without default initial state79 // 0 additional arguments72 <S = any>(73 recipe: (this: Draft<S>, draftState: Draft<S>) => void | S74 ): (currentState: S) => S80 <S = any>(recipe: (this: Draft<S>, draftState: Draft<S>) => void | S): (81 currentState: S82 ) => S83 // 1 additional argument of type A84 <S = any, A = any>(85 recipe: (this: Draft<S>, draftState: Draft<S>, a: A) => void | S86 ): (currentState: S, a: A) => S
2 unmodified lines
89 recipe: (this: Draft<S>, draftState: Draft<S>, a: A, b: B) => void | S90 ): (currentState: S, a: A, b: B) => S91 // 3 additional arguments of types A, B and C92 <S = any, A = any, B = any, C = any>(85 recipe: (this: Draft<S>, draftState: Draft<S>, a: A, b: B, c: C) => void | S93 recipe: (94 this: Draft<S>,95 draftState: Draft<S>,96 a: A,97 b: B,98 c: C99 ) => void | S100 ): (currentState: S, a: A, b: B, c: C) => S101 // any number of additional arguments, but with loss of type safety102 // this may be alleviated if "variadic kinds" makes it into Typescript:103 // https://github.com/Microsoft/TypeScript/issues/5453104 <S = any>(91 recipe: (this: Draft<S>, draftState: Draft<S>, ...extraArgs: any[]) => void | S105 recipe: (106 this: Draft<S>,107 draftState: Draft<S>,108 ...extraArgs: any[]109 ) => void | S110 ): (currentState: S, ...extraArgs: any[]) => S111}112113export const produce: IProduce
21 unmodified lines