having vague thoughtfeels about how API object design in (plain, but also TS) JavaScript is generally "this one object actually represents multiple different shapes and types but we shove them all together and hope you change them in the right order"

vs when you make new types.
And not just new types, but also newtypes, to track type flow even when the actual data an object happens to hold is identical.

And then there's much heavier composition through nesting.

Sorry, they're vague, but my brain has gotten very Rusty lately.
this is all coming from the fact that I've been reimplementing an algorithm I'm somewhat familiar with (the installer algorithm), and having to make new types for what was honestly a super hard to work with and complicated set of types for manipulating packages in a tree in NPM.
I was having a bit of frustration recently where I felt like all the types I was making were hard to keep track of and picture the flow in my head and...

...they were just as hard to track in plain ol' JS. It's just that the essential complexity is _revealed_ now (and verified)
You can follow @zkat__.
Tip: mention @twtextapp on a Twitter thread with the keyword “unroll” to get a link to it.

Latest Threads Unrolled: