MCPcopy Create free account
hub / github.com/Effect-TS/effect / functionSignature

Function functionSignature

packages/tools/jsdocs/src/Jsdocs.ts:2941–2980  ·  view source on GitHub ↗
(
  name: string,
  symbol: ts.Symbol,
  location: ts.Node,
  checker: ts.TypeChecker,
  cwd: string
)

Source from the content-addressed store, hash-verified

2939}
2940
2941function 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
2982function symbolSignature(
2983 name: string,

Callers 1

symbolSignatureFunction · 0.85

Calls 8

resolvedSymbolTargetFunction · 0.85
representativeSignaturesFunction · 0.85
normalizeSignatureFunction · 0.85
parseableSignatureFunction · 0.85
signatureAliasFunction · 0.85
pushMethod · 0.80
joinMethod · 0.80
mapMethod · 0.45

Tested by

no test coverage detected