react-instantsearch
react-instantsearch copied to clipboard
Add TypeScript definitions
Please add typings for TypeScript Do you want to request a feature or report a bug? FEATURE
Some inspiration from other react libraries:
Feel free to get started with it @FDiskas, it's not exactly a priority for us, since this is the first request for it AFAIK, but we will definitely help out with validating. Maybe something can be done to convert proptypes to TS definitions?
https://yarn.pm/react-to-typescript-definitions can be tried
@alexandremeunier you might have something to share here :)
Is there any news/improvement on Types with Typescript ?
There's an open PR for using a tool to generate typings, but it didn't completely work. Feel free to contribute @romainquellec :) https://github.com/algolia/react-instantsearch/pull/701
Hi All, I've opened a PR to DefinitelyTyped with definitions for the types that we've been maintaining in our repo. You all could use it as a base to build out the rest of the type definitions.
https://github.com/DefinitelyTyped/DefinitelyTyped/pull/29793
Thanks @gburgett, that's definitely a solid start for typings! We will take a look and see if there's any missing things.
I see you're documenting internals as well, is that because you use them, or because you simply wanted to add typings for everything?
Thanks a lot @gburgett I'll review the PR and probably fill the missing types next week.
Hi @Haroenv , I'm not sure which of them were internals. I've definitely reworked the definitions since getting feedback from the DefinitelyTyped folks, are they still exporting internal functions?
I didn’t mean that in a way that they shouldn’t be documented, but e.g. createInstantSearch usually isn’t necessary to use, unless you’re targeting something which isn’t web, and isn’t react native either.
In definitely typed they seem to want everything documented, so that was a good call from you to make it complete!
Definitely need more types. Currently, the amount of any and the lack of generic type that defines results is really bad (e.g. InstantSearchProps at react-instantsearch-dom)
@ivawzh the typings are open source and not maintained by us. Feel free to contribute:
https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/react-instantsearch-core https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/react-instantsearch-dom
Disappointment to Algolia's strategy and altitude.
You are asking the paid customers to create and maintain the for-profit products you sell.
Say even if I maintain the types for you, how will they get up-to-date whenever you deliver changes if you don't take the ownership yourself.
This is also ignorant of your competitors' standard. Have a look at https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/elasticsearch/index.d.ts. They are types maintained by Elasticsearch, an open-source competitor that offers free-for-ever community tier. The quality is just too obviously better than what you currently have.
Thanks for your interest in the definition files of React InstantSearch! Like @Haroenv said those files are not mainly maintained by us for one simple reason: it takes a lot of time to do it manually. We maintain the definition file for the Algolia JavaScript client but not all the InstantSearch flavors available (Vanilla, Vue, React).
We choose another strategy to fill the gap with those definition files. We gradually move our codebases to TypeScript. Which means that the definition files will be automatically generated and officially supported. But this process takes times since it's a gradual migration. Hope you understand our strategy on the topic.
Any way to follow your progress for the Typescript migration for each of the projects @samouss ?
This is not totally representative but the GitHub language repartition is an indicator of the TypeScript migration progress:

We'll be explicit about the TypeScript definitions once they are available in a release.
@samouss - I hope you had a nice weekend, and any updates on this? Big congrats on your work on Algolia's JS as it now natively supports TypeScript.
@ACPK to focus our efforts, we have migrated InstantSearch.js (the vanilla.js) version completely to TS first, which is done now. Currently we are working on writing a new version of React InstantSearch using hooks, which internally is based on InstantSearch.js and supports typescript out of the box. You can follow along on #2870
React InstantSearch Hooks is globally available now and will soon replace React InstantSearch. You can follow the upgrade guide to migrate and benefit from first-class TypeScript support.