Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeScript types aren't all exposed from the library #866

Closed
2 tasks done
sernaferna opened this issue Jun 13, 2023 · 3 comments
Closed
2 tasks done

TypeScript types aren't all exposed from the library #866

sernaferna opened this issue Jun 13, 2023 · 3 comments
Labels
enhancement New feature or request

Comments

@sernaferna
Copy link

Before you start - checklist

  • I followed instructions in documentation written for my React-Calendar version
  • I have checked if this bug is not already reported

Description

When I was using @types/react-calendar all of the types were exposed, which allowed me to to create memo-ized callback functions to handle events coming from the calendar (via useCallback()).

For example, I could do something like this:

import React, { useCallback, useState } from 'react';
import Calendar, { CalendarTileProperties, ViewCallback } from 'react-calendar';

export const SomeComponent = () => {

  const getTileContent = useCallback(
    ({ date, view }: CalendarTileProperties) => {
      // do a bunch of work

      return <p>blah</p>;
    },
    [...]
  );

  return (
          <Calendar
            tileContent={getTileContent}
          />
  );
};

Steps to reproduce

Any attempt to use types outside of the <Calendar/> component itself.

Expected behavior

I'd like to see all of the types exposed from the library as types that can be leveraged in the calling application.

Actual behavior

Everything works fine if writing the functions within the context of the component itself; e.g.

<Calendar tileContent={({ activeStartDate }) => {
     // TypeScript can make use of the types in here
  }}
/>

Additional information

The types are all defined in the library but they're not exposed from the package, so I have to import them from react-calendar/dist/cjs/shared/types which feels like a hack to me.

Environment

  • Browser (if applicable): N/A
  • React-Calendar version: 4.2.1
  • React version: 18.2.0
@sernaferna sernaferna added the bug Something isn't working label Jun 13, 2023
@wojtekmaj
Copy link
Owner

You can always use React.ComponentPropsWithoutRef<typeof Calendar> but I totally get that, that's why it was done in b648740 already.

Released in 4.3.0.

@wojtekmaj wojtekmaj added enhancement New feature or request and removed bug Something isn't working labels Jun 13, 2023
@sernaferna
Copy link
Author

Thanks for this, but it only exposes CalendarProps, not TileContentFunc and/or TileProps.

@wojtekmaj
Copy link
Owner

Right. We could do that for you :D

wojtekmaj added a commit that referenced this issue Jun 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants