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

Function functionSignature

packages/tools/jsdocs/src/Jsdocs.ts:3011–3050  ·  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

3009}
3010
3011function 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
3052function symbolSignature(
3053 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.65
joinMethod · 0.45
mapMethod · 0.45

Tested by

no test coverage detected