elysiajs / elysia

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

type errors when running `bun -b check-dts` #370

Open btakita opened 8 months ago

btakita commented 8 months ago

Create a package with elysia & check-dts. Run bun -b check-dts.

tsconfig.json

{
    "compileOnSave": true,
    "compilerOptions": {
        "module": "ESNext",
        "moduleResolution": "nodenext",
        "target": "ESNext",
        "strict": true,
        "skipLibCheck": true
    },
    "exclude": [
        "node_modules"
    ],
    "references": []
}

There should be no errors. However, the following errors appear. The first 3 errors are related to elysia. The rest are reported with bun-types.

✖ Check types

✖ ../../node_modules/.pnpm/elysia@0.7.30_@sinclair+typebox@0.32.0_typescript@5.4.0-dev.20231212/node_modules/elysia/dist/type-system.d.ts:2:41: Type error TS2724
  '"@sinclair/typebox"' has no exported member named 'NumericOptions'. Did you mean 'NumberOptions'?

✖ ../../node_modules/.pnpm/elysia@0.7.30_@sinclair+typebox@0.32.0_typescript@5.4.0-dev.20231212/node_modules/elysia/dist/types.d.ts:6:32: Type error TS2307
  Cannot find module 'openapi-types' or its corresponding type declarations.

✖ ../../node_modules/.pnpm/elysia@0.7.30_@sinclair+typebox@0.32.0_typescript@5.4.0-dev.20231212/node_modules/elysia/dist/type-system.d.ts:19:82: Type error TS2304
  Cannot find name 'TUnsafe'.

✖ ../../node_modules/.pnpm/bun-types@1.0.19/node_modules/bun-types/types.d.ts:255:13: Type error TS2502
  'onmessage' is referenced directly or indirectly in its own type annotation.

✖ ../../node_modules/.pnpm/bun-types@1.0.19/node_modules/bun-types/types.d.ts:291:13: Type error TS2502
  'ReadableStream' is referenced directly or indirectly in its own type annotation.

✖ ../../node_modules/.pnpm/bun-types@1.0.19/node_modules/bun-types/types.d.ts:309:13: Type error TS2502
  'WritableStream' is referenced directly or indirectly in its own type annotation.

✖ ../../node_modules/.pnpm/bun-types@1.0.19/node_modules/bun-types/types.d.ts:805:13: Type error TS2502
  'Worker' is referenced directly or indirectly in its own type annotation.

✖ ../../node_modules/.pnpm/bun-types@1.0.19/node_modules/bun-types/types.d.ts:919:13: Type error TS2502
  'File' is referenced directly or indirectly in its own type annotation.

✖ ../../node_modules/.pnpm/bun-types@1.0.19/node_modules/bun-types/types.d.ts:1034:13: Type error TS2502
  'WebSocket' is referenced directly or indirectly in its own type annotation.

✖ ../../node_modules/.pnpm/bun-types@1.0.19/node_modules/bun-types/types.d.ts:1052:13: Type error TS2502
  'Crypto' is referenced directly or indirectly in its own type annotation.

✖ ../../node_modules/.pnpm/bun-types@1.0.19/node_modules/bun-types/types.d.ts:1062:13: Type error TS2502
  'crypto' is referenced directly or indirectly in its own type annotation.

✖ ../../node_modules/.pnpm/bun-types@1.0.19/node_modules/bun-types/types.d.ts:1115:13: Type error TS2502
  'TextEncoder' is referenced directly or indirectly in its own type annotation.

✖ ../../node_modules/.pnpm/bun-types@1.0.19/node_modules/bun-types/types.d.ts:1129:13: Type error TS2502
  'TextDecoder' is referenced directly or indirectly in its own type annotation.

✖ ../../node_modules/.pnpm/bun-types@1.0.19/node_modules/bun-types/types.d.ts:1237:13: Type error TS2502
  'performance' is referenced directly or indirectly in its own type annotation.

✖ ../../node_modules/.pnpm/bun-types@1.0.19/node_modules/bun-types/types.d.ts:1441:13: Type error TS2502
  'Event' is referenced directly or indirectly in its own type annotation.

✖ ../../node_modules/.pnpm/bun-types@1.0.19/node_modules/bun-types/types.d.ts:1448:13: Type error TS2502
  'EventTarget' is referenced directly or indirectly in its own type annotation.

✖ ../../node_modules/.pnpm/bun-types@1.0.19/node_modules/bun-types/types.d.ts:1577:13: Type error TS2502
  'MessageEvent' is referenced directly or indirectly in its own type annotation.

✖ ../../node_modules/.pnpm/bun-types@1.0.19/node_modules/bun-types/types.d.ts:1617:13: Type error TS2502
  'URL' is referenced directly or indirectly in its own type annotation.

✖ ../../node_modules/.pnpm/bun-types@1.0.19/node_modules/bun-types/types.d.ts:1648:13: Type error TS2502
  'URLSearchParams' is referenced directly or indirectly in its own type annotation.

✖ ../../node_modules/.pnpm/bun-types@1.0.19/node_modules/bun-types/types.d.ts:2124:13: Type error TS2502
  'DOMException' is referenced directly or indirectly in its own type annotation.

✖ ../../node_modules/.pnpm/bun-types@1.0.19/node_modules/bun-types/types.d.ts:2146:13: Type error TS2502
  'SubtleCrypto' is referenced directly or indirectly in its own type annotation.

✖ ../../node_modules/.pnpm/bun-types@1.0.19/node_modules/bun-types/types.d.ts:2445:7: Type error TS2502
  'CompileError' is referenced directly or indirectly in its own type annotation.

✖ ../../node_modules/.pnpm/bun-types@1.0.19/node_modules/bun-types/types.d.ts:2465:7: Type error TS2502
  'Global' is referenced directly or indirectly in its own type annotation.

✖ ../../node_modules/.pnpm/bun-types@1.0.19/node_modules/bun-types/types.d.ts:2479:7: Type error TS2502
  'Instance' is referenced directly or indirectly in its own type annotation.

✖ ../../node_modules/.pnpm/bun-types@1.0.19/node_modules/bun-types/types.d.ts:2496:7: Type error TS2502
  'Module' is referenced directly or indirectly in its own type annotation.

✖ ../../node_modules/.pnpm/bun-types@1.0.19/node_modules/bun-types/types.d.ts:2656:13: Type error TS2502
  'EventSource' is referenced directly or indirectly in its own type annotation.

✖ ../../node_modules/.pnpm/bun-types@1.0.19/node_modules/bun-types/types.d.ts:2746:13: Type error TS2502
  'Blob' is referenced directly or indirectly in its own type annotation.

✖ ../../node_modules/.pnpm/bun-types@1.0.19/node_modules/bun-types/types.d.ts:2779:13: Type error TS2502
  'Request' is referenced directly or indirectly in its own type annotation.

✖ ../../node_modules/.pnpm/bun-types@1.0.19/node_modules/bun-types/types.d.ts:2812:13: Type error TS2502
  'Response' is referenced directly or indirectly in its own type annotation.

✖ ../../node_modules/.pnpm/bun-types@1.0.19/node_modules/bun-types/types.d.ts:2878:13: Type error TS2502
  'FormData' is referenced directly or indirectly in its own type annotation.

✖ ../../node_modules/.pnpm/bun-types@1.0.19/node_modules/bun-types/types.d.ts:2891:13: Type error TS2502
  'Headers' is referenced directly or indirectly in its own type annotation.

✖ ../../node_modules/.pnpm/bun-types@1.0.19/node_modules/bun-types/types.d.ts:2919:13: Type error TS2502
  'MessagePort' is referenced directly or indirectly in its own type annotation.

