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

rokucommunity / brighterscript / #15129

28 Jan 2026 03:47PM UTC coverage: 87.193% (-1.8%) from 88.969%
#15129

push

web-flow
Merge aa579b555 into 610607efc

14637 of 17741 branches covered (82.5%)

Branch coverage included in aggregate %.

69 of 71 new or added lines in 11 files covered. (97.18%)

825 existing lines in 47 files now uncovered.

15395 of 16702 relevant lines covered (92.17%)

24785.89 hits per line

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

88.29
/src/types/ArrayType.ts
1

2
import { SymbolTypeFlag } from '../SymbolTypeFlag';
1✔
3
import { isArrayType, isDynamicType, isEnumMemberType, isInvalidType, isObjectType } 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();
195,788✔
18
        this.innerTypes = innerTypes;
195,788✔
19
    }
20

21
    public readonly kind = BscTypeKind.ArrayType;
195,788✔
22
    public isBuiltIn = true;
195,788✔
23

24
    public innerTypes: BscType[] = [];
195,788✔
25

26
    public _defaultType: BscType;
27
    private isCheckingInnerTypesForDefaultType = false;
195,788✔
28

29
    public get defaultType(): BscType {
30
        if (this._defaultType) {
10,760✔
31
            return this._defaultType;
1,855✔
32
        }
33
        if (this.innerTypes?.length === 0 || this.isCheckingInnerTypesForDefaultType) {
8,905!
34
            return DynamicType.instance;
8,706✔
35
        }
36
        this.isCheckingInnerTypesForDefaultType = true;
199✔
37

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

50
    public isTypeCompatible(targetType: BscType, data?: TypeCompatibilityData) {
51

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

73
    public toString() {
74
        return `Array<${this.defaultType.toString()}>`;
9,036✔
75
    }
76

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

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

96
    addBuiltInInterfaces() {
97
        if (!this.hasAddedBuiltInInterfaces) {
141✔
98
            const overrideMap = new Map<string, BuiltInInterfaceOverride>();
60✔
99
            const defaultType = this.defaultType;
60✔
100
            overrideMap
60✔
101
                // ifArray
102
                .set('peek', { returnType: defaultType })
103
                .set('pop', { returnType: defaultType })
104
                .set('push', { parameterTypes: [defaultType] })
105
                .set('shift', { returnType: defaultType })
106
                .set('unshift', { parameterTypes: [defaultType] })
107
                .set('append', { parameterTypes: [this] })
108
                // ifArrayGet
109
                .set('get', { returnType: defaultType })
110
                // ifArraySet
111
                .set('get', { parameterTypes: [IntegerType.instance, defaultType] })
112
                //ifEnum
113
                .set('next', { returnType: defaultType });
114
            BuiltInInterfaceAdder.addBuiltInInterfacesToType(this, overrideMap);
60✔
115
        }
116
        this.hasAddedBuiltInInterfaces = true;
141✔
117
    }
118
}
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