派生npm包时,类型'IntrinsicAttributes&IntrinsicClassAttributes'上的打字稿“属性“ XXX”不存在”

时间:2020-06-23 20:20:49

标签: reactjs typescript

https://github.com/jasonsalzman/react-add-to-calendar/pull/36/files

我分叉了this project以添加一个afterItemClick事件。您可以here看到它。我运行npm install生成一个/dist文件夹,并使用yarn add "https://github.com/itmart/react-add-to-calendar#item-after-click-event"将其安装到我的项目中,并能够成功地将其安装在我的项目中。但是,当我尝试像这样使用它时:

import AddToCalendar from 'react-add-to-calendar'
...
  onCloseCalendarClick = (clubreadyId: string) => {
    //logic here
  }

  render() {
    ...
     <AddToCalendar
       event={event}
       buttonClassClosed="d-none"
       optionsOpen={bookingCalendarDropdownOpen}
       listItems={calendarListItems}
       afterItemClick={onCloseCalendarClick}
       clubreadyId={booking.clubreadyId!}
     />

我收到此错误:

Type '{ event: { title: string | undefined; description: string | undefined; location: string; startTime: string; endTime: string; }; buttonClassClosed: string; optionsOpen: any; listItems: ({ apple: string; google?: undefined; outlook?: undefined; outlookcom?: undefined; yahoo?: undefined; } | { ...; } | { ...; } | { ......' is not assignable to type 'IntrinsicAttributes & IntrinsicClassAttributes<Component<AddToCalendarProps, any, any>> & Readonly<AddToCalendarProps> & Readonly<{ children?: ReactNode; }>'.
  Property 'afterItemClick' does not exist on type 'IntrinsicAttributes & IntrinsicClassAttributes<Component<AddToCalendarProps, any, any>> & Readonly<AddToCalendarProps> & Readonly<{ children?: ReactNode; }>'.

编辑程序包时我丢失了什么吗?在react-add-to-calendar/dist/react-add-to-calendar.js中,我确实看到afterItemClick是propTypes的一部分:

ReactAddToCalendar.propTypes = {
  ...
  afterItemClick: _propTypes2.default.func
};

我看到其他几个线程在询问这个错误,但是没有一个有助于弄清楚这个错误。谢谢您的阅读。

0 个答案:

没有答案