Skip to content

recursive private static gets missed in --noUnusedLocals #41027

Closed
@beauxq

Description

@beauxq

TypeScript Version: 3.8.3

Search Terms:
noUnusedLocals, recursive

Code

class C {
    private static staticFactorial(n: number): number {  // no error
        return (n === 0) ? 1 : (n * C.staticFactorial(n - 1));
    }

    private static foo() {  // unused error
        return 42;
    }
}

function main() {
    function localFactorial(n: number): number {  // unused error
        return (n === 0) ? 1 : (n * localFactorial(n - 1));
    }
}

Expected behavior:
both localFactorial and staticFactorial have the same result when compiled with --noUnusedLocals

Actual behavior:
localFactorial triggers error
staticFactorial does not

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugA bug in TypeScript

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions