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

rokucommunity / brighterscript / #13760

26 Dec 2023 07:45PM UTC coverage: 88.161% (+0.07%) from 88.089%
#13760

push

TwitchBronBron
0.65.15

5675 of 6904 branches covered (82.2%)

Branch coverage included in aggregate %.

8570 of 9254 relevant lines covered (92.61%)

1652.26 hits per line

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

85.71
/src/types/InterfaceType.ts
1
import { isDynamicType, isInterfaceType, isObjectType } from '../astUtils/reflection';
1✔
2
import type { BscType } from './BscType';
3

4
export class InterfaceType implements BscType {
1✔
5
    public constructor(
6
        public members: Map<string, BscType>
42✔
7
    ) {
8

9
    }
10

11
    /**
12
     * The name of the interface. Can be null.
13
     */
14
    public name: string;
15

16
    public isAssignableTo(targetType: BscType) {
17
        //we must have all of the members of the target type, and they must be equivalent types
18
        if (isInterfaceType(targetType)) {
20✔
19
            for (const [targetMemberName, targetMemberType] of targetType.members) {
17✔
20
                //we don't have the target member
21
                if (!this.members.has(targetMemberName)) {
21✔
22
                    return false;
2✔
23
                }
24
                //our member's type is not assignable to the target member type
25
                if (!this.members.get(targetMemberName).isAssignableTo(targetMemberType)) {
19✔
26
                    return false;
5✔
27
                }
28
            }
29
            //we have all of the target member's types. we are assignable!
30
            return true;
10✔
31

32
            //we are always assignable to dynamic or object
33
        } else if (isDynamicType(targetType) || isObjectType(targetType)) {
3✔
34
            return true;
2✔
35

36
            //not assignable to any other object types
37
        } else {
38
            return false;
1✔
39
        }
40
    }
41

42
    public isConvertibleTo(targetType: BscType) {
43
        return this.isAssignableTo(targetType);
×
44
    }
45

46
    public toString() {
47
        let result = '{';
4✔
48
        for (const [key, type] of this.members.entries()) {
4✔
49
            result += ' ' + key + ': ' + type.toString() + ';';
4✔
50
        }
51
        if (this.members.size > 0) {
4✔
52
            result += ' ';
3✔
53
        }
54
        return result + '}';
4✔
55
    }
56

57
    public toTypeString(): string {
58
        return 'object';
×
59
    }
60

61
    public equals(targetType: BscType): boolean {
62
        if (isInterfaceType(targetType)) {
2!
63
            if (targetType.members.size !== this.members.size) {
2!
64
                return false;
×
65
            }
66
            return targetType.isAssignableTo(this);
2✔
67
        }
68
        return false;
×
69
    }
70
}
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