UNPKG

dilswer

Version:

Blazingly fast data validation library with TypeScript integration.

36 lines (34 loc) 1.29 kB
var __defProp = Object.defineProperty; var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value; var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value); // src/ts-type-generator/type-builders/instanceof-builder.ts import { TemplateBuilder } from "../template-builder.mjs"; import { TsBaseBuilder } from "./base-builder.mjs"; var INSTANCEOF_TEMPLATE = new TemplateBuilder( "InstanceType<typeof {{type}}>" ); var EXPORTED_INSTANCEOF_TEMPLATE = new TemplateBuilder(`{{description}} {{export}}type {{name}} = InstanceType<typeof {{type}}>`); var TsInstanceOfBuilder = class extends TsBaseBuilder { constructor(constructorName) { super(); __publicField(this, "constructorName", constructorName); } build() { return INSTANCEOF_TEMPLATE.build({ type: this.constructorName }); } buildExport(type) { var _a; return EXPORTED_INSTANCEOF_TEMPLATE.build({ name: (_a = this.name) != null ? _a : this.generateName("ClassInstance"), description: this.description, type: this.constructorName, export: this.parseExportType(type) }); } }; export { TsInstanceOfBuilder };