Function collectVariableUsage

  • Creates a mapping of each declared type and value to its type information.

    Parameters

    • sourceFile: SourceFile

    Returns Map<ts.Identifier, VariableInfo>

    Example

    declare const sourceFile: ts.SourceFile;

    const usage = collectVariableUsage(sourceFile);

    for (const [identifier, information] of usage) {
    console.log(`${identifier.getText()} is used ${information.uses.length} time(s).`);
    }