2021-10-01から1ヶ月間の記事一覧
function removeValueSubOrder<T, K extends keyof T, P extends keyof T[K]>( target: T, subOrder: K, keys: P[] ): T { const obj = { ...target } as any for (const key of keys) { obj[subOrder][key] = undefined } return obj as T } function removeValue<T, K extends keyof T>(target: T, keys: K[]): T { const…</t,></t,>
関数のモック import * as Utils from "hogehoge" jest.mock("hogehoge") jest .spyOn(Utils, "hogeFunc") .mockReturnValue(exampleValue)
作ってみた。 const replace: <T, S extends T>( list: T[], condition: (ob: T) => ob is S, callback: (ob: S) => T ) => T[] = (list, condition, callback) => list.map(t => (condition(t) ? callback(t) : t))</t,>