elysiajs / elysia-swagger

A plugin for Elysia to auto-generate Swagger page
MIT License
88 stars 46 forks source link

use(swagger()) return error: The last overload gave the following error. #57

Open tindecken opened 1 year ago

tindecken commented 1 year ago

mouse move to the use(swagger()) return error: The last overload gave the following error.

image

image

But still able to access swagger

image

BeGj commented 1 year ago

No overload matches this call.
The last overload gave the following error.
Argument of type '(app: Elysia<"", { request: {}; store: {}; }, { type: {}; error: {}; }, {}, {}, false>) => Elysia<"", { request: {}; store: {}; }, { type: {}; error: {}; }, {}, {}, false>' is not assignable to parameter of type 'Promise<{ default: Elysia<any, any, any, any, any, any>; }>'.ts(2769)
index.d.ts(392, 5): The last overload is declared here.

Same issue here. The app compiles and swagger works fine. But the editor is complaining.

bun v1.0.7 and bun.lockdb:

# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
# yarn lockfile v1
# bun ./bun.lockb --hash: C34DBC2701F70AE4-69e0f13ce5c1229c-44F8A9453AFAA2DC-d5a07984016a1325

"@elysiajs/swagger@^0.7.4": 
  version "0.7.4"
  resolved "https://registry.npmjs.org/@elysiajs/swagger/-/swagger-0.7.4.tgz"
  integrity sha512-dTZ2ucf9cBgol8X8ekq7dVJ7agw1bvB4ICMpOf7lihfIA8Te3Z0FpXPuGkog27qUKJC8LF5xLxcGwJtAFiVeSg==
  dependencies: 
    "@types/lodash.clonedeep" "^4.5.7"
    "@types/swagger-ui" "^3.52.2"
    lodash.clonedeep "^4.5.0"
    openapi-types "^12.1.3"

"@sinclair/typebox@^0.31.17": 
  version "0.31.18"
  resolved "https://registry.npmjs.org/@sinclair/typebox/-/typebox-0.31.18.tgz"
  integrity sha512-p2JGz+SciGJVl1zokCIK15f7LYDrI2ZsxItcLhkAyx50hEYEj/Qdy7z30qRYiakzdIu8dV4DfBi+e6xEZuugiQ==

"@sinclair/typebox@^0.31.17": 
  version "0.31.21"
  resolved "https://registry.npmjs.org/@sinclair/typebox/-/typebox-0.31.21.tgz"
  integrity sha512-Wtq/K44EMkREaXytK+2c5DrygtYsH7ZxT0StQL8HMJz2BoOM7NZ/xfrUFBVuZxDrhJCoXf5Im282P2CCz5DHwQ==

"@types/lodash@*": 
  version "4.14.200"
  resolved "https://registry.npmjs.org/@types/lodash/-/lodash-4.14.200.tgz"
  integrity sha512-YI/M/4HRImtNf3pJgbF+W6FrXovqj+T+/HpENLTooK9PnkacBsDpeP3IpHab40CClUfhNmdM2WTNP2sa2dni5Q==

"@types/lodash.clonedeep@^4.5.7": 
  version "4.5.8"
  resolved "https://registry.npmjs.org/@types/lodash.clonedeep/-/lodash.clonedeep-4.5.8.tgz"
  integrity sha512-I5toZLLfTvhnuAnejjVgSpBSLSC316bVURbI0sCYI0dKY3jaJgOg2arfPC6miTNnHRi/Tk/J6BB+kzT3iB5mcw==
  dependencies: 
    "@types/lodash" "*"

"@types/swagger-ui@^3.52.2": 
  version "3.52.3"
  resolved "https://registry.npmjs.org/@types/swagger-ui/-/swagger-ui-3.52.3.tgz"
  integrity sha512-CeD8e7peng0ONguJiDsUOaebsf39Dthxqt1geUNecgFFtuKTGxN8D+FEAEkJi3AH4sKf5v42eijU5QGcwL4K7g==

bun-types@latest: 
  version "1.0.7"
  resolved "https://registry.npmjs.org/bun-types/-/bun-types-1.0.7.tgz"
  integrity sha512-zlIp+SCutbbugs6xDy+3WC3KO3zKySpF/bRfiTk/VJUdKt+WHAzlCtLplS7XglRYDFzhRhlzXMW/R5BHkw+u2Q==

commander@^11.1.0: 
  version "11.1.0"
  resolved "https://registry.npmjs.org/commander/-/commander-11.1.0.tgz"
  integrity sha512-yPVavfyCcRhmorC7rWlkHn15b4wDVgVmBA7kV4QVBsF7kv/9TKJAbAXVTxvTnwP8HHKjRCJDClKbciiYS7p0DQ==

cookie@^0.5.0: 
  version "0.5.0"
  resolved "https://registry.npmjs.org/cookie/-/cookie-0.5.0.tgz"
  integrity sha512-YZ3GUyn/o8gfKJlnlX7g7xq4gyO6OSuhGPKaaGssGB2qgDUS0gPgtTvoyZLTt9Ab6dC4hfc9dV5arkvc/OCmrw==

"elysia@>= 0.7.0": 
  version "0.7.17"
  resolved "https://registry.npmjs.org/elysia/-/elysia-0.7.17.tgz"
  integrity sha512-d+kopAonTBezt5ATijVAe4pwvbxTr+yQAP52K8cbMwbHR07HmnwFa4EpZi+sAjqCU20CJNIs1WpJFnnie2ukwQ==
  dependencies: 
    "@sinclair/typebox" "^0.31.17"
    cookie "^0.5.0"
    eventemitter3 "^5.0.1"
    fast-querystring "^1.1.2"
    memoirist "0.1.4"
    openapi-types "^12.1.3"

