check-dts

v0.8.2
Unit tests for .d.ts TypeScript definitions
typescript types test check

Check TypeScript Definitions

Unit tests for .d.ts TypeScript definitions in your JavaScript open source library.

It is useful for non-TypeScript project, which wants to provide typing support for TypeScript users and autocompletion for IDE and text editors.

It becomes especially useful for complex types with generics, like we have in Nano Events or Storeon.

// Negative test: test/index.errors.ts
import lib = require('../')

interface Events {
  'set': (a: string, b: number) => void
}
// THROWS Expected 3 arguments, but got 2
lib.on<Events>('set', 2)
// Positive test: test/index.types.ts
import lib = require('../')

interface Events {
  'set': (a: string, b: number) => void
}
lib.on<Events>('set', 'prop', 1)
Print Snapshots example Sponsored by Evil Martians

Docs

Read full docs here.

npm i check-dts

Metadata

  • MIT
  • >=18.0.0
  • Andrey Sitnik
  • released 8/20/2024

Downloads

Maintainers