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

Type Issue with params Property in Eden Fetch #40

Closed
trylovetom opened this issue Jan 2, 2024 · 2 comments · Fixed by #41
Closed

Type Issue with params Property in Eden Fetch #40

trylovetom opened this issue Jan 2, 2024 · 2 comments · Fixed by #41

Comments

@trylovetom
Copy link

First off, I want to express my appreciation for the Elysia project! It's been instrumental in building efficient and type-safe servers, and the thoughtfulness in design truly shows. I've been using it for a while and am continually impressed by its capabilities and performance.

Expected

I was expecting to utilize the edenFetch from @elysiajs/eden with App type from server.ts without encountering type errors, ensuring smooth integration between client and server-side code.

Actual

However, I encountered a TypeScript error when trying to use the edenFetch with the App type. The error is as follows:

Property 'params' is missing in type '{}' but required in type '{ params: never; }'.ts(2345)
types.ts(40, 23): 'params' is declared here.
Screenshot 2024-01-02 at 10 10 25 AM

Reproduction

The following code represents a simplified scenario based on the official example provided in the Elysia documentation for edenFetch. I've encountered the TypeScript error while working with this example directly from the Elysia Eden Fetch Documentation.

// server.ts
import { Elysia, t } from 'elysia'

const app = new Elysia().get('/', () => 'Hi Elysia').listen(8080)

export type App = typeof app
import { edenFetch } from '@elysiajs/eden'
import type { App } from './server'

const fetch = edenFetch<App>('http://localhost:8080')

// response type: 'Hi Elysia'
const pong = await fetch('/', {})

I understand the challenge and intricacies involved in type definitions and intersection types, especially when dealing with external type declarations. I suspect this issue might be related to the intersection types or perhaps an optional property that isn't set correctly in the typings.

I'm not entirely sure of the best solution here, but I wanted to bring it to your attention in case it's something that can be improved or if there's a workaround that I'm not aware of. Your insight and guidance would be immensely valuable.

Thank you again for all your hard work on this project. It's been a pleasure to use, and I look forward to continuing with it!

@fredericoo
Copy link
Contributor

Super easy fix, not as complex as you thought 🤣

@trylovetom
Copy link
Author

@fredericoo Wonderful you are great! I am not good at typescript.

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

Successfully merging a pull request may close this issue.

2 participants