Skip to content

Conversation

@cabello
Copy link
Contributor

@cabello cabello commented Jul 31, 2023

Type(s) of changes

  • (Bug) fix export types in package exports so modern version of Typescript find the library type definitions.

Description of the change

While using this amazing component in a new modern project, eslint was complaining it could not find type definitions even though the project is written in Typescript, upon looking online for help, I found this one liner in package json fixes it.

Fix:

Could not find a declaration file for module 'add-to-calendar-button-react'. 'node_modules/add-to-calendar-button-react/dist/atcb.js' implicitly has an 'any' type.
  There are types at 'node_modules/add-to-calendar-button-react/dist/index.d.ts', but this result could not be resolved when respecting package.json "exports". The 'add-to-calendar-button-react' library may need to update its package.json or typings.

import { AddToCalendarButton } from "add-to-calendar-button-react"

I checked the related issues from this main issue and this is the common way to fix it.

Checklist

  • My code follows the code style of this project (I ran npm run format).
  • I have read the CONTRIBUTING document.

jekuer and others added 4 commits July 11, 2023 18:29
Fix:

```
Could not find a declaration file for module 'add-to-calendar-button-react'. 'node_modules/add-to-calendar-button-react/dist/atcb.js' implicitly has an 'any' type.
  There are types at 'node_modules/add-to-calendar-button-react/dist/index.d.ts', but this result could not be resolved when respecting package.json "exports". The 'add-to-calendar-button-react' library may need to update its package.json or typings.

import { AddToCalendarButton } from "add-to-calendar-button-react"
```

I checked the related issues from this main issue and the common way to fix it, is by exporting the types as well: microsoft/TypeScript#52363
@jekuer
Copy link
Collaborator

jekuer commented Jul 31, 2023

Hi @cabello !
Thanks a lot for your contribution. Totally forgot that.
One question, asking for your opinion: Would it make sense to include the AddToCalendarButton.d.ts as well? It gets imported by the index.d.ts, so should be fine, but would also not hurt.

@jekuer jekuer changed the base branch from main to dev August 2, 2023 17:32
@jekuer jekuer merged commit 1d4683e into add2cal:dev Aug 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants