meilisearch / meilisearch-js

JavaScript client for the Meilisearch API

Home Page:https://www.meilisearch.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

TS2345: Argument of type unknown is not assignable to parameter of type MeiliSearchErrorInfo

tdawn0-0 opened this issue · comments

commented

Hi, I have been using Meilisearch for my project and have found it to be incredibly useful due to its friendly SDK and high performance. However, while working with Meilisearch js SDK, I have come across an issue that cause Next.js build failed.

Description
Next.js build log

./node_modules/meilisearch/src/errors/http-error-handler.ts:22:35
Type error: Argument of type 'unknown' is not assignable to parameter of type 'MeiliSearchErrorInfo'.

  20 |     // If the body is parsable, then it means Meilisearch returned a body with
  21 |     // information on the error.
> 22 |     throw new MeiliSearchApiError(responseBody, response.status)
     |                                   ^
  23 |   }
  24 |
  25 |   return response

tsconfig.json

{
  "compilerOptions": {
    "esModuleInterop": true,
    "skipLibCheck": true,
    "target": "es2022",
    "allowJs": true,
    "resolveJsonModule": true,
    "moduleDetection": "force",
    "isolatedModules": true,

    "strict": true,
    "noUncheckedIndexedAccess": true,
    "checkJs": true,

    "lib": ["dom", "dom.iterable", "ES2022"],
    "noEmit": true,
    "module": "ESNext",
    "moduleResolution": "Bundler",
    "jsx": "preserve",
    "plugins": [{ "name": "next" }],
    "incremental": true,

    "baseUrl": ".",
    "paths": {
      "~/*": ["./src/*"]
    }
  },
  "include": [
    ".eslintrc.cjs",
    "next-env.d.ts",
    "**/*.ts",
    "**/*.tsx",
    "**/*.cjs",
    "**/*.js",
    ".next/types/**/*.ts"
  ],
  "exclude": ["node_modules"]
}

Expected behavior
Eliminate the type error and pass the Next.js build process.

Current behavior
Next.js build failed.

Environment:

  • OS: MacOS 14.2
  • Meilisearch version: v1.5.1
  • meilisearch-js version: v0.36.0
  • Next.js: v14.0.3

How do you import this package? Maybe you are importing the source code instead of the build.

commented

How do you import this package? Maybe you are importing the source code instead of the build.

I do find a source code accidentally imported by WebStorm IDE. I was negligent. Thank you for the advice. 🥳