Skip to content
New issue

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

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

Already on GitHub? # to your account

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

Open
Nosfistis opened this issue Nov 22, 2024 · 0 comments
Open

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

Nosfistis opened this issue Nov 22, 2024 · 0 comments
Labels
type: question Questions about the usage of the library.

Comments

@Nosfistis
Copy link

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.

@Nosfistis Nosfistis added the type: question Questions about the usage of the library. label Nov 22, 2024
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
type: question Questions about the usage of the library.
Development

No branches or pull requests

1 participant