Skip to content

Instantly share code, notes, and snippets.

@subtleGradient
Last active March 15, 2025 23:46
Show Gist options
  • Save subtleGradient/1dc158484173efab4db0a8b7b32cd614 to your computer and use it in GitHub Desktop.
Save subtleGradient/1dc158484173efab4db0a8b7b32cd614 to your computer and use it in GitHub Desktop.
How should we name the Deps/Props type?
import {Thing} from "./Thing"
import {Flarm} from "./Flarm"
interface Thing_ { thing: Thing }
interface Flarm_ { flarm: Flarm }
interface hasThing { thing: Thing }
interface hasFlarm { flarm: Flarm }
interface withThing { thing: Thing }
interface withFlarm { flarm: Flarm }
interface ThingProp { thing: Thing }
interface FlarmProp { flarm: Flarm }
// ❌ can't just merge dependencies together
export const DoStuff = (deps: Thing & Flarm) => (abc: 123) => deps + abc + deps
// ❌ can't work because of sorting
export const DoStuff = (thing:Thing, flarm:Flarm) => (abc: 123) => thing + abc + flarm
// can merge deps if they're objects with unique keys
export const DoStuff = (deps: Thing_ & Flarm_) => (abc: 123) => deps.thing + abc + deps.flarm
export const DoStuff = (deps: hasThing & hasFlarm) => (abc: 123) => deps.thing + abc + deps.flarm
export const DoStuff = (deps: withThing & withFlarm) => (abc: 123) => deps.thing + abc + deps.flarm
export const DoStuff = (deps: ThingProp & FlarmProp) => (abc: 123) => deps.thing + abc + deps.flarm
export const DoStuff = (deps: ThingProp & FlarmProp) => (abc: 123) => deps.thing + abc + deps.flarm
// or maybe declare the deps type just in time and don't use `&`
type DoStuffDeps = { thing: Thing; flarm: Flarm }
export const DoStuff = (deps: DoStuffDeps) => (abc: 123) => deps.thing + abc + deps.flarm
// zero naming no "deps" var and no "Deps" type
export const DoStuff = ({thing, flarm}: {thing:Thing; flarm:Flarm}) => (abc: 123) => thing + abc + flarm
export const DoStuff = ({thing, flarm}: {thing:Thing} & {flarm:Flarm}) => (abc: 123) => thing + abc + flarm
export type Flarm = {"some other kind of opaque object":true; [Symbol.dispose]():void}
export const Flarm = type({"'some other kind of opaque object'":'true'})
export type Thing = {"some kind of opaque object":true; [Symbol.dispose]():void}
export const Thing = type({"'some kind of opaque object'":'true'})
¿How should we name the Deps/Props type?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment