Skip to content

Document library with type definitions #5

@demurgos

Description

@demurgos

Hi,
It would be great if this project bundled its Typescript type definitions to document its API.
I am bringing this up because of the recent deprecation of gulp-util. This library is one of the recommended replacements and there are no types at the moment. By providing types directly, I hope to prevent duplicated effort in other codebases.
It would be be an improvement in documentation and distribution by packaging the types next to the Javascript implementation.

  • Let's start with the most obvious: it reduces friction when using this library in a Typescript project. It allows to have a single dependency on the library and get the right version of the code and types (without any mismatch issue).

  • Keeping type definitions as close to the source as possible makes it easier to ensure that they are up to date. Even if they are only updated by external contributors, the library's repo is a natural place to at when they want to send improvements.

  • Type definitions offer a more formal syntax to document the API. It nicely complement any manually-written documentation that may have some ambiguities. This allows to quickly pick new code by describing expectations and guarantees offered by the API.

  • Publishing type definitions in the same package as the code is the recommend method. DefinitelyTyped is more of a fallback solution when there is nowhere else to put the definitions. Despite its bots, working with this huge repo is a pain because everything is tossed together. It also has some other more fundamental flaws such as not supporting namespaced packages or individual issues.

  • Editors start to pull documentation for Javascript libraries from their type definitions

    Code completion and parameter info for the standard JavaScript objects and methods and Web APIs have improved, as these features are now powered by the TypeScript declaration files.

  • Some other important Javascript libraries are already documenting their own API with Typescript. These projects treat their hand-written type definitions as documentation that both humans and computers can understand. Here are some examples:

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions