Today we're happy to announce the release of official TypeScript type definitions for Google Publisher Tags (GPT)!
Why TypeScript?
According to a recent State of JS developer survey, nearly 70% of developers regularly use TypeScript in some capacity, up from 60% the year before. As this segment of the community continues to grow, we are committed to providing the best experience possible for those working with TypeScript and GPT. We believe this is important not just because TypeScript is popular, but because it helps developers validate the correctness of their code and provides a number of quality of life improvements that make working with GPT more delightful.
How we got here
Until now, a number of community-led projects such as @types/doubleclick-gpt and @types/googletag have provided unofficial GPT type definitions. While these projects have done a great job of making our API more accessible to TypeScript developers, manually curated type definitions inevitably lag behind changes made to GPT, leading to those definitions sometimes being out of date. To address this, we've updated our release process to automatically generate type definitions from internal source code and sync changes to our own GitHub repository and the DefinitelyTyped project. This ensures that our official definitions are always up to date with the most recently released versions of GPT.
Try it and let us know what you think
For users new to TypeScript, we've published a TypeScript and Google Publisher Tags guide that covers the basics and provides a demo of the new type definitions in action. For those already familiar who want to try the new definitions right away, they can be installed via NPM by running:
npm install --save-dev @types/google-publisher-tag
If you'd like to make a suggestion, report a bug, or leave any other feedback about this new offering, feel free to open an issue on our GitHub issue tracker.