May 18 '21 ~ 1 ~ 1 mins

Adding a layer of more explicit typings on top of 3rd party library interfaces

You may have noticed that the typing provided by 3rd party libraries often feels very loose. This should not come as a surprise as to maintain flexibility for all users it is not always possible to provide stricter typings.

However, there is nothing to stop us, within our own applications, adding a layer of more explicit typing on top of the library interface. In doing so we can leverage Typescript to greatly improve the developer experience, as well as encouraging consistently in how the library is used.

To demonstrate the benefits of this approach we will work through two use cases.

  1. Adding type safety to AG Grid column types.
  2. Generating type safe custom builders for the Angular Formly library.

With both of these scenarios we will show how adding an additional level of explicit types prevents bugs and speeds up development.

Continue reading at

Headshot of Stephen Cooper

Hi, I'm Stephen. I'm a senior software engineer at AG Grid. If you like my content then please follow / contact me on Twitter and say hello!