Skip to content

Required properties are typed as optional in useMachine input #2411

@iyefrat

Description

@iyefrat

🐛 Bug report

It seems that all properties in useMachine input are typed as optional, even if they are required in the documentation and in practice. This causes code that typechecks to fail in runtime.

💥 Steps to reproduce

  1. Create a splitter without a panels input
  2. see that it typechecks tsc -b
  3. see that the website doesn't load, and that the console log shows [zag-js] missing required props: panels
  4. add panels and see that it solves the issue.

💻 Link to reproduction

https://stackblitz.com/edit/sb1-3xdwzhmb?file=src%2FApp.tsx

🧐 Expected behavior

Since panels are a required property I would expect this to fail type checking.

🧭 Possible Solution

It seems that the input is partial'd on purpose, see

userProps: Partial<T["props"]> | Accessor<Partial<T["props"]>> = {},

I'm not sure why that is, but maybe it's possible to remove that and do something else instead.

🌍 System information

Software Version(s)
Zag Version 1.9.3
Browser Chrome 134.0.6998.166
Operating System MacOS 15.3.2

📝 Additional information

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions