PhoenixAssets.Generators.Typespec (PhoenixAssets v0.1.0)

View Source

Renders named Elixir typespecs as TypeScript declarations.

The source module, declaration order, root union name, output path, and optional trailer are supplied by the host. Product type names never live in this module.

Summary

Functions

Fetches types from source_module and renders configured TypeScript.

Writes rendered types to the configured output path.

Types

option()

@type option() ::
  {:types, [atom()]}
  | {:root, atom()}
  | {:root_name, String.t()}
  | {:discriminator_name, String.t()}
  | {:trailer, String.t()}

Functions

render(source_module, opts)

@spec render(module(), [option()]) :: {:ok, String.t()} | :error

Fetches types from source_module and renders configured TypeScript.

write(source_module, output, opts)

@spec write(module(), Path.t(), [option()]) :: :ok | :error | {:error, term()}

Writes rendered types to the configured output path.