MCPcopy Create free account
hub / github.com/angular/angular / importCollisionExists

Function importCollisionExists

packages/language-service/src/utils/ts_utils.ts:311–318  ·  view source on GitHub ↗

* Given an unqualified name, determine whether an existing import is already using this name in * the current scope. * TODO: It would be better to check if *any* symbol uses this name in the current scope.

(importDeclaration: ts.ImportDeclaration[], name: string)

Source from the content-addressed store, hash-verified

309 * TODO: It would be better to check if *any* symbol uses this name in the current scope.
310 */
311function importCollisionExists(importDeclaration: ts.ImportDeclaration[], name: string): boolean {
312 const bindings = importDeclaration.map((declaration) => declaration.importClause?.namedBindings);
313 const namedBindings: ts.NamedImports[] = bindings.filter(
314 (binding) => binding !== undefined && ts.isNamedImports(binding),
315 ) as ts.NamedImports[];
316 const specifiers = namedBindings.flatMap((b) => b.elements);
317 return specifiers.some((s) => s.name.text === name);
318}
319
320/**
321 * Generator function that yields an infinite sequence of alternative aliases for a given symbol

Callers 1

nonCollidingImportNameFunction · 0.85

Calls 3

mapMethod · 0.80
someMethod · 0.80
filterMethod · 0.45

Tested by

no test coverage detected