dilswer
Version:
Blazingly fast data validation library with TypeScript integration.
92 lines (90 loc) • 2.69 kB
JavaScript
;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
// src/ts-type-generator/type-builders/type-reference.ts
var type_reference_exports = {};
__export(type_reference_exports, {
TsNamedReference: () => TsNamedReference,
TsTypeReference: () => TsTypeReference
});
module.exports = __toCommonJS(type_reference_exports);
var TsTypeReference = class _TsTypeReference {
constructor(fileScope, type, name) {
this.fileScope = fileScope;
this.type = type;
this.name = name;
__publicField(this, "isTitled", false);
__publicField(this, "isAddedToScope", true);
}
static resolveReference(reference) {
let b = reference;
while (b instanceof _TsTypeReference) {
b = b.type;
}
return b;
}
getDescription(indent) {
return this.type.getDescription(indent);
}
setName(name) {
this.fileScope.changeReferenceName(this, name);
}
getName() {
return this.name;
}
build() {
return this.name;
}
buildExport(type) {
switch (type) {
case "export":
case "export/declare":
return `export type { ${this.name} };`;
}
return void 0;
}
};
var TsNamedReference = class {
constructor(name) {
this.name = name;
__publicField(this, "isTitled", false);
__publicField(this, "isAddedToScope", true);
}
getDescription() {
return "";
}
setName() {
throw new Error("Cannot set name of a named reference.");
}
getName() {
return this.name;
}
build() {
return this.name;
}
buildExport(type) {
switch (type) {
case "export":
case "export/declare":
return `export type { ${this.name} };`;
}
return void 0;
}
};