/** * Fixtures for source-level DEFAULT prop extraction. TypeScript types don't carry * defaults — they live in the implementation — so `extractDefaultProps` recovers them * syntactically. Each export isolates one real-world shape. */ /** (1) Defaults in the destructured PARAMETER. */ export const ParamDefaults = ({ size = 'md', count = 2, open = true, }: { size?: 'sm' | 'md' | 'lg'; count?: number; open?: boolean; }) => null; /** (2) Defaults in BODY destructuring of the props param (GSK's Badge shape). */ export const BodyDefaults = (props: { variant?: 'primary' | 'secondary'; label?: string; }) => { const { variant = 'secondary', label = 'Hello' } = props; return { variant, label }; }; /** (3) Generic component with a body-destructuring default (Badge exact shape). */ type Kind = 'pill' | 'square'; export const GenericBodyDefaults = (props: { kind?: T }) => { const { kind = 'pill' } = props; return { kind }; }; /** (4) Static `defaultProps`. */ export function DefaultPropsComp(props: { tone?: 'a' | 'b'; n?: number }) { return props; } DefaultPropsComp.defaultProps = { tone: 'a', n: 5 }; /** (5a) RENAMED body destructuring — default must key off the PROP, not the local var. */ export const RenamedDefaults = (props: { label?: string; size?: 'sm' | 'md'; }) => { const { label: text = 'Hello', size: s = 'md' } = props; return { text, s }; }; /** (5) Non-literal default (identifier) — must be SKIPPED, not crash. */ const FALLBACK = 'fallback-icon'; export const NonLiteralDefault = (props: { icon?: string }) => { const { icon = FALLBACK } = props; return { icon }; }; /** (6) No defaults at all. */ export const NoDefaults = (props: { name?: string }) => { const { name } = props; return { name }; };