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

fix: typing on IconComponent #241

Merged
merged 2 commits into from
Aug 21, 2024
Merged

fix: typing on IconComponent #241

merged 2 commits into from
Aug 21, 2024

Conversation

murrple-1
Copy link
Contributor

This is a probable fix for #240

Expand the type of IconComponent to support the types employed by react-native-vector-icons

@vonovak
Copy link
Owner

vonovak commented Aug 16, 2024

Hello, and thank you for the PR!

When you say it's a "probable" fix, how should I understand that? How did you test the change?

Thank you 👍 🙂

@murrple-1
Copy link
Contributor Author

Strictly speaking, I didn't test it within the confines of this project exclusively - the patch was written using Github tools, not a full git clone/npm install/npm run tests-like cycle. I can do that if you require it for approval, no problem. Though I can't imagine a scenario where extending the type definition alone would break any tests, so I'm not sure if that would be useful.

However, in the project in which I encountered the issue, I was able to workaround the issue from the opposite direction - by casting to the more restrictive type:

import React from 'react';
import { ColorValue } from 'react-native';
import MaterialIcons from 'react-native-vector-icons/MaterialIcons';
import {
  HeaderButton,
  HeaderButtonProps,
} from 'react-navigation-header-buttons';

export const IconHeaderButton: React.FunctionComponent<
  HeaderButtonProps
> = props => (
  <HeaderButton
    IconComponent={
      MaterialIcons as React.ComponentType<{
        name: any;
        style?: any;
        color?: ColorValue;
        size?: number;
      }>
    }
    iconSize={23}
    {...props}
  />
);

and there were no issues encountered with using MaterialIcons like that, for what it's worth.

On the other hand, you, as the architect, may have legitimate concerns with extending the type definition, and what that means going forward for your exposed API. I have not deep-dived the project's code enough to know what those concerns may be, so this PR is a naive attempt at fixing a bug that affected "me", and hopefully others.

Hence the use of "probable" - this PR fixes a bug, but I can't know the wider implications of this fix.

@vonovak
Copy link
Owner

vonovak commented Aug 21, 2024

hi @murrple-1 and thanks for your patience :)

  • the patch was written using Github tools, not a full git clone/npm install/npm run tests-like cycle

that is just fine, my question was directed at whether you made sure in your project that the change has the intended effect?

I'm happy to merge fixes, but, generally speaking, I merge fixes when there's some confirmation / indication that they work, I do not merge "probable" fixes.

Thank you and hope this makes sense. 👍

@murrple-1
Copy link
Contributor Author

Yes, in my project, the change has the intended and expected effect.

@murrple-1
Copy link
Contributor Author

I'll see what I can do about the lint failure...

@murrple-1
Copy link
Contributor Author

Issue was that the typing broke @expo/vector-icons (which I'm not using) type-checking unexpectedly. New commit resolves the typing issues

@vonovak vonovak merged commit b87abb1 into vonovak:master Aug 21, 2024
3 checks passed
@vonovak
Copy link
Owner

vonovak commented Aug 21, 2024

Thank you! :)

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.

2 participants