you are viewing a single comment's thread
view the rest of the comments
[–] 7 points 2 days ago (4 children)

We use typescript and try very hard not to return any... But 95% of out back ends api returns are type bob: Type || undefined

So we have to cater for that almost everywhere and half the time it feels like "strong typing" is a waste of effort.

But I still prefer the relative certainty of typescript

  • source
  • parent
  • hideshow 4 child comments
  • [–] 3 points 1 day ago

    You may need a tagged type. It is done on our code base such that currency of one type can't be operated on currency of another type. The basic is that TAG<number, 'USD'> !== TAG<number, 'EUR'> because even if the underlying type is the same (number), they are of different types on the type system. See also type-fest library that provide a ton more helper type like that

  • source
  • parent
  • [–] 3 points 1 day ago (1 child)

    I don't know shit about your codebase. But it sounds like you aren't abstracting your API calls property. Ideally you have an API Client that consumes those blobs and converts them to some generically typed return value.

    On top of that you have your actual API, which accepts actions and returns actual objects/collections, or just fucking fails and bubbles up as a generic error because something's gone fucking wrong.

  • source
  • parent
  • hideshow 1 child comment
  • [–] 3 points 1 day ago

    It's mainly because, for the industry we're in, we're not very big. So we have small teams with few devs...

    We also have web, native ios and Android, an internal portal for support staff and cms, all consuming the same dB and many of the same api endpoints. This means they can be undefined for one, but not the other.

    So even though on Web you will always have join_table_id... It could be undefined (for another platform)

  • source
  • parent