Skip to content

Usages regex is not comprehensive enough when types are invovled #95

@marcins

Description

@marcins

When updating our codebase to TypeScript we found instances where the usages regex was not comprehensive enough to find all usages. While ideally we would move to an AST based approach, in the meantime @MonicaOlejniczak provided a patch that enhanced the regex to cover more usages.

// This is going to assume you call the library, with an optional generic type parameter, and no whitespace...
const usageStartRe = new RegExp(`${importSpecifier}(?:<.+>)?\\(`);

-    const usageStartRe = new RegExp(`${importSpecifier}(?:<.+>)?\\(`);
+    const usageStartRe = new RegExp(`${importSpecifier}(?:<[^>]+[>\s]+)?\\(`);

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions