Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Type instantiation is excessively deep and possibly infinite #13210

Closed
2 of 15 tasks
buqiyuan opened this issue Feb 14, 2024 · 3 comments
Closed
2 of 15 tasks

Type instantiation is excessively deep and possibly infinite #13210

buqiyuan opened this issue Feb 14, 2024 · 3 comments
Labels
needs triage This issue has not been looked into

Comments

@buqiyuan
Copy link

buqiyuan commented Feb 14, 2024

Is there an existing issue for this?

  • I have searched the existing issues

Current behavior

image image image

Minimum reproduction code

none

Steps to reproduce

No response

Expected behavior

Maybe we need writing a depth limiter manually (see microsoft/TypeScript#45711).

Package

  • I don't know. Or some 3rd-party package
  • @nestjs/common
  • @nestjs/core
  • @nestjs/microservices
  • @nestjs/platform-express
  • @nestjs/platform-fastify
  • @nestjs/platform-socket.io
  • @nestjs/platform-ws
  • @nestjs/testing
  • @nestjs/websockets
  • Other (see below)

Other package

@nestjs/config

NestJS version

No response

Packages versions

    "@nestjs/common": "^10.3.2",
    "@nestjs/config": "^3.2.0",
    "@nestjs/core": "^10.3.2",

Node.js version

18

In which operating systems have you tested?

  • macOS
  • Windows
  • Linux

Other

No response

@buqiyuan buqiyuan added the needs triage This issue has not been looked into label Feb 14, 2024
@micalevisk
Copy link
Member

Which version of typescript are you using?

@buqiyuan
Copy link
Author

您使用的是哪个版本的打字稿?

"typescript": "^5.3.3"

@buqiyuan
Copy link
Author

Sorry, this is my problem, I used DataSourceOptions as ConfigType incorrectly, sorry for wasting your precious time.

import { registerAs } from '@nestjs/config'

import { DataSource, DataSourceOptions } from 'typeorm'
+ import { MysqlConnectionCredentialsOptions } from 'typeorm/driver/mysql/MysqlConnectionCredentialsOptions'
import { env, envBoolean, envNumber } from '~/global/env'
// eslint-disable-next-line import/order
import dotenv from 'dotenv'

dotenv.config({ path: `.env.${process.env.NODE_ENV}` })

const dataSourceOptions: DataSourceOptions = {
  type: 'mysql',
  host: env('DB_HOST', '127.0.0.1'),
  port: envNumber('DB_PORT', 3306),
  username: env('DB_USERNAME'),
  password: env('DB_PASSWORD'),
  database: env('DB_DATABASE'),
  synchronize: envBoolean('DB_SYNCHRONIZE', false),
  entities: ['dist/modules/**/*.entity{.ts,.js}'],
  migrations: ['dist/migrations/*{.ts,.js}'],
  subscribers: ['dist/modules/**/*.subscriber{.ts,.js}'],
}
export const dbRegToken = 'database'

export const DatabaseConfig = registerAs(
  dbRegToken,
  (): DataSourceOptions => dataSourceOptions,
)

- export type IDatabaseConfig = ConfigType<typeof DatabaseConfig>
+ export type IDatabaseConfig = Pick<MysqlConnectionCredentialsOptions, 'host' | 'port' | 'username' | 'password' | 'database'>

const dataSource = new DataSource(dataSourceOptions)

export default dataSource

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs triage This issue has not been looked into
Projects
None yet
Development

No branches or pull requests

2 participants