Since last October, all our new projects at Breathe Life are in TypeScript and we really love it! Our previous project was almost all Flow annotated, but as new features and libraries were added, a lot didn’t come with Flow typings. This was especially true for backend projects. After hearing how much TypeScript was gaining traction, we had to try it. The benefits were instantly obvious: TypeScript offers more and better typings, and better tooling (Visual Studio provides great TypeScript support, while Flow would get stuck at 100% CPU multiple times a day). We’ll have more to share on the other advantages it holds for us once we transition our older project.
Today, we thought instead we would highlight a moment of Open Source joy. While not all projects are written in TypeScript, the community has picked up on providing typings for libraries through DefinitelyTyped. It makes it so easy to contribute fixes to the type definitions that keeping your fixes locally is actually more work. You can look at this PR for an example of how, in basically three hours, a fix was merged and a new release made, making the fix available to the whole community!
Here’s how easy it is to contribute:
- Fork the DefinitelyTyped project
- Create a branch with the name of the package (or any other relevant name)
- Run the tests with
npm run test, to make sure the tests for this package are running before making your changes. Unfortunately, you cannot specify the name of your package, it will run the tests for all of them.
- Find the relevant
index.d.ts, and apply your changes in this file
- As the DefinitelyTyped README mentions, test your changes in your own code to make sure you actually fixed your issue and that you didn’t break anything else
- Add a test case in the test file
[package-name]-tests.tsrun the tests again
- Run the linter with
npm run lint package-name
- Push your code to the forked project
- Open a pull request in the DefinitelyTyped repository. A checklist will show up. You’ll need to add a link to the piece of documentation or code that validates your changes.
- Wait for your PR to be merged (sometimes it only takes a few hours!)
A big part of the magic comes from
typescript-bot. It automates the workflow to get the PR approved as quickly as possible. As soon as the PR is opened, it tags definition owners who worked on those typings for reviews. Provided you included a link to the documentation of the project, it takes little time to accept your fix. As a fallback, the bot will tag a maintainer after 7 days for review.
typescript-botalso takes care of tagging the PRs with “Awaiting reviewer feedback”, or “Revision needed” if someone requested a change. Once approved, the PR will be merged by a maintainer, and there will be a new release of the types package with a new version. Update your
package.jsonand you’re done!
We’ve been actively contributing and we’d like to give a big shout out to the community for such an awesome project! It is definitely playing a big part in driving TypeScript adoption and we encourage you to contribute as well.
We’ll continue sharing more around TypeScript and our migration strategy from Flow. In case you’re wondering, yes, we do need your help! We’re always hiring. See our open positions here.