﻿---
title: Finding References
---

## Finding References

You can find all the references of a node by calling `.findReferences()` on an identifier.

### Example

Simple example:

```typescript
const classDeclaration = ...; // get a class or some other declaration somehow
const referencedSymbols = classDeclaration.getNameIdentifier().findReferences();

for (const referencedSymbol of referencedSymbols) {
    for (const reference of referencedSymbol.getReferences()) {
        console.log("---------")
        console.log("REFERENCE")
        console.log("---------")
        console.log("File path: " + reference.getSourceFile().getFilePath());
        console.log("Start: " + reference.getTextSpan().getStart());
        console.log("Length: " + reference.getTextSpan().getLength());
        console.log("Parent kind: " + reference.getNode().getParentOrThrow().getKindName());
        console.log("\n");
    }
}
```

---
title: Finding References
---

## Finding References

You can find all the references of a node by calling `.findReferences()` on an identifier.

### Example

Simple example:

```typescript
const classDeclaration = ...; // get a class or some other declaration somehow
const referencedSymbols = classDeclaration.getNameIdentifier().findReferences();

for (const referencedSymbol of referencedSymbols) {
    for (const reference of referencedSymbol.getReferences()) {
        console.log("---------")
        console.log("REFERENCE")
        console.log("---------")
        console.log("File path: " + reference.getSourceFile().getFilePath());
        console.log("Start: " + reference.getTextSpan().getStart());
        console.log("Length: " + reference.getTextSpan().getLength());
        console.log("Parent kind: " + reference.getNode().getParentOrThrow().getKindName());
        console.log("\n");
    }
}
```

Save .md file as UTF-8 without signature to get it to work with github pages (so annoying to have to do this)
Save .md file as UTF-8 without signature to get it to work with github pages (so annoying to have to do this)
