Skip to content

feature request: type inference on Response type codegen #1883

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

Open
devtempmac opened this issue Apr 23, 2025 · 0 comments
Open

feature request: type inference on Response type codegen #1883

devtempmac opened this issue Apr 23, 2025 · 0 comments

Comments

@devtempmac
Copy link

hello!

I just tried out encore hello-world (restapi) + encore's client code gen (typescript)

when I removed response type from the source, the codegen gives me 'void' response type:

export const get = api(
  { expose: true, method: "GET", path: "/hello/:name" },
  async ({ name }: { name: string }) => { //  removed: Promise<Response>
    const msg = `Hello ${name}!`;
    return { message: msg };
  }
);
import * as generatedClientSrc from './generated_client2';

const apiclient = new generatedClientSrc.default('')
const r = apiclient.hello.get("aa"); // type is: Promise<void>  but expected: Promise<{ message: string }>

is type inference on the roadmap? (or is it currently impossible?)

also, is there any way to express "branded-types", like zod's z.number.branded('user_id') ?

@devtempmac devtempmac changed the title feature request: type inference on Response feature request: type inference on Response type codegen Apr 24, 2025
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