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

Wrong Typescript types for IMaskMixin #1094

Open
LKay opened this issue Nov 26, 2024 · 0 comments
Open

Wrong Typescript types for IMaskMixin #1094

LKay opened this issue Nov 26, 2024 · 0 comments

Comments

@LKay
Copy link

LKay commented Nov 26, 2024

Describe the bug

Types for IMaskMixin are not correct and don't unwrap inner component's props correctly. The example uses bare bone Styled Component, that passes outer ref.

This migt be related to #996 or #1002

To Reproduce

interface InputCustomProps {
  size?: 'big' | 'small';
}

const InputCustomStyled = styled.input<InputCustomProps>`
  color: blue;
`;

const InputCustom = React.forwardRef(function InputCustom(
  props: InputCustomProps,
  ref: React.ForwardedRef<HTMLInputElement>,
) {
  return <InputCustomStyled {...props} ref={ref} />;
});

const InputCustomExtendedStyled = styled(InputCustom)`
  color: red;
`;

const InputCustomMaskedStyled = IMaskMixin(
  ({ inputRef, ...props }) => <InputCustomExtendedStyled {...props} ref={inputRef} />,
);

There are types errors due to conflicting types and uncorrect unwrap.

Looks IMaskMixin injects conflicting props to inner component ie. size. Props on outer component do not expose props from inner component.

Expected behavior

Types are unwrapped and used correctly. Any custom prop types should be either prioritized or merged together with output union type.

Environment:

  • IMask version: 7.5.0
  • Framework/plugin version if used: React 7.5.0
@LKay LKay changed the title Wrong Typescript types for IMaskMixing Wrong Typescript types for IMaskMixin Nov 26, 2024
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

No branches or pull requests

1 participant