park-ui: Missing Arc types using Arc components with createStyleContext / withProvider
Using an Arc component with createStyleContext respectively the returned HOC withProvider function the returned Component is stripped from typescript types previously assigned to an Arc component.
Ark direct use:
<Ark.Combobox.Root onInputValueChange={handleChange} // onInputValueChange available
Signature of callback
onInputValueChange?: (details: InputValueChangeDetails)
Park indirect use:
const ComboboxRoot = withProvider(Ark.Combobox.Root, 'root'); // using withProvider looses types assigned to Ark.Combobox.Root
<ComboboxRoot onInputValueChange // onInputValueChange not recognised by typescript
The identical behaviour can be observed creating a new Object Combobox and setting the Root slice to ComboboxRoot and using it later
export const Combobox = Object.assign(ComboboxRoot, {
Root: ComboboxRoot,
...
});
<Combobox.Root onInputValueChange // onInputValueChange not recognised by typescript
Summary:
Wrapping Ark.Combobox.Root in withProvider and using the returned component in an app will not have any types available defined in Ark.Combobox.Root, this happens with all Arc components.
About this issue
- Original URL
- State: closed
- Created 8 months ago
- Comments: 16 (5 by maintainers)
Commits related to this issue
- fix: strict variant and arc props in tailwind Closes Missing Arc types using Arc components with createStyleContext / withProvider #87 — committed to cschroeter/park-ui by sholzmayer 8 months ago
Ok, used the latest one, the component does not complain and finds the function onInputValueChange but the type is
onInputValueChange: anyat least on my end, your intelli sense shows clearly the detail argument with a type? Maybe my setup is buggy not sure. I used this https://github.com/cschroeter/park-ui/blob/main/packages/tailwind/src/lib/create-style-context.tsxUpdate: I think this version is working, its in the website the other one not working is in packages/tailwind lib folder. I only replaced the withProvider function, but I don`t get it its identical… https://github.com/cschroeter/park-ui/blob/main/website/src/lib/create-style-context.tsx
Update: Ignore the previous update! The version on website folder is older and shows an error when used about splitVariantProps missing from recipe. I returns the right type for onInputValueChange, but then withProvider(Ark.Combobox.Root, ‘root’) is invalid, no clue.