Open danvk opened 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? 🤔
@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.
Hmmm, I guess if you're using typesearch as a kind of psuedo-npm-search that's reasonable.
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).
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.
fyi the link to pika.dev is outdated, search is now here: https://www.pika.dev/search
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](https://user-images.githubusercontent.com/98301/50917947-e07d9380-140c-11e9-8cc0-830bb731e9a0.png)
The arrow indicates that
package.json
for that module has atypes
property. cc @FredKSchott