Skip to content

Emitter: {component}.contract.ts #137

Description

@nathanacurtis

Summary

Add a {component}.contract.ts emitter to specs-cli that projects a validated component contract into a framework-agnostic TypeScript file containing prop interfaces, slot signatures, defaults, and slot visibility rules.

RFC

This emitter is specified in RFC 001: Component Dictionary — emitter group contracts, priority high, complexity trivial.

Framework-agnostic TS prop interface + slot signature, no framework imports. Lossless within its idiom; the load-bearing platform emitter for typed languages.

Sketch

rfc/001-component-dictionary/sketches/button.contract.ts

The sketch covers:

  • Prop type unions and interface ButtonProps
  • ButtonDefaults (as const satisfies Required<...>) for compile-time default enforcement
  • ButtonSlots interface
  • SlotVisibility discriminated union (always / whenTrue / whenNotNull)
  • ButtonSlotRules (as const satisfies Record<keyof ButtonSlots, SlotVisibility>)

The inline comments in the sketch document the mapping from Specs schema types (PropBinding, Conditional, structural absence) to the SlotVisibility consumer-facing form, including an open question on structural-absence recovery that must be resolved before implementation.

Acceptance criteria

  • Emitter registered under the contracts group
  • Prop interface derived from component prop schema (types, nullability)
  • Defaults object uses as const satisfies Required<...>
  • Slot signature derived from anatomy elements
  • SlotVisibility rules projected from styles.visible bindings and structural variant presence
  • Output is deterministic (same contract -> identical file)
  • Covered by unit tests using a fixture component

Metadata

Metadata

Assignees

No one assigned

    Labels

    clispecs-cli and MCP server

    Type

    No type
    No fields configured for issues without a type.

    Projects

    Status
    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions