elysiajs / elysia

Ergonomic Framework for Humans
https://elysiajs.com
MIT License
10.27k stars 219 forks source link

Type infer issue with sub plugins #577

Closed qlaffont closed 6 months ago

qlaffont commented 6 months ago

What version of Elysia.JS is running?

latest (1.0.9)

What platform is your computer?

Linux 6.8.0-76060800daily20240311-generic x86_64 x86_64

What steps can reproduce the bug?

What is the expected behavior?

What do you see instead?

No overload matches this call.
  The last overload gave the following error.
    Argument of type 'Elysia<"", false, { decorator: {}; store: {}; derive: {}; resolve: {}; }, { type: {}; error: {}; }, { schema: {}; macro: {}; }, {}, { derive: {}; resolve: {}; schema: {}; }, { derive: {}; resolve: {}; schema: {}; }>' is not assignable to parameter of type 'Promise<{ default: Elysia<any, any, any, any, any, any, any, any>; }>'.
      Type 'Elysia<"", false, { decorator: {}; store: {}; derive: {}; resolve: {}; }, { type: {}; error: {}; }, { schema: {}; macro: {}; }, {}, { derive: {}; resolve: {}; schema: {}; }, { derive: {}; resolve: {}; schema: {}; }>' is missing the following properties from type 'Promise<{ default: Elysia<any, any, any, any, any, any, any, any>; }>': then, catch, finally, [Symbol.toStringTag]ts(2769)
index.d.ts(794, 5): The last overload is declared here.
This expression is not callable.
  Each member of the union type '{ <const NewElysia extends Elysia<any, any, any, any, any, any, any, any>, const Param extends Elysia<any, any, any, any, any, any, any, any> = Elysia<"", false, { [x: string]: { [x: string]: any; }; }, { [x: string]: { ...; }; }, { ...; }, any, { ...; }, { ...; }>>(plugin: MaybePromise<...>): NewElysia["_scoped"] e...' has signatures, but none of those signatures are compatible with each other.ts(2349)

Additional information

No response

zipme commented 4 months ago

Is this fixed? I am getting the same typescript error when using the cors plugin:

import { Elysia } from "elysia";
import { cors } from "@elysiajs/cors";
const app = new Elysia()
  .use(cors())
No overload matches this call.
  The last overload gave the following error.
    Argument of type 'Elysia<"", false, { decorator: {}; store: {}; derive: {}; resolve: {}; }, { type: {}; error: {}; }, { schema: {}; macro: {}; }, {}, { derive: {}; resolve: {}; schema: {}; }, { derive: {}; resolve: {}; schema: {}; }>' is not assignable to parameter of type 'Promise<{ default: AnyElysia; }>'.
      Type 'Elysia<"", false, { decorator: {}; store: {}; derive: {}; resolve: {}; }, { type: {}; error: {}; }, { schema: {}; macro: {}; }, {}, { derive: {}; resolve: {}; schema: {}; }, { derive: {}; resolve: {}; schema: {}; }>' is missing the following properties from type 'Promise<{ default: AnyElysia; }>': then, catch, finally,