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

docs: fix migration to V2 docs tsc error #308

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

adam-ali
Copy link

Description

Fixes ()

Fixes tsc errors thrown in the migrating-to-v2 example in the README

Here's the example code from the README.

import {TouchableOpacity, View} from 'react-native';
import {
  useRestyle,
  spacing,
  border,
  backgroundColor,
  SpacingProps,
  BorderProps,
  BackgroundColorProps,
  composeRestyleFunctions,
} from '@shopify/restyle';

import Text from './Text';
import {Theme} from './theme';

const restyleFunctions = composeRestyleFunctions([
  spacing,
  border,
  backgroundColor,
]);
type Props = SpacingProps<Theme> &
  BorderProps<Theme> &
  BackgroundColorProps<Theme> & {
    onPress: () => void;
  };

const Button = ({onPress, label, ...rest}: Props) => {
  const props = useRestyle(restyleFunctions, rest);

  return (
    <TouchableOpacity onPress={onPress}>
      <View {...props}>
        <Text variant="buttonLabel">{label}</Text>
      </View>
    </TouchableOpacity>
  );
};

This is the error shown in the restyleFunctions being passed to the useRestyle hook.

Argument of type '{ buildStyle: (props: { [key: string]: any; }, { theme, dimensions, }: { theme: BaseTheme; dimensions: Dimensions | null; }) => RNStyle; properties: (string | number)[]; propertiesMap: { ...; }; }' is not assignable to parameter of type '{ buildStyle: <TInputProps extends { margin?: ResponsiveValue<"m" | "s" | "l" | "xl", {}> | undefined; marginTop?: ResponsiveValue<"m" | "s" | "l" | "xl", {}> | undefined; ... 43 more ...; backgroundColor?: ResponsiveValue<...> | undefined; }>(props: TInputProps, { theme, dimensions, }: { ...; }) => RNStyle; propert...'.

Screenshots or videos (if needed)

Screenshot 2024-09-15 174540

@adam-ali
Copy link
Author

I've signed the CLA!

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.

1 participant