0Pricing
TypeScript Academy · Lesson

Dealing with Untyped Third-Party Libraries

Use @types packages and write manual declarations.

The Problem: Missing Types

Some npm packages do not ship TypeScript declarations and have no @types/ package. TypeScript treats them as any by default, losing type safety at the boundary.

import legacyLib from "untyped-lib"; // legacyLib: any

@types Packages

The DefinitelyTyped project provides community-maintained type declarations for thousands of libraries. Search npm for @types/library-name.

npm install --save-dev @types/lodash
npm install --save-dev @types/express
# Now lodash and express have full TypeScript types

All lessons in this course

  1. Starting the Migration: allowJs and checkJs
  2. JSDoc Type Annotations as a Bridge
  3. File-by-File Conversion Strategy
  4. Dealing with Untyped Third-Party Libraries
← Back to TypeScript Academy