Skip to content

Instantly share code, notes, and snippets.

View jossmac's full-sized avatar
🎨
Design Tokens

Joss Mackison jossmac

🎨
Design Tokens
View GitHub Profile
@jossmac
jossmac / styleVars.ts
Created October 13, 2025 21:15
CSS custom properties in TS/React `style` attribute. Alternative to module declarations, or comment directives.
import type { CSSProperties } from 'react';
type StyleVars = Record<
`--${string}`,
string | number | boolean | undefined | null
>;
/**
* Type casting identity function. Maintains the autocompletion and type safety
* of `CSSProperties`, while allowing the addition of CSS variables.
@jossmac
jossmac / pluralize.ts
Created November 5, 2025 22:35
Returns the count and appropriate plural or singular form of a term.
/**
* Returns the count and appropriate plural or singular form of a term.
*
* @example
* pluralize(0, 'wallet'); // '0 wallets'
* pluralize(1, 'wallet'); // '1 wallet'
* pluralize(2, 'wallet'); // '2 wallets'
* pluralize(1, ['person', 'people']); // '1 person'
* pluralize(2, ['person', 'people']); // '2 people'
* pluralize(1, ['person', 'people'], false); // 'person'
@jossmac
jossmac / js-vs-ts.md
Last active July 16, 2026 01:39
It's JavaScript that's complicated, not TypeScript

It's JavaScript that's complicated, not TypeScript

When I first started writing TypeScript, it felt strange and bureaucratic, like I was being asked to constantly justify things that were already obvious.

Then, after enough time, you realise TypeScript isn’t being pedantic. It’s compensating for the fact that JavaScript itself is wildly permissive.

Everything is an object, somehow

JavaScript’s type system has the energy of a witness being cross-examined.