简体   繁体   English

输入“日期范围”<date | null> ' 不可分配给类型 'ValueType'</date>

[英]Type 'DateRange<Date | null>' is not assignable to type 'ValueType'

i want to implement a calendar where the user will be able to select multiple full weeks.我想实现一个日历,用户将能够 select 多个整周。 i am using the library rsuite for that.我正在为此使用图书馆 rsuite。 I want to pass inside the property value of dateRangePicker of rsuite the value "selectedDates" which is of type我想在 rsuite 的 dateRangePicker 的属性值中传递类型为“selectedDates”的值

  const [selectedDate, handleDateChange] = useState<DateRange<Date | null>>([checkIn, checkOut]);"
   const checkIn = row.checkInDate ? row.checkInDate : null;
   const checkOut = row.checkOutDate ? row.checkOutDate : null;

and i got the following error我收到以下错误

Type 'DateRange<Date |键入'日期范围<日期 | null>' is not assignable to type 'ValueType'. null>' 不可分配给类型“ValueType”。 Type at position 0 in source is not compatible with type at position 0 in target.源中 position 0 处的类型与目标中 position 0 处的类型不兼容。 Type 'Date |输入“日期 | null' is not assignable to type 'Date | null' 不可分配给类型 'Date | undefined'.不明确的'。 Type 'null' is not assignable to type 'Date |类型 'null' 不能分配给类型 'Date | undefined'.ts(2322) common.d.ts(103, 3): The expected type comes from property 'value' which is declared here on type 'IntrinsicAttributes & IntrinsicClassAttributes<Component<DateRangePickerProps, any, any>> & Readonly<...> & Readonly<...>' undefined'.ts(2322) common.d.ts(103, 3):预期的类型来自属性'value',它在类型'IntrinsicAttributes & IntrinsicClassAttributes<Component<DateRangePickerProps, any, any>> & Readonly< ...> & 只读<...>'

Can anyone help me solve that?谁能帮我解决这个问题?

UPDATE:更新:

with the valueType as i understand i can only pass Date |据我了解,使用 valueType 我只能通过 Date | undefined, but if I pass inside the value property of the daterangepicker an undifined, when i try to change month i got NaN dates and invalid dates (look image)未定义,但是如果我在 daterangepicker 的 value 属性中传递一个未定义的,当我尝试更改月份时,我得到 NaN 日期和无效日期(看图片) 在此处输入图像描述

i want to implement a calendar where the user will be able to select multiple full weeks.我想实现一个日历,用户将能够 select 多个整周。 i am using the library rsuite for that.我正在为此使用图书馆 rsuite。 I want to pass inside the property value of dateRangePicker of rsuite the value "selectedDates" which is of type我想在 rsuite 的 dateRangePicker 的属性值中传递类型为“selectedDates”的值

  const [selectedDate, handleDateChange] = useState<DateRange<Date | null>>([checkIn, checkOut]);"
   const checkIn = row.checkInDate ? row.checkInDate : null;
   const checkOut = row.checkOutDate ? row.checkOutDate : null;

and i got the following error我收到以下错误

Type 'DateRange<Date |键入'日期范围<日期 | null>' is not assignable to type 'ValueType'. null>' 不可分配给类型“ValueType”。 Type at position 0 in source is not compatible with type at position 0 in target.源中 position 0 处的类型与目标中 position 0 处的类型不兼容。 Type 'Date |输入“日期 | null' is not assignable to type 'Date | null' 不可分配给类型 'Date | undefined'.不明确的'。 Type 'null' is not assignable to type 'Date |类型 'null' 不能分配给类型 'Date | undefined'.ts(2322) common.d.ts(103, 3): The expected type comes from property 'value' which is declared here on type 'IntrinsicAttributes & IntrinsicClassAttributes<Component<DateRangePickerProps, any, any>> & Readonly<...> & Readonly<...>' undefined'.ts(2322) common.d.ts(103, 3):预期的类型来自属性'value',它在类型'IntrinsicAttributes & IntrinsicClassAttributes<Component<DateRangePickerProps, any, any>> & Readonly< ...> & 只读<...>'

Can anyone help me solve that?谁能帮我解决这个问题?

UPDATE:更新:

with the valueType as i understand i can only pass Date |据我了解,使用 valueType 我只能通过 Date | undefined, but if I pass inside the value property of the daterangepicker an undifined, when i try to change month i got NaN dates and invalid dates (look image)未定义,但是如果我在 daterangepicker 的 value 属性中传递一个未定义的,当我尝试更改月份时,我得到 NaN 日期和无效日期(看图片) 在此处输入图像描述

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 反应选择和打字稿:类型“字符串”不可分配给类型“ValueType”<OptionTypeBase> &#39; - react-select and typescript: Type 'string' is not assignable to type 'ValueType<OptionTypeBase>' '日期 | 类型的参数 null”不能分配给类型为“SetStateAction”的参数<date> '</date> - Argument of type 'Date | null' is not assignable to parameter of type 'SetStateAction<Date>' 'Date | 类型的参数 null' 不能分配给“字符串”类型的参数 - Argument of type 'Date | null' is not assignable to parameter of type 'string' [错误] [react-datepicker] 'Date | 类型的参数 null”不能分配给类型为“SetStateAction”的参数<date> ?</date> - [Error][react-datepicker] Argument of type 'Date | null' is not assignable to parameter of type 'SetStateAction<Date>? TS2345:“日期”类型的参数 | null' 不可分配给类型为“string |”的参数日期 | 不明确的' - TS2345: Argument of type 'Date | null' is not assignable to parameter of type 'string | Date | undefined' 打字稿:类型“ null”不可分配给类型错误 - Typescript: Type 'null' is not assignable to type error 类型“计时器”不可分配给 typescript 中的类型“空” - Type 'Timer' is not assignable to type 'null' in typescript 类型“undefined”不可分配给类型“Element | 无效的' - Type 'undefined' is not assignable to type 'Element | null' null 类型的参数不可分配给 RadioGroupState 类型的参数 - Argument of type null is not assignable to parameter of type RadioGroupState 类型“null”不可分配给类型“元素”.ts(2345) - Type 'null' is not assignable to type 'Element'.ts(2345)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM