Skip to content

Commit

Permalink
fix: make the forFeature type more loose and accept any EntitySchema
Browse files Browse the repository at this point in the history
Closes #79
  • Loading branch information
B4nan committed Aug 14, 2022
1 parent d6789f6 commit c0012c9
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/mikro-orm.common.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { EntityName } from '@mikro-orm/core';
import { MikroORM, Utils } from '@mikro-orm/core';
import { Inject, Logger } from '@nestjs/common';
import type { EntityName } from './typings';

export const MIKRO_ORM_MODULE_OPTIONS = Symbol('mikro-orm-module-options');
export const CONTEXT_NAMES: string[] = [];
Expand Down
3 changes: 2 additions & 1 deletion src/mikro-orm.entities.storage.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import type { AnyEntity, EntityName } from '@mikro-orm/core';
import type { AnyEntity } from '@mikro-orm/core';
import type { EntityName } from './typings';

export class MikroOrmEntitiesStorage {

Expand Down
3 changes: 2 additions & 1 deletion src/mikro-orm.module.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { AnyEntity, EntityName } from '@mikro-orm/core';
import type { AnyEntity } from '@mikro-orm/core';
import { Utils } from '@mikro-orm/core';
import type { DynamicModule } from '@nestjs/common';
import { Module } from '@nestjs/common';
Expand All @@ -9,6 +9,7 @@ import type {
MikroOrmModuleSyncOptions,
MikroOrmMiddlewareModuleOptions,
MikroOrmModuleFeatureOptions,
EntityName,
} from './typings';
import { MikroOrmMiddlewareModule } from './mikro-orm-middleware.module';
import { MikroOrmEntitiesStorage } from './mikro-orm.entities.storage';
Expand Down
4 changes: 2 additions & 2 deletions src/mikro-orm.providers.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { getEntityManagerToken, getMikroORMToken, getRepositoryToken, logger, MIKRO_ORM_MODULE_OPTIONS } from './mikro-orm.common';
import type { AnyEntity, EntityName } from '@mikro-orm/core';
import type { AnyEntity } from '@mikro-orm/core';
import { ConfigurationLoader, EntityManager, MetadataStorage, MikroORM } from '@mikro-orm/core';

import type { MikroOrmModuleAsyncOptions, MikroOrmModuleOptions, MikroOrmOptionsFactory } from './typings';
import type { MikroOrmModuleAsyncOptions, MikroOrmModuleOptions, MikroOrmOptionsFactory, EntityName } from './typings';
import type { Provider, Type } from '@nestjs/common';
import { Scope } from '@nestjs/common';
import { MikroOrmEntitiesStorage } from './mikro-orm.entities.storage';
Expand Down
4 changes: 3 additions & 1 deletion src/typings.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { AnyEntity, EntityName, IDatabaseDriver, Options } from '@mikro-orm/core';
import type { AnyEntity, EntityName as CoreEntityName, EntitySchema, IDatabaseDriver, Options } from '@mikro-orm/core';
import type { MiddlewareConsumer, ModuleMetadata, Scope, Type } from '@nestjs/common';
import type { AbstractHttpAdapter } from '@nestjs/core';

Expand Down Expand Up @@ -44,3 +44,5 @@ export interface MikroOrmModuleAsyncOptions<D extends IDatabaseDriver = IDatabas
useFactory?: (...args: any[]) => Promise<Omit<MikroOrmModuleOptions<D>, 'contextName'>> | Omit<MikroOrmModuleOptions<D>, 'contextName'>;
inject?: any[];
}

export declare type EntityName<T extends AnyEntity<T>> = CoreEntityName<T> | EntitySchema<any>;

0 comments on commit c0012c9

Please sign in to comment.