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

Plugin type error after updating Elysia version #29

Closed
tnraro opened this issue Mar 28, 2023 · 10 comments
Closed

Plugin type error after updating Elysia version #29

tnraro opened this issue Mar 28, 2023 · 10 comments
Labels
good first issue Good for newcomers

Comments

@tnraro
Copy link

tnraro commented Mar 28, 2023

I would like to report that I'm experiencing a type error after updating to version 0.3.2.
I have tested the packages @elysiajs/cookie, @elysiajs/static, and @elysiajs/swagger.

import { cookie } from "@elysiajs/cookie";
import { staticPlugin } from "@elysiajs/static";
import { swagger } from "@elysiajs/swagger";
import { Elysia } from "elysia";

new Elysia()
  .use(staticPlugin())
  .use(cookie())
  .use(swagger())

Each plugins has type error like this:

Argument of type 'Promise<(app: Elysia<ElysiaInstance<{ store: Record<string, unknown>; request: {}; schema: {}; meta: Record<unique symbol, {}> & Record<unique symbol, {}> & Record<unique symbol, {}>; }>>) => Elysia<...>>' is not assignable to parameter of type 'Promise<{ default: (elysia: Elysia<any>) => MaybePromise<Elysia<never>>; }> | MaybePromise<(app: Elysia<ElysiaInstance<{ store: Record<string, unknown>; request: {}; schema: {}; meta: Record<...> & ... 1 more ... & Record<...>; }>>) => MaybePromise<...>>'.
  Type 'Promise<(app: Elysia<ElysiaInstance<{ store: Record<string, unknown>; request: {}; schema: {}; meta: Record<unique symbol, {}> & Record<unique symbol, {}> & Record<unique symbol, {}>; }>>) => Elysia<...>>' is not assignable to type 'Promise<{ default: (elysia: Elysia<any>) => MaybePromise<Elysia<never>>; }>'.
    Type '(app: Elysia<ElysiaInstance<{ store: Record<string, unknown>; request: {}; schema: {}; meta: Record<unique symbol, {}> & Record<unique symbol, {}> & Record<unique symbol, {}>; }>>) => Elysia<...>' is not assignable to type '{ default: (elysia: Elysia<any>) => MaybePromise<Elysia<never>>; }'.

Additionally, I have encountered a runtime issue with @elysiajs/swagger.

31 | const typebox_1 = require("../typebox");
32 | const index_1 = require("../custom/index");
33 | const index_2 = require("../format/index");
34 | class TypeSystemDuplicateTypeKind extends Error {
35 |     constructor(kind) {
36 |         super(`Duplicate kind '${kind}' detected`);
            ^
error: Duplicate kind 'File' detected
      at new TypeSystemDuplicateTypeKind (/node_modules/@sinclair/typebox/system/system.js:36:8)
      at CreateType (/node_modules/@sinclair/typebox/system/system.js:56:18)
      at /node_modules/elysia/dist/custom-types.js:1:1031
      at /node_modules/elysia/dist/index.js:1:9516

For your reference, the tested package versions are as follows:

elysia: 0.3.2
@elysiajs/cookie: 0.3.0
@elysiajs/static: 0.3.2
@elysiajs/swagger: 0.3.0

@SaltyAom
Copy link
Member

This might sound weird but while I was able to replicate the error, seems like Bun accidentally installed an experimental channel instead of stable randomly causing the type error.

To verify, can you please go into node_modules/@elysiajs/static, the correct results should be no node_modules folder inside, but if so, can you please go inside the node_modules/@elysiajs/static/node_modules/elysia/package.json and see if the version match your installed version.

If this happens, can you try deleting node_modules, and bun.lockb and reinstall again using bun install, restart your IDE if needed, and see if the problem stills persists?

If the issue still persists, can you please try again with either npm / yarn / pnpm to see if the problem still occurs?

@SaltyAom
Copy link
Member

Additionally, I found that, this occurs only when you update from elysia version with plugin installed.

So, suppose you previously has Elysia 0.3.1 installed with @elysiajs/cookie, @elysiajs/static, and @elysiajs/swagger, and then update to Elysia 0.3.2, bun install for some reason, will grab the latest release (regardless of channel) instead of reusing the installed module.

Deleting node_modules and bun.lockb solve the problem, for some reason.

Will report this to Bun.

@tnraro
Copy link
Author

tnraro commented Mar 29, 2023

Oh, There was a node_modules folder inside node_modules/@elysiajs/static, and the elysia version inside it was locked at 0.3.1. I resolved the issue by deleting the node_modules and bun.lockb as you wrote. Thank you.

@tnraro tnraro closed this as completed Mar 29, 2023
@SaltyAom SaltyAom added the good first issue Good for newcomers label Apr 8, 2023
@SaltyAom SaltyAom pinned this issue Apr 8, 2023
@SaltyAom SaltyAom changed the title Type error occurs when using plugins in 0.3.2 Plugin type error after updating Elysia version Apr 28, 2023
@1bye
Copy link

1bye commented Dec 27, 2023

@SaltyAom Hi! After updating elysia from 0.7.21 to 0.8.5 got error:

TypeError: Spread syntax requires ...iterable not be null or undefined
      at _use (/home/mrbye/Documents/GitHub/flow-server/node_modules/elysia/dist/bun/index.js:341:34605)
      at /home/mrbye/Documents/GitHub/flow-server/node_modules/elysia-autoroutes/dist/index.js:10186:5
      at processTicksAndRejections (:61:77)

(Also tested 0.8.3 and 0.8.0 which throwing errors too, but 0.7.31 don't throw)
As you can see I use elysia-autoroutes
Thanks

@kravetsone
Copy link
Contributor

kravetsone commented Dec 27, 2023

@SaltyAom Hi! After updating elysia from 0.7.21 to 0.8.5 got error:

TypeError: Spread syntax requires ...iterable not be null or undefined
      at _use (/home/mrbye/Documents/GitHub/flow-server/node_modules/elysia/dist/bun/index.js:341:34605)
      at /home/mrbye/Documents/GitHub/flow-server/node_modules/elysia-autoroutes/dist/index.js:10186:5
      at processTicksAndRejections (:61:77)

(Also tested 0.8.3 and 0.8.0 which throwing errors too, but 0.7.31 don't throw)
As you can see I use elysia-autoroutes
Thanks

@1bye when i used this library, i got the same error)
And i release a elysia-autoload plugin
You can use it instead of elysia-autoroutes
https://github.com/kravetsone/elysia-autoload

@1bye
Copy link

1bye commented Dec 28, 2023

@kravetsone Hi! Thanks for this plugin

@kravetsone
Copy link
Contributor

@kravetsone Hi! Thanks for this plugin, but unfortunately is not working, the same error:

TypeError: Spread syntax requires ...iterable not be null or undefined
      at _use (/home/mrbye/Documents/GitHub/flow-server/node_modules/elysia/dist/bun/index.js:341:34613)

But maybe this error occurs because in your plugin, elysia version is 0.7.31

In my plugin elysia version never been 0.7.31...

@1bye
Copy link

1bye commented Dec 28, 2023

@kravetsone Sorry this error was in my project, I've installed your plugin when I had elysia 0.7.21

@jellydn
Copy link

jellydn commented Feb 12, 2024

Could we open this issue again? This is my starter and got linter and type-checking issue when upgrade from 0.7 to 0.8? jellydn/elysia-demo-app#68

@lnfel
Copy link

lnfel commented May 5, 2024

I just shot myself on the foot with this one. Gonna switch to pnpm now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

7 participants
@jellydn @tnraro @SaltyAom @lnfel @1bye @kravetsone and others