有没有办法使用 TypeScript 文件代替 ormconfig.json?

Is there a way to use a TypeScript file in place of ormconfig.json?

我确实想从位于路径 src/config/ormconfig.ts 的 TypeScript 文件导出我的 ormConfig,其中包含以下内容内容

export const ormConfig = {
  type: 'postgres',
  host: 'localhost',
  port: 5432,
  username: 'admin',
  password: '123456',
  database: 'hello-world',
}

所以我可以使用以下策略从文件 src/database/index.ts 导入它:

import { DataSource } from "typeorm";
import { ormConfig } from "../config/ormconfig";

const dataSource: DataSource = new DataSource(ormConfig);

问题是 TypeScript 抛出一个错误,指出缺少参数: "[...] 类型 'AuroraMysqlConnectionOptions' 中缺少以下属性:区域、secretArn、resourceArnts"

有人有解决此问题的方法吗? 提前致谢

您只需指定 ormConfig

的类型
import { PostgresConnectionOptions } from "typeorm/driver/postgres/PostgresConnectionOptions";

const ormConfig: PostgresConnectionOptions = {