Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Discussion options

Hi there,
I am having a hard time with Typescript and RQB in regard of the Option type. When I access its properties .name or .value I get

Property 'label' does not exist on type 'Option'
Property 'name' does not exist on type 'Option'

however I do see the type correctly as

export interface BaseOption<N extends string = string> {
	name?: N;
	value?: N;
	label: string;
	disabled?: boolean;
}
/**
* A generic option. Used directly in {@link OptionList} or
* as the child element of an {@link OptionGroup}.
*/
export interface Option<N extends string = string> extends WithUnknownIndex<SetRequired<BaseOption<N>, "name">> {}

if I cast to FlexibleOption, it helps a little as it then recognizes them as any. however that conflicts with my @typescript-eslint/no-unsafe-.... linter settings

other types of RQB are working fine.

does that ring a bell?

You must be logged in to vote

Replies: 1 comment · 10 replies

Comment options

Can you provide a minimal repo or TypeScript playground that demonstrates the issue?

Also confirm which RQB version you're using. v8.1.1 contained some fixes to many of the Option-based types.

You must be logged in to vote
10 replies
@philicious
Comment options

ugh! that easy to fix/workaround. didnt think about that. thanks!!!

@jakeboone02
Comment options

Would you mind trying one of CodeSandbox templates in #858 (comment)? Or you can install the PR builds with your package manager using these URLs:

https://pkg.csb.dev/react-querybuilder/react-querybuilder/commit/901ed761/react-querybuilder
https://pkg.csb.dev/react-querybuilder/react-querybuilder/commit/901ed761/@react-querybuilder/material

It shouldn't be necessary to install type-fest with those builds.

@philicious
Comment options

@jakeboone02 sure thing: I installed bot and removed type-fest and Option type still looks good. well done 👍

@jakeboone02
Comment options

Thanks for testing! I'll get a patch out soon.

@jakeboone02
Comment options

v8.3.1 includes the fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
🙏
Q&A
Labels
None yet
2 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.