✖ ../../node_modules/.pnpm/bun-types@1.0.19/node_modules/bun-types/types.d.ts:2929:13: Type error TS2502
  'MessageChannel' is referenced directly or indirectly in its own type annotation.

✖ ../../node_modules/.pnpm/bun-types@1.0.19/node_modules/bun-types/types.d.ts:2940:13: Type error TS2502
  'BroadcastChannel' is referenced directly or indirectly in its own type annotation.

✖ ../../node_modules/.pnpm/bun-types@1.0.19/node_modules/bun-types/types.d.ts:2963:13: Type error TS2502
  'AbortController' is referenced directly or indirectly in its own type annotation.

✖ ../../node_modules/.pnpm/bun-types@1.0.19/node_modules/bun-types/types.d.ts:2973:13: Type error TS2502
  'AbortSignal' is referenced directly or indirectly in its own type annotation.
btakita commented 8 months ago

I reported the issue with @sinclair/typebox.

btakita commented 8 months ago

The v0.8 release fixed a couple of the type errors. I'm reopening this because there is still one type error as of v0.8.3.

✖ ../../node_modules/.pnpm/elysia@0.8.3_@sinclair+typebox@0.32.1_typescript@5.4.0-dev.20231212/node_modules/elysia/dist/types.d.ts:6:32: Type error TS2307
  Cannot find module 'openapi-types' or its corresponding type declarations.
kravetsone commented 5 months ago

bun -b check-dts.

I didn't find them in 1.0.0

bunx -b check-dts
✔ Check types
btakita commented 5 months ago

I have the following in the main branch (HEAD commit 8b269257ca46c5d55cb192765758105064b080f8):

➜  elysia git:(main) bun -v
1.0.33
➜  elysia git:(main) bunx -b check-dts
✖ Check types

✖ build.ts:1:10: Type error TS2305
  Module '"bun"' has no exported member '$'.

✖ example/analysis.ts:1:23: Type error TS2307
  Cannot find module 'benchmark' or its corresponding type declarations.

✖ src/type-system.ts:1:23: Type error TS2724
  '"@sinclair/typebox"' has no exported member named 'NumberOptions'. Did you mean 'NumericOptions'?

✖ build.ts:2:37: Type error TS2307
  Cannot find module 'tsup' or its corresponding type declarations.

✖ example/video.ts:4:12: Type error TS2345
  Argument of type 'BunFile' is not assignable to parameter of type 'Handler<MergeSchema<UnwrapRoute<InputSchema<never>, {}>, {}>, { request: {}; store: {}; }, "/">'.

✖ example/extension.ts:5:53: Type error TS2339
  Property 'extends' does not exist on type 'Elysia<"", false, { decorator: {}; store: {}; derive: {}; resolve: {}; }, { type: {}; error: {}; }, { schema: {}; macro: {}; }, {}, { derive: {}; resolve: {}; schema: {}; }, { derive: {}; resolve: {}; schema: {}; }>'.

✖ example/extension.ts:6:5: Type error TS7031
  Binding element 'onBeforeHandle' implicitly has an 'any' type.

✖ example/extension.ts:6:21: Type error TS7031
  Binding element 'events' implicitly has an 'any' type.

✖ test/aot/response.test.ts:9:2: Type error TS2578
  Unused '@ts-expect-error' directive.

✖ example/schema.ts:63:23: Type error TS2339
  Property 'meta' does not exist on type 'Elysia<"", false, { decorator: {}; store: {}; derive: {}; resolve: {}; }, { type: { readonly name: { name: string; }; readonly b: { response: number; }; readonly authorization: { authorization: string; }; }; error: {}; }, { ...; }, { ...; }, { ...; }, { ...; }>'.

✖ example/schema.ts:63:38: Type error TS2304
  Cannot find name 'SCHEMA'.

