AshTypescript.TypedChannel.Verifiers.VerifyTypedChannel (ash_typescript v0.19.3)

Copy Markdown View Source

Verifies that typed channel configurations are valid.

Checks:

  1. All declared events exist as publications on their respective resources.
  2. Event names are unique across all resources in the channel.
  3. Publications whose returns type is known are pushed as a JSON object. Phoenix only pushes map payloads (Phoenix.Socket.V2.JSONSerializer raises 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.
  4. Publications are marked public?: true (warning if not).
  5. Publications have returns set — either auto-derived via transform :calc or explicitly declared (warning if not — TypeScript type falls back to unknown).

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.