Skip to content
Drew Noakes edited this page Mar 5, 2014 · 23 revisions

Quality Criteria

To ensure the quality of DefinitelyTyped repository, the typings must meet the following criteria:

Version

  • Definition files should be called library.d.ts. In case there are multiple versions supported, the latest one will be without a version number in the file name. Older versions will be in the form of library-1.0.d.ts.

Header

  • The typing must have a header with the following format:
// Type definitions for [LIBRARY NAME]
// Project: [LIBRARY URL]
// Definitions by: [AUTHOR NAME] <[AUTHOR URL]>
// Definitions: https://github.com/borisyankov/DefinitelyTyped

Example:

// Type definitions for Backbone 0.9.10
// Project: http://backbonejs.org/
// Definitions by: Boris Yankov <https://github.com/borisyankov/>
// Definitions: https://github.com/borisyankov/DefinitelyTyped	

Location

  • The typing must be placed in a folder. The folder name must be similar to library name.

Example: qunit.d.ts in in a folder named qunit

Documentation

Tests

  • The typing must have tests. These tests must be in a files called library-tests.ts. They are not runnable, in the TDD way. They contain code that should compile with no errors, usually taken from the documentation samples of the library.

Example: backbone.d.ts has a test file named backbone-tests.ts Here you can see a real test file.

  • Check your code. Run npm test before sending your pull request.
    • Tests must be run from the DefinitelyTyped project's root directory.
    • You'll need to run npm update once to download the packages required by the test suite.
    • If test fail try recompiling your code using tsc --noImplicitAny your/code.d.ts to show where the typings leak any. Fix your code or add your/code.d.ts.tscparams.

If you need to use tscparams note that the contents of tscparams should be quoted. i.e. "" e.g. https://github.com/borisyankov/DefinitelyTyped/blob/master/ace/all-tests.ts.tscparams

Namespacing

  • Be careful to use a module to avoid conflicts to your internal interfaces and the interfaces from another typings.

The jQuery.bbq typing has the interfaces in a module named JQueryBbq Example:

    module JQueryBbq {
        interface JQuery {
            //...
        }
        //...
    }
    interface JQueryStatic {
        bbq: JQueryBbq.JQuery;
        //...
    }

Readme

  • Update the README file to put a reference to your definition with the following style: * [LIBRARY NAME WITH LINK] (by [AUTHOR NAME WITH LINK])

Example:

Pull Requests FAQ

This is general guidance to answer common questions.

Getting latest upstream changes

You don't need to do this unless we request you to do so.

Initially make sure you have DT added as an upstream remote in your fork. Do this by :

git remote add upstream https://github.com/borisyankov/DefinitelyTyped.git

Now whenever you want the latest changes from DT added to your local branch just run these two commands :

git fetch upstream
# Fetches any new changes from DefinitelyTyped
git merge upstream/master
# Merges any changes fetched into your working files

Broken Build

If tests fail and you know how to fix them, just add a commit to fix that error in your local branch. The Pull Request will update automatically and tests will run again.

Thanks for contributing!

Clone this wiki locally