✖ example/schema.ts:64:23: Type error TS2339
  Property 'meta' does not exist on type 'Elysia<"", false, { decorator: {}; store: {}; derive: {}; resolve: {}; }, { type: { readonly name: { name: string; }; readonly b: { response: number; }; readonly authorization: { authorization: string; }; }; error: {}; }, { ...; }, { ...; }, { ...; }, { ...; }>'.

✖ example/schema.ts:64:38: Type error TS2304
  Cannot find name 'DEFS'.

✖ example/schema.ts:65:23: Type error TS2339
  Property 'meta' does not exist on type 'Elysia<"", false, { decorator: {}; store: {}; derive: {}; resolve: {}; }, { type: { readonly name: { name: string; }; readonly b: { response: number; }; readonly authorization: { authorization: string; }; }; error: {}; }, { ...; }, { ...; }, { ...; }, { ...; }>'.

✖ example/schema.ts:65:38: Type error TS2304
  Cannot find name 'SCHEMA'.

✖ src/ws/types.ts:68:9: Type error TS2503
  Cannot find namespace 'Bun'.

✖ src/ws/types.ts:68:9: Type error TS4081
  Exported type alias 'LocalHook' has or is using private name 'Bun'.

✖ src/ws/types.ts:69:32: Type error TS2503
  Cannot find namespace 'Bun'.

✖ src/ws/types.ts:69:32: Type error TS4081
  Exported type alias 'LocalHook' has or is using private name 'Bun'.

✖ test/lifecycle/transform.test.ts:70:24: Type error TS2554
  Expected 1 arguments, but got 2.

✖ test/core/elysia.test.ts:124:4: Type error TS2578
  Unused '@ts-expect-error' directive.

✖ test/types/scoped.ts:138:50: Type error TS2344
  Type '{ derive: { readonly b: "b"; }; }' does not satisfy the constraint '"Expected: ..., Actual: boolean"'.

✖ test/core/modules.test.ts:141:49: Type error TS2339
  Property 'derived' does not exist on type '{ body: unknown; query: Record<string, string | undefined>; params: never; headers: Record<string, string | undefined>; cookie: Record<string, Cookie<any>>; ... 4 more ...; error: <const Code extends number | ... 59 more ... | "Network Authentication Required", const T = Code extends 100 | ... 58 more ... | 511 ? { ...'.

✖ test/types/scoped.ts:144:51: Type error TS2344
  Type '{ derive: { readonly b: "b"; }; }' does not satisfy the constraint '{ derive: "Expected: ..., Actual: never"; b: "Expected: never, Actual: literal string: b"; }'.

✖ test/types/scoped.ts:144:51: Type error TS2344
  Type '{ derive: { readonly b: "b"; }; }' does not satisfy the constraint '{ derive: "Expected: ..., Actual: never"; b: "Expected: never, Actual: literal string: b"; }'.

✖ test/lifecycle/transform.test.ts:225:24: Type error TS2554
  Expected 1 arguments, but got 2.

✖ src/compose.ts:821:12: Type error TS2339
  Property 'Default' does not exist on type 'typeof Value'.

✖ src/compose.ts:849:12: Type error TS2339
  Property 'Default' does not exist on type 'typeof Value'.

✖ src/compose.ts:877:12: Type error TS2339
  Property 'Default' does not exist on type 'typeof Value'.

✖ src/compose.ts:906:13: Type error TS2339
  Property 'Default' does not exist on type 'typeof Value'.

✖ src/compose.ts:936:12: Type error TS2339
  Property 'Default' does not exist on type 'typeof Value'.

✖ src/index.ts:4266:30: Type error TS2503
  Cannot find namespace 'Bun'.

✖ src/index.ts:5208:7: Type error TS2352
  Conversion of type '{ websocket: { message(ws: ServerWebSocket<any>, message: string | Buffer): void | Promise<void>; open?(ws: ServerWebSocket<any>): void | Promise<...>; ... 10 more ...; perMessageDeflate?: boolean | ... 1 more ... | undefined; }; ... 8 more ...; reusePort: boolean; } | ... 62 more ... | { ...; }' to type 'Serve' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first.

