1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | const index_1 = require("./index");
|
4 | class ArrayType extends index_1.Type {
|
5 | constructor(elementType) {
|
6 | super();
|
7 | this.type = 'array';
|
8 | this.elementType = elementType;
|
9 | }
|
10 | clone() {
|
11 | return new ArrayType(this.elementType);
|
12 | }
|
13 | equals(type) {
|
14 | if (!(type instanceof ArrayType)) {
|
15 | return false;
|
16 | }
|
17 | return type.elementType.equals(this.elementType);
|
18 | }
|
19 | toObject() {
|
20 | const result = super.toObject();
|
21 | result.elementType = this.elementType.toObject();
|
22 | return result;
|
23 | }
|
24 | toString() {
|
25 | const elementTypeStr = this.elementType.toString();
|
26 | if (this.elementType instanceof index_1.UnionType || this.elementType instanceof index_1.IntersectionType) {
|
27 | return '(' + elementTypeStr + ')[]';
|
28 | }
|
29 | else {
|
30 | return elementTypeStr + '[]';
|
31 | }
|
32 | }
|
33 | }
|
34 | exports.ArrayType = ArrayType;
|
35 |
|
\ | No newline at end of file |