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

ModalSelector renderItem typing error #168

Closed
scousino opened this issue Aug 5, 2021 · 14 comments
Closed

ModalSelector renderItem typing error #168

scousino opened this issue Aug 5, 2021 · 14 comments

Comments

@scousino
Copy link

scousino commented Aug 5, 2021

Somewhere between versions 2.0.2 and 2.0.7 the typings for the props on ModalSelector were changed to include FlatListProps. Since that change, TypeScript now throws an error unless you provide the renderItem property that is required for a FlatList. However, I know that is wrong, because this package already takes care of providing a renderItem implementation in its code.

I believe the solution is to utilize Pick, Omit, Exclude from TypeScript in some way, but I'm not familiar with exactly how

@andkom
Copy link

andkom commented Aug 9, 2021

same for me

@cesarve77
Copy link

Same

@GoreckiK
Copy link

same here

@joseclaudiojr
Copy link

joseclaudiojr commented Aug 19, 2021

Adding PropTypes.array to line 32 solves the problem:
style: PropTypes.oneOfType([PropTypes.object, PropTypes.number, PropTypes.array]),

@peacechen
Copy link
Owner

@joseclaudiojr
Please submit a PR

@scousino
Copy link
Author

scousino commented Aug 30, 2021

Adding PropTypes.array to line 32 solves the problem:
style: PropTypes.oneOfType([PropTypes.object, PropTypes.number, PropTypes.array]),

This in no way fixes the problem mentioned in this issue. Your fix isn't even a typescript change.

@joseclaudiojr
Copy link

Adding PropTypes.array to line 32 solves the problem:
style: PropTypes.oneOfType([PropTypes.object, PropTypes.number, PropTypes.array]),

This in no way fixes the problem mentioned in this issue. Your fix isn't even a typescript change.

This repo uses prop-types to document the intended types of properties passed to components. (https://www.npmjs.com/package/prop-types)

@scousino
Copy link
Author

scousino commented Sep 1, 2021

Adding PropTypes.array to line 32 solves the problem:
style: PropTypes.oneOfType([PropTypes.object, PropTypes.number, PropTypes.array]),

This in no way fixes the problem mentioned in this issue. Your fix isn't even a typescript change.

This repo uses prop-types to document the intended types of properties passed to components. (https://www.npmjs.com/package/prop-types)

This has nothing to do with prop types and the style prop type has nothing to do with renderItem.

I am describing a TypeScript error. I suggest learning the difference between the two before submitting a PR for packages

@joseclaudiojr
Copy link

Adding PropTypes.array to line 32 solves the problem:
style: PropTypes.oneOfType([PropTypes.object, PropTypes.number, PropTypes.array]),

This in no way fixes the problem mentioned in this issue. Your fix isn't even a typescript change.

This repo uses prop-types to document the intended types of properties passed to components. (https://www.npmjs.com/package/prop-types)

This has nothing to do with prop types and the style prop type has nothing to do with renderItem.

I am describing a TypeScript error. I suggest learning the difference between the two before submitting a PR for packages

Well, it looks like you didn't really check the solution. Anyway, i was having a typescript issue and that worked for me. Good luck in finding your answer, looks like you gonna need it....

@scousino
Copy link
Author

scousino commented Sep 2, 2021

Again PropTypes are not for TypeScript, literally look it up. PropTypes provide typing for JAVASCRIPT. Type Script is only affected by changes to type definition files. In this case index.d.ts. Again your change is still not even related to the issue you commented on. Please try and follow standard issue guidelines. Open a separate issue if you're having problems with the PropTypes

mikaello added a commit that referenced this issue Sep 2, 2021
See #168 for description of error
@mikaello
Copy link
Collaborator

mikaello commented Sep 2, 2021

Thanks for your interest in this issue, @scousino and @joseclaudiojr :-) I think I found a fix: 539673a

Could you test default branch and confirm if this works for you or not?

You could test default branch (master) by installing like this: npm install peacechen/react-native-modal-selector.

@andkom
Copy link

andkom commented Sep 2, 2021

please also add methods

-export default class ModalSelector<TOption = IOption> extends React.Component<IModalSelectorProps<TOption> & FlatListProps<any>, any> {}
+export default class ModalSelector<TOption = IOption> extends React.Component<IModalSelectorProps<TOption> & Omit<FlatListProps<any>, any>, 'renderItem'> {
+  open(): void;
+  close(): void;
+  getSelectedItem(): string | undefined;
+}

@mikaello
Copy link
Collaborator

mikaello commented Sep 2, 2021

They are added in another PR: #161 (or at least open and getSelectedItem), I will merge that when this issue is resolved.

@mikaello mikaello closed this as completed Sep 2, 2021
@mikaello
Copy link
Collaborator

mikaello commented Sep 2, 2021

Fixed in v2.0.9

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.

7 participants