elysiajs / elysia

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

Elysia's fork of Typebox (`t`) seems to break on v1.0.10 #583

Closed mateo-m closed 3 months ago

mateo-m commented 3 months ago

What version of Elysia.JS is running?

^1.0.10

What platform is your computer?

Darwin 23.4.0 arm64 arm

What steps can reproduce the bug?

Here's a simple chunk of code to reproduce the issue:

import { pgTable, varchar } from "drizzle-orm/pg-core";

import { createSelectSchema } from "drizzle-typebox";

import { t, Static } from "elysia";

export const products = pgTable("products", {
  id: varchar("id", { length: 64 }).notNull().primaryKey(),
  name: varchar("name", { length: 32 }).notNull(),
});

export const selectProductSchema = createSelectSchema(products);

export const GetProductsDTO = t.Pick(selectProductSchema, ["name"]);

export function getProducts(args: Static<typeof GetProductsDTO>) {
  console.log(args.name);
}

What is the expected behavior?

Any method from t should work as before (pre-v1).

What do you see instead?

In the t.Pick() method of GetProductsDTO, selectProductSchema shows an error in VS Code:

No overload matches this call.
  The last overload gave the following error.
    Argument of type 'TObject<{ id: TString; name: TString; }>' is not assignable to parameter of type 'TSchema'.
      Property '[Kind]' is missing in type 'TObject<{ id: TString; name: TString; }>' but required in type 'TSchema'.ts(2769)
schema.d.ts(21, 5): '[Kind]' is declared here.
json.d.ts(152, 5): The last overload is declared here.

Additional information

Rolling back to Elysia v0.8.6 seems to fix the issue.

SaltyAom commented 3 months ago

Have you try removing node_modules, bun.lockb and try again yet?

mateo-m commented 3 months ago

Have you try removing node_modules, bun.lockb and try again yet?

Sorry for the late reply - no, but this is the first thing I should've tried... I'll try migrating to v ^1.0.* again and do this, I'll let you know if it fixes the issue I was having

mateo-m commented 3 months ago

Sorry for bothering you with this @SaltyAom, deleting the node_modules and reinstalling dependencies finally fixed the issue - I had to install dependencies/delete the node_modules directory a few (2-3) times to make the error go away tho, weird bug...

eknowles commented 3 months ago

this issue can be closed then?

mateo-m commented 3 months ago

this issue can be closed then?

For sure @eknowles, sorry I forgot to do it