Issue with generated code on circular dependency
See original GitHub issueIssue 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:
- Created 3 years ago
- Comments:11 (3 by maintainers)
Top GitHub Comments
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
Got the same issue with nextjs, still no solution ? =(