crybapp / api

Core service used to handle events from clients
MIT License
36 stars 8 forks source link

Running the "npm run dev" gives errors involving a type of "user" #2

Closed RW456 closed 4 years ago

RW456 commented 5 years ago

I ran npm run dev, and it's giving me 22 errors involving a "user" and something related to conversion. Node 10, Centos 7, I did edit config file. Here's what it said:

7:23:30 PM - Starting compilation in watch mode... src/controllers/admin.controller.ts(161,60): error TS2345: Argument of type 'User' is not assignable to parameter of type 'string | User'. Type 'User' is missing the following properties from type 'User': id, joinedAt, username, roles, and 13 more. src/controllers/controller.controller.ts(12,22): error TS2352: Conversion of type 'Request<Dictionary>' to type '{ user: User; }' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first. Types of property 'user' are incompatible. Type 'User' is missing the following properties from type 'User': id, joinedAt, username, roles, and 13 more. src/controllers/controller.controller.ts(25,22): error TS2352: Conversion of type 'Request<Dictionary>' to type '{ user: User; }' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first. Types of property 'user' are incompatible. Type 'Express.User' is not comparable to type 'import("/home/rob/hildacordCryb/api/src/models/user/index").default'. src/controllers/controller.controller.ts(39,22): error TS2352: Conversion of type 'Request<Dictionary>' to type '{ user: User; }' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first. Types of property 'user' are incompatible. Type 'Express.User' is not comparable to type 'import("/home/rob/hildacordCryb/api/src/models/user/index").default'. src/controllers/invite.controller.ts(12,22): error TS2352: Conversion of type 'Request<Dictionary>' to type '{ user: User; }' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first. Types of property 'user' are incompatible. Type 'Express.User' is not comparable to type 'import("/home/rob/hildacordCryb/api/src/models/user/index").default'. src/controllers/invite.controller.ts(16,89): error TS2345: Argument of type 'User' is not assignable to parameter of type 'string | User'. Type 'Express.User' is not assignable to type 'import("/home/rob/hildacordCryb/api/src/models/user/index").default'. src/controllers/invite.controller.ts(25,22): error TS2352: Conversion of type 'Request<Dictionary>' to type '{ user: User; }' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first. Types of property 'user' are incompatible. Type 'Express.User' is not comparable to type 'import("/home/rob/hildacordCryb/api/src/models/user/index").default'. src/controllers/member.controller.ts(12,22): error TS2352: Conversion of type 'Request<Dictionary>' to type '{ user: User; }' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first. Types of property 'user' are incompatible. Type 'Express.User' is not comparable to type 'import("/home/rob/hildacordCryb/api/src/models/user/index").default'. src/controllers/message.controller.ts(15,22): error TS2352: Conversion of type 'Request<Dictionary>' to type '{ user: User; }' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first. Types of property 'user' are incompatible. Type 'Express.User' is not comparable to type 'import("/home/rob/hildacordCryb/api/src/models/user/index").default'. src/controllers/message.controller.ts(32,22): error TS2352: Conversion of type 'Request<Dictionary>' to type '{ user: User; }' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first. Types of property 'user' are incompatible. Type 'Express.User' is not comparable to type 'import("/home/rob/hildacordCryb/api/src/models/user/index").default'. src/controllers/message.controller.ts(45,22): error TS2352: Conversion of type 'Request<Dictionary>' to type '{ user: User; }' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first. Types of property 'user' are incompatible. Type 'Express.User' is not comparable to type 'import("/home/rob/hildacordCryb/api/src/models/user/index").default'. src/controllers/message.controller.ts(57,31): error TS2345: Argument of type 'Express.User' is not assignable to parameter of type 'import("/home/rob/hildacordCryb/api/src/models/user/index").default'. src/controllers/room.controller.ts(13,22): error TS2352: Conversion of type 'Request<Dictionary>' to type '{ user: User; }' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first. Types of property 'user' are incompatible. Type 'Express.User' is not comparable to type 'import("/home/rob/hildacordCryb/api/src/models/user/index").default'. src/controllers/room.controller.ts(35,22): error TS2352: Conversion of type 'Request<Dictionary>' to type '{ user: User; }' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first. Types of property 'user' are incompatible. Type 'Express.User' is not comparable to type 'import("/home/rob/hildacordCryb/api/src/models/user/index").default'. src/controllers/room.controller.ts(52,22): error TS2352: Conversion of type 'Request<Dictionary>' to type '{ user: User; }' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first. Types of property 'user' are incompatible. Type 'Express.User' is not comparable to type 'import("/home/rob/hildacordCryb/api/src/models/user/index").default'. src/controllers/room.controller.ts(66,22): error TS2352: Conversion of type 'Request<Dictionary>' to type '{ user: User; }' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first. Types of property 'user' are incompatible. Type 'Express.User' is not comparable to type 'import("/home/rob/hildacordCryb/api/src/models/user/index").default'. src/controllers/room.controller.ts(85,22): error TS2352: Conversion of type 'Request<Dictionary>' to type '{ user: User; }' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first. Types of property 'user' are incompatible. Type 'Express.User' is not comparable to type 'import("/home/rob/hildacordCryb/api/src/models/user/index").default'. src/controllers/room.controller.ts(104,22): error TS2352: Conversion of type 'Request<Dictionary>' to type '{ user: User; }' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first. Types of property 'user' are incompatible. Type 'Express.User' is not comparable to type 'import("/home/rob/hildacordCryb/api/src/models/user/index").default'. src/controllers/room.controller.ts(114,55): error TS2345: Argument of type 'Express.User' is not assignable to parameter of type 'import("/home/rob/hildacordCryb/api/src/models/user/index").default'. src/controllers/room.controller.ts(123,22): error TS2352: Conversion of type 'Request<Dictionary>' to type '{ user: User; }' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first. Types of property 'user' are incompatible. Type 'Express.User' is not comparable to type 'import("/home/rob/hildacordCryb/api/src/models/user/index").default'. src/controllers/user.controller.ts(13,22): error TS2352: Conversion of type 'Request<Dictionary>' to type '{ user: User; }' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first. Types of property 'user' are incompatible. Type 'Express.User' is not comparable to type 'import("/home/rob/hildacordCryb/api/src/models/user/index").default'. src/controllers/user.controller.ts(25,22): error TS2352: Conversion of type 'Request<Dictionary>' to type '{ user: User; }' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first. Types of property 'user' are incompatible. Type 'Express.User' is not comparable to type 'import("/home/rob/hildacordCryb/api/src/models/user/index").default'. 7:23:38 PM - Found 22 errors. Watching for file changes.

