microsoft / TypeSearch

368 stars 52 forks source link

Search DefinitelyTyped _and_ NPM #30

Open danvk opened 5 years ago

danvk commented 5 years ago

So far as I can tell, TypeSearch only searches packages whose types are defined in DefinitelyTyped. But it's preferable if a package defines and distributes its own types (so that the versions always match).

It would be better if TypeSearch were able to find these packages. For instance, if I type react-mapbox-gl on https://microsoft.github.io/TypeSearch/, nothing comes up, even though that package distributes TypeScript type declarations.

There are NPM indices which can do this sort of search, for example: https://www.pikapkg.com/packages/?q=has:types

or https://www.pikapkg.com/packages/?q=react-mapbox-gl image

The arrow indicates that package.json for that module has a types property. cc @FredKSchott

weswigham commented 5 years ago

You might be right, but... consider: If a package ships its own types, why would someone be searching for types for it, as it already has them? 🤔

danvk commented 5 years ago

@weswigham Because I'm looking for a module that does X, and I'd like to find one that has type declarations.

The old typings search ... command was a great way to do this, but increasingly it misses packages that provide their own type declarations.

weswigham commented 5 years ago

Hmmm, I guess if you're using typesearch as a kind of psuedo-npm-search that's reasonable.

karlhorky commented 5 years ago

This would be potentially solved by some implementation of #22 (along with the addition of the types information to the npm search index by @orta in https://github.com/algolia/npm-search/pull/346).

danvk commented 4 years ago

I put together a CLI tool based on @orta's Algolia integration: dtsearch

$ 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

I think it works pretty well in practice. TypeSearch might want to consider a similar approach.

FredKSchott commented 4 years ago

fyi the link to pika.dev is outdated, search is now here: https://www.pika.dev/search