arthur-fontaine / agrume

Server-side functions in your frontend for any tool. Easy, customizable and type-safe. Made for frontend developers.
https://agrume.js.org
MIT License
9 stars 0 forks source link

Bug: Type is `any` when only options without `getClient` is provided #86

Closed arthur-fontaine closed 3 weeks ago

arthur-fontaine commented 1 month ago
const moveCar = createRoute(DI.provide(async function* (
  { carId, coordinates }: { carId: CarId, coordinates: Coordinates },
) {
  const { moveCarByJoystickPosition } = yield * DI.requireService(carService)
  await moveCarByJoystickPosition(carId, coordinates)
  return true as const
}, serverImpls), {
  path: '/move-car',
})

In the above example, moveCar is any. But in the below example, moveCar is correctly typed.

const moveCar = createRoute(DI.provide(async function* (
  { carId, coordinates }: { carId: CarId, coordinates: Coordinates },
) {
  const { moveCarByJoystickPosition } = yield * DI.requireService(carService)
  await moveCarByJoystickPosition(carId, coordinates)
  return true as const
}, serverImpls))