suhaotian / xior

A lite request lib based on fetch with plugin support and similar API to axios.
https://suhaotian.github.io/xior/
MIT License
193 stars 4 forks source link

Type checks failing after upgrading to version 0.5.1 #24

Closed WoetDev closed 4 months ago

WoetDev commented 4 months ago

Hi

First of all, great work on the package!

I've been using it, but after upgrading to version 0.5.1, all the typechecks that were previously passing started failing and not sure if this was expected behaviour and I need to migrate something or it there's bug/other issue.

I'm receiving the typescript error: Error: Unsafe argument of type 'any' assigned to a parameter of type 'Xior'. @typescript-eslint/no-unsafe-argument everywhere.

An example of what was working before was that I created an instance:

import xior from "xior";

const neonInstance = xior.create({
  baseURL: "https://console.neon.tech/api/v2",
  headers: {
    Accept: "application/json",
    "Content-Type": "application/json",
    Authorization: `Bearer ${process.env.NEON_API_KEY}`,
  },
});

export default neonInstance;

And then add the type as follows when performing a request:

import {
  type NeonApiProjectOperation,
} from "@/types/neonApi";
import neonInstance from "@/utils/neon/neonInstance";

const neonProjectOperation =
        await neonInstance.get<NeonApiProjectOperation>(
          `/projects/${projectId}/operations/${operation.id}`,
        );

const operationData = neonProjectOperation.data.operation;

From the typescript definitions in the project, my guess is that this should still work, but maybe I'm missing that I needed to update something else?

WoetDev commented 4 months ago

Apologies!

Looks like this was caching issue locally in my project.

For anyone else that might come across such an error; I'm using Next.js v14.2.4

I had to manually delete my .next folder locally, after that the local build was working.