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

ReactDataTableComponentProps should use generics so that rowItem is T instead of any #2486

Closed
mschipperheyn opened this issue Oct 24, 2023 · 3 comments · Fixed by #2500
Closed
Assignees

Comments

@mschipperheyn
Copy link
Collaborator

Is your feature request related to a problem? Please describe.
The typescript definition for ReactDataTableComponentProps returns rowItem as any, which is a flexible default.
But using T is more correct and offers code insight.

Describe the solution you'd like
ReactDataTableComponentProps possibly but not necessarily defaulting to any

export const Label: React.FC<ReactDataTableComponentProps<Address>> = ({ rowItem }) => {
    const street = rowItem.street;
    const phone = rowItem.phneNumber; // error
    return (
        <a href={`https://example.com/address/${rowItem.id}`} target="_blank">
            {street}
        </a>
    );
}

Describe alternatives you've considered
One could create a wrapper to provide the behavior

Additional context
any in Typescript is a v1.0 quickie. It defeats the purpose of Typescript. V1.1 should imho remove it.

@michaelbromley
Copy link
Member

This is a good point. Would you be interested in submitting a pull request to rectify this? The file in question is located here: https://github.com/vendure-ecommerce/vendure/blob/master/packages/admin-ui/src/lib/react/src/register-react-data-table-component.ts#L48

@barakamwakisha
Copy link
Contributor

@michaelbromley, I want to work on this

@michaelbromley
Copy link
Member

@barakamwakisha Great! Thanks for jumping in 👍

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 a pull request may close this issue.

3 participants