Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Signature mismatch x compile errors TS2339, TS2358, TS2339 #1590

Closed
bitbreakr opened this issue Oct 9, 2023 · 6 comments
Closed

Signature mismatch x compile errors TS2339, TS2358, TS2339 #1590

bitbreakr opened this issue Oct 9, 2023 · 6 comments
Labels
bug Something isn't working needs more info This issue needs a minimal complete and verifiable example

Comments

@bitbreakr
Copy link

bitbreakr commented Oct 9, 2023

Description
The Meilisearch JavaScript library, meilisearch-js, is causing my TypeScript project to fail to compile due to some type signature errors in the file http-requests.ts.

I have cloned the repo, and I have precisely found where is the faulty code (see screenshot below)
CleanShot 2023-10-09 at 17 04 26@2x

When I try to compile my project, I get 3 errors that fall under TS2339, TS2358, TS2339:

Expected behavior
Errorless compilation

Current behavior
compile errors TS2339, TS2358, TS2339

Screenshots or Logs
CleanShot 2023-10-09 at 16 50 23@2x

ERROR in ./node_modules/meilisearch/src/http-requests.ts:24:37
TS2339: Property 'join' does not exist on type 'T[keyof T]'.
    22 |       return acc
    23 |     } else if (Array.isArray(value)) {
  > 24 |       return { ...acc, [key]: value.join(',') }
       |                                     ^^^^
    25 |     } else if (value instanceof Date) {
    26 |       return { ...acc, [key]: value.toISOString() }
    27 |     }

ERROR in ./node_modules/meilisearch/src/http-requests.ts:25:16
TS2358: The left-hand side of an 'instanceof' expression must be of type 'any', an object type or a type parameter.
    23 |     } else if (Array.isArray(value)) {
    24 |       return { ...acc, [key]: value.join(',') }
  > 25 |     } else if (value instanceof Date) {
       |                ^^^^^
    26 |       return { ...acc, [key]: value.toISOString() }
    27 |     }
    28 |     return { ...acc, [key]: value }

ERROR in ./node_modules/meilisearch/src/http-requests.ts:26:37
TS2339: Property 'toISOString' does not exist on type 'never'.
    24 |       return { ...acc, [key]: value.join(',') }
    25 |     } else if (value instanceof Date) {
  > 26 |       return { ...acc, [key]: value.toISOString() }
       |                                     ^^^^^^^^^^^
    27 |     }
    28 |     return { ...acc, [key]: value }
    29 |   }, {} as queryParams<T>)

Environment (please complete the following information):

  • OS: [e.g. Debian GNU/Linux] MacOS Sonoma
  • Meilisearch version: [e.g. v.0.20.0] Irrelevant information
  • meilisearch-js version: [e.g v0.18.2] 0.35.0
  • Browser: [e.g. Chrome version 90.0] Irrelevant information
  • Node version: v18.17.1
@curquiza
Copy link
Member

Hello @bitbreakr
Thanks for the report and for finding where the issue is coming from ❤️

Feel free to open a PR to fix it

@curquiza curquiza added the bug Something isn't working label Oct 11, 2023
@brunoocasali
Copy link
Member

Hi @bitbreakr, I'm quite surprised to see these errors. Can you provide a test/pet project where this issue happens?

Also, if you ask this question in our Discord, you may find someone who shared this issue because it seems to be related to something particular on your project.

@brunoocasali brunoocasali added the needs more info This issue needs a minimal complete and verifiable example label Oct 17, 2023
@flevi29
Copy link
Collaborator

flevi29 commented Dec 17, 2023

You have skipLibCheck as false (default value) in your tsconfig.json. While in a world closer to perfect it would make sense to check libraries as well, we live in JS world, very far from perfect.
Many many packages don't keep their projects strictly type safe, and there are many other issues that can pop up because of different possible configurations and TS versions being used on library end versus client end.

Set this option to true, you'll run into a lot of issues otherwise that you can't do anything about (not just with this package).

@flevi29
Copy link
Collaborator

flevi29 commented Dec 17, 2023

For me TS is not complaining on a git cloned repo. You must've not installed dependencies correctly, or messed with some configuration.
Only Jetbrains IDE is giving me some warnings.
image
image
image

@flevi29
Copy link
Collaborator

flevi29 commented Dec 29, 2023

Never mind I can see the problem. You are importing the source files instead of the build files. Same issue in #1613 . In your screenshots you can see the path ./node_modules/meilisearch/src/(...) so you are probably doing import { /* ... */ } from "meilisearch/src/whatever". Usually IDE auto imports do this.

@flevi29
Copy link
Collaborator

flevi29 commented May 29, 2024

We can clearly see in the provided logs that the source code (TypeScript files) is imported, and so I'm closing it.
#1611 should make this error a lot more obvious, also IDE auto-imports should no longer look at src either.

@flevi29 flevi29 closed this as completed May 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working needs more info This issue needs a minimal complete and verifiable example
Projects
None yet
Development

No branches or pull requests

4 participants