Skip to content

Instantly share code, notes, and snippets.

View ackvf's full-sized avatar
🏡
Remote Fullstack Node.js / Frontend React.js

Qwerty (Vítězslav Ackermann Ferko) ackvf

🏡
Remote Fullstack Node.js / Frontend React.js
View GitHub Profile
@ackvf
ackvf / index.tsx
Last active March 2, 2021 03:41
React TypeScript types
/* Type guards */
export function assertType<T>(obj: any, assertion: (obj: T) => boolean): asserts obj is T {
if (!assertion(obj)) throw new Error('Invalid type')
}
export function is<T>(obj: any, assertion: (obj: T) => boolean): obj is T {
return assertion(obj);
}
@ackvf
ackvf / functionArgumentsType.ts
Created March 12, 2019 11:59
Extracting Arguments type of an abstract action executor method
// Class-based Tree Shaking - HTTP203 @ Google Chrome Developers
// https://www.youtube.com/watch?v=lsd2-TCgHEs&t=599
class Store {
/**
* Do the given action with the given parameters.
*
* @param {A => R} action Action to be taken.
* @param {A} args Arguments to be passed to the action.
* @returns {R} Returns the result of original action call.