import type { ApiDeclaredItem, ApiItemContainerMixin, ApiProperty, ApiPropertySignature, } from '@microsoft/api-extractor-model'; import type { PropsWithChildren } from 'react'; import { Anchor } from './Anchor'; import { ExcerptText } from './ExcerptText'; import { InheritanceText } from './InheritanceText'; import { TSDoc } from './documentation/tsdoc/TSDoc'; export enum PropertySeparatorType { Type = ':', Value = '=', } export function Property({ item, children, separator, inheritedFrom, }: PropsWithChildren<{ inheritedFrom?: (ApiDeclaredItem & ApiItemContainerMixin) | undefined; item: ApiProperty | ApiPropertySignature; separator?: PropertySeparatorType; }>) { const isDeprecated = Boolean(item.tsdocComment?.deprecatedBlock); const hasSummary = Boolean(item.tsdocComment?.summarySection); return (
{isDeprecated || item.isReadonly || item.isOptional || (item as ApiProperty).isStatic ? (
{isDeprecated ? (
Deprecated
) : null} {(item as ApiProperty).isStatic ? (
Static
) : null} {item.isReadonly ? (
Readonly
) : null} {item.isOptional ? (
Optional
) : null}
) : null}

{item.displayName} {item.isOptional ? '?' : ''}

{item.propertyTypeExcerpt.text ? ( <>

{separator}

) : null}
{hasSummary || inheritedFrom ? (
{item.tsdocComment ? : null} {inheritedFrom ? : null} {children}
) : null}
); }