If you are using Travis CI to automate the build of a TypeScript, that’s a problem you probably encountered. As Travis CI can allow you to automatically build in various environment, TSD is hitting hard on the GitHub API, which can cause the “GitHub rate limit reached” message to appear.
The solution is quite simple, you’ll have to create a GitHub token and add it in Travis as an environment variable. This tutorial will also work with any build automation system that support environment variables.
Creating a token
Login to GitHub and create a token on this page: https://github.com/settings/tokens/new
TSD does not require any scope to function properly, so uncheck all the scope checkboxes:
Then, after submitting the form, you will be able to copy your token:
Adding the token in Travis CI
Now, let’s go to the setting page of the failing build:
Add an environment variable named TSD_GITHUB_TOKEN and paste the token you got from GitHub (and don’t forget to click the Add button).
You can now use this token for all your automated builds that involve TSD (or you can also generate more tokens if you have a large number of projects 😉 ).
End note: it would also have been possible to add the token as a parameter of the tsd command, but as that would expose your token to anyone that has access to the repository…