6
kobenz
176d

ah, APIs... writing APIs is fine, even typing an API can be great! 😃👍🏻

that's it

---

No, actually, all of the above is invalid if you've gotta do it in typescript

Comments
  • 1
    I’ve gotta refactor a testing framework I wrote into valid typescript so I can automatically generate documentation from it.

    It’s … mostly valid, but I cheated in a few places because e.g. it didn’t matter if something was a string or a number, or I don’t know what the proper Playwright types are.

    Just. Ugh. Tedium.

    I tried other documentation utilities, but they either make a mess of things (all methods, public and private, in the same giant list regardless of their namespacing) or don’t understand basic things like the spread operator and therefore can’t parse my code. 🤦🏻‍♀️
  • 0
    I, sort of, understand you, where yoiu coming from; to some extent even agree: TS can be bitch; there are better langs for API........as there are langs that are greater bitches; let Python be examplary one: have you tried it? If yes: go away as fast as possible; if no: lucky you.
  • 0
    @macfanpl I've found python to be a delightful language. Incredible stdlib, pattern matching through `match`, walrus operator. Superb typing library that's actually tangible. only thing better for APIs I think would be Erlang. Though a did very little Erlang in my life
  • 0
    I'm not gonna lie, I enjoy writing APIs in TS, typing them is fun to me.
    I'm probably a masochist
  • 0
    @Ranchonyx how would you handle stuff liks /moms/{mom_id}/[credits|details|towns]?
  • 0
    @kobenz As type? Or logic wise?
  • 1
    @kobenz TS can automatically convert such a string into { momId: string, action: "credits" | "details" | "towns" }
  • 0
    @Ranchonyx types. I know template literal types could cover it, but, let's say `moms/${number}` has a searchParam with an append_to_response query whose value is a comma separated list of values of type "credits"|"details"|"town" which will have their respective `moms/${number}/${"credits"|"details"|"town"}` response added to `moms/${number}`'s response. We can obviously see there's a root object of which mom's derived but not its "children" URIs, or else they would not be there. It's doable, but, shit, what a chore, even with type manipulation since typescript's type system lacks introspection:/
  • 1
    @kobenz I never really found that to be too much a chore... As I said, probably typescript turned be into a masochist.
Add Comment