MCPcopy
hub / github.com/npmx-dev/npmx.dev / formatTypeLiteralType

Function formatTypeLiteralType

server/utils/docs/format.ts:124–137  ·  view source on GitHub ↗
(lit: NonNullable<TsType['typeLiteral']>)

Source from the content-addressed store, hash-verified

122}
123
124function formatTypeLiteralType(lit: NonNullable<TsType['typeLiteral']>): string {
125 const parts: string[] = []
126 for (const prop of lit.properties) {
127 const opt = prop.optional ? '?' : ''
128 const ro = prop.readonly ? 'readonly ' : ''
129 parts.push(`${ro}${prop.name}${opt}: ${formatType(prop.tsType) || 'unknown'}`)
130 }
131 for (const method of lit.methods) {
132 const params = method.params?.map(p => formatParam(p)).join(', ') || ''
133 const ret = formatType(method.returnType) || 'void'
134 parts.push(`${method.name}(${params}): ${ret}`)
135 }
136 return `{ ${parts.join('; ')} }`
137}

Callers 1

format.tsFile · 0.85

Calls 2

formatTypeFunction · 0.85
formatParamFunction · 0.85

Tested by

no test coverage detected