import { createDecoratorOrDecoratorFactory , MemberDescriptor , isField } from "@esfx/decorators-stage1-core" ; /**
 * Converts a field declaration into an accessor with a backing property.
 */ export const autoproperty = createDecoratorOrDecoratorFactory ( ( member , readonly ? ) => { if ( ! isField ( member ) ) throw new TypeError ( `'@autoproperty' is only supported on fields.` ) ; const backingField = Symbol ( `__backingField<${ member . key . toString ( ) }>` ) ; const descriptor = { enumerable : false , configurable : true , get ( this ) { return this [ backingField ] ; } , set ( this , value ) { if ( backingField in this && readonly ) throw new TypeError ( "Property not writable." ) ; this [ backingField ] = value ; } } ; Object . defineProperty ( member . target , member . key , descriptor ) ; } ) ;