Helpers for ts-morph
npm install ts-morph-helpersHelpers for ts-morph.
```
experimental/findJsxIdentifiersInJsxExpressions
experimental/findJsxSymbolsInJsxExpressions
experimental/getRealSourceFilesForImportDeclarations
experimental/getReferencedSourceFiles
experimental/hasSymbol
experimental/isBarrel
expressions/findCallExpressionsByName
expressions/findCallExpressionsWithArg
file/getRealSourceFileForImportDeclaration
file/getSourceFilesForNodes
jsx/findJsxNodeByName
jsx/findJsxNodes
jsx/isJsx
module/findDuplicateExportedNames
module/findExportDeclarationByIdentifier
module/findExportDeclarationByName
module/findExportIdentifierByName
module/findExportSpecifierByName
module/findImportIdentifierByName
module/findImportSpecifierByName
module/findReferencingNamespaceExports
module/findReferencingNamespaceImports
module/findReferencingNamespaceNodes
module/getImportDeclarationsForSymbols
module/hasReferencingDefaultImport
node/getDeclarationsForSymbols
node/getSymbolsOfNodes
react/findContextProviderIdentifierByContextName
react/findHookCallExpressions
react/findHookIdentifierByContextName
When looking at this example code...
`ts`
import { a } from './a';
import { b } from 'b';
const c = a + b;
const d = b(c);
export { c };
...we can apply the following (incomplete) list of terms:
| Name | Description | Example |
| ------------------ | ------------------------------------------------------- | -------------------------------------------- |
| Symbol | Named declaration, connects declaration nodes. | a, b, c, d |a
| Identifier | Node, references a symbol | (2x), b (3x), c (2x), d (1x) |ImportSpecifier
| Specifier | More specific classification of identifier | a, ExportSpecifier c |b(c)
| Call expression | Function call with arguments | |import { b } from 'b'
| Import declaration | An import declaration with named and/or default imports | |export { b } from 'b'
| Export declaration | An export declaration with named (not default) exports | |
Here is the
example code in the TypeScript AST Viewer
to see the nodes as described.
- SourceFile: The AST of a given source file
- Program: Collection of source files, and its main entry
The following conventions are used to name the helper functions:
- To get something means the thing is a reference expected to be there (upwards and/or linked).find
- To something means to query for things from a certain starting point (downwards).For
- To get things something expresses an AncestorForDescendant hierarchy.Of
- To get things something means the opposite: descendantOfAncestor`.