UNPKG

1 kBJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3const abstract_1 = require("./abstract");
4class TupleType extends abstract_1.Type {
5 constructor(elements) {
6 super();
7 this.type = 'tuple';
8 this.elements = elements;
9 }
10 clone() {
11 return new TupleType(this.elements);
12 }
13 equals(type) {
14 if (!(type instanceof TupleType)) {
15 return false;
16 }
17 return abstract_1.Type.isTypeListEqual(type.elements, this.elements);
18 }
19 toObject() {
20 const result = super.toObject();
21 if (this.elements && this.elements.length) {
22 result.elements = this.elements.map((e) => e.toObject());
23 }
24 return result;
25 }
26 toString() {
27 const names = [];
28 this.elements.forEach((element) => {
29 names.push(element.toString());
30 });
31 return '[' + names.join(', ') + ']';
32 }
33}
34exports.TupleType = TupleType;
35//# sourceMappingURL=tuple.js.map
\No newline at end of file