cschroeter / park-ui

Beautifully designed components built on Ark UI that work for the JS and CSS frameworks of your choice.
https://park-ui.com
MIT License
1.47k stars 59 forks source link

[Dialog] RootProps does not satisfy the constraint Props #339

Closed renchris closed 4 weeks ago

renchris commented 4 weeks ago

The Dialog Component https://github.com/cschroeter/park-ui/blob/main/components/panda/react/src/components/ui/dialog.tsx has an error of

Type 'RootProps' does not satisfy the constraint 'Props'.
  Index signature for type 'string' is missing in type 'RootProps'.ts(2344)

on RootProps

image
// Dialog.tsx

import type { Assign } from '@ark-ui/react'
import { Dialog } from '@ark-ui/react/dialog'
import { type DialogVariantProps, dialog } from 'styled-system/recipes'
import type { JsxStyleProps } from 'styled-system/types'
import createStyleContext from '@lib/create-style-context'

const { withRootProvider, withContext } = createStyleContext(dialog)

export interface RootProps extends Dialog.RootProps, DialogVariantProps {}
export const Root = withRootProvider<RootProps>(Dialog.Root)

export const Backdrop = withContext<HTMLDivElement, Assign<JsxStyleProps, Dialog.BackdropProps>>(
  Dialog.Backdrop,
  'backdrop',
)

export const CloseTrigger = withContext<
HTMLButtonElement,
Assign<JsxStyleProps, Dialog.CloseTriggerProps>
>(Dialog.CloseTrigger, 'closeTrigger')

export const Content = withContext<HTMLDivElement, Assign<JsxStyleProps, Dialog.ContentProps>>(
  Dialog.Content,
  'content',
)

export const Description = withContext<
HTMLParagraphElement,
Assign<JsxStyleProps, Dialog.DescriptionProps>
>(Dialog.Description, 'description')

export const Positioner = withContext<
HTMLDivElement,
Assign<JsxStyleProps, Dialog.PositionerProps>
>(Dialog.Positioner, 'positioner')

export const Title = withContext<HTMLHeadingElement, Assign<JsxStyleProps, Dialog.TitleProps>>(
  Dialog.Title,
  'title',
)

export const Trigger = withContext<HTMLButtonElement, Assign<JsxStyleProps, Dialog.TriggerProps>>(
  Dialog.Trigger,
  'trigger',
)

export {
  DialogContext as Context,
  type DialogContextProps as ContextProps,
} from '@ark-ui/react/dialog'
renchris commented 4 weeks ago

I am on the latest dependencies "@ark-ui/react": "^3.2.0" and "@park-ui/panda-preset": "^0.38.0",

cschroeter commented 4 weeks ago

@renchris

Thanks for reporting the issue. I checked on the. Park repository and the Ark UI repo (consumer) and I could not find any typescript issue. Please try to restart the TypeScript Server, ensure you have the latest dependencies and all Panda and Ark related dependencies are identical (monorepo).

renchris commented 3 weeks ago

@cschroeter

From the create-style-context.tsx file, the Props type is

type Props = Record<string, unknown>

https://github.com/cschroeter/park-ui/blob/5cfd0a344493d8be849d5010b1c3eb8393adf212/components/panda/react/src/lib/create-style-context.tsx#L13C6-L13C11

From the dialog.tsx file, the RootProps type is

export interface RootProps extends Dialog.RootProps, DialogVariantProps {}

https://github.com/cschroeter/park-ui/blob/5cfd0a344493d8be849d5010b1c3eb8393adf212/components/panda/react/src/components/ui/dialog.tsx#L9

Dialog.RootProps is

export interface DialogRootProps extends UseDialogProps, UsePresenceProps {
    children?: ReactNode;
}

{ children?: ReactNode; } does not satisfy on Record<string, unknown>

I re-ran my server and am on the latest dependencies "typescript": "5.4.5" and "@ark-ui/react": "^3.2.1",

What is Dialog.RootProps for you? It makes sense that a ReactNode children object does not conform to the string key Record type