diff --git a/lib/typeorm-core.module.ts b/lib/typeorm-core.module.ts index 05095c1b4..e59d1966f 100644 --- a/lib/typeorm-core.module.ts +++ b/lib/typeorm-core.module.ts @@ -217,7 +217,10 @@ export class TypeOrmCoreModule implements OnApplicationShutdown { const dataSource = await createTypeormDataSource( options as DataSourceOptions, ); - return dataSource.initialize && !dataSource.isInitialized ? dataSource.initialize() : dataSource; + // TODO: remove "dataSource.initialize" condition (left for backward compatibility) + return (dataSource as any).initialize && !dataSource.isInitialized + ? dataSource.initialize() + : dataSource; } let entities = options.entities; @@ -233,7 +236,11 @@ export class TypeOrmCoreModule implements OnApplicationShutdown { ...options, entities, } as DataSourceOptions); - return dataSource.initialize && !dataSource.isInitialized ? dataSource.initialize() : dataSource; + + // TODO: remove "dataSource.initialize" condition (left for backward compatibility) + return (dataSource as any).initialize && !dataSource.isInitialized + ? dataSource.initialize() + : dataSource; }).pipe( handleRetry( options.retryAttempts,