barthofu / tscord

🤖 A fully-featured discord bot template written in Typescript, intended to provide a framework that's easy to use, extend and modify
https://tscord.discbot.app
MIT License
251 stars 19 forks source link

[Bug] yarn & pnpm unsupported #66

Closed airone01 closed 2 years ago

airone01 commented 2 years ago

What happened?

I cannot build or run dev with the latest version pulled from github

Reproduction

Relevant log output

src/api/controllers/health.ts:26:50 - error TS2339: Property 'get' does not exist on type 'SqlEntityRepository<object>'.

26             lastStartup: await this.db.get(Data).get('lastStartup'),
                                                    ~~~

src/commands/Admin/prefix.ts:44:14 - error TS2339: Property 'prefix' does not exist on type 'object'.

44    guildData.prefix = prefix || null
                ~~~~~~

src/events/custom/simpleCommandCreate.ts:31:33 - error TS2339: Property 'updateLastInteract' does not exist on type 'SqlEntityRepository<object>'.

31         await this.db.get(User).updateLastInteract(command.message.author.id)
                                   ~~~~~~~~~~~~~~~~~~

src/events/custom/simpleCommandCreate.ts:32:34 - error TS2339: Property 'updateLastInteract' does not exist on type 'SqlEntityRepository<object>'.

32         await this.db.get(Guild).updateLastInteract(command.message.guild?.id)
                                    ~~~~~~~~~~~~~~~~~~

src/events/interactionCreate.ts:37:33 - error TS2339: Property 'updateLastInteract' does not exist on type 'SqlEntityRepository<object>'.

37         await this.db.get(User).updateLastInteract(interaction.user.id)
                                   ~~~~~~~~~~~~~~~~~~

src/events/interactionCreate.ts:38:34 - error TS2339: Property 'updateLastInteract' does not exist on type 'SqlEntityRepository<object>'.

38         await this.db.get(Guild).updateLastInteract(interaction.guild?.id)
                                    ~~~~~~~~~~~~~~~~~~

src/events/ready.ts:56:33 - error TS2339: Property 'set' does not exist on type 'SqlEntityRepository<object>'.

56         await this.db.get(Data).set('lastStartup', Date.now())
                                   ~~~

src/services/Database.ts:55:43 - error TS2769: No overload matches this call.
  Overload 1 of 2, '(entityName: EntityName<object>): SqlEntityRepository<object>', gave the following error.
    Argument of type 'EntityName<T>' is not assignable to parameter of type 'EntityName<object>'.
      Type 'EntitySchema<T, any>' is not assignable to type 'EntityName<object>'.
        Type 'EntitySchema<T, any>' is not assignable to type 'EntitySchema<object, any>'.
          Types of property 'addProperty' are incompatible.
            Type '(name: string & keyof T, type?: TypeType | undefined, options?: EntityProperty<any> | PropertyOptions<T> | undefined) => void' is not assignable to type '(name: never, type?: TypeType | undefined, options?: EntityProperty<any> | PropertyOptions<object> | undefined) => void'.
              Types of parameters 'options' and 'options' are incompatible.
                Type 'EntityProperty<any> | PropertyOptions<object> | undefined' is not assignable to type 'EntityProperty<any> | PropertyOptions<T> | undefined'.
                  Type 'PropertyOptions<object>' is not assignable to type 'EntityProperty<any> | PropertyOptions<T> | undefined'.
                    Type 'PropertyOptions<object>' is not assignable to type 'PropertyOptions<T>'.
                      Type 'T' is not assignable to type 'object'.
  Overload 2 of 2, '(entityName: EntityName<object>): EntityRepository<object>', gave the following error.
    Argument of type 'EntityName<T>' is not assignable to parameter of type 'EntityName<object>'.

55         return this._orm.em.getRepository(entity)
                                             ~~~~~~

src/services/ImagesUpload.ts:31:9 - error TS2322: Type 'SqlEntityRepository<object>' is not assignable to type 'ImageRepository'.
  Types of property 'entityName' are incompatible.
    Type 'EntityName<object>' is not assignable to type 'EntityName<Image>'.
      Type 'EntitySchema<object, any>' is not assignable to type 'EntityName<Image>'.
        Type 'EntitySchema<object, any>' is not assignable to type 'EntitySchema<Image, any>'.
          The types of 'meta.addProperty' are incompatible between these types.
            Type '(prop: EntityProperty<object>, sync?: boolean | undefined) => void' is not assignable to type '(prop: EntityProperty<Image>, sync?: boolean | undefined) => void'.
              Types of parameters 'prop' and 'prop' are incompatible.
                Type 'EntityProperty<Image>' is not assignable to type 'EntityProperty<object>'.
                  Types of property 'name' are incompatible.
                    Type 'string' is not assignable to type 'never'.
                      Type 'string' is not assignable to type 'never'.

31         this.imageRepo = this.db.get(Image)
           ~~~~~~~~~~~~~~

src/services/Pastebin.ts:50:49 - error TS2339: Property 'editCode' does not exist on type 'object'.

50         await this.client.deletePaste(id, paste.editCode)
                                                   ~~~~~~~~

