Changelog
View SourceAll notable changes to this project will be documented in this file.
The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.
0.5.5 - 2026-11-06
Added
- Add
docoption support tofield/3in bothtypedstructandtypedrecordso field-level documentation can be included in generated module docs under aFieldssection. - Add validated constructor generation with
constructors: true.typedstruct:new/1,new!/1,from_map/1,from_keyword/1.typedrecord:<record>_new/1,<record>_new!/1,<record>_from_map/1,<record>_from_keyword/1.
- Add
default_fn: &Mod.fun/0field option for dynamic defaults used bygenerated constructors. - Add reflection helpers with
reflection: true. Add docs merge controls with
docs: :full | :module_only | :fields_only | false.- Add strict mode with
strict: truefor bothtypedstructandtypedrecord. - Add
derive: [...]support fortypedstruct. - Add
plugins: [...]option touse TypedStructto automatically inject default plugins into alltypedstructandtypedrecorddefinitions. This enables wrapper modules to provide preset plugins without manual configuration per struct definition (#5).
Changed
- Add validation for unknown top-level options in
typedstructandtypedrecord. - Improve duplicate field errors with source line information.
Fixed
- Preserve internal typedstruct attributes until plugin callbacks finish, fixing
reflection plugins that read
:ts_*attributes duringfield/4andafter_definition/1callbacks (#9). - Verify that issue #15 is fixed.
0.3.0 - 2022-02-15
Added
- [Plugin] Add the
field/4callback with an additionalenvargument. This is the same asfield/3but gives access to the environment of the field definition.
Deprecated
- [Plugin] Deprecate the
field/3callback in favour offield/4. You should migrate tofield/4, simply by adding_envas the last argument in your implementation. Currently, if a plugin implementsfield/3,field/4is derived from it and a compilation warning is emitted.field/3will be removed in TypedStruct 1.0.0.
Removed
- Drop support for unsupported Elixir versions in the tests and CI. The library may still be compatible, but this is not tested.
Fixed
- Fix the lexical scope of the
typestructblock, so it covers it completely. Previously, anything defined inside thetypedstructblock, such as aliases, would not be available for the field definitions. See #22 and #21 for details. - Fix a typo in the documentation.
0.2.1 - 2020-07-19
Added
- Add the
module: ModuleNametop-level option to create the typed struct in a submodule.
Changed
- Update the
@typedocexample in the documentation to put it inside thetypedstructblock and not above. While putting it above works in the general case, it is mandatory to put it inside the block when defining a submodule.
0.2.0 - 2020-05-31
Added
- Add a plugin API.
Removed
- Remove reflection support through the
__keys__/0,__defaults__/0and__types__/0function which where defined by TypedStruct in the user modules. If you rely on these functions, please use the TypedStructLegacyReflection plugin to enable them again, and consider creating a plugin for your needs.
Fixed
- Do not enforce fields with a default value set to nil (fixes #14).
- Prefix all internal module attributes and clean them after use (fixes #15).
- Create a scope in the
typedstructblock to avoid import leaks.
0.1.4 - 2018-11-13
Added
- Add the ability to generate an opaque type (#10).
0.1.3 - 2018-09-06
Fixed
- Fix a bug where boolean fields with
default: falsewhere still enforced when settingenforce: trueat top-level.
0.1.2 - 2018-09-06
Added
- Add the ability to enforce keys by default (#6).
Fixed
- Clarify the documentation about
runtime: false.
0.1.1 - 2018-06-20
Fixed
- Do not make the type nullable when there is a default value.
0.1.0 - 2018-06-19
Added
- Struct definition
- Type definition
- Default values
- Enforced keys