All Projects → danvk → dtsearch

danvk / dtsearch

Licence: other
Find packages with TypeScript types, either bundled or on Definitely Typed

Programming Languages

typescript
32286 projects
javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to dtsearch

Quickshare
Quick and simple file sharing between different devices.
Stars: ✭ 190 (+691.67%)
Mutual labels:  yarn
Core
Native HTML Elements with CSS superpowers. 🕶
Stars: ✭ 237 (+887.5%)
Mutual labels:  yarn
zsh-yarn-completions
Yarn completions for Z-shell that supports yarn workspaces
Stars: ✭ 35 (+45.83%)
Mutual labels:  yarn
Corepack
Zero-runtime-dependency package acting as bridge between Node projects and their package managers
Stars: ✭ 196 (+716.67%)
Mutual labels:  yarn
Yalc
Work with yarn/npm packages locally like a boss.
Stars: ✭ 3,155 (+13045.83%)
Mutual labels:  yarn
Express Mongoose Es6 Rest Api
💥 A boilerplate application for building RESTful APIs Microservice in Node.js using express and mongoose in ES6 with code coverage and JsonWebToken Authentication
Stars: ✭ 2,811 (+11612.5%)
Mutual labels:  yarn
Xity Starter
A blog-ready 11ty starter based on PostCSS, with RSS feed and Native Elements!
Stars: ✭ 184 (+666.67%)
Mutual labels:  yarn
ansible-role-yarn
Install Yarn via Ansible to Ubuntu and RedHat systems!
Stars: ✭ 20 (-16.67%)
Mutual labels:  yarn
Yarn Completion
Bash completion for Yarn
Stars: ✭ 210 (+775%)
Mutual labels:  yarn
Forward-Framework
A killer WordPress theme framework built using underscores, gulp, sass, bourbon neat, bower & browsersync.
Stars: ✭ 23 (-4.17%)
Mutual labels:  yarn
Gulp Webpack Starter
Gulp Webpack Starter - fast static website builder. The starter uses gulp toolkit and webpack bundler. Download to get an awesome development experience!
Stars: ✭ 199 (+729.17%)
Mutual labels:  yarn
Front End Guide
📚 Study guide and introduction to the modern front end stack.
Stars: ✭ 14,073 (+58537.5%)
Mutual labels:  yarn
docker-hadoop
Docker image for main Apache Hadoop components (Yarn/Hdfs)
Stars: ✭ 59 (+145.83%)
Mutual labels:  yarn
My Wallet V3 Frontend
Blockchain Web Wallet Frontend
Stars: ✭ 192 (+700%)
Mutual labels:  yarn
express-starter
ARCHIVED: Please use @neutrinojs/create-project
Stars: ✭ 14 (-41.67%)
Mutual labels:  yarn
Cheat Sheets
Cheat Sheets 🐭🤖👀
Stars: ✭ 185 (+670.83%)
Mutual labels:  yarn
21 Points
❤️ 21-Points Health is an app you can use to monitor your health.
Stars: ✭ 244 (+916.67%)
Mutual labels:  yarn
koa-mongoDB
😊😊Koa and mongoose build services
Stars: ✭ 24 (+0%)
Mutual labels:  yarn
erupt-web
Erupt 框架前端源码,实现了 erupt 开发过程中零前端代码能力
Stars: ✭ 82 (+241.67%)
Mutual labels:  yarn
introduction-nodejs
Introduction to NodeJS
Stars: ✭ 13 (-45.83%)
Mutual labels:  yarn

dtsearch

Find npm packages that have type declarations, either bundled or on DefinitelyTyped.

Usage with npx:

$ npx dtsearch sprintf
   DLS NAME              TYPES             DESCRIPTION
533.3k sprintf           @types/sprintf    sprintf() for node.js
 47.4m sprintf-js        @types/sprintf-js JavaScript sprintf implementation
 82.9m extsprintf        @types/extsprintf extended POSIX-style sprintf
  2.1m ssf               <bundled>         Format data using ECMA-376 spreadsheet Format Codes
  1.6m printj            <bundled>         Pure-JS printf
  123k voca              @types/voca       The ultimate JavaScript string library
746.4k printf            <bundled>         Full implementation of the `printf` family in pure JS.
  1.5k sprintfjs         <bundled>         POSIX sprintf(3)-style String Formatting for JavaScript
   169 @jitesoft/sprintf <bundled>         sprintf function for javascript.
    94 stringd           <bundled>         A string variable parser for JavaScript

Alternatively, you can install dtsearch globally using either:

npm install --global dtsearch
yarn global add dtsearch

You can use --yarn or --npm to produce copy/pastable commands to depend on packages and their types:

Demonstration of search for a library and installing it using yarn

Background

There are two ways to distribute TypeScript types for a package on npm:

  1. With the package itself ("bundled" or "included"). This is common if the package is written in TypeScript, or if the owner is committed to maintaining its type declarations. The tell-tale sign of bundled types is a typings entry in package.json.
  2. As a separate @types package on DefinitelyTyped. This is more common for packages which are written in plain JavaScript or another language. The type declarations are often written by someone other than the package author.

Both approaches are common and there are many tradeoffs between them.

As a TypeScript user, you'll often find yourself wanting to search for a package that does X and has type declarations (of either form). The usual approach is to search for packages and then check if they have type declarations (yarnpkg has recently added TypeScript badges which help with this).

Once you've found a package, you need to run different commands depending on whether it bundles its types or gets them from DefinitelyTyped. For example, using yarn and moment:

yarn add moment  # bundled types

# Types on DefinitelyTyped
yarn add moment-timezone
yarn add -D @types/moment-timzeone

dtsearch aims to solve these problems with a fast, simple CLI. It lets you search only packages with types and shows you the exact commands you need to run to add them to your project.

How this works

This uses Algolia's npm search, the same search that you find on yarnpkg.

Options

  • -n, --num <number> Maximum number of results to show (default: 10)
  • --npm Output npm install commands
  • -y, --yarn Output yarn add commands
  • --bundled Only show packages with bundled types
  • --dt Only show packages with types on DefinitelyTyped (@types)
  • -u, --untyped Search all packages, even those without type declarations.
  • --repo Show repo URLs, even if package specifies a homepage
  • --stars Show GitHub star counts. This is a useful quality signal but it does slow dtsearch down, so it is off by default.
  • --debug Enable debug logging

Development

Run tsc --watch in the background to iterate:

yarn
yarn tsc --watch &
./bin/dtsearch --debug args

To publish a new version:

yarn tsc
npm publish

Related Work

  • The old typings search command from c. 2016 (before @types).
  • Microsoft's TypeSearch. Unfortunately this only searches DefinitelyTyped and only searches package names. It does not search bundled types or package descriptions.
  • yarnpkg's search. This shows small "TS" icons next to packages with type declarations, either bundled or on DT. It does not surface a filter to search only packages with type declarations, however.
  • pikapkg lets you search packages with a has:types filter. This only searches bundled typings; it does not consider types on DT.
  • The yarn TypesScript plugin automatically installs @types when you yarn add a package that has them.

Support

If you like this tool, consider buying a copy of my book, Effective TypeScript. Chapter 6 and particularly Item 46 ("Understand the Three Versions Involved in Type Declarations") are all about the trials and tribulations of getting TypeScript types for your dependencies. And it's got a bird on the cover!

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].