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

rokucommunity / brighterscript / #13186

15 Oct 2024 11:38AM UTC coverage: 89.043% (+2.2%) from 86.831%
#13186

push

web-flow
Merge 2b9d8bd39 into 1519a87aa

7212 of 8538 branches covered (84.47%)

Branch coverage included in aggregate %.

10 of 10 new or added lines in 1 file covered. (100.0%)

539 existing lines in 53 files now uncovered.

9619 of 10364 relevant lines covered (92.81%)

1781.3 hits per line

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

69.81
/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>
72✔
7
    ) {
8

9
    }
10

11
    /**
12
     * The name of the interface. Can be undefined.
13
     */
14
    public name: string | undefined;
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
                const ourMemberType = this.members.get(targetMemberName);
21✔
21
                //we don't have the target member
22
                if (!ourMemberType) {
21✔
23
                    return false;
2✔
24
                }
25
                //our member's type is not assignable to the target member type
26
                if (!ourMemberType.isAssignableTo(targetMemberType)) {
19✔
27
                    return false;
5✔
28
                }
29
            }
30
            //we have all of the target member's types. we are assignable!
31
            return true;
10✔
32

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

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

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

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

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

62
    public equals(targetType: BscType): boolean {
63
        if (isInterfaceType(targetType)) {
2!
64
            if (targetType.members.size !== this.members.size) {
2!
UNCOV
65
                return false;
×
66
            }
67
            return targetType.isAssignableTo(this);
2✔
68
        }
UNCOV
69
        return false;
×
70
    }
71

72
    public clone() {
UNCOV
73
        let members = new Map<string, BscType>();
×
UNCOV
74
        for (const [key, member] of this.members) {
×
UNCOV
75
            members.set(key, member?.clone());
×
76
        }
UNCOV
77
        const result = new InterfaceType(members);
×
UNCOV
78
        result.name = this.name;
×
UNCOV
79
        return result;
×
80
    }
81
}
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