Skip to content

Instantly share code, notes, and snippets.

View maxhilliard's full-sized avatar
💭
☕️

Max Hilliard maxhilliard

💭
☕️
View GitHub Profile
@maxhilliard
maxhilliard / deepObjectKeys.ts
Created May 26, 2023 09:01
TypeScript utility type to pick deep keys of an object
type DeepObjectKeys<T> = T extends Record<string, unknown>
? {
[K in keyof T]-?: K extends string ? `${K}` | `${K}.${DeepObjectKeys<T[K]>}` : never
}[keyof T]
: never
const testObj = {
foo: {
bar: false,
baz: {
@maxhilliard
maxhilliard / split-and-join-utility-types.ts
Created November 5, 2021 11:41
Utility types to improve JS's native `.split` and `.join`
// So let's say we have a string of known parts, Str
type Foo = 'foo'
type Bar = 'bar'
type Baz = 'baz'
type Str = `${Foo}.${Bar}.${Baz}`
const str: Str = 'foo.bar.baz'
// I want to split it into the known parts,
// Which I can do in a nice way with this Split type
@maxhilliard
maxhilliard / iterm.json
Created August 5, 2020 13:39
Iterm Profile Backup - Aug 2020
{
"Ansi 5 Color" : {
"Red Component" : 0.82745098039215681,
"Color Space" : "sRGB",
"Blue Component" : 0.50980392156862742,
"Green Component" : 0.21176470588235294
},
"Tags" : [
],