UNPKG

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