Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BaseType in props validation is missing type FunctionConstructor #1448

Closed
sdegueldre opened this issue Jun 2, 2023 · 3 comments · Fixed by #1560
Closed

BaseType in props validation is missing type FunctionConstructor #1448

sdegueldre opened this issue Jun 2, 2023 · 3 comments · Fixed by #1560
Labels
bug Something isn't working

Comments

@sdegueldre
Copy link
Contributor

No description provided.

@sdegueldre sdegueldre added the bug Something isn't working label Jun 2, 2023
@ged-odoo
Copy link
Contributor

ged-odoo commented Jun 8, 2023

probably stupid question, but I do not have a clear picture of a situation where we manipulate a FunctionConstructor. Can you give me a short explanation or example?

@sdegueldre
Copy link
Contributor Author

sdegueldre commented Jun 8, 2023

At the moment typescript will complain if you declare a prop to be of type Function in the static props definition as that's not a valid value for a type in schemas because BaseType is missing FunctionConstructor from the union

image

@sdegueldre
Copy link
Contributor Author

Apparently this is only a problem with ComponentConstructor and not components because on components the static props are any but the root component in an app is ComponentConstructor on which props is of type Schema

sdegueldre added a commit that referenced this issue Nov 22, 2023
Previously, having a Function as a type in the static props description
of a component would only work if the component was not the root
component, as the static props description on Component was "any",
whereas the static props description on ComponentConstructor was
"Schema". This meant that static props description on non-root
components was not type-checked, and on root components it was
type-checked only on the mount call.

This commit makes it so that static type description is of type "Schema"
on Component, now causing static props description to be type-checked,
and adds `typeof Function` to the `BaseType` union, which allows
declaring that a component expects a function as a prop.

Closes #1448
ged-odoo pushed a commit that referenced this issue Dec 4, 2023
Previously, having a Function as a type in the static props description
of a component would only work if the component was not the root
component, as the static props description on Component was "any",
whereas the static props description on ComponentConstructor was
"Schema". This meant that static props description on non-root
components was not type-checked, and on root components it was
type-checked only on the mount call.

This commit makes it so that static type description is of type "Schema"
on Component, now causing static props description to be type-checked,
and adds `typeof Function` to the `BaseType` union, which allows
declaring that a component expects a function as a prop.

Closes #1448
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants