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

Function parseType

packages/tools/docgen/src/Parser.ts:170–184  ·  view source on GitHub ↗
(node: ast.Node)

Source from the content-addressed store, hash-verified

168 )
169
170const parseType = (node: ast.Node) => {
171 let text = getTypeText(node)
172 for (const property of node.getDescendantsOfKind(ast.ts.SyntaxKind.PropertySignature)) {
173 if (!shouldIgnore(parseDoc(getJSDocText(property.getJsDocs())))) continue
174 const readonly = property.getFirstModifierByKind(ast.ts.SyntaxKind.ReadonlyKeyword) ? "readonly " : ""
175 const optional = property.hasQuestionToken() ? "?" : ""
176 const type = property.getTypeNode()?.getText() ?? getTypeText(property)
177 const signature = `${readonly}${property.getName()}${optional}: ${type}`
178 text = text
179 .replaceAll(`; ${signature}`, "")
180 .replaceAll(`${signature}; `, "")
181 .replaceAll(signature, "")
182 }
183 return text
184}
185
186const getFunctionDeclarationJSDocs = (fd: ast.FunctionDeclaration): Array<ast.JSDoc> =>
187 Array.matchLeft(fd.getOverloads(), {

Callers 7

parseFunctionDeclarationFunction · 0.85
parseExportSpecifierFunction · 0.85
parseMethodFunction · 0.85
parsePropertyFunction · 0.85

Calls 3

getTypeTextFunction · 0.85
shouldIgnoreFunction · 0.85
parseDocFunction · 0.85

Tested by

no test coverage detected