declaration-helpers.ts view source
(declarationNames: ReadonlySet<string>): [string, RegExp][] Pre-compile identifier-boundary patterns for a set of declaration names.
When scanning many type strings against the same declaration set, call this once and pass the result to findTypeReferences to avoid recompiling regexes on every call.
declarationNames
set of known in-project declaration names
ReadonlySet<string>returns
[string, RegExp][] array of [name, pattern] pairs for use with findTypeReferences
examples
const names = new Set(modules.flatMap(m => m.declarations.map(d => d.name)));
const patterns = buildTypeReferencePatterns(names);
for (const decl of declarations) {
const refs = findTypeReferences(decl.typeSignature, patterns);
}