ts-json-schema-generator
Version:
Generate JSON schema from your Typescript sources
43 lines • 1.78 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.derefType = derefType;
exports.derefAnnotatedType = derefAnnotatedType;
exports.isHiddenType = isHiddenType;
exports.derefAliasedType = derefAliasedType;
const AliasType_js_1 = require("../Type/AliasType.js");
const AnnotatedType_js_1 = require("../Type/AnnotatedType.js");
const DefinitionType_js_1 = require("../Type/DefinitionType.js");
const HiddenType_js_1 = require("../Type/HiddenType.js");
const NeverType_js_1 = require("../Type/NeverType.js");
const ReferenceType_js_1 = require("../Type/ReferenceType.js");
function derefType(type) {
if (type instanceof DefinitionType_js_1.DefinitionType || type instanceof AliasType_js_1.AliasType || type instanceof AnnotatedType_js_1.AnnotatedType) {
return derefType(type.getType());
}
if (type instanceof ReferenceType_js_1.ReferenceType && type.hasType()) {
return derefType(type.getType());
}
return type;
}
function derefAnnotatedType(type) {
if (type instanceof AnnotatedType_js_1.AnnotatedType || type instanceof AliasType_js_1.AliasType) {
return derefAnnotatedType(type.getType());
}
return type;
}
function isHiddenType(type) {
if (type instanceof HiddenType_js_1.HiddenType || type instanceof NeverType_js_1.NeverType) {
return true;
}
else if (type instanceof DefinitionType_js_1.DefinitionType || type instanceof AliasType_js_1.AliasType || type instanceof AnnotatedType_js_1.AnnotatedType) {
return isHiddenType(type.getType());
}
return false;
}
function derefAliasedType(type) {
if (type instanceof AliasType_js_1.AliasType) {
return derefAliasedType(type.getType());
}
return type;
}
//# sourceMappingURL=derefType.js.map