(nodes: ts.Node[])
| 832 | } |
| 833 | |
| 834 | const findNodeByPreference = (nodes: ts.Node[]): ts.Node | undefined => { |
| 835 | if (nodes.length === 0) return undefined |
| 836 | const typeReference = nodes.find( |
| 837 | node => syntax.isTypeReferenceNode(node) || syntax.isTypeQueryNode(node) |
| 838 | ) |
| 839 | if (typeReference) return typeReference |
| 840 | const declaration = nodes.find( |
| 841 | node => |
| 842 | syntax.isVariableDeclaration(node) || |
| 843 | syntax.isFunctionDeclaration(node) || |
| 844 | syntax.isClassDeclaration(node) || |
| 845 | syntax.isInterfaceDeclaration(node) |
| 846 | ) |
| 847 | if (declaration) return declaration |
| 848 | const propertyAccess = nodes.find(node => |
| 849 | syntax.isPropertyAccessExpression(node) |
| 850 | ) |
| 851 | if (propertyAccess) return propertyAccess |
| 852 | const assignment = nodes.find( |
| 853 | node => |
| 854 | syntax.isBinaryExpression(node) && |
| 855 | node.operatorToken.kind === syntax.SyntaxKind.EqualsToken |
| 856 | ) |
| 857 | if (assignment) return assignment |
| 858 | const expression = nodes.find( |
| 859 | node => syntax.isExpressionStatement(node) || syntax.isExpression(node) |
| 860 | ) |
| 861 | if (expression) return expression |
| 862 | return nodes.sort((a, b) => a.end - a.pos - (b.end - b.pos))[0] |
| 863 | } |
| 864 | |
| 865 | const writeToCsv = ( |
| 866 | filePath: string, |
no test coverage detected