UNPKG

clasp-types

Version:

A d.ts generator for clasp projects

40 lines (39 loc) 2.17 kB
"use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; return extendStatics(d, b); }; return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); Object.defineProperty(exports, "__esModule", { value: true }); exports.Interface = void 0; var Definition_1 = require("./Definition"); var Method_1 = require("./Method"); var Property_1 = require("./Property"); var Interface = /** @class */ (function (_super) { __extends(Interface, _super); function Interface(kind, depth) { return _super.call(this, kind, depth) || this; } Interface.prototype.render = function (builder) { var _this = this; var methods = this.kind.children.filter(function (k) { return _this.kind.kindString === 'Interface' ? true : k.flags.isPublic; }).filter(function (k) { return k.kindString === 'Method' || k.kindString === 'Function'; }).map(function (k) { return new Method_1.Method(k, _this.tab()); }); var properties = this.kind.children.filter(function (k) { return _this.kind.kindString === 'Interface' ? true : k.flags.isPublic; }).filter(function (k) { return k.kindString === 'Property'; }).map(function (k) { return new Property_1.Property(k, _this.tab()); }); this.addComment(builder, this.kind.comment); if (methods.length > 0 || properties.length > 0) { builder.append(this.ident() + "export interface " + this.kind.name + " {").doubleLine(); properties.forEach(function (p) { return p.render(builder); }); methods.forEach(function (m) { return m.render(builder); }); builder.append(this.ident() + "}").doubleLine(); } }; return Interface; }(Definition_1.Definition)); exports.Interface = Interface;