feathersjs / feathers

The API and real-time application framework
https://feathersjs.com
MIT License
15.03k stars 748 forks source link

Type error in bundle:client from freshly generated app #3116

Closed VaughnVink closed 1 year ago

VaughnVink commented 1 year ago

Steps to reproduce

Ran

npm create feathers@latest feathers-chat
? Do you want to use JavaScript or TypeScript? TypeScript
? Write a short description test
? Which HTTP framework do you want to use? KoaJS (recommended)
? What APIs do you want to offer? HTTP (REST), Real-time
? Which package manager are you using? Yarn
? Generate end-to-end typed client? Can be used with React, Angular, Vue, React Native, Node.js etc. Yes
? What is your preferred schema (model) definition format? Schemas allow to type, validate, secure and populate your
data and configuration TypeBox (recommended)
? Which database are you connecting to? Databases can be added at any time SQLite
? Enter your database connection string feathers-chat.sqlite

cd feathers-chat/
yarn bundle:client

Returns:

yarn run v1.22.19
$ npm run compile && npm pack --pack-destination ./public

> feathers-chat@0.0.0 compile
> shx rm -rf lib/ && tsc

node_modules/@feathersjs/typebox/lib/index.d.ts:123:127 - error TS2344: Type '[T["properties"][K_2], TPartial<TIntersect<[TObject<{ $gt: T["properties"][K_2]; $gte: T["properties"][K_2]; $lt: T["properties"][K_2]; $lte: T["properties"][K_2]; $ne: T["properties"][K_2]; $in: TArray<...>; $nin: TArray<...>; }>, TObject<...>]>>]' does not satisfy the constraint 'TSchema[]'.
  Type 'T["properties"][K_2] | TPartial<TIntersect<[TObject<{ $gt: T["properties"][K_2]; $gte: T["properties"][K_2]; $lt: T["properties"][K_2]; $lte: T["properties"][K_2]; $ne: T["properties"][K_2]; $in: TArray<...>; $nin: TArray<...>; }>, TObject<...>]>>' is not assignable to type 'TSchema'.
    Type 'T["properties"][K_2]' is not assignable to type 'TSchema'.
      Type 'T["properties"][keyof T_4]' is not assignable to type 'TSchema'.
        Type 'T["properties"][string] | T["properties"][number] | T["properties"][symbol]' is not assignable to type 'TSchema'.
          Type 'T["properties"][string]' is not assignable to type 'TSchema'.

123 }>>, TOptional<TObject<T["properties"] extends infer T_4 ? { [K_2 in keyof T_4]: TOptional<import("@sinclair/typebox").TUnion<[T["properties"][K_2], import("@sinclair/typebox").TPartial<TIntersect<[TObject<{

          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
124     $gt: T["properties"][K_2];
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
...
130     $nin: import("@sinclair/typebox").TArray<T["properties"][K_2]>;
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
131 }>, TObject<X[K_2]>]>>]>>; } : never>>]>;
    ~~~~~~~~~~~~~~~~~~~~~~~

Found 1 error in node_modules/@feathersjs/typebox/lib/index.d.ts:123

error Command failed with exit code 2.

Expected behavior

Should generate client bundle.

Actual behavior

Returns Typebox error.

System configuration

Tell us about the applicable parts of your setup.

Module versions (especially the part that's not working): "dependencies": { "@feathersjs/adapter-commons": "^5.0.1", "@feathersjs/authentication": "^5.0.1", "@feathersjs/authentication-client": "^5.0.1", "@feathersjs/configuration": "^5.0.1", "@feathersjs/errors": "^5.0.1", "@feathersjs/feathers": "^5.0.1", "@feathersjs/knex": "^5.0.1", "@feathersjs/koa": "^5.0.1", "@feathersjs/schema": "^5.0.1", "@feathersjs/socketio": "^5.0.1", "@feathersjs/transport-commons": "^5.0.1", "@feathersjs/typebox": "^5.0.1", "knex": "^2.4.2", "sqlite3": "^5.1.4", "winston": "^3.8.2" }, "devDependencies": { "@feathersjs/cli": "5.0.1", "@feathersjs/rest-client": "^5.0.1", "@types/mocha": "^10.0.1", "@types/node": "^18.14.6", "axios": "^1.3.4", "cross-env": "^7.0.3", "mocha": "^10.2.0", "nodemon": "^2.0.21", "prettier": "^2.8.4", "shx": "^0.3.4", "ts-node": "^10.9.1", "typescript": "^5.0.2" } NodeJS version: v18.12.1

Operating System: Ubuntu 22.04.2 LTS

Browser Version:

React Native Version:

Module Loader:

Sezar-SZ commented 1 year ago

I have the same issue too!

sikbrad commented 1 year ago

same here. node v16.19.1, mac 12.6 Happens in both feathers feathers@5.0.0 and feathers@latest (5.0.1)

anatollixx commented 1 year ago

same here, node v18.5.0, mac 12.6.3 intel both feathers@5.0.0 and feathers@latest (5.0.1)

daffl commented 1 year ago

This seems to be a TypeScript 5 problem. A fix for now is to install version 4 via

npm i typescript@4
daffl commented 1 year ago

This has been fixed now in v5.0.2 and will install TypeScript 4 in a generated application until everything has been updated to 5.0 and tested.