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 'Elysia<...>' does not satisfy the constraint 'Elysia' #77

Open
QAdamek opened this issue Apr 5, 2024 · 2 comments
Open

Type 'Elysia<...>' does not satisfy the constraint 'Elysia' #77

QAdamek opened this issue Apr 5, 2024 · 2 comments

Comments

@QAdamek
Copy link

QAdamek commented Apr 5, 2024

Am I doing something wrong?

// Server

=================================================
package.json deps:

    "@elysiajs/cookie": "^0.8.0",
    "@elysiajs/cors": "^1.0.2",
    "@elysiajs/jwt": "^0.8.0",
    "@elysiajs/swagger": "^0.8.5",
    "@prisma/client": "5.10.2",
    "elysia": "latest"
=================================================

const app = new Elysia();

app
  .use(swagger())  // It does not change after commenting out this line
  .use(cookie())  // It does not change after commenting out this line
  .use(corsHandler)  // It does not change after commenting out this line
  .use(errorHandler)  // It does not change after commenting out this line
  .use(eventHandler)  // It does not change after commenting out this line
  .use(jwtHandler)  // It does not change after commenting out this line
  .use(authRoutes)
  .listen(process.env.PORT || 4000);

export type App = typeof app;


// type App = Elysia<"", {
//    request: {};
//    store: {};
//    derive: {};
//    resolve: {};
// }, {
//    type: {};
//    error: {};
// }, {}, {}, {}, false> <== This is what VSC is showing when I hover App object
// Client

=================================================
package.json deps:

    "@elysiajs/eden": "latest",
    "elysia": "latest",  // It does not change after commenting out this line
=================================================

import { edenTreaty } from "@elysiajs/eden";
import type { App } from "../../../../project-api/src/index";

const app = edenTreaty<App>("http://localhost:4000");

// Outcome

Type 'Elysia<"", { request: {}; store: {}; derive: {}; resolve: {}; }, { type: {}; error: {}; }, {}, {}, {}, false>' does not satisfy the constraint 'Elysia<any, any, any, any, any, any, any, any>'.
  Type 'Elysia<"", { request: {}; store: {}; derive: {}; resolve: {}; }, { type: {}; error: {}; }, {}, {}, {}, false>' is missing the following properties from type 'Elysia<any, any, any, any, any, any, any, any>': _routes, _types, _ephemeral, _volatile, and 11 more.ts(2344)

Screenshot from 2024-04-05 21-04-48

@kelvinwop
Copy link

also getting this

@kelvinwop
Copy link

it seems to work well if

import { treaty } from '@elysiajs/eden';
const app = treaty<App>("localhost:4000")

goes into the same file as the server definition, so maybe a monorepo could fix this

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

2 participants