UNPKG

check-dts

Version:

Unit tests for .d.ts TypeScript definitions

45 lines (33 loc) 1.22 kB
# 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]. ```ts // 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) ``` ```ts // Positive test: test/index.types.ts import lib = require('../') interface Events { 'set': (a: string, b: number) => void } lib.on<Events>('set', 'prop', 1) ``` [Nano Events]: https://github.com/ai/nanoevents/#typescript [Storeon]: https://github.com/storeon/storeon#typescript <img src="./screenshot.png" alt="Print Snapshots example" width="585"> <a href="https://evilmartians.com/?utm_source=check-dts"> <img src="https://evilmartians.com/badges/sponsored-by-evil-martians.svg" alt="Sponsored by Evil Martians" width="236" height="54"> </a> ## Docs Read full docs **[here](https://github.com/ai/check-dts#readme)**.