Re: reasons for learning typescript

@9 I actually fully agree badly-typed libraries and other members on the team that for whatever reason don't use typing well are a barrier to this. particularly libraries that were designed as js and then had types tacked on can be pretty bad. a lot of the times it isn't even that they can't be typed well, but whoever wrote the type declaration file didn't fully know what they were doin. happened to me with MaterialUI. event types on a lot of widgets just didn't have type written well for some event types. that was the closest I came to just using type casting, but in the end figured out how to preserve type safety in that instance. however, I can definitely imagine there are some libraries that are so badly typed that you might not be able to avoid it, but hasn't happened to me yet. but it is a totally fair point.

I feel your point on rust and haskell and open unions might be off topic. but I might be missing how type casting and open unions relate. I was just pointing out that #7's claim that type casting is universal among staticly typed languages isn't exactly true.

as an aside, open unions do have their advantages of course, but so do closed unions as I argued to you in another thread. personally, I think the advantages of closed unions overweigh the ones for open unions, but in the end that is my opinion and comes down to personal preference.
also, open unions aren't necessary to represent a hierarchy of types. in #8 I showed a inheritance style type hierarchy with a closed union (MyEvent). albeeit that hierarchy has a single level, here is one with two levels:

type BaseEvent = { message: string }
type TimeEvent = BaseEvent & { kind: 'time', timestamp: number }
type BaseIO = BaseEvent & { device: string }
type PrintEvent = BaseIO & { kind: 'print', charsPrinted: number }
type ReadEvent = BaseIO & { kind: 'read', charsRead: number }

type IOEvent = PrintEvent | ReadEvent
type MyEvent = IOEvent | TimeEvent

-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector
  • ... AudioGames . net Forum — Developers room : Dragonlee via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : camlorn via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : mechaSkyGuardian via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : Turret via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : TJ . Breitenfeldt via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : Hijacker via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : camlorn via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : camlorn via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : camlorn via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : TJ . Breitenfeldt via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : Dragonlee via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : Dragonlee via Audiogames-reflector

Reply via email to