npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

tscheck

v0.1.5

Published

Find bugs in hand-written TypeScript type definitions.

Downloads

481

Readme

About tscheck

TSCheck is a tool for finding bugs in hand-written TypeScript type definitions (.d.ts files). It works by comparing the type definitions to the actual JavaScript library implementation.

Installation

  • Install node.js if you don't already have it.
  • npm install -g tscheck

Usage

To check foo.d.ts against the library foo.js, run the command:

tscheck foo.js foo.d.ts

Or simply:

tscheck foo

Run tscheck -h for a list of options.

Output

TSCheck prints a series of warnings, one warning per line, in no particular order.

The warnings have the format foo.bar.baz: expected X but found Y. This means the value one would get by evaluating the pseudo-expression foo.bar.baz was expected to have type X, but tscheck found something of type Y instead.

If there is no output, it means tscheck found no bugs in your .d.ts file. This does not guarantee that the type definitions are actually correct, it just means that tscheck could not find anything wrong.

In some cases, tscheck may get confused and report "false warnings", complaining about type definitions that are actually correct. TSCheck apologizes for the inconvenience.

API Discovery

Pass --missing to tscheck and it will suggest parts of the API that are not yet documented in the .d.ts file. This is a useful way to check if you missed any parts of the API.

TSCheck cannot deduce the types for these features so it cannot write the .d.ts file for you.

Performance

TSCheck can take several minutes to complete. If you are impatient, pass the flag --no-analysis, this will perform a much faster check, but it will also find fewer bugs.

If you wish to check a specific part of the API, you can pass the flag --path foo to only check paths that contain the string foo; this will typically speed things up a lot.

If tscheck seems to get stuck, try passing --expose-gc to the node process. This alleviates a problem with the v8 garbage collector.

Note that even for tiny .d.ts files, tscheck still has a warm-up time of a few seconds due to parsing TypeScript's lib.d.ts file.

Other Usage Notes

The JavaScript library must be compiled to a single .js file; so try to get the unminified compiled version of the library you are using. If you are testing a plug-in you should concatenate it with the base library (and use the --path argument if possible, to only test the plug-in).

Please run tsc on your .d.ts file before running tscheck. tscheck assumes that your .d.ts passes some well-formedness checks performed by the TypeScript compiler, and will react violently otherwise.

TSCheck will leave a .jsnap file next to your .js file. It contains a snapshot created with jsnap. Feel free to delete it; tscheck will regenerate it if necessary, although it speeds things up a bit if you leave it there.

Research

Created by Asger Feldthaus as part of a research project at CASA, Aarhus University.

Programming language enthusiasts: consider looking at jsnap and tscore.