-
Notifications
You must be signed in to change notification settings - Fork 32
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
[BUG] selectedOptionStyle
and variant
are missing from Select
types.
#273
Comments
I'm having trouble reproducing this issue, but it seems to be a problem with the module augmentation piece where I add extra keys to
And finally, if you could give me a reproduction of any kind, or even just a code snippet, that could help a lot. |
I'm running two projects with the same package versions (chakra v2.8.1, chakra-react-select v5.7.2), but different package managers. The project using npm has no issue, the one using yarn/bun is showing error for non react-select props. E.g. Seems like npm knows to merge react-select & chakra's props, whereas the yarn/bun one doesn't. The issue being related to the module augmentation file makes sense. I believe if you install this package with either yarn or bun, you'll be able to recreate this issue. |
@Joeao So I have this package set up with yarn as well, but I haven't had any issues with this. Can you tell me which version of yarn you're using? Also, can you check if you have multiple versions of the base |
Sure. For the sake of potential reproduction I've switched back to yarn, from bun. Starting with a fresh yarn.lock. There's only one version of tsconfig.json: {
"compilerOptions": {
"target": "ESNext",
"useDefineForClassFields": true,
"lib": [
"DOM",
"DOM.Iterable",
"ESNext"
],
"baseUrl": ".",
"paths": {
"@/*": [
"./src/*"
],
},
"allowJs": false,
"skipLibCheck": true,
"esModuleInterop": false,
"allowSyntheticDefaultImports": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"module": "ESNext",
"moduleResolution": "Node",
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"jsx": "react"
},
"include": [
"./src/*"
],
"exclude": ["worker/**/*"],
"references": [
{
"path": "./tsconfig.node.json"
}
]
} |
Same issue for me, i just start a new project with Vite and "chakra-react-select": "^4.7.2"
"typescript": "^5.2.2" like a workaround i pass the unsupported props with spread syntax and any type to skip the type validation, but i hope to find a better solutions const rest: any = {
variant: 'main',
selectedOptionColorScheme: 'brand',
chakraStyles,
isInvalid: !isValidated,
};
return (
<Select
isClearable={isClearable}
options={options}
isMulti={isMulti}
placeholder={placeholder}
onChange={handleChange}
onBlur={handleBlur}
isDisabled={disabled}
{...rest}
/>
) |
Ok I finally had a chance to dig into this, and I believe it has nothing to do with the cli tool you use, but the Apparently the issue is with using
@Joeao in your example tsconfig, it appears you are actually using I will continue to update this issue as I learn more about the subject., but for now try changing |
Ok, so I put in a little more time trying to figure out a fix for this. I first tried using After that I just went ahead and made a PR to React Select to try and actually fix the issue. You can check out all of the details here: JedWatson/react-select#5762 There was already a PR open on react-select to fix this issue, but it was technically incomplete, as it was causing the build to fail, so I tried to make one more likely to be merged. However, the React Select maintainers aren't the best about keeping up with issues and PRs, so if you guys want to help the process along it might help if you interact with the PR in some way haha. |
Thanks for spending the time on this issue. I can confirm that |
Honestly, the real issue is that any project that uses the package.json Hopefully this fixes the issue, but if not it's still definitely a step in the right direction! |
On that note actually, @Joeao do you have any other info you can give me about your setup? Like what node version you're using? And are you using something like Vite or Nextjs? There might be some further reason there I haven't though of. |
Both projects are using the same version of Vite (4.4.9), same version of Node (18.17). Same version of Typescript too (5.1.x) |
Huh, that's very odd then. Are the tsconfig files set up exactly the same way? If not, could I see both? I'm also curious what's in the And regardless, I still have a strong feeling that my PR to react-select will fix the issue, I'm just trying to learn as much as I can about this issue in case it doesn't |
I removed Now, by going through each mismatching |
@Joeao Aah ok, that would make sense! Thanks for looking further into it, that gives me more confidence that my PR should fix the issue. |
So I decided that this issue is more important than being on the latest version of |
Ok, there has been an update! The maintainers of This is what their docs had recommended previously, which is why I hadn't realized this approach was possible. Anyway, a real fix has been published in v4.7.5, so if you were having issues with this, please try out the new version and let me know if you're still having any problems! |
Description
selectedOptionStyle
andvariant
are missing from types. It is passed to component itself, but causing type error.As a temporary solution i had to thow
// @ts-expect-error
to silnce typescipt.For the
variant
TS error is:Property variant does not exist on type 'IntrinsicAttributes & Omit<PublicBaseSelectProps<{ value: string; label: string; }, true, { label: string; options: { value: string; label: string; }[]; }>, StateManagedPropKeys> & Partial<...> & StateManagerAdditionalProps<...> & RefAttributes<...>'.
For the
selectedOptionStyle
is:Property selectedOptionStyle does not exist on type 'IntrinsicAttributes & Omit<PublicBaseSelectProps<{ value: string; label: string; }, true, { label: string; options: { value: string; label: string; }[]; }>, StateManagedPropKeys> & Partial<...> & StateManagerAdditionalProps<...> & RefAttributes<...>'.
chakra-react-select Version
4.7.0
Link to Reproduction
No response
TypeScript?
Steps to reproduce
selectedOptionStyle
orvariant
props onSelect
componentOperating System
Additional Information
"typescript": "^5.1.6"
The text was updated successfully, but these errors were encountered: