( name: string, symbol: ts.Symbol, location: ts.Node, checker: ts.TypeChecker, cwd: string )
| 3009 | } |
| 3010 | |
| 3011 | function functionSignature( |
| 3012 | name: string, |
| 3013 | symbol: ts.Symbol, |
| 3014 | location: ts.Node, |
| 3015 | checker: ts.TypeChecker, |
| 3016 | cwd: string |
| 3017 | ): string | null { |
| 3018 | const target = resolvedSymbolTarget(symbol, checker) |
| 3019 | const type = checker.getTypeOfSymbolAtLocation(target, location) |
| 3020 | const signatures = checker.getSignaturesOfType(type, ts.SignatureKind.Call) |
| 3021 | if (signatures.length === 0) return null |
| 3022 | const callSignatures: Array<string> = [] |
| 3023 | for (const signature of representativeSignatures(signatures, checker, location)) { |
| 3024 | const text = normalizeSignature( |
| 3025 | cwd, |
| 3026 | checker.signatureToString(signature, location, signatureTypeFormatFlags, ts.SignatureKind.Call) |
| 3027 | ) |
| 3028 | if (text === null) return null |
| 3029 | callSignatures.push(text) |
| 3030 | } |
| 3031 | const declaration = parseableSignature( |
| 3032 | cwd, |
| 3033 | callSignatures.map((text) => `declare function ${name}${text}`).join("\n") |
| 3034 | ) |
| 3035 | if (declaration !== null) return declaration |
| 3036 | const callSignatureAlias = parseableSignature( |
| 3037 | cwd, |
| 3038 | signatureAlias( |
| 3039 | name, |
| 3040 | `{ |
| 3041 | ${callSignatures.map((text) => ` ${text};`).join("\n")} |
| 3042 | }` |
| 3043 | ) |
| 3044 | ) |
| 3045 | if (callSignatureAlias !== null) return callSignatureAlias |
| 3046 | const typeText = normalizeSignature(cwd, checker.typeToString(type, location, signatureTypeFormatFlags)) |
| 3047 | if (typeText === null) return null |
| 3048 | return parseableSignature(cwd, `declare const ${name}: ${typeText}`) ?? |
| 3049 | parseableSignature(cwd, signatureAlias(name, typeText)) |
| 3050 | } |
| 3051 | |
| 3052 | function symbolSignature( |
| 3053 | name: string, |
no test coverage detected