This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| type ExtractReturnTypes<T extends ((...args: unknown[]) => unknown)[]> = [ | |
| ...{ [K in keyof T]: T[K] extends ((...args: unknown[]) => infer R) ? R : never } | |
| ] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import type { ActionsUnion } from '@/store/action-helper' | |
| import { createAction } from '@/store/action-helper' | |
| export enum StoreActionType { | |
| HYDRATE = '@@store/HYDRATE', | |
| } | |
| export const StoreAction = { | |
| hydrate(payload: Record<string, unknown>) { | |
| return createAction(StoreActionType.HYDRATE, payload) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import type { SagaIterator } from 'redux-saga' | |
| declare type CallReturnType<T extends (...args: any) => any> = ReturnType<T> extends Promise<infer U> | |
| ? U | |
| : ReturnType<T> extends SagaIterator<infer U> | |
| ? U | |
| : ReturnType<T> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| type KnownKeys<T> = { | |
| [K in keyof T]: string extends K ? never : number extends K ? never : K | |
| } extends { [_ in keyof T]: infer U } ? U : never; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import type { CountedItem} from './counter'; | |
| import { getCounter } from './counter' | |
| describe('Counter tests', () => { | |
| it('should work with functions', () => { | |
| const noop1 = () => null | |
| const noop2 = () => null | |
| const counter = getCounter() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { useEffect, useLayoutEffect } from 'react' | |
| // React currently throws a warning when using useLayoutEffect on the server. | |
| // To get around it, we can conditionally useEffect on the server (no-op) and | |
| // useLayoutEffect in the browser. We need useLayoutEffect to ensure the store | |
| // subscription callback always has the selector from the latest render commit | |
| // available, otherwise a store update may happen between render and the effect, | |
| // which may cause missed updates; we also must ensure the store subscription | |
| // is created synchronously, otherwise a store update may occur before the | |
| // subscription is created and an inconsistent state may be observed |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| export const getArrayRange = (length: number, startFrom = 0): number[] => { | |
| return Array.from({ length }, (_, index) => index + startFrom) | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| export type InferGetStaticPropsQueryType<Fn> = Fn extends GetStaticProps<any, infer Query> | |
| ? Query | |
| : Fn extends ( | |
| context?: GetStaticPropsContext<infer Query>, | |
| ) => Promise<GetStaticPropsResult<any>> | GetStaticPropsResult<any> | |
| ? Query | |
| : never | |
| export type InferGetServerSidePropsQueryType<Fn> = Fn extends GetServerSideProps<any, infer Query> | |
| ? Query |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function censor(censor: any) { | |
| let i = 0 | |
| return function(_: any, value: unknown) { | |
| if (i !== 0 && typeof censor === 'object' && typeof value === 'object' && censor === value) { | |
| return '[Circular]' | |
| } | |
| // seems to be a harded maximum of 11 serialized objects? | |
| if (i >= 10) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| version: 2 | |
| updates: | |
| - package-ecosystem: npm | |
| directory: '/' | |
| schedule: | |
| interval: weekly | |
| time: '12:00' | |
| open-pull-requests-limit: 100 |