import { DocsSpec, Documented } from './documented'; import { Expression } from './expressions'; import { MemberType } from './member-type'; import { Block } from './statements/block'; import { Type } from './type'; import { MemberKind, MemberVisibility, TypeMember } from './type-member'; export interface PropertySpec { /** * The name of the property. * * @minLength 1 */ name: string; /** * Indicates if this property only has a getter (immutable). * * @default false */ immutable?: boolean; /** * Indicates if this property is protected (otherwise it is public) * * @deprecated Use visibility instead. * @default false */ protected?: boolean; /** * Indicates the visibility of this property * * Cannot be used together with `protected`. * * @default false */ visibility?: MemberVisibility; /** * Indicates if this property is abstract * * @default false */ abstract?: boolean; /** * Indicates if this is a static property. * * @default false */ static?: boolean; /** * A hint that indicates that this static, immutable property is initialized * during startup. This allows emitting "const" idioms in different target * languages. Implies `static` and `immutable`. * * @default false */ const?: boolean; /** * Documentation for this entity. * * @default none */ docs?: DocsSpec; /** * Determines whether the value is, indeed, optional. * * @default false */ optional?: boolean; /** * The declared type of the value, when it's present. */ type: Type; /** * The initial assignment of the property. */ initializer?: Expression; /** * Body of the getter implementation */ getterBody?: Block; /** * Signature and body of the setter implementation */ setterBody?: (value: Expression) => Block; } export interface IProperty extends Documented { readonly name: string; readonly abstract: boolean; readonly immutable: boolean; readonly optional: boolean; readonly type: Type; readonly initializer?: Expression; readonly visibility: MemberVisibility; readonly static: boolean; } export declare class Property extends TypeMember implements IProperty { readonly scope: MemberType; readonly spec: PropertySpec; readonly kind = MemberKind.Property; /** * Indicates if this property only has a getter (immutable). */ get immutable(): boolean; /** * Is the property optional. */ get optional(): boolean; /** * The visibility of the member. */ get visibility(): MemberVisibility; get initializer(): Expression | undefined; /** * The type of the property as a reference. */ readonly type: Type; constructor(scope: MemberType, spec: PropertySpec); /** * Read a property from an object */ from(x: Expression): Expression; get getter(): Block | undefined; get setter(): ((value: Expression) => Block) | undefined; get isGetterSetter(): Block | ((value: Expression) => Block) | undefined; }