View a.ts
This file contains 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
const setCount = (n: number) => { | |
return { | |
type: 'SET_COUNT', | |
payload: n | |
} as const; | |
} | |
const resetCount = () => { | |
return { | |
type: 'RESET_COUNT' |
View a.ts
This file contains 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
const setCount = (n: number) => { | |
return <const>{ | |
type: 'SET_COUNT', | |
payload: n | |
} | |
} | |
const resetCount = () => { | |
return <const>{ | |
type: 'RESET_COUNT' |
View i.ts
This file contains 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 BundlerState = | |
| { type: 'UNBUNDLED' } | |
| { type: 'BUILDING'; warnings: BundlerWarning[] } | |
| { type: 'GREEN'; path: string; warnings: BundlerWarning[] } | |
| { type: 'ERRORED'; error: BundlerError } | |
export type BundlerTypes = Pick<BundlerState, 'type'>['type']; |
View asyncFlatMap.ts
This file contains 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 CallBackFN<T, R> = (value: T, index: number, array: T[]) => Promise<R>; | |
export const flatten = <T>(arr: T[][]): T[] => { | |
return arr.reduce((acc, value) => acc.concat(value), [] as T[]); | |
}; | |
export const asyncMap = <T, R>(arr: T[], asyncFn: CallBackFN<T, R>): Promise<R[]> => { | |
return Promise.all(arr.map(asyncFn)); | |
}; |
View typesafenulls.ts
This file contains 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
feature.children = e | |
.flatMap(el => (notNothing(el.pickle) ? [el.pickle] : [])) | |
.flatMap(pickle => { | |
let scenario = testBuilder(`scenario: ${pickle.name}`); |
View config.ts
This file contains 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 { CompilerOptions } from 'typescript'; | |
export type DeepPartial<T> = T extends object ? { [K in keyof T]?: DeepPartial<T[K]> } : T; | |
export interface FullBuildConfig { | |
client: { | |
entries: string; | |
hotReloading: boolean; | |
publicPath: string; | |
}; |
View umount.js
This file contains 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
useEffect(() => { | |
let didCancel = false; | |
// ... | |
// you can check didCancel | |
// before running any setState | |
// ... | |
return () => { | |
didCancel = true; |
View ts.ts
This file contains 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
const obj = { | |
obj = { | |
chunkName() { | |
return \\"moment\\"; | |
}, | |
isReady(props) { | |
return __loadable_isReady__(this, props); | |
}, | |
importAsync: (), | |
requireAsync(props) { |
View eslintrc.js
This file contains 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
module.exports = { | |
globals: { | |
MyGlobal: true, | |
}, | |
parser: '@typescript-eslint/parser', | |
extends: [ | |
'plugin:@typescript-eslint/recommended', | |
'plugin:jest/recommended', | |
'plugin:jest-formatting/recommended', | |
'prettier/@typescript-eslint', |
View test.ts
This file contains 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
test.each` | |
url | path | expected | message | |
${'/csg/product-selector'} | ${RoleDetailsUrl} | ${makeCsgUrl(RoleDetailsUrl)} | ${'should be csg url'} | |
${'/applicant/join/product-selector'} | ${ProductSelector} | ${makeApplicantJoinUrl(ProductSelector)} | ${'should be applicant url'} | |
${'/applicant/existing/current-name'} | ${CurrentName} | ${makeApplicantExistingUrl(CurrentName)} | ${'should be applicant url'} | |
${'/personal-employer/join/details'} | ${PERoleDetailsUrl} | ${makePersonalEmployerJoinUrl(PERoleDetailsUrl)} | ${'should be personal employer url'} | |
`('url:$url is is $expected, // $message ', ({ url, expected }) => { | |
history.push(url); | |
const { |