Skip to content

Instantly share code, notes, and snippets.

@wojtekKrol
wojtekKrol / TypeSafeDynamicKeys.ts
Created January 11, 2024 14:39
TypeScript utility for type-safe dynamic key lookup
export const myObject = {
a: 1,
b: 2,
c: 3,
};
const ObjectKeys = <Obj extends Object>(obj: Obj): (keyof Obj)[] => {
return Object.keys(obj) as (keyof Obj)[];
};
@wojtekKrol
wojtekKrol / jest.config.ts
Last active June 4, 2024 09:24
Jest + TS + Path Aliases
import { pathsToModuleNameMapper } from 'ts-jest'
import { compilerOptions } from './tsconfig.json'
import type { JestConfigWithTsJest } from 'ts-jest'
const config: JestConfigWithTsJest = {
moduleNameMapper: pathsToModuleNameMapper(compilerOptions.paths, {
prefix: '<rootDir>/',
}),