elysia@^0.7.21: 
  version "0.7.21"
  resolved "https://registry.npmjs.org/elysia/-/elysia-0.7.21.tgz"
  integrity sha512-E0QVS8ry6PGU195FqJPH1B9BViXI0lveazr8zzuojiBwhPZBcL8aeWfIcSyF44i/T+zppeNGrlInU/mpiTZKVg==
  dependencies: 
    "@sinclair/typebox" "^0.31.17"
    cookie "^0.5.0"
    eventemitter3 "^5.0.1"
    fast-querystring "^1.1.2"
    memoirist "0.1.4"
    openapi-types "^12.1.3"

eventemitter3@^5.0.1: 
  version "5.0.1"
  resolved "https://registry.npmjs.org/eventemitter3/-/eventemitter3-5.0.1.tgz"
  integrity sha512-GWkBvjiSZK87ELrYOSESUYeVIc9mvLLf/nXalMOS5dYrgZq9o5OVkbZAVM06CVxYsCwH9BDZFPlQTlPA1j4ahA==

fast-decode-uri-component@^1.0.1: 
  version "1.0.1"
  resolved "https://registry.npmjs.org/fast-decode-uri-component/-/fast-decode-uri-component-1.0.1.tgz"
  integrity sha512-WKgKWg5eUxvRZGwW8FvfbaH7AXSh2cL+3j5fMGzUMCxWBJ3dV3a7Wz8y2f/uQ0e3B6WmodD3oS54jTQ9HVTIIg==

fast-querystring@^1.1.2: 
  version "1.1.2"
  resolved "https://registry.npmjs.org/fast-querystring/-/fast-querystring-1.1.2.tgz"
  integrity sha512-g6KuKWmFXc0fID8WWH0jit4g0AGBoJhCkJMb1RmbsSEUNvQ+ZC8D6CUZ+GtF8nMzSPXnhiePyyqqipzNNEnHjg==
  dependencies: 
    fast-decode-uri-component "^1.0.1"

lodash.clonedeep@^4.5.0: 
  version "4.5.0"
  resolved "https://registry.npmjs.org/lodash.clonedeep/-/lodash.clonedeep-4.5.0.tgz"
  integrity sha512-H5ZhCF25riFd9uB5UCkVKo61m3S/xZk1x4wA6yp/L3RFP6Z/eHH1ymQcGLo7J3GMPfm0V/7m1tryHuGVxpqEBQ==

memoirist@0.1.4: 
  version "0.1.4"
  resolved "https://registry.npmjs.org/memoirist/-/memoirist-0.1.4.tgz"
  integrity sha512-D6GbPSqO2nUVOmm7VZjJc5tC60pkOVUPzLwkKl1vCiYP+2b1cG8N9q1O3P0JmNM68u8vsgefPbxRUCSGxSXD+g==

openapi-types@^12.1.3: 
  version "12.1.3"
  resolved "https://registry.npmjs.org/openapi-types/-/openapi-types-12.1.3.tgz"
  integrity sha512-N4YtSYJqghVu4iek2ZUvcN/0aqH1kRDuNqzcycDxhOUpg7GdvLa2F3DgS6yBNhInhv2r/6I0Flkn7CqL8+nIcw==

"typescript@>= 5.0.0", typescript@^5.0.0: 
  version "5.2.2"
  resolved "https://registry.npmjs.org/typescript/-/typescript-5.2.2.tgz"
  integrity sha512-mI4WrpHsbCIcwT9cF4FZvr80QUeKvsUsUvKDoR+X/7XHQH98xYD8YHZg7ANtz2GtZt/CBq2QJ0thkGJMHfqc1w==
besmillahibrahimi commented 1 year ago

I think this is somehow a bug of Elysiajs because I have such type complaining while using @elysiajs/jwt and many more plugins.

Mudbill commented 10 months ago

I got the same type errors after upgrading Elysia and the plugins. I don't know why.

I tried deleting node_modules and purging the Bun cache and reinstalling, but same issue. But if I bun create elysia <name> again and add the plugins anew, I don't get the issue. I investigated some and found both the old and new project to be using the exact same versions of both Elysia and the plugins (checked the package.json inside node_modules for each).

Maybe resetting the lockfile would help, that's the only thing I can think of that I didn't try.

I ended up just moving all the source code over to the newly created project folder, and the issue was "fixed".

It smells like some kind of versioning or caching on Bun's side, but I honestly have no clue.

maxios commented 2 months ago

I got the same type errors after upgrading Elysia and the plugins. I don't know why.

I tried deleting node_modules and purging the Bun cache and reinstalling, but same issue. But if I bun create elysia <name> again and add the plugins anew, I don't get the issue. I investigated some and found both the old and new project to be using the exact same versions of both Elysia and the plugins (checked the package.json inside node_modules for each).

Maybe resetting the lockfile would help, that's the only thing I can think of that I didn't try.

I ended up just moving all the source code over to the newly created project folder, and the issue was "fixed".

It smells like some kind of versioning or caching on Bun's side, but I honestly have no clue.

Yes, I have deleted bun.lcokb file and node_modules and then bun install it again. The editor typescript stopped crying. It is versioning issue