Am I doing something wrong?

ujukauboi commented 5 years ago

Making progress right now, changed all (most?) of the controllers where req as { user: User } to req.user as { user: User }. Also, made sure to copy and update a version of .env for both web and api. Made sure redis/mongod were installed. You'll also need Discord creds.

I also may have broke everything, we will see.

NootThePenguin commented 5 years ago

Use yarn instead

Making progress right now, changed all (most?) of the controllers where req as { user: User } to req.user as { user: User }. Also, made sure to copy and update a version of .env for both web and api. Made sure redis/mongod were installed. You'll also need Discord creds.

I also may have broke everything, we will see.

ujukauboi commented 5 years ago

Looks like Discord gives the code /?code=xxx but the server doesn't accept it?

NootThePenguin commented 5 years ago

Looks like Discord gives the code /?code=xxx but the server doesn't accept it?

Do you get redirected? Are you in the cryb discord? If so check out #programming we've been helping each other out.

Akrilla commented 5 years ago

needs confirmed if this is an issue

NootThePenguin commented 5 years ago

needs confirmed if this is an issue

npm is the issue in this case (it's broken and confirmed by William) https://i.imgur.com/uS0hY1S.png

darnfish commented 5 years ago

I'll look into this locally soon, seems like an issue where the dependencies used for TypeScript types aren't properly being installed, might be because those dependencies are listed under devDependencies in package.json.

ujukauboi commented 5 years ago

Looks like Discord gives the code /?code=xxx but the server doesn't accept it?

Do you get redirected? Are you in the cryb discord? If so check out #programming we've been helping each other out.

Joined thanks!

Akrilla commented 5 years ago

dev dependencies can be installed with a flag on npm, but these should be part of the core dependencies anyway.

jiayang commented 5 years ago

This happens using yarn as well now.

darnfish commented 5 years ago

We just reverted to the last working version, looks like Dependabot messed a couple things up. Try running git pull && git reset --soft 84eb2e1b80ea2c2c558e1d154ffdaa3beacaf972 and then yarn again and try again. Sorry for the issue, closing this out for now!

JeDaYoshi commented 5 years ago

This was happening since before with npm though..

darnfish commented 5 years ago

My dumbass thought this was related to the dependabot stuff, reopening. Last message still applies with yarn @jiayang, reopening 🙃

JeDaYoshi commented 4 years ago

This got fixed already. Closing!