A common case in applications is to work with types where certain properties are nullable. However, it is also common to need derived types of these same types which are stricter around nullablity of properties.
Let’s imagine a note taking app: We have a Notebook type where id is nullable because u...
I have a love-hate relationship with type safety. Type Checkers can be amazingly powerful tools when they work and yet can be frustrating every now and then when you hit some unsupported edge case.
Thankfully more and more of these corners are getting eliminated with the hard work that the typescri...
Most object oriented programming languages encourage the pattern of Programming to an interface. TypeScript supports this of course, you can create one or more interfaces, and then define classes (or factories) that generate instances of this interface.
However, as the linked article above points o...
A frequently occuring issue when creating interrelated MST models, is that of circular type references.
Usually we don’t don’t have to explicitly define interfaces for our models, because they can be inferred for us through the APIs exposed by MST. However, when defining models that depend on each ...
The title may sound something like an oxymoron, so perhaps some clarification is needed.
I freqently deal with operations against databases. When I mention that I increasingly prefer using a functional style, in particular, using a query builder directly as opposed to an ORM – one of the primary co...
TypeScript conditional types have an interesting property that they can “distribute” over union types. As explained better by the official docs:
Conditional types in which the checked type is a naked type parameter are called distributive conditional types. Distributive conditional types are automa...
worker-loader and comlink are two solution which make web-workers a joy to use. This short post summarizes how to make them play well with each other in a typescript codebase.
What is comlink ?
Comlink is a Google project that implements a proxy based RPC mechanism to invoke methods on objects pr...
When we define a typescript class, we are actually defining two things, a constructor function, and a type. The instances constructed using the constructor defined by a class will have the type of the class.
One might wonder, if it is possible, say from a library, to expose only the type of the cla...
Writing generics-heavy code code in Typescript can sometimes be arduous, especially because typescript doesn’t facilitate higher kinded types at language level.
So, a function that accepts multiple arguments of generic types often has to accept type parameters of all these generic types in order to...
One of the interesting aspects in Typescript is that it is easy to extract out individual types from composite types.
In case of Array, Tuple and Object types, this is really simple, as the type extraction syntax mimic member access syntax.
1234567891011121314type Person = {name: string;age: ...