Eyas's Blog

Occasional musings on software development, tech, the Middle East, and anything else.

Typescript Archives

Unexpected Lessons from 100% Test Coverage

The conventional wisdom of the software engineering community is that striving to 100% test coverage is a fool's errand. It won't necessarily help you catch all bugs, and it might lead you down questionable paths when writing your code. My recent attempts at 100% test coverage showed me the answer is much more subtle. At times I was tempted to make questionable code changes just for the sake of…

Read more →


Learning by Implementing: Observables

Sometimes, the best way to learn a new concept is to try to implement it. With my journey with reactive programming, my attempts at implementing Observables were key to to my ability to intuit how to best use them. In this post, we'll be trying various strategies of implementing an Observable and see if we can make get to working solution. I'll be using TypeScript and working to implement…

Read more →


Schema.org Classes in TypeScript: Properties and Special Cases

In our quest to model Schema.org classes in TypeScript, we've so far managed to model the type hierarchy , scalar DataType values , and enums . The big piece that remains, however, is representing what's actually inside of the class: it's properties. After all, what it means for a JSON-LD literal to have "@type" equal to "Person" is that certain properties — e.g. "birthPlace" or…

Read more →


Schema.org DataType in TypeScript: Structural Typing Doesn't Cut It

Schema.org has a concept of a DataType , things like Text , Number , Date , etc. In JSON-LD, we represent these as strings or numbers, rather than array or object literals. This data could describe the name of a Person , a check-in date and time for a LodgingReservation , a URL of a Corporation , publication date of an Article , etc. As we'll see, the Schema.org DataType hierarchy is far…

Read more →


Schema.org Enumerations in TypeScript

Last time, we talked about modeling the Schema.org class hierarchy in TypeScript . We ended up with an elegant, recursive solution that treats any type Thing as a "@type" -discriminated union of ThingLeaf and all the direct sub-classes of the type. The next challenge in the journey of building TypeScript typings for the Schema.org vocabulary is modeling Enumeration s. Learning from Examples…

Read more →


12