InstantSearch.js now is bundled with typescript definitions ⌨️

If you’ve been following InstantSearch development, you might have noticed a bunch of contributions over the last year related to adding type definitions to our library. This was a long process and in the mean time also uncovered and fixed some edge-cases. We are very proud of that process now being completed!

Note that there are only definitions for the “es modules” build of InstantSearch for now, that means you can import like this to get definitions:

import instantsearch from 'instantsearch.js/es';
import { menu } from 'instantsearch.js/es/widgets';
import { connectMenu } from 'instantsearch.js/es/connectors';
import { createInsightsMiddleware } from 'instantsearch.js/es/middlewares';
import { reverseHighlight } from 'instantsearch.js/es/helpers';
import { history } from 'instantsearch.js/es/lib/routers';
import { simple } from 'instantsearch.js/es/lib/stateMappings';
import { Widget } from 'instantsearch.js/es/types';

This is available from version 4.27.0

Hope you enjoy the added safety and developer-friendly autocomplete when using InstantSearch!

Feel free to let us know if you have any questions or thoughts around this in the comments here.

You can find a codesandbox example with the definitions here