Skip to content
TheChatArchiveThe Chat Archive
gpt-3.5-turbo-0613· OpenAIAi2 WildChat-4.8M (AI2)

export interface CandleChartProps { setChartYAxisType?: (value: YAxisType) => void; }…

  1. User

    export interface CandleChartProps { setChartYAxisType?: (value: YAxisType) => void; }

    export const CandleChart = ({ setChartYAxisType, }: CandleChartProps) => {

    return (<> <Button onClick={() => setChartYAxisType && setChartYAxisType((prev: YAxisType) => prev === YAxisType.Log ? YAxisType.Normal : YAxisType.Log)}

    {chartYAxisType === YAxisType.Log ? "Логарифмический" : "Обычный"} Argument of type ‘(prev: YAxisType) => YAxisType.Normal | YAxisType.Log’ is not assignable to parameter of type ‘YAxisType’.ts(2345)

    исправь код, чтобы не было ошибки

  2. Assistant

    export enum YAxisType { Normal = 'normal', Log = 'log', }

    export interface CandleChartProps { setChartYAxisType?: (value: YAxisType) => void; chartYAxisType?: YAxisType; }

    export const CandleChart = ({ setChartYAxisType, chartYAxisType }: CandleChartProps) => { return ( <> <Button onClick={() => setChartYAxisType && setChartYAxisType((prev) => prev === YAxisType.Log ? YAxisType.Normal : YAxisType.Log ) } > {chartYAxisType === YAxisType.Log ? "Логарифмический" : "Обычный"} </> ); }

  3. User

    исправь типизацию

  4. Assistant

    export type YAxisType = "normal" | "log";

    export interface CandleChartProps { setChartYAxisType?: (value: YAxisType) => void; chartYAxisType?: YAxisType; }

    export const CandleChart = ({ setChartYAxisType, chartYAxisType }: CandleChartProps) => { return ( <> <Button onClick={() => setChartYAxisType && setChartYAxisType((prev) => prev === "log" ? "normal" : "log" ) } > {chartYAxisType === "log" ? "Логарифмический" : "Обычный"} </> ); }