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 ts error about withTour #642

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

Conversation

zenoskongfu
Copy link

@zenoskongfu zenoskongfu commented Aug 25, 2024

In the current implementation, withTour injects tourProps into the WrappedComponent, which means the props of the resulting ComponentWithTour should exclude the keys from TourProps.

Example

import { TourProps } from '...';
import { WithTour } from '...';
import { useTour } from '...';

type DemoProps = {
  data: any
}

const Demo = (props: DemoProps & TourProps)=>{
  return <div>{...}</div>
}

const DemoWithTour = WithTour(Demo);

const App = ()=>{
  const data = [];
  const tourProps = useTour();
  return <div>
    <Demo data={data} {...tourProps} /> // ✅
    <Demo data={data} /> // ❌

    <DemoWithTour data={data} /> //✅
    <DemoWithTour data={data} {...tourProps} /> //❌
  </div>
}

In this case, the props of DemoWithTour should only include DemoProps, not DemoProps & TourProps.

To address this, I've updated the prop types of ComponentWithTour to Omit<P, keyof TourProps> in my pull request.

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