AshTypescript. TypedChannel. Verifiers. VerifyTypedChannel
(ash_typescript v0.19.3)
Copy Markdown
View Source
Verifies that typed channel configurations are valid.
Checks:
- All declared events exist as publications on their respective resources.
- Event names are unique across all resources in the channel.
- Publications whose
returnstype is known are pushed as a JSON object. Phoenix only pushes map payloads (Phoenix.Socket.V2.JSONSerializerraises for anything else), so a string, number, boolean, date, atom, enum or array payload would crash the channel when broadcast. Maps, structs, resources, embedded resources, unions, keywords and tuples (and NewTypes of them) are all formatted to a map before the push. Types whose shape is not known (:term, hand-rolled custom types) are not checked. - Publications are marked
public?: true(warning if not). - Publications have
returnsset — either auto-derived viatransform :calcor explicitly declared (warning if not — TypeScript type falls back tounknown).
Checks 1 to 3 are hard errors. Checks 4 and 5 write to stderr and are each
gated by an application-level toggle (mirroring VerifyRpcWarnings):
config :ash_typescript, warn_on_non_public_publications: true(default)config :ash_typescript, warn_on_missing_channel_returns: true(default)
Checks 4 and 5 deliberately use IO.puts(:stderr, ...) rather than IO.warn/1.
This verifier runs during compilation of the channel module, where IO.warn/1
would register a compiler diagnostic and so fail mix compile --warnings-as-errors. A non-public? publication or a missing returns may
well be intentional, so it must not break the build.