( node: Node, module: SourceModule )
| 61 | |
| 62 | // e.g. `T` in `<t>(T: Type<t>) => T.or("null")`, with the function's name |
| 63 | export const parameterOf = ( |
| 64 | node: Node, |
| 65 | module: SourceModule |
| 66 | ): { binding: Binding; fn: string; isAnnotated: boolean } | undefined => { |
| 67 | const id = unwrapChain(node) |
| 68 | const binding = |
| 69 | id.type === "Identifier" ? module.scopes.byId.get(id)?.binding : undefined |
| 70 | if (binding?.kind !== "param") return |
| 71 | return { |
| 72 | binding, |
| 73 | fn: inferredNameOf(binding.declaration as FunctionNode), |
| 74 | isAnnotated: !!(binding.id as { typeAnnotation?: unknown }).typeAnnotation |
| 75 | } |
| 76 | } |
| 77 | |
| 78 | // e.g. "BeforeNavigate" for `nav: BeforeNavigate` |
| 79 | export const annotationSnippetOf = ( |
no test coverage detected