#community-help

Using TypeScript with Typesense JS Library

TLDR michtio asked how to use TypeScript with Typesense JS library, and Ross provided detailed example code.

Powered by Struct AI

1

3
17mo
Solved
Join the chat
Jul 20, 2022 (17 months ago)
michtio
Photo of md5-68e2637c7df7044e63075bd8ec098420
michtio
02:05 PM
Hey all 👋

Quick question for the Typesense JS library, are there docs somewhere that describe how to use TypeScript within it?

e.g. if I want to do something like:

import Typesense from 'typesense'```
export const useTypesenseClient = (protocol = 'https', port = 443): SearchClient => {`` Where it will say SearchClient` not found, which is kind of obvious, but I find no information whatsoever on how to import types / which types / etc … ?
Ross
Photo of md5-faf0fdba0b6739a6706f05c15b6738c6
Ross
02:33 PM
Some example imports from our app:
import { Client } from 'typesense';
import {
  SearchParams,
  SearchOptions,
  SearchResponse
} from 'typesense/lib/Typesense/Documents';
import {
  MultiSearchRequestSchema,
  MultiSearchRequestsSchema,
  MultiSearchResponse
} from 'typesense/lib/Typesense/MultiSearch';
import { CollectionSchema } from 'typesense/lib/Typesense/Collection';

1

michtio
Photo of md5-68e2637c7df7044e63075bd8ec098420
michtio
03:52 PM
Thank you Ross that is really helpful 🙂