spraypaint.js icon indicating copy to clipboard operation
spraypaint.js copied to clipboard

Cyclic dependencies in ES2015

Open piotrpalek opened this issue 6 years ago • 1 comments

Hey, I've been looking into graphitti and saw that you use classes to define relationships in the JS Client. I'm currently using https://github.com/ghidoz/angular2-jsonapi with the "jsonapi suite" and they use a similar approach for this. But while using it I've had to upgrade to a new angular version, which also upgraded my "target" in tsconfig to es2015.

Now the issue is that it seems that when you change the target, you can no longer define classes that depend on each other in this way, see: https://github.com/ghidoz/angular2-jsonapi/issues/236#issuecomment-519473153. Meaning if you define Post which hasMany Comments, but Comment also belongsTo Post it would throw a Uncaught ReferenceError: Cannot access '<insert class herr>' before initialization error.

Would this be an issue with spraypaint.js as well?

piotrpalek avatar Sep 12 '19 12:09 piotrpalek

@piotrpalek I came across this issue because I was writing tests and started getting that exact initialization error, but it seems to be because I had my models setup incorrectly.

So to answer your question: Not that I've seen, yet, when things are setup right.

Petercopter avatar Oct 10 '19 23:10 Petercopter