Skip to content

question: ReferenceError: Cannot access 'XXX' before initialization #1789

Open
@Nosfistis

Description

@Nosfistis

I was trying to...
This has been also described in #1622. My case is a TypeORM entity collection where I also use class-validator decorators. One of the entities is a polymorphic entity, therefore I use discriminator at the type to determine the type. However, since the type has a reverse relation, it results in circular dependency.

The problem:
Normally I avoid type-level circular dependencies by using type X in the import. However, since this is a runtime usage, I cannot avoid the class reference.

Metadata

Metadata

Assignees

No one assigned

    Labels

    type: questionQuestions about the usage of the library.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions