Brussels / 4 & 5 February 2023


Strong Dynamic Type Checking for JavaScript

Where TypeScript is helpless, JavaScript Proxies come to the rescue!

JavaScript developers learned to love TypeScript after seeing the benefits of static type-checking. But there is still a lot of data that that TypeScript is not able to check, because it is only known at runtime: JSON responses from an API, user inputs in a form, content taken from client-side local storages, browsers API quirks... In that case, you can only assume the types and pray for the best, or manually code tedious specific type checks. I'd like to introduce you to ObjectModel, an open source library I created with the intent to bring automatic strong dynamic type-checking to JavaScript projects. By leveraging ES6 Proxies, this library ensures that your variables always match the model definition and validation constraints you added to them. Thanks to the generated exceptions, it will help you spot potential bugs and save you time spent on debugging. I will also discuss the many other benefits of validating types at runtime, because as you will see, it leads to more than just type checking.

I will present a few scenarios where TypeScript is helpless to detect type errors. Then I will discuss about ES6 Proxies, and how you can make type-safe objects in JavaScript itself. Finally I will present ObjectModel, a mature, well tested open source library that has ~2500 weekly downloads on NPM. ObjectModel is very easy to master: no new language to learn, no new tools, no compilation step, just a minimalist and intuitive API in a plain old JS micro-library. The audience should be able to immediately understand the interest of this library regarding the type assertions, but as a conclusion I will show how ObjectModel can also be used for other usecases such as form validation or API unit testing.


Photo of Sylvain Pollet-Villard Sylvain Pollet-Villard