How to get named export node (more easily)
- Dominant language
- TypeScript
- Stars
- 6.2k
- Forks
- 238
- Avg merge
- 2m
- Merged PRs (30d)
- 1
Description
First of all, great project. Had fun using it!
Maybe someone knows a better way to do this, I found it a bit inconvenient for something I would expect to be easier.
Let's take this input file:
```ts
export { ExportA, ExportB } from './DepA';
export { ExportC } from './DepB';
export type { TypeA, TypeB } from './types';
```
Now I wanted to get the node of `ExportC` so I can find it's references in other source files:
```ts
const namedExports = sourceFile.getExportDeclarations().map(declaration => declaration.getNamedExports());
const exportSpecifier = namedExports.flat().find(namedExport => namedExport.getName() === 'ExportC');
const node = exportSpecifier?.getNameNode();
const references = node?.findReferencesAsNodes();
```
It works as intended, yet I think this is slightly tedious, maybe there's a better way?
Contributor guide
Research direction
Start by reproducing the TypeScript export example and reading the existing getExportDeclarations(), getNamedExports(), getNameNode(), and findReferencesAsNodes() APIs. Determine whether a simpler supported path can expose the named export's references; done means the proposed API is clear, implemented, and preserves the existing behavior for ExportA, ExportB, ExportC, and type exports.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100