Skip to content

Contract, analyzers, and react transforms read nullable backwards #275

Description

@nathanacurtis

Subissue of #229.

ADR-065 documents what an absent nullable means on a prop:

  • true for StringProp, NumberProp, SlotProp, ImageProp — open value sets
  • false for EnumPropenum enumerates every accepted value

Three consumers predate that and read omission as not-nullable, which inverts the documented default:

  • specs/packages/cli/src/transforms/Contract.ts:72 — an omitted nullable emits label: string where string | null is meant, for essentially every non-enum string prop
  • specs/packages/cli/src/analyzers/Props.ts:123 — reports omission as non-nullable
  • specs-from-figma/packages/react-from-specs/src/React — ignores nullable entirely; only slot props get optional treatment in scaffold.ts:157

Scope

  • Apply the per-type default in all three, rather than testing for an explicit true
  • Generated contracts will widen to include null for open-valued props — expected, and the correction; regenerate fixtures
  • Use nullability when deriving React prop optionality

Depends on

Schema side ships in @directededges/specs-schema 0.29.0 (PR #273).

Metadata

Metadata

Assignees

No one assigned

    Labels

    clispecs-cli and MCP server

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions