← Back to DefinitelyTyped/DefinitelyTyped

How to Deploy & Use DefinitelyTyped/DefinitelyTyped

Definitely Typed Deployment and Usage Guide

Prerequisites

  • Node.js (version 16 or later recommended)
  • pnpm (package manager for monorepo management)
  • TypeScript (for development and testing)
  • Git (for version control and repository management)

Installation

  1. Clone the repository:

    git clone https://github.com/DefinitelyTyped/DefinitelyTyped.git
    cd DefinitelyTyped
    
  2. Clean and install dependencies:

    # On Windows:
    node ./scripts/clean-node-modules.js
    # On other platforms:
    git clean -fdx
    
    pnpm install --filter .
    

Configuration

  • No specific environment variables are required for local development
  • TypeScript configuration is handled by the monorepo structure
  • API keys are not needed for local development

Build & Run

For Contributors (Testing Changes)

  1. Test editing an existing package:

    • Navigate to the package in node_modules/@types/foo/index.d.ts
    • Make changes and validate them
    • Use the package in your project to test
  2. Testing with local type definitions:

    // Create typename.d.ts in your project
    declare module "libname" {
        export function helloWorldMessage(): string;
    }
    

For Repository Maintenance

  1. Type checking and linting:

    pnpm run build
    pnpm run lint
    
  2. Running tests:

    pnpm test
    

Deployment

Publishing to npm

Definitely Typed packages are automatically published to npm through the DefinitelyTyped-tools publisher.

For Contributors:

  • Submit a pull request with your type definitions
  • Once merged, packages are automatically published based on the schedule
  • Check the publishing status for updates

Repository Status

  • Build status: Check the CI badge for current build health
  • Package status: All packages should be type-checking/linting cleanly
  • Support window: Packages are tested on TypeScript versions less than 2 years old

Troubleshooting

Common Issues

  1. "Package not found" when installing types:

    • Ensure you're using the correct naming convention: @types/package-name
    • For scoped modules, use double underscores: @types/babel__preset-env
  2. Types not being automatically included:

    • Add a types reference if not using modules:
      /// <reference types="node" />
      
  3. Outdated types for older TypeScript versions:

    • Use tagged versions from npm:
      npm dist-tags @types/react
      
    • Example: TypeScript 2.5 can use react@16.0 types
  4. Repository layout issues after recent changes:

    • Run git clean -fdx to clean up node_modules
    • Reinstall with pnpm install --filter .
  5. Build failures:

Support

Legacy Support

For TypeScript 1.*:

  • Manually download from the master branch
  • Place in your project directory
  • Add manual triple-slash references as needed