Properties define computed member access on classes.

A property is written as a getter, a setter, or both.

💡 User (
	get name() is string (
		return firstName + " " + lastName
	)
	
	set name(value is string) (
		firstName = value
	)
)

This spelling intentionally stays close to TypeScript accessor syntax. Typical uses is for type annotations and ( / ) for bodies.

Accessors

A getter is written with get, the property name, an empty parameter list, a return type, and a body.

get name() is string (
	return firstName + " " + lastName
)

A setter is written with set, the property name, one parameter, and a body.

set name(value is string) (
	firstName = value
)

A property may have only a getter, only a setter, or both. A class may define at most one getter and one setter for the same property name.

Setters do not return values.

Getter And Setter Types

When a property has both a getter and a setter, the getter return type and setter parameter type may differ.

Typical should follow TypeScript's accessor behavior as closely as possible while preserving Typical's nominal type system. Where TypeScript relies on structural assignability, Typical uses nominal compatibility.

💡 Setting (
	get value() is SavedValue (
		return savedValue
	)
	
	set value(value is NewValue) (
		savedValue = value.toSavedValue()
	)
)

Visibility

Properties use visibility groups like other class members.

💡 User (
	get name() is string (
		return firstName + " " + lastName
	)
	
	set name(value is string) (
		firstName = value
	)
	
	export (
		get name
	)
	
	expose (
		set name
	)
)

When a property name is listed directly, the visibility applies to both the getter and setter.

export (
	name
)

get name applies only to the getter. set name applies only to the setter.

This allows common read/write API shapes without inline visibility modifiers.

💡 User (
	get id() is string (
		return internalId
	)
	
	set id(value is string) (
		internalId = value
	)
	
	export (
		get id
	)
	
	exclude (
		set id
	)
)

Static Properties

Properties may appear inside static scopes.

💡 Registry (
	static (
		get count() is int (
			return items.length
		)
	)
)

Static properties do not have an implicit instance. They follow the normal static scope rules.

Automatic Properties

Typical does not currently have a condensed automatic property syntax.

Fields, properties, constructor parameter promotion, and visibility groups cover the supported storage and API shapes. The text format should not add a second spelling only to make common read/write visibility shorter.