(node: SyntaxNode)
| 27 | * function targets. |
| 28 | */ |
| 29 | export function classifyTsClassMember(node: SyntaxNode): 'method' | 'property' { |
| 30 | if (node.type !== 'public_field_definition' && node.type !== 'field_definition') { |
| 31 | return 'method'; // method_definition, getters/setters — untouched |
| 32 | } |
| 33 | for (let i = 0; i < node.namedChildCount; i++) { |
| 34 | const child = node.namedChild(i); |
| 35 | if (!child) continue; |
| 36 | if (child.type === 'arrow_function' || child.type === 'function_expression') { |
| 37 | return 'method'; |
| 38 | } |
| 39 | if (child.type === 'call_expression') { |
| 40 | const args = getChildByField(child, 'arguments'); |
| 41 | if (args) { |
| 42 | for (let j = 0; j < args.namedChildCount; j++) { |
| 43 | const arg = args.namedChild(j); |
| 44 | if (arg && (arg.type === 'arrow_function' || arg.type === 'function_expression')) { |
| 45 | return 'method'; |
| 46 | } |
| 47 | } |
| 48 | } |
| 49 | } |
| 50 | } |
| 51 | return 'property'; |
| 52 | } |
| 53 | |
| 54 | /** |
| 55 | * Flow's own syntax, blanked to spaces (offsets survive) so a Flow file reads |
nothing calls this directly
no test coverage detected