Skip to content

Instantly share code, notes, and snippets.

View hrustinszkiadam's full-sized avatar
:octocat:

Hrustinszki Ádám hrustinszkiadam

:octocat:
View GitHub Profile
@hrustinszkiadam
hrustinszkiadam / try-catch.ts
Last active October 14, 2025 14:39
Typesafe type-catch with Error return
type SuccessResult<T> = readonly [T, null];
type ErrorResult<E = Error> = readonly [null, E];
type Result<T, E = Error> = SuccessResult<T> | ErrorResult<E>;
const tryCatch = async <T, E = Error>(
promise: Promise<T>
): Promise<Result<T, E>> => {
try {
const result = await promise;
@hrustinszkiadam
hrustinszkiadam / .prettierrc
Last active October 14, 2025 14:40
Prettier config
{
"tabWidth": 2,
"useTabs": false,
"semi": true,
"singleQuote": true,
"jsxSingleQuote": true,
"singleAttributePerLine": true,
"trailingComma": "all"
}