Last active
March 15, 2025 23:46
-
-
Save subtleGradient/1dc158484173efab4db0a8b7b32cd614 to your computer and use it in GitHub Desktop.
How should we name the Deps/Props type?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export type Flarm = {"some other kind of opaque object":true; [Symbol.dispose]():void} | |
export const Flarm = type({"'some other kind of opaque object'":'true'}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export type Thing = {"some kind of opaque object":true; [Symbol.dispose]():void} | |
export const Thing = type({"'some kind of opaque object'":'true'}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
¿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