all files / dist/writers/ ExtendsImplementsClauseWriter.js

100% Statements 21/21
100% Branches 2/2
100% Functions 8/8
100% Lines 21/21
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39  15×   12×                 19× 13×                
"use strict";
var ExtendsImplementsClauseWriter = (function () {
    function ExtendsImplementsClauseWriter(writer) {
        this.writer = writer;
    }
    ExtendsImplementsClauseWriter.prototype.writeExtends = function (def) {
        this.writeClause({
            word: "extends",
            types: def.extendsTypes
        });
    };
    ExtendsImplementsClauseWriter.prototype.writeImplements = function (def) {
        this.writeClause({
            word: "implements",
            types: def.implementsTypes
        });
    };
    ExtendsImplementsClauseWriter.prototype.writeClause = function (obj) {
        if (obj.types.length === 0)
            return;
        this.writer.write(" " + obj.word + " ");
        this.writeTypes(obj.types);
    };
    ExtendsImplementsClauseWriter.prototype.writeTypes = function (types) {
        var _this = this;
        types.forEach(function (t, i) {
            _this.writer.conditionalWrite(i !== 0, ", ");
            _this.writer.write(_this.toGenericArrayIfArray(t.text));
        });
    };
    ExtendsImplementsClauseWriter.prototype.toGenericArrayIfArray = function (str) {
        return str.replace(/^(.*)\[\]$/, "Array<$1>");
    };
    return ExtendsImplementsClauseWriter;
}());
exports.ExtendsImplementsClauseWriter = ExtendsImplementsClauseWriter;
 
//# sourceMappingURL=ExtendsImplementsClauseWriter.js.map