MCPcopy Create free account
hub / github.com/angular/components / getTypeOfFunctionLikeDoc

Function getTypeOfFunctionLikeDoc

tools/dgeni/processors/async-functions.ts:50–64  ·  view source on GitHub ↗

* Gets the type of the function-like doc. If no explicit type has been specified, * the type checker is used to compute a type string based on the function body.

(doc: FunctionLikeDoc)

Source from the content-addressed store, hash-verified

48 * the type checker is used to compute a type string based on the function body.
49 */
50function getTypeOfFunctionLikeDoc(doc: FunctionLikeDoc): string | null {
51 if (doc.type) {
52 return doc.type;
53 }
54
55 const decl = doc.declaration as ts.MethodDeclaration | ts.FunctionDeclaration;
56 const signature = doc.typeChecker.getSignatureFromDeclaration(decl);
57
58 if (!signature) {
59 return null;
60 }
61
62 const returnType = doc.typeChecker.getReturnTypeOfSignature(signature);
63 return doc.typeChecker.typeToString(returnType);
64}
65
66/** Whether the given API doc is a function-like doc. */
67function isFunctionLikeDoc(doc: ApiDoc): doc is FunctionLikeDoc {

Callers 1

$processMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected