Next.js Discord

Discord Forum

Why it shows `any` type

Unanswered
Giant Angora posted this in #help-forum
Open in Discord
Giant AngoraOP
hello there...
why options and groupedOptions shows any type when groupBy is defined

import React from 'react'

type SelectProps<Value,> =
    { value?: Value, } & (
        | {
            groupBy?: undefined,
            children?: (props: {
                groupedOptions: null;
                options: string[];
            }) => string
        }
        | {
            groupBy: (option: Value) => string
            children?: (props: {
                groupedOptions: Record<string, string[]>;
                options: null;
            }) => string
        })


const Select = <Value,>
    (props: SelectProps<Value>) => null;


<Select
// groupBy={() => 'option.title'}
>
    {({ options, groupedOptions }) => ''}
</Select >

playground https://tsplay.dev/NrEpow

0 Replies