✖ src/index.ts:5220:7: Type error TS2352
  Conversion of type '{ websocket: { message(ws: ServerWebSocket<any>, message: string | Buffer): void | Promise<void>; open?(ws: ServerWebSocket<any>): void | Promise<...>; ... 10 more ...; perMessageDeflate?: boolean | ... 1 more ... | undefined; }; ... 8 more ...; reusePort: boolean; } | ... 6 more ... | { ...; }' to type 'Serve' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first.
kravetsone commented 1 month ago

I have the following in the main branch (HEAD commit 8b26925):

➜  elysia git:(main) bun -v
1.0.33
➜  elysia git:(main) bunx -b check-dts
✖ Check types

✖ build.ts:1:10: Type error TS2305
  Module '"bun"' has no exported member '$'.

✖ example/analysis.ts:1:23: Type error TS2307
  Cannot find module 'benchmark' or its corresponding type declarations.

✖ src/type-system.ts:1:23: Type error TS2724
  '"@sinclair/typebox"' has no exported member named 'NumberOptions'. Did you mean 'NumericOptions'?

✖ build.ts:2:37: Type error TS2307
  Cannot find module 'tsup' or its corresponding type declarations.

✖ example/video.ts:4:12: Type error TS2345
  Argument of type 'BunFile' is not assignable to parameter of type 'Handler<MergeSchema<UnwrapRoute<InputSchema<never>, {}>, {}>, { request: {}; store: {}; }, "/">'.

✖ example/extension.ts:5:53: Type error TS2339
  Property 'extends' does not exist on type 'Elysia<"", false, { decorator: {}; store: {}; derive: {}; resolve: {}; }, { type: {}; error: {}; }, { schema: {}; macro: {}; }, {}, { derive: {}; resolve: {}; schema: {}; }, { derive: {}; resolve: {}; schema: {}; }>'.

✖ example/extension.ts:6:5: Type error TS7031
  Binding element 'onBeforeHandle' implicitly has an 'any' type.

✖ example/extension.ts:6:21: Type error TS7031
  Binding element 'events' implicitly has an 'any' type.

✖ test/aot/response.test.ts:9:2: Type error TS2578
  Unused '@ts-expect-error' directive.

✖ example/schema.ts:63:23: Type error TS2339
  Property 'meta' does not exist on type 'Elysia<"", false, { decorator: {}; store: {}; derive: {}; resolve: {}; }, { type: { readonly name: { name: string; }; readonly b: { response: number; }; readonly authorization: { authorization: string; }; }; error: {}; }, { ...; }, { ...; }, { ...; }, { ...; }>'.

✖ example/schema.ts:63:38: Type error TS2304
  Cannot find name 'SCHEMA'.

✖ example/schema.ts:64:23: Type error TS2339
  Property 'meta' does not exist on type 'Elysia<"", false, { decorator: {}; store: {}; derive: {}; resolve: {}; }, { type: { readonly name: { name: string; }; readonly b: { response: number; }; readonly authorization: { authorization: string; }; }; error: {}; }, { ...; }, { ...; }, { ...; }, { ...; }>'.

✖ example/schema.ts:64:38: Type error TS2304
  Cannot find name 'DEFS'.

✖ example/schema.ts:65:23: Type error TS2339
  Property 'meta' does not exist on type 'Elysia<"", false, { decorator: {}; store: {}; derive: {}; resolve: {}; }, { type: { readonly name: { name: string; }; readonly b: { response: number; }; readonly authorization: { authorization: string; }; }; error: {}; }, { ...; }, { ...; }, { ...; }, { ...; }>'.

✖ example/schema.ts:65:38: Type error TS2304
  Cannot find name 'SCHEMA'.

