Skip to content
This repository has been archived by the owner on Jan 19, 2021. It is now read-only.

Search DefinitelyTyped _and_ NPM #30

Open
danvk opened this issue Jan 9, 2019 · 6 comments
Open

Search DefinitelyTyped _and_ NPM #30

danvk opened this issue Jan 9, 2019 · 6 comments

Comments

@danvk
Copy link

danvk commented Jan 9, 2019

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
Copy link
Member

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
Copy link
Author

danvk commented Jan 9, 2019

@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
Copy link
Member

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

@karlhorky
Copy link

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 algolia/npm-search#346).

@danvk
Copy link
Author

danvk commented Apr 5, 2020

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
Copy link

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants