• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

rokucommunity / brighterscript / #15225

23 Feb 2026 03:37PM UTC coverage: 87.228% (-1.8%) from 88.989%
#15225

push

web-flow
Merge c2f319ba4 into fd4d8c43f

14853 of 17988 branches covered (82.57%)

Branch coverage included in aggregate %.

31 of 31 new or added lines in 5 files covered. (100.0%)

828 existing lines in 47 files now uncovered.

15519 of 16831 relevant lines covered (92.2%)

25630.39 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

91.15
/src/types/ArrayType.ts
1

2
import { SymbolTypeFlag } from '../SymbolTypeFlag';
1✔
3
import { isArrayType, isDynamicType, isEnumMemberType, isInvalidType, isObjectType, isTypeStatementType } from '../astUtils/reflection';
1✔
4
import type { TypeCompatibilityData } from '../interfaces';
5
import { BscType } from './BscType';
1✔
6
import { BscTypeKind } from './BscTypeKind';
1✔
7
import type { BuiltInInterfaceOverride } from './BuiltInInterfaceAdder';
8
import { BuiltInInterfaceAdder } from './BuiltInInterfaceAdder';
1✔
9
import { DynamicType } from './DynamicType';
1✔
10
import { IntegerType } from './IntegerType';
1✔
11
import { unionTypeFactory } from './UnionType';
1✔
12
import { getUniqueType, isUnionTypeCompatible } from './helpers';
1✔
13
import { util } from '../util';
1✔
14

15
export class ArrayType extends BscType {
1✔
16
    constructor(...innerTypes: BscType[]) {
17
        super();
200,149✔
18
        this.innerTypes = innerTypes;
200,149✔
19
    }
20

21
    public readonly kind = BscTypeKind.ArrayType;
200,149✔
22
    public isBuiltIn = true;
200,149✔
23

24
    public innerTypes: BscType[] = [];
200,149✔
25

26
    public _defaultType: BscType;
27
    private isCheckingInnerTypesForDefaultType = false;
200,149✔
28

29
    public get defaultType(): BscType {
30
        if (this._defaultType) {
11,136✔
31
            return this._defaultType;
2,004✔
32
        }
33
        if (this.innerTypes?.length === 0 || this.isCheckingInnerTypesForDefaultType) {
9,132!
34
            return DynamicType.instance;
8,898✔
35
        }
36
        this.isCheckingInnerTypesForDefaultType = true;
234✔
37

38
        let resultType = this.innerTypes[0];
234✔
39
        if (this.innerTypes?.length > 1) {
234!
40
            resultType = getUniqueType(this.innerTypes, unionTypeFactory) ?? DynamicType.instance;
38!
41
        }
42
        if (isEnumMemberType(resultType)) {
234✔
43
            resultType = resultType.parentEnumType ?? resultType;
2!
44
        }
45
        this._defaultType = util.getDefaultTypeFromValueType(resultType);
234✔
46
        this.isCheckingInnerTypesForDefaultType = false;
234✔
47
        return this._defaultType;
234✔
48
    }
49

50
    public isTypeCompatible(targetType: BscType, data?: TypeCompatibilityData) {
51
        while (isTypeStatementType(targetType)) {
26✔
UNCOV
52
            targetType = targetType.wrappedType;
×
53
        }
54
        if (isDynamicType(targetType)) {
26✔
55
            return true;
1✔
56
        } else if (isObjectType(targetType)) {
25✔
57
            return true;
3✔
58
        } else if (isInvalidType(targetType)) {
22✔
59
            return true;
5✔
60
        } else if (isUnionTypeCompatible(this, targetType)) {
17!
UNCOV
61
            return true;
×
62
        } else if (isArrayType(targetType)) {
17✔
63
            const compatible = this.defaultType.isTypeCompatible(targetType.defaultType, data);
11✔
64
            if (data) {
11✔
65
                data.actualType = targetType.defaultType;
7✔
66
                data.expectedType = this.defaultType;
7✔
67
            }
68
            return compatible;
11✔
69
        } else if (this.checkCompatibilityBasedOnMembers(targetType, SymbolTypeFlag.runtime, data)) {
6✔
70
            return true;
3✔
71
        }
72
        return false;
3✔
73
    }
74

75
    public toString() {
76
        return `Array<${this.defaultType.toString()}>`;
9,284✔
77
    }
78

79
    public toTypeString(): string {
UNCOV
80
        return 'object';
×
81
    }
82

83
    public isEqual(targetType: BscType): boolean {
84
        if (isArrayType(targetType)) {
19✔
85
            if (targetType.innerTypes.length !== this.innerTypes.length) {
17!
UNCOV
86
                return false;
×
87
            }
88
            for (let i = 0; i < this.innerTypes.length; i++) {
17✔
89
                if (!this.innerTypes[i].isEqual(targetType.innerTypes[i])) {
16✔
90
                    return false;
8✔
91
                }
92
            }
93
            return true;
9✔
94
        }
95
        return false;
2✔
96
    }
97

98
    addBuiltInInterfaces() {
99
        if (!this.hasAddedBuiltInInterfaces) {
158✔
100
            const overrideMap = new Map<string, BuiltInInterfaceOverride>();
67✔
101
            const defaultType = this.defaultType;
67✔
102
            overrideMap
67✔
103
                // ifArray
104
                .set('peek', { returnType: defaultType })
105
                .set('pop', { returnType: defaultType })
106
                .set('push', { parameterTypes: [defaultType] })
107
                .set('shift', { returnType: defaultType })
108
                .set('unshift', { parameterTypes: [defaultType] })
109
                .set('append', { parameterTypes: [this] })
110
                // ifArrayGet
111
                .set('get', { returnType: defaultType })
112
                // ifArraySet
113
                .set('get', { parameterTypes: [IntegerType.instance, defaultType] })
114
                //ifEnum
115
                .set('next', { returnType: defaultType });
116
            BuiltInInterfaceAdder.addBuiltInInterfacesToType(this, overrideMap);
67✔
117
        }
118
        this.hasAddedBuiltInInterfaces = true;
158✔
119
    }
120
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc