|
| 1 | +// The source code is kindly borrowed from `ts-is-kind` npm module. |
| 2 | +// Original repo: https://github.com/mohsen1/ts-is-kind by @mohsen1 |
| 3 | + |
| 4 | +import * as ts from 'typescript'; |
| 5 | + |
| 6 | +/** |
| 7 | + * Return true if node is `PropertyAccessExpression` |
| 8 | + * @param node A TypeScript node |
| 9 | + */ |
| 10 | +export function isPropertyAccessExpression(node: ts.Node): node is ts.PropertyAccessExpression { |
| 11 | + return node.kind === ts.SyntaxKind.PropertyAccessExpression; |
| 12 | +} |
| 13 | + |
| 14 | +/** |
| 15 | + * Return true if node is `CallExpression` |
| 16 | + * @param node A TypeScript node |
| 17 | + */ |
| 18 | +export function isCallExpression(node: ts.Node): node is ts.CallExpression { |
| 19 | + return node.kind === ts.SyntaxKind.CallExpression; |
| 20 | +} |
| 21 | + |
| 22 | +/** |
| 23 | + * Return true if node is `Identifier` |
| 24 | + * @param node A TypeScript node |
| 25 | + */ |
| 26 | +export function isIdentifier(node: ts.Node): node is ts.Identifier { |
| 27 | + return node.kind === ts.SyntaxKind.Identifier; |
| 28 | +} |
| 29 | + |
| 30 | +/** |
| 31 | + * Return true if node is `VariableDeclaration` |
| 32 | + * @param node A TypeScript node |
| 33 | + */ |
| 34 | +export function isVariableDeclaration(node: ts.Node): node is ts.VariableDeclaration { |
| 35 | + return node.kind === ts.SyntaxKind.VariableDeclaration; |
| 36 | +} |
| 37 | + |
| 38 | +/** |
| 39 | + * Return true if node is `ExportAssignment` |
| 40 | + * @param node A TypeScript node |
| 41 | + */ |
| 42 | +export function isExportAssignment(node: ts.Node): node is ts.ExportAssignment { |
| 43 | + return node.kind === ts.SyntaxKind.ExportAssignment; |
| 44 | +} |
| 45 | + |
| 46 | +/** |
| 47 | + * Return true if node is `TaggedTemplateExpression` |
| 48 | + * @param node A TypeScript node |
| 49 | + */ |
| 50 | +export function isTaggedTemplateExpression(node: ts.Node): node is ts.TaggedTemplateExpression { |
| 51 | + return node.kind === ts.SyntaxKind.TaggedTemplateExpression; |
| 52 | +} |
0 commit comments