✖ src/ws/types.ts:68:9: Type error TS2503
  Cannot find namespace 'Bun'.

✖ src/ws/types.ts:68:9: Type error TS4081
  Exported type alias 'LocalHook' has or is using private name 'Bun'.

✖ src/ws/types.ts:69:32: Type error TS2503
  Cannot find namespace 'Bun'.

✖ src/ws/types.ts:69:32: Type error TS4081
  Exported type alias 'LocalHook' has or is using private name 'Bun'.

✖ test/lifecycle/transform.test.ts:70:24: Type error TS2554
  Expected 1 arguments, but got 2.

✖ test/core/elysia.test.ts:124:4: Type error TS2578
  Unused '@ts-expect-error' directive.

✖ test/types/scoped.ts:138:50: Type error TS2344
  Type '{ derive: { readonly b: "b"; }; }' does not satisfy the constraint '"Expected: ..., Actual: boolean"'.

✖ test/core/modules.test.ts:141:49: Type error TS2339
  Property 'derived' does not exist on type '{ body: unknown; query: Record<string, string | undefined>; params: never; headers: Record<string, string | undefined>; cookie: Record<string, Cookie<any>>; ... 4 more ...; error: <const Code extends number | ... 59 more ... | "Network Authentication Required", const T = Code extends 100 | ... 58 more ... | 511 ? { ...'.

✖ test/types/scoped.ts:144:51: Type error TS2344
  Type '{ derive: { readonly b: "b"; }; }' does not satisfy the constraint '{ derive: "Expected: ..., Actual: never"; b: "Expected: never, Actual: literal string: b"; }'.

✖ test/types/scoped.ts:144:51: Type error TS2344
  Type '{ derive: { readonly b: "b"; }; }' does not satisfy the constraint '{ derive: "Expected: ..., Actual: never"; b: "Expected: never, Actual: literal string: b"; }'.

✖ test/lifecycle/transform.test.ts:225:24: Type error TS2554
  Expected 1 arguments, but got 2.

✖ src/compose.ts:821:12: Type error TS2339
  Property 'Default' does not exist on type 'typeof Value'.

✖ src/compose.ts:849:12: Type error TS2339
  Property 'Default' does not exist on type 'typeof Value'.

✖ src/compose.ts:877:12: Type error TS2339
  Property 'Default' does not exist on type 'typeof Value'.

✖ src/compose.ts:906:13: Type error TS2339
  Property 'Default' does not exist on type 'typeof Value'.

✖ src/compose.ts:936:12: Type error TS2339
  Property 'Default' does not exist on type 'typeof Value'.

✖ src/index.ts:4266:30: Type error TS2503
  Cannot find namespace 'Bun'.

✖ src/index.ts:5208:7: Type error TS2352
  Conversion of type '{ websocket: { message(ws: ServerWebSocket<any>, message: string | Buffer): void | Promise<void>; open?(ws: ServerWebSocket<any>): void | Promise<...>; ... 10 more ...; perMessageDeflate?: boolean | ... 1 more ... | undefined; }; ... 8 more ...; reusePort: boolean; } | ... 62 more ... | { ...; }' to type 'Serve' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first.

✖ src/index.ts:5220:7: Type error TS2352
  Conversion of type '{ websocket: { message(ws: ServerWebSocket<any>, message: string | Buffer): void | Promise<void>; open?(ws: ServerWebSocket<any>): void | Promise<...>; ... 10 more ...; perMessageDeflate?: boolean | ... 1 more ... | undefined; }; ... 8 more ...; reusePort: boolean; } | ... 6 more ... | { ...; }' to type 'Serve' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first.

Many of the errors that it shows do not exist...

SaltyAom commented 1 week ago

Does this problem still persists in the latest version?

kravetsone commented 1 week ago

Does this problem still persists in the latest version?

Looks likes this library shows errors which did't exists in elysia source code Idk why