Hello, I'm encountering an issue with my app.ts. When trying to load my settings from ormconfig.ts for the typeorm function that creates the connection, I receive the following error:
No overload matches this call.
Overload 1 of 3, '(name: string): Promise<Connection>', gave the following error.
Argument of type 'typeof import("d:/EmasaTi_StockControl/src/shared/infra/http/ormconfig")' is not assignable to parameter of type 'string'.
Overload 2 of 3, '(options: ConnectionOptions): Promise<Connection>', gave the following error.
Argument of type 'typeof import("d:/EmasaTi_StockControl/src/shared/infra/http/ormconfig")' is not assignable to parameter of type 'ConnectionOptions'.
Type 'typeof import("d:/EmasaTi_StockControl/src/shared/infra/http/ormconfig")' is missing the following properties from type 'ExpoConnectionOptions': type, database, driverts(2769)
Peek Problem (Alt+F8)
No quick fixes available
Code snippet:
import 'dotenv/config';
import { createConnection } from 'typeorm';
import App from './app';
import validateEnv from '@utils/validateEnv';
import * as config from './ormconfig';
validateEnv();
(async () => {
try {
const connection = await createConnection(config);
await connection.runMigrations();
} catch (error) {
console.log('Error while connecting to the database', error);
return error;
}
const app = new App(
);
app.listen();
})();
Here is a snippet from my config file:
import { ConnectionOptions } from 'typeorm';
const rootDir = process.env.NODE_ENV === 'development' ? 'src' : 'build/src';
export const config: ConnectionOptions = {
type: 'postgres',
host: process.env.DB_HOST,
port: Number(process.env.DB_PORT),
username: process.env.DB_USER,
password: process.env.DB_PASS,
database: process.env.DB_NAME,
entities: [rootDir + '/entities/**/*.{js,ts}'],
migrations: [rootDir + '/migrations/*.{js,ts}'],
subscribers: [rootDir + '/subscribers/**/*.{js,ts}'],
cli: {
entitiesDir: `${rootDir}/entities`,
migrationsDir: `${rootDir}/migration`,
subscribersDir: `${rootDir}/subscriber`,
},
synchronize: false,
logging: true
};
module.exports = config;
I'm stuck on how to resolve this problem. Any assistance would be greatly appreciated.