src/services/Pastebin.ts:60:51 - error TS2339: Property 'createdAt' does not exist on type 'object'.

60             const diff = dayjs().diff(dayjs(paste.createdAt), 'day')
                                                     ~~~~~~~~~

src/services/Pastebin.ts:62:31 - error TS2339: Property 'lifetime' does not exist on type 'object'.

62             if (diff >= paste.lifetime) {
                                 ~~~~~~~~

src/services/Pastebin.ts:63:53 - error TS2339: Property 'id' does not exist on type 'object'.

63                 await this.client.deletePaste(paste.id, paste.editCode)
                                                       ~~

src/services/Pastebin.ts:63:63 - error TS2339: Property 'editCode' does not exist on type 'object'.

63                 await this.client.deletePaste(paste.id, paste.editCode)
                                                                 ~~~~~~~~

src/services/Stats.ts:34:9 - error TS2322: Type 'SqlEntityRepository<object>' is not assignable to type 'EntityRepository<Stat>'.
  Types of property 'entityName' are incompatible.
    Type 'EntityName<object>' is not assignable to type 'EntityName<Stat>'.
      Type 'EntitySchema<object, any>' is not assignable to type 'EntityName<Stat>'.
        Type 'EntitySchema<object, any>' is not assignable to type 'EntitySchema<Stat, any>'.
          The types of 'meta.addProperty' are incompatible between these types.
            Type '(prop: EntityProperty<object>, sync?: boolean | undefined) => void' is not assignable to type '(prop: EntityProperty<Stat>, sync?: boolean | undefined) => void'.
              Types of parameters 'prop' and 'prop' are incompatible.
                Type 'EntityProperty<Stat>' is not assignable to type 'EntityProperty<object>'.
                  Types of property 'name' are incompatible.
                    Type 'string' is not assignable to type 'never'.
                      Type 'string' is not assignable to type 'never'.

34         this.statsRepo = this.db.get(Stat)
           ~~~~~~~~~~~~~~

src/services/Stats.ts:179:32 - error TS2339: Property 'id' does not exist on type 'object'.

179                     user: user.id
                                   ~~

src/services/Stats.ts:201:49 - error TS2339: Property 'getActiveGuilds' does not exist on type 'SqlEntityRepository<object>'.

201         const guilds = await this.db.get(Guild).getActiveGuilds()
                                                    ~~~~~~~~~~~~~~~

src/utils/functions/database.ts:20:30 - error TS2339: Property 'add' does not exist on type 'SqlEntityRepository<object>'.

20         await dataRepository.add(
                                ~~~

src/utils/functions/image.ts:25:19 - error TS2339: Property 'url' does not exist on type 'object'.

25     return image?.url || null
                     ~~~

src/utils/functions/maintenance.ts:12:46 - error TS2339: Property 'get' does not exist on type 'SqlEntityRepository<object>'.

12     const maintenance = await dataRepository.get('maintenance')
                                                ~~~

src/utils/functions/maintenance.ts:23:26 - error TS2339: Property 'set' does not exist on type 'SqlEntityRepository<object>'.

23     await dataRepository.set('maintenance', maintenance)
                            ~~~

src/utils/functions/prefix.ts:19:23 - error TS2339: Property 'prefix' does not exist on type 'object'.

19     return guildData?.prefix || generalConfig.simpleCommandsPrefix
                         ~~~~~~

src/utils/functions/synchronizer.ts:100:40 - error TS2339: Property 'getActiveGuilds' does not exist on type 'SqlEntityRepository<object>'.

100     const guildsData = await guildRepo.getActiveGuilds()
                                           ~~~~~~~~~~~~~~~

Found 23 errors in 14 files.

Errors  Files
     1  src/api/controllers/health.ts:26
     1  src/commands/Admin/prefix.ts:44
     2  src/events/custom/simpleCommandCreate.ts:31
     2  src/events/interactionCreate.ts:37
     1  src/events/ready.ts:56
     1  src/services/Database.ts:55
     1  src/services/ImagesUpload.ts:31
     5  src/services/Pastebin.ts:50
     3  src/services/Stats.ts:34
     1  src/utils/functions/database.ts:20
     1  src/utils/functions/image.ts:25
     2  src/utils/functions/maintenance.ts:12
     1  src/utils/functions/prefix.ts:19
     1  src/utils/functions/synchronizer.ts:100
 ELIFECYCLE  Command failed with exit code 2.

Code of Conduct

airone01 commented 2 years ago

Ok, the template is working as intended if I use npm and not pnpm, which I would guess is because the code only works with a specific version of the pakages.

The exact same error occurs with yarn, as it automatically updates the packages like pnpm does

airone01 commented 2 years ago

This issue is now pretty useless. I can see two directions to take from this:

  1. We add support for pnpm (which has another package-lock file, not the native npm one, so more work)
  2. We ignore it and remove this issue because it's now useless

You decide @barthofu

barthofu commented 2 years ago

Fixed in the v2 with the use of tsed instead of routing-controllers and the bump of typescript to the 4.8.x version