function isJustNamespace()

in src/rules/exportJustNamespaceRule.ts [48:80]


function isJustNamespace(statements: ReadonlyArray<ts.Statement>, exportEqualsName: string): boolean {
    let anyNamespace = false;

    for (const statement of statements) {
        switch (statement.kind) {
            case ts.SyntaxKind.ModuleDeclaration:
                anyNamespace = anyNamespace || nameMatches((statement as ts.ModuleDeclaration).name);
                break;
            case ts.SyntaxKind.VariableStatement:
                if ((statement as ts.VariableStatement).declarationList.declarations.some(d => nameMatches(d.name))) {
                    // OK. It's merged with a variable.
                    return false;
                }
                break;
            case ts.SyntaxKind.FunctionDeclaration:
            case ts.SyntaxKind.ClassDeclaration:
            case ts.SyntaxKind.TypeAliasDeclaration:
            case ts.SyntaxKind.InterfaceDeclaration:
                if (nameMatches((statement as ts.DeclarationStatement).name)) {
                    // OK. It's merged with a function/class/type/interface.
                    return false;
                }
                break;
            default:
        }
    }

    return anyNamespace;

    function nameMatches(nameNode: ts.Node | undefined): boolean {
        return nameNode !== undefined && ts.isIdentifier(nameNode) && nameNode.text === exportEqualsName;
    }
}