hey guys, has anyone faced type errors after insta...
# community-help
k
hey guys, has anyone faced type errors after installing the typesense-js library, getting a whole bunch of type errors from node_modules even tho the library is written in typescript. All the errors below: typesense-js: v1.8.2 typescript: v5.3.3
Copy code
node_modules/typesense/src/Typesense/ApiCall.ts:1:66 - error TS2307: Cannot find module 'axios' or its corresponding type declarations.

1 import axios, { AxiosRequestConfig, AxiosResponse, Method } from "axios";
                                                                   ~~~~~~~

node_modules/typesense/src/Typesense/ApiCall.ts:2:24 - error TS2307: Cannot find module 'loglevel' or its corresponding type declarations.

2 import { Logger } from "loglevel";
                         ~~~~~~~~~~

node_modules/typesense/src/Typesense/ApiCall.ts:176:28 - error TS7006: Parameter 'status' implicitly has an 'any' type.

176           validateStatus: (status) => {
                               ~~~~~~

node_modules/typesense/src/Typesense/ApiCall.ts:184:14 - error TS7006: Parameter 'data' implicitly has an 'any' type.

184             (data, headers) => {
                 ~~~~

node_modules/typesense/src/Typesense/ApiCall.ts:184:20 - error TS7006: Parameter 'headers' implicitly has an 'any' type.

184             (data, headers) => {
                       ~~~~~~~

node_modules/typesense/src/Typesense/ApiCall.ts:333:9 - error TS2322: Type 'Node | undefined' is not assignable to type 'Node'.
  Type 'undefined' is not assignable to type 'Node'.

333     let candidateNode: Node = this.nodes[0];
            ~~~~~~~~~~~~~

node_modules/typesense/src/Typesense/ApiCall.ts:336:7 - error TS2322: Type 'Node | undefined' is not assignable to type 'Node'.
  Type 'undefined' is not assignable to type 'Node'.

336       candidateNode = this.nodes[this.currentNodeIndex];
          ~~~~~~~~~~~~~

node_modules/typesense/src/Typesense/ApiCall.ts:356:25 - error TS7006: Parameter 'node' implicitly has an 'any' type.

356   nodeDueForHealthcheck(node, requestNumber = 0): boolean {
                            ~~~~

node_modules/typesense/src/Typesense/ApiCall.ts:380:22 - error TS7006: Parameter 'node' implicitly has an 'any' type.

380   setNodeHealthcheck(node, isHealthy): void {
                         ~~~~

node_modules/typesense/src/Typesense/ApiCall.ts:380:28 - error TS7006: Parameter 'isHealthy' implicitly has an 'any' type.

380   setNodeHealthcheck(node, isHealthy): void {
                               ~~~~~~~~~

node_modules/typesense/src/Typesense/ApiCall.ts:385:28 - error TS7006: Parameter 'node' implicitly has an 'any' type.

385   uriFor(endpoint: string, node): string {
                               ~~~~

node_modules/typesense/src/Typesense/ApiCall.ts:395:7 - error TS7053: Element implicitly has an 'any' type because expression of type '"X-TYPESENSE-API-KEY"' can't be used to index type '{}'.
  Property 'X-TYPESENSE-API-KEY' does not exist on type '{}'.

395       defaultHeaders[APIKEYHEADERNAME] = this.apiKey;
          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

node_modules/typesense/src/Typesense/ApiCall.ts:397:5 - error TS7053: Element implicitly has an 'any' type because expression of type '"Content-Type"' can't be used to index type '{}'.
  Property 'Content-Type' does not exist on type '{}'.

397     defaultHeaders["Content-Type"] = "application/json";
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

node_modules/typesense/src/Typesense/ApiCall.ts:401:15 - error TS7006: Parameter 'seconds' implicitly has an 'any' type.

401   async timer(seconds): Promise<void> {
                  ~~~~~~~

node_modules/typesense/src/Typesense/Collection.ts:121:7 - error TS2322: Type 'Document<T> | undefined' is not assignable to type 'Documents<T> | Document<T>'.
  Type 'undefined' is not assignable to type 'Documents<T> | Document<T>'.

121       return this.individualDocuments[documentId];
          ~~~~~~

node_modules/typesense/src/Typesense/Collection.ts:138:7 - error TS2322: Type 'Override | undefined' is not assignable to type 'Override | Overrides'.
  Type 'undefined' is not assignable to type 'Override | Overrides'.

138       return this.individualOverrides[overrideId];
          ~~~~~~

node_modules/typesense/src/Typesense/Collection.ts:155:7 - error TS2322: Type 'Synonym | undefined' is not assignable to type 'Synonym | Synonyms'.
  Type 'undefined' is not assignable to type 'Synonym | Synonyms'.

155       return this.individualSynonyms[synonymId];
          ~~~~~~

node_modules/typesense/src/Typesense/Configuration.ts:1:25 - error TS2307: Cannot find module 'loglevel' or its corresponding type declarations.

1 import * as logger from "loglevel";
                          ~~~~~~~~~~

node_modules/typesense/src/Typesense/Configuration.ts:2:38 - error TS2307: Cannot find module 'loglevel' or its corresponding type declarations.

2 import { Logger, LogLevelDesc } from "loglevel";
                                       ~~~~~~~~~~

node_modules/typesense/src/Typesense/Configuration.ts:179:13 - error TS7053: Element implicitly has an 'any' type because expression of type '"url"' can't be used to index type 'NodeConfiguration | NodeConfigurationWithHostname | NodeConfigurationWithUrl'.
  Property 'url' does not exist on type 'NodeConfiguration | NodeConfigurationWithHostname | NodeConfigurationWithUrl'.

179       }) && node["url"] == null
                ~~~~~~~~~~~

node_modules/typesense/src/Typesense/Configuration.ts:195:7 - error TS7053: Element implicitly has an 'any' type because expression of type '"path"' can't be used to index type 'NodeConfiguration | NodeConfigurationWithHostname | NodeConfigurationWithUrl'.
  Property 'path' does not exist on type 'NodeConfiguration | NodeConfigurationWithHostname | NodeConfigurationWithUrl'.

195       node["path"] = "";
          ~~~~~~~~~~~~

node_modules/typesense/src/Typesense/Configuration.ts:216:15 - error TS7053: Element implicitly has an 'any' type because expression of type '"protocol"' can't be used to index type 'NodeConfiguration | NodeConfigurationWithHostname | NodeConfigurationWithUrl'.
  Property 'protocol' does not exist on type 'NodeConfiguration | NodeConfigurationWithHostname | NodeConfigurationWithUrl'.

216       switch (node["protocol"]) {
                  ~~~~~~~~~~~~~~~~

node_modules/typesense/src/Typesense/Configuration.ts:218:11 - error TS7053: Element implicitly has an 'any' type because expression of type '"port"' can't be used to index type 'NodeConfiguration | NodeConfigurationWithHostname | NodeConfigurationWithUrl'.
  Property 'port' does not exist on type 'NodeConfiguration | NodeConfigurationWithHostname | NodeConfigurationWithUrl'.

218           node["port"] = 443;
              ~~~~~~~~~~~~

node_modules/typesense/src/Typesense/Configuration.ts:221:11 - error TS7053: Element implicitly has an 'any' type because expression of type '"port"' can't be used to index type 'NodeConfiguration | NodeConfigurationWithHostname | NodeConfigurationWithUrl'.
  Property 'port' does not exist on type 'NodeConfiguration | NodeConfigurationWithHostname | NodeConfigurationWithUrl'.

221           node["port"] = 80;
              ~~~~~~~~~~~~

node_modules/typesense/src/Typesense/Configuration.ts:246:24 - error TS7006: Parameter 'array' implicitly has an 'any' type.

246   private shuffleArray(array) {
                           ~~~~~

node_modules/typesense/src/Typesense/Documents.ts:269:9 - error TS7053: Element implicitly has an 'any' type because expression of type '"filter_by"' can't be used to index type 'DocumentWriteParameters | UpdateByFilterParameters'.
  Property 'filter_by' does not exist on type 'DocumentWriteParameters | UpdateByFilterParameters'.

269     if (options["filter_by"] != null) {
            ~~~~~~~~~~~~~~~~~~~~

node_modules/typesense/src/Typesense/Errors/ImportError.ts:6:15 - error TS7006: Parameter 'message' implicitly has an 'any' type.

6   constructor(message, importResults) {
                ~~~~~~~

node_modules/typesense/src/Typesense/Errors/ImportError.ts:6:24 - error TS7006: Parameter 'importResults' implicitly has an 'any' type.

6   constructor(message, importResults) {
                         ~~~~~~~~~~~~~

node_modules/typesense/src/Typesense/SearchOnlyDocuments.ts:41:7 - error TS7053: Element implicitly has an 'any' type because expression of type '"use_cache"' can't be used to index type '{}'.
  Property 'use_cache' does not exist on type '{}'.

41       additionalQueryParams["use_cache"] = true;
         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

node_modules/typesense/src/Typesense/SearchOnlyDocuments.ts:44:25 - error TS7053: Element implicitly has an 'any' type because expression of type 'string' can't be used to index type 'SearchParams | SearchParamsWithPreset'.
  No index signature with a parameter of type 'string' was found on type 'SearchParams | SearchParamsWithPreset'.

44       if (Array.isArray(searchParameters[key])) {
                           ~~~~~~~~~~~~~~~~~~~~~

node_modules/typesense/src/Typesense/SearchOnlyDocuments.ts:45:9 - error TS7053: Element implicitly has an 'any' type because expression of type 'string' can't be used to index type '{}'.
  No index signature with a parameter of type 'string' was found on type '{}'.

45         additionalQueryParams[key] = searchParameters[key].join(",");
           ~~~~~~~~~~~~~~~~~~~~~~~~~~

node_modules/typesense/src/Typesense/SearchOnlyDocuments.ts:45:38 - error TS7053: Element implicitly has an 'any' type because expression of type 'string' can't be used to index type 'SearchParams | SearchParamsWithPreset'.
  No index signature with a parameter of type 'string' was found on type 'SearchParams | SearchParamsWithPreset'.

45         additionalQueryParams[key] = searchParameters[key].join(",");
f
Could you try updating to latest? Axios itself is bundled with the library and that shouldn't be the case. Also, in your ts-config you should exclude the node modules dir altogether And turn
skiplibcheck
to true
k
I think I am on the latest, 1.8.2 seems to be the latest version here https://github.com/typesense/typesense-js
have excluded node_modules in tsconfig but wondering if there's still an issue with the install
This one is our latest pre-release version
If that didn't help, try to create a reproducible example with a git repo and link that to us, I'll check it out myself
k
hmm seems like it might be a pnpm issue, i'll take a further look - thank you tho
❤️ 1