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

Allow passing in a generic type for the client #76

Open
razor-x opened this issue Apr 5, 2024 · 1 comment
Open

Allow passing in a generic type for the client #76

razor-x opened this issue Apr 5, 2024 · 1 comment

Comments

@razor-x
Copy link
Contributor

razor-x commented Apr 5, 2024

  • Consumers who use seam.client would like to use https://www.npmjs.com/package/typed-axios-instance
  • Supporting typed-axios-instance directly in this library is out of scope.
  • Instead, the SeamHttp class could provide setting the client type via 'fromClient`, e.g.,
import { SeamHttp } from '@seamapi/http'
import type { TypedAxios } from 'typed-axios-instance'

import type { Routes } from './routes.js'

const seam = new Seam() // create a new instance normally

type Client = TypedAxios<Routes>

const seamWithTypedRoutes = Seam.fromClient<Client>(seam.client)
@razor-x
Copy link
Contributor Author

razor-x commented Apr 24, 2024

Reviewing this again, I don't feel the generic parameter is the correct solution. We should just be able to respect the type of the client passed to fromClient, e.g., does this work?

import { SeamHttp } from '@seamapi/http'
import type { TypedAxios } from 'typed-axios-instance'

import type { Routes } from './routes.js'

const seam = new Seam() // create a new instance normally

type Client = TypedAxios<Routes>

const seamWithTypedRoutes = Seam.fromClient(seam.client as Client)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant