COMMUNITY

Type.typeof(d) question

	switch (Type.typeof(d)) {
		case TNull    : o.writeByte(0xc0);
		case TBool    : o.writeByte(d ? 0xc3 : 0xc2);
		case TInt     : writeInt(d);
		case TFloat   : writeFloat(d);
		
		case TClass(c): 
		     var __name=Type.getClassName(c);//I extra add this helper to avoid bug.
			var _name=Std.string(__name)=="true"?"String":__name;//why sometime _name==true?

target js and use Vue webpack.

don’t know why some time Type.getClassName© =true?

Could it be because JavaScript is essentially “typeless?”

Try to debug generated js. Probably, it’s not “string” case:

Type["typeof"] = function(v) {
	var _g = typeof(v);
	switch(_g) {
	case "boolean":
		return ValueType.TBool;
	case "function":
		if(v.__name__ || v.__ename__) {
			return ValueType.TObject;
		}
		return ValueType.TFunction;
	case "number":
		if(Math.ceil(v) == v % 2147483648.0) {
			return ValueType.TInt;
		}
		return ValueType.TFloat;
	case "object":
		if(v == null) {
			return ValueType.TNull;
		}
		var e = v.__enum__;
		if(e != null) {
			return ValueType.TEnum(e);
		}
		var c = js_Boot.getClass(v);
		if(c != null) {
			return ValueType.TClass(c); //maybe your case here???
		}
		return ValueType.TObject;
	case "string":
		return ValueType.TClass(String);
	case "undefined":
		return ValueType.TNull;
	default:
		return ValueType.TUnknown;
	}
};

Are you using a haxe-compiled js module in another haxe-compiled js module? Because Haxe/JS generates __name__ = true instead of the full name if Type.getClassName is not used in the current compilation, just to mark that it’s a Haxe class and not some random JS function.

Are you using a haxe-compiled js module in another haxe-compiled js modul?

no,I say : I use haxe-compiled js to VUE only ,there only one haxe-compiled js file.