question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Issue with generated code on circular dependency

See original GitHub issue

Issue It seems like the generated code through this Babel plugin raises an issue in using a variable before it is initialized.

let User = ...
_dec9 = Reflect.metadata("design:type", typeof Profile === "undefined" ? Object : Profile)
...

let Profile = ...
_dec9 = Reflect.metadata("design:type", typeof User === "undefined" ? Object : User)

I did see the same issue reported by someone here - https://stackoverflow.com/questions/61297622/typescript-metadata-reflection-references-other-classes-before-they-are-defined, but I don’t think it’s closed with a solution to the core problem.

Context I’m using TypeORM for my interaction with a database. And in this example I defined two entities that need each other (a one-to-one relationship) I provide a minimal reproduction code in this repo - https://github.com/kelvien/repro-next-circ-metadata/

It seems like you’ve mentioned this as one of the pitfalls. I’m just wondering if there is an alternate way in solving this issue, and perhaps a longer term solution to this.

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:11 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
leonardfactorycommented, Mar 18, 2021

Probably TypeScript is smarter here while generating decorators and is wrapping them in functions. I’ll see if this is solvable using this plugin alone, or if the problem arises from babel decorators generation process

0reactions
MatthieuCoelhocommented, Feb 17, 2021

Got the same issue with nextjs, still no solution ? =(

Read more comments on GitHub >

github_iconTop Results From Across the Web

Dagger2 Circular Dependency Error · Issue #1227 - GitHub
I am using dagger2 2.16 version for dependency injection inside mine android project. I examine a lot of examples, and although I do...
Read more >
Circular Dependencies in Spring - Baeldung
A quick writeup on dealing with circular dependencies in Spring: how they occur and several ways to work around them.
Read more >
Dagger 2: error: [ComponentProcessor:MiscError] circular ...
I have solved the circular dependency problem as suggested in the comment. The issue can't be addressed without going through all the ...
Read more >
Circular dependencies - The Apache Software Foundation!
In software, a circular dependency is a relation between two or more classes ... a circular dependency can generate an infinite recursion leading...
Read more >
Avoiding circular dependency errors in DAX - SQLBI
If your code looks correct, that is if you do not see any obvious circular dependencies, then there are two possible causes for...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found