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

Typescript yells at Config<Props> for Render and Puck components #185

Closed
BleedingDev opened this issue Oct 22, 2023 · 3 comments · Fixed by #257 or #297
Closed

Typescript yells at Config<Props> for Render and Puck components #185

BleedingDev opened this issue Oct 22, 2023 · 3 comments · Fixed by #257 or #297

Comments

@BleedingDev
Copy link

Problem

Strict Typescript yells that types Config and Config<Props> are not compatible.

Here are my types:

type PuckProps = {
  Typography: PropsFrom<typeof Typography>
  Spoiler: PropsFrom<typeof Spoiler>
  Link: PropsFrom<typeof Link>
  Image: PropsFrom<typeof Image>
  Video: PropsFrom<typeof Video>
  Audio: PropsFrom<typeof Audio>
  Divider: PropsFrom<typeof Divider>
  List: PropsFrom<typeof List>
  CopyText: PropsFrom<typeof CopyText>
  AskLLM: PropsFrom<typeof AskLLM>
  Code: PropsFrom<typeof Code>
}

I use them like this:

const config = { ... } satisfies Config<PuckProps>

Solution

Allow passing props to React components (same as you allow for Config type).

My suggested solution (fixed locally, but won't work everywhere)

declare function Render<Props>({ config, data }: {
    config: Config<Props>;
    data: Data;
}): react_jsx_runtime.JSX.Element;
@chrisvxd
Copy link
Member

@BleedingDev what do you mean by "won't work everywhere"?

We'd have to add that kind of type definition for each component in Puck, which It think is acceptable.

@BleedingDev
Copy link
Author

I did a manual edit in my node_modules, that's why it won't work. But I checked that it fixes the problem.

@chrisvxd
Copy link
Member

@BleedingDev I believe this should be fixed in 0.13.0-canary.b95050d!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants