Buy tickets

Buy tickets

Giuseppe Maggiore | Hoppinger

Type-safe client-side queries in TypeScript

As an academician, Giuseppe holds a PhD in Computer Science from the University of Venice in strict cooperation with the University of Tilburg. During his MSc and PhD, Giuseppe worked as an assistant teacher and researcher at the universities of Venezia and Verona. His research has mostly focused on the design of programming languages in order to simplify complex tasks. He has been lecturer at the NHTV College in Breda (NL), and associate professor at the Hogeschool Rotterdam.

As a developer, he started as a freelance web developer, and then later became Student Evangelist for Microsoft Italy, and finally consultant for companies in the North-East region of the country and speaker at major Microsoft events. He also made videogames via an own startup. Giuseppe is now working as CTO of Hoppinger, a fantastic bureau in the heart of Rotterdam, in order to unite web development pragmatism, beautiful designs, and reliable software engineering into excellent products. Giuseppe is also co-owner and founder of GrandeOmega, an innovative startup for teaching programming to colleges and universities.

Such engagements leave little time over for hobbies, so all remaining time is devoted to his wonderful family (Giulia, his wife, and companion of almost two decades, and the two lovely daughters Rebecca and Rachel).

About this session

The introduction of statically typed languages for client-side programming, such as TypeScript, has greatly boosted the quality of creation of large client-side applications such as commonly seen when building a modern SPA.

This increase in safety only extends up to the boundary of API calls. Results from a remote call are always returned as unstructured JSON, or any in TypeScript. Deserialisation is thus done manually, a tedious and error prone process. Moreover, deserialisation routines suffer from various forms of bit-rotting: as the underlying model evolves, its validation might become obsolete or, even worse, slightly off. This results in false negatives (the data is correct, but the deserializer thinks there is a mistake), or false positives (the wrong data is simply cast to the right model type, wreaking havoc in the rest of the application).

In short, client-side deserialisation is, mildly put, not a lot of fun.

The ever growing adoption of rich protocols such as OData (or its recent, hipster variant of GraphQL) make querying from the client side much more efficient: the client can reduce the number of received attributes ($select), rows ($filter), and even overall number of queries by requesting joined data ($expand). Unfortunately, this makes the received data even more complex to parse, adding a dynamic dimension to the problem that really does not help.

In this talk, we will study the advanced typing mechanisms of TypeScript that make it possible to automatically generate a type-safe deserializer, based on a declarative description of the queried data constructed as an object.