nestjs-json-api icon indicating copy to clipboard operation
nestjs-json-api copied to clipboard

`TypeOrmOptions` entities field is not compatiable with TypeORM entity

Open ppodds opened this issue 7 months ago • 0 comments
trafficstars

Test Environment

Nest 10


 _   _             _      ___  _____  _____  _     _____
| \ | |           | |    |_  |/  ___|/  __ \| |   |_   _|
|  \| |  ___  ___ | |_     | |\ `--. | /  \/| |     | |
| . ` | / _ \/ __|| __|    | | `--. \| |    | |     | |
| |\  ||  __/\__ \| |_ /\__/ //\__/ /| \__/\| |_____| |_
\_| \_/ \___||___/ \__|\____/ \____/  \____/\_____/\___/


[System Information]
OS Version     : Linux 6.8.0-56-generic
NodeJS Version : v22.14.0
PNPM Version    : 9.15.4 

[Nest CLI]
Nest CLI Version : 10.4.9 

[Nest Platform Information]
platform-express version : 10.4.15
schematics version       : 10.2.3
typeorm version          : 10.0.2
testing version          : 10.4.15
common version           : 10.4.15
core version             : 10.4.15
cli version              : 10.4.9

Nest 11


 _   _             _      ___  _____  _____  _     _____
| \ | |           | |    |_  |/  ___|/  __ \| |   |_   _|
|  \| |  ___  ___ | |_     | |\ `--. | /  \/| |     | |
| . ` | / _ \/ __|| __|    | | `--. \| |    | |     | |
| |\  ||  __/\__ \| |_ /\__/ //\__/ /| \__/\| |_____| |_
\_| \_/ \___||___/ \__|\____/ \____/  \____/\_____/\___/


[System Information]
OS Version     : Linux6.8.0-56-generic
NodeJS Version : v22.14.0
PNPM Version    : 9.15.4 

[Nest CLI]
Nest CLI Version : 11.0.5 

[Nest Platform Information
platform-express version : 11.0.12
schematics version       : 11.0.2
testing version          : 11.0.12
common version           : 11.0.12
core version             : 11.0.12
cli version              : 11.0.5

Reproduce Steps

  1. Create a new project using nest cli (nest new)
  2. Install typeorm, @nestjs/typeorm , json-api-nestjs

src/entities/test.entity.ts

import { Column, Entity, PrimaryGeneratedColumn } from 'typeorm';

@Entity()
export class Test {
  @PrimaryGeneratedColumn()
  id: number;
  @Column({ type: 'varchar', length: 12 })
  name: string;
}

src/app.module.ts

import { Module } from '@nestjs/common';
import { AppController } from './app.controller';
import { AppService } from './app.service';
import { JsonApiModule, TypeOrmJsonApiModule } from 'json-api-nestjs';
import { Test } from './entities/test.entity';

@Module({
  imports: [JsonApiModule.forRoot(TypeOrmJsonApiModule, {
    entities: [Test]
  })],
  controllers: [AppController],
  providers: [AppService],
})
export class AppModule { }

Log

No overload matches this call.
  Overload 1 of 3, '(module: typeof TypeOrmJsonApiModule, options: TypeOrmOptions): DynamicModule', gave the following error.
    Argument of type '{ entities: [typeof Test]; }' is not assignable to parameter of type 'TypeOrmOptions'.
      Property 'options' is missing in type '{ entities: [typeof Test]; }' but required in type '{ options: Partial<TypeOrmConfigParam>; }'.
  Overload 2 of 3, '(module: typeof MicroOrmJsonApiModule, options: MicroOrmOptions): DynamicModule', gave the following error.
    Argument of type 'typeof TypeOrmJsonApiModule' is not assignable to parameter of type 'typeof MicroOrmJsonApiModule'.
      Types of property 'module' are incompatible.
        Type '"typeOrm"' is not assignable to type '"microOrm"'.ts(2769)

ppodds avatar Apr 02 '25 18:04 ppodds