( name: string, symbol: ts.Symbol, location: ts.Node, checker: ts.TypeChecker, cwd: string )
| 2939 | } |
| 2940 | |
| 2941 | function functionSignature( |
| 2942 | name: string, |
| 2943 | symbol: ts.Symbol, |
| 2944 | location: ts.Node, |
| 2945 | checker: ts.TypeChecker, |
| 2946 | cwd: string |
| 2947 | ): string | null { |
| 2948 | const target = resolvedSymbolTarget(symbol, checker) |
| 2949 | const type = checker.getTypeOfSymbolAtLocation(target, location) |
| 2950 | const signatures = checker.getSignaturesOfType(type, ts.SignatureKind.Call) |
| 2951 | if (signatures.length === 0) return null |
| 2952 | const callSignatures: Array<string> = [] |
| 2953 | for (const signature of representativeSignatures(signatures, checker, location)) { |
| 2954 | const text = normalizeSignature( |
| 2955 | cwd, |
| 2956 | checker.signatureToString(signature, location, signatureTypeFormatFlags, ts.SignatureKind.Call) |
| 2957 | ) |
| 2958 | if (text === null) return null |
| 2959 | callSignatures.push(text) |
| 2960 | } |
| 2961 | const declaration = parseableSignature( |
| 2962 | cwd, |
| 2963 | callSignatures.map((text) => `declare function ${name}${text}`).join("\n") |
| 2964 | ) |
| 2965 | if (declaration !== null) return declaration |
| 2966 | const callSignatureAlias = parseableSignature( |
| 2967 | cwd, |
| 2968 | signatureAlias( |
| 2969 | name, |
| 2970 | `{ |
| 2971 | ${callSignatures.map((text) => ` ${text};`).join("\n")} |
| 2972 | }` |
| 2973 | ) |
| 2974 | ) |
| 2975 | if (callSignatureAlias !== null) return callSignatureAlias |
| 2976 | const typeText = normalizeSignature(cwd, checker.typeToString(type, location, signatureTypeFormatFlags)) |
| 2977 | if (typeText === null) return null |
| 2978 | return parseableSignature(cwd, `declare const ${name}: ${typeText}`) ?? |
| 2979 | parseableSignature(cwd, signatureAlias(name, typeText)) |
| 2980 | } |
| 2981 | |
| 2982 | function symbolSignature( |
| 2983 | name: string, |
no test coverage detected