Support searching for package types TypeScript / Flow
iamandrewluca opened this issue · 6 comments
Allow to search for main entry types file from package.json if exists, or link to definitelytyped if exists
Candidates for keywords
t
not available (list of git tags)dt
from definitelytypeddts
from *.d.tsts
typescript types *.tsft
flow typedflow
flow types *.flowtypes
for both TypeScript and Flow, but better to have them separated
Think would be better to have different keywords for TypeScript and Flow
Hi @iamandrewluca! What URL do you expect users to land once they’ve typed the keyword? Not sure I fully understand the use case.
If you are mainly interested in searching for TypeScript typings, there is an official tool for that:
https://www.typescriptlang.org/dt/search?search=react
Wondering if that’s enough already 🤔
There are multiple cases. I'll start a PR for this. Types can be in package repo or can be in definetlytyped repo
Let’s discuss the spec first 🙂 To be honest, I’m not fully sure if this feature is useful at this point.
https://www.typescriptlang.org/dt/search?search=react Is searching only in https://github.com/DefinitelyTyped/DefinitelyTyped repository, but some packages can have their types included in the source code repository.
Me personally I use a lot njt for go to github repo, go to npm package
And a lot of times I'm searching for types for a package, and everytime I have to go search manually in source code repo,
if types are not there, I search on DefinitelyTyped
https://www.typescriptlang.org/docs/handbook/declaration-files/publishing.html#including-declarations-in-your-npm-package
https://www.typescriptlang.org/docs/handbook/declaration-files/publishing.html#publish-to-types
And a lot of times I'm searching for types for a package
How do you do this without njt? At what stage and what for?
My workflow:
-
Add a package I’m interested in
-
Add an import into one of my project files
-
If autocompletion kicks in, typings are there so I don’t need to do anything. If VSCode highlights the first character of the import with a dashed line, this means that the package missing the typings. In that case, I do
njt @types/PACKAGE
, take a quick glance at the number of weekly downloads andyarn add -D @types/PACKAGE
. -
If I need to refer to a typing of a particular package resource, I command+click on the symbol and get straight to a corresponding
.d.ts
file innode_modules
. No need to manually navigate to the package repo or explore the@types/PACKAGE
folder on GitHub.
If the presence of typings affects the decision to install a package, then https://www.typescriptlang.org/dt/search is the tool to check. If a package is found, typings are available. A hexagon icon means that they are built in, a square with DT in it means that the typings are in DefinietelyTyped repo.
If you still believe that there is scope for a new feature in njt
, happy to discuss the added value, the use cases and the spec. Note that adding keywords of 2+ chars affects the simplicity of the tool, so this leap needs to be really well justified.
You are killing all my PR's 😄
Actually I did not thought to search for njt @types/PACKAGE
. It makes sense.
Thanks for making this clear to me
I think this can be closed.
Thanks again for njt
🙂
I'll go and add a OpenSearch definition for https://www.typescriptlang.org/dt/search?search=