{{ self::ts_doc_block(doc, "") }}export interface {{ name }} {
{%- for field in fields %}
{{ self::ts_doc_block(field.doc, "  ") }}  readonly {{ field.name }}: {{ field.ts_type }};
{%- endfor %}
}

const {{ name }}Codec: WireCodec<{{ name }}> = {
{%- if let Some(size) = wire_size %}
  size: (_v) => {{ size }},
{%- else %}
  size: (v) => {{ size_expr }},
{%- endif %}
  encode: (writer, v) => {
{%- for field in fields %}
    {{ field.wire_encode_expr("writer", "v") }};
{%- endfor %}
{%- if tail_padding > 0 %}
    writer.skip({{ tail_padding }});
{%- endif %}
  },
  decode: (reader) => {
{%- if tail_padding > 0 %}
    const result = {
{%- for field in fields %}
      {{ field.name }}: {{ field.wire_decode_expr() }},
{%- endfor %}
    };
    reader.skip({{ tail_padding }});
    return result;
{%- else %}
    return {
{%- for field in fields %}
      {{ field.name }}: {{ field.wire_decode_expr() }},
{%- endfor %}
    };
{%- endif %}
  },
};
