Skip to content

Conversation

@sjwilczynski
Copy link
Contributor

@sjwilczynski sjwilczynski commented Aug 7, 2025

We previously did some work to add good, strong types for parameters for nova decorator. One of the big things was making sure that referenceEntries fields match props of the component. However, we are now verifying only if the name of the prop matches, instead of of actually checking the value, which causes a number of random errors for folks using this in 1JS.

In scope of this PR we add a validation of return type of each field in referenceEntries. So previously

referenceEntries: {
       // the key "feedback" is checked against component props but the return value of the function is ignored
        feedback: (data) => data.feedback,
},

now

referenceEntries: {
       // also "data.feedback" is checked so that it matches the type that feedback prompt on the component expects
        feedback: (data) => data.feedback,
},

Thanks to @MikeBarker-MSFT for providing a first version of this within 1JS

@MikeBarker-MSFT
Copy link
Member

This looks like a REALLY good addition to the testing framework. Thank you for adding.

@sjwilczynski sjwilczynski merged commit 850b3dd into microsoft:main Aug 8, 2025
2 checks passed
@sjwilczynski sjwilczynski deleted the sjwilczy/strongReferenceEntries branch August 8, 2025 20:14
* Utility type to extract the props of a React component.
*/
export type Props<Component> =
Component extends React.ComponentType<infer P> ? P : never;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor nit, this should already be available with (iirc) React.ComponentProps<T>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants