All files InterfaceSymbol.ts

91.48% Statements 43/47
100% Branches 1/1
20% Functions 1/5
91.48% Lines 43/47

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 481x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 374x 374x 374x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x     1x 1x 1x 1x 1x 1x 1x     1x  
/*
 * This file is released under the MIT license.
 * Copyright (c) 2023, Mike Lischke
 *
 * See LICENSE file for more info.
 */
 
import { Type, ReferenceKind, TypeKind } from "./types";
 
import { ClassSymbol } from "./ClassSymbol";
import { FieldSymbol } from "./FieldSymbol";
import { MethodSymbol } from "./MethodSymbol";
import { ScopedSymbol } from "./ScopedSymbol";
 
export class InterfaceSymbol extends ScopedSymbol implements Type {
    public reference = ReferenceKind.Irrelevant;
 
    /** Typescript allows an interface to extend a class, not only interfaces. */
    // eslint-disable-next-line no-use-before-define
    public readonly extends: Array<ClassSymbol | InterfaceSymbol>;
 
    public constructor(name: string, ext: Array<ClassSymbol | InterfaceSymbol>) {
        super(name);
        this.extends = ext;
    }
 
    public get baseTypes(): Type[] { return this.extends; }
    public get kind(): TypeKind { return TypeKind.Interface; }
 
    /**
     * @param includeInherited Not used.
     *
     * @returns a list of all methods.
     */
    public getMethods(includeInherited = false): Promise<MethodSymbol[]> {
        return this.getSymbolsOfType(MethodSymbol);
    }
 
    /**
     * @param includeInherited Not used.
     *
     * @returns all fields.
     */
    public getFields(includeInherited = false): Promise<FieldSymbol[]> {
        return this.getSymbolsOfType(FieldSymbol);
    }
}