tscore.js
function resolveType(x) {
	if (x instanceof TReference) {
		return resolveReference(x)
	} else if (x instanceof TMember) {
		return resolveReference(x)
	} else if (x instanceof TObject) {
        if (x.qname)
            return new TQualifiedReference(x.qname) // can happen if a qname was synthesized by resolveReference
		return resolveObject(x);
	} else if (x instanceof TQualifiedReference) {
		return x;
	} else if (x instanceof TTypeParam) {
		return new TTypeParam(x.name, x.constraint && resolveType(x.constraint))
	} else if (x instanceof TGeneric) {
		return new TGeneric(resolveType(x.base), x.args.map(resolveType))
	} else if (x instanceof TString) {
		return x;
	} else if (x instanceof TBuiltin) {
		return x;
	} else if (x instanceof TTypeQuery) {
        return resolveReference(x);
    } else if (x instanceof TEnum) {
        return x;
    }
	var msg;
	if (x.constructor.name === 'Object')
		msg = util.inspect(x)
	else
		msg = '' + x;
	throw new TypeError("Cannot canonicalize reference to " + (x && x.constructor.name + ': ' + msg))
}
function resolveType(x) {
	if (x instanceof TReference) {
		return resolveReference(x)
	} else if (x instanceof TMember) {
		return resolveReference(x)
	} else if (x instanceof TObject) {
        if (x.qname)
            return new TQualifiedReference(x.qname) // can happen if a qname was synthesized by resolveReference
		return resolveObject(x);
	} else if (x instanceof TQualifiedReference) {
		return x;
	} else if (x instanceof TTypeParam) {
		return new TTypeParam(x.name, x.constraint && resolveType(x.constraint))
	} else if (x instanceof TGeneric) {
		return new TGeneric(resolveType(x.base), x.args.map(resolveType))
	} else if (x instanceof TString) {
		return x;
	} else if (x instanceof TBuiltin) {
		return x;
	} else if (x instanceof TTypeQuery) {
        return resolveReference(x);
    } else if (x instanceof TEnum) {
        return x;
    }
	var msg;
	if (x.constructor.name === 'Object')
		msg = util.inspect(x)
	else
		msg = '' + x;
	throw new TypeError("Cannot canonicalize reference to " + (x && x.constructor.name + ': ' + msg))
}
function resolveType ( x ) { if ( x instanceof TReference ) { return resolveReference ( x ) } else if ( x instanceof TMember ) { return resolveReference ( x ) } else if ( x instanceof TObject ) { if ( x . qname ) return new TQualifiedReference ( x . qname ) // can happen if a qname was synthesized by resolveReference return resolveObject ( x ) ; } else if ( x instanceof TQualifiedReference ) { return x ; } else if ( x instanceof TTypeParam ) { return new TTypeParam ( x . name , x . constraint && resolveType ( x . constraint ) ) } else if ( x instanceof TGeneric ) { return new TGeneric ( resolveType ( x . base ) , x . args . map ( resolveType ) ) } else if ( x instanceof TString ) { return x ; } else if ( x instanceof TBuiltin ) { return x ; } else if ( x instanceof TTypeQuery ) { return resolveReference ( x ) ; } else if ( x instanceof TEnum ) { return x ; } var msg ; if ( x . constructor . name === 'Object' ) msg = util . inspect ( x ) else msg = '' + x ; throw new TypeError ( "Cannot canonicalize reference to " + ( x && x . constructor . name + ': ' + msg ) ) }
Recursively builds a type where all references have been resolved
Recursively builds a type where all references have been resolved