Hello, when I set the property type “GameManager” in my class “Lighty.ts” I got this error.
GameManager.ts imports the “Lighty” class too. It’s probablity why I got this error but I can’t understand how to fix this.
cr.mjs:15 Found possible circular reference in “http://localhost:7456/scripting/x/chunks/ce/cec23828dad35c5a650627fa53378b8a58384e48.js”, happened when use “GameManager” imported from “./GameManager” Error
at Object.execute (Lighty.ts:24:21)
at doExec (system.js:482:32)
at postOrderExec (system.js:472:23)
at system.js:461:30
at Array.forEach ()
at postOrderExec (system.js:459:12)
at system.js:461:30
at Array.forEach ()
at postOrderExec (system.js:459:12)
at system.js:406:14
report @ cr.mjs:15
debug.ts:80 You are explicitly specifyingundefined
type to cc property “gameManager” of cc class “Lighty”.
Is this intended? If not, this may indicate a circular reference.
For example:// foo.ts
import { _decorator } from ‘cc’;
import { Bar } from ‘./bar’; // Given that ‘./bar’ also reference ‘foo.ts’.
// When importing ‘./bar’, execution of ‘./bar’ is hung on to wait execution of ‘foo.ts’,
// theBar
imported here isundefined
until ‘./bar’ finish its execution.
// It leads to that
@_decorator.ccclass // ↓
export class Foo { // ↓
@_decorator.type(Bar) // → is equivalent to@_decorator.type(undefined)
public bar: Bar; // To eliminate this error, either:
// - Refactor your module structure(recommended), or
// - specify the type as cc class name:@_decorator.type('Bar'/* or any name you specified for
Bar*/)
}
Here is the property in my “Lighty” class
//#region SerializeFields
@property({ type: GameManager })
public gameManager: GameManager = null;
And in my GameManager class
@property(Lighty)
public lighty: Lighty | null;
Thanks.