( outputDir: string, node: ts.TypeNode, )
| 391 | // The label of a declared type: the members of an intersection or union joined, a getter's result, the |
| 392 | // keys of an object type, or the name looked up through the same wrappers as `typeNameInCode`. |
| 393 | async function declaredTypeLabel( |
| 394 | outputDir: string, |
| 395 | node: ts.TypeNode, |
| 396 | ): Promise<string | undefined> { |
| 397 | if (ts.isParenthesizedTypeNode(node)) { |
| 398 | return declaredTypeLabel(outputDir, node.type) |
| 399 | } |
| 400 | if (ts.isIntersectionTypeNode(node) || ts.isUnionTypeNode(node)) { |
| 401 | const members = await Promise.all( |
| 402 | node.types.map((member) => declaredTypeLabel(outputDir, member)), |
| 403 | ) |
| 404 | return members.every(Boolean) |
| 405 | ? members.join(ts.isIntersectionTypeNode(node) ? ' & ' : ' | ') |
| 406 | : undefined |
| 407 | } |
| 408 | if (ts.isFunctionTypeNode(node) && node.parameters.length === 0) { |
| 409 | const result = await declaredTypeLabel(outputDir, node.type) |
| 410 | return result && `() => ${result}` |
| 411 | } |
| 412 | if (ts.isTypeLiteralNode(node)) { |
| 413 | const keys = node.members |
| 414 | .map((member) => member.name?.getText()) |
| 415 | .filter(Boolean) |
| 416 | return keys.length > 0 ? `{ ${keys.join(', ')} }` : undefined |
| 417 | } |
| 418 | if ( |
| 419 | ts.isTypeReferenceNode(node) && |
| 420 | typeTransforms.has(node.typeName.getText()) && |
| 421 | node.typeArguments?.[0] |
| 422 | ) { |
| 423 | const target = await declaredTypeLabel(outputDir, node.typeArguments[0]) |
| 424 | return target && `${node.typeName.getText()}<${target}>` |
| 425 | } |
| 426 | return typeNameInCode(outputDir, node.getText()) |
| 427 | } |
| 428 | |
| 429 | // The property table for the first type line that has one. |
| 430 | async function findPropertiesTable( |
no test coverage detected