The 'type' attribute of 'Script' is undefined when loading script

The 'type' attribute of 'Script' is undefined when loading script
0

#1

I’ve just started developing for cocos creator 2.0 using typescript and I’ve got a pair of classes that each reference each other in the editor However in editor I get the error “The ‘type’ attribute of ‘Weapon.playerController’ is undefined when loading script”. Additionally, the “PlayerController” property is always null and cannot have anything dragged into it. The classes are in separate files.

From what I can find it appears to be a circular reference and I did find a couple people with similar issues but they were using Javascript and it didn’t help me. Below is the relevant snippets, any suggestions?

PlayerController.ts:

import Weapon from "./Weapon";

const {ccclass, property} = cc._decorator;

@ccclass
export default class PlayerController extends cc.Component 
{	
	@property(
	{
		visible: true,
		type: Weapon
	})
	private weapon: Weapon = null;

}

Weapon.ts:

import PlayerController from "./PlayerController";

const {ccclass, property} = cc._decorator;

@ccclass
export default class Weapon extends cc.Component 
{	
	@property
	({
		type: PlayerController
	})
	private playerController : PlayerController = null;	
}

Untitled