Skip to content

Instantly share code, notes, and snippets.

@eheikes
Last active August 26, 2019 20:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eheikes/1898b96c66b70690fc3dd99bf04bf6ea to your computer and use it in GitHub Desktop.
Save eheikes/1898b96c66b70690fc3dd99bf04bf6ea to your computer and use it in GitHub Desktop.
Contributing Types

Prep

First check if the original package is maintained and open to adding types. Check if the package is being actively maintained; if so, create an issue (or look for existing/closed issues) asking for types to be added, and if the maintainers would be open to merging a PR for it.

If the original package can't have the types, they should be added to Definitely Typed. Check in the DT issues/PRs if anyone else is already working on this.

Implementation

If no one else is working on it, we're good to create a PR adding them:

  1. Fork the DT repo. (For Banno, we already have a fork at https://github.com/banno/DefinitelyTyped that can be cloned.)
  2. Create a new branch for your changes.
  3. Generate the project: npx dts-gen --dt --template module --name package-name where package-name is the name of the npm package you're adding types for.
  4. Generate the code: npm i package-name -g; npx dts-gen -m package-name. This doesn't usually work very well, but it's a start sometimes.
  5. Look through the origina pacakage's docs and/or code and write the types.
  6. Test the project with tsc --project types/package-name/tsconfig.json.
  7. Lint the project with npm run lint package-name.
  8. When done, copy it to a project (under node_modules/@types/package-name that uses the package and check that it works as expected.
  9. When ready, create a PR in the Definitely Typed repo.

Tips

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment