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

fix: Export missing type AnimationConfig #2128

Merged
merged 2 commits into from
Mar 29, 2023

Conversation

dubzzz
Copy link
Contributor

@dubzzz dubzzz commented Mar 29, 2023

Some open-source and largely used libraries such as nivo directly bind to the types being declared by @react-pring/core in some of their code.

For instance in nivo, the following code:

import { SpringValues } from '@react-spring/web'

//...
export interface NodeProps<Datum extends object> {
    //...
    animatedProps: SpringValues<NodeAnimatedProps>
    //...
}

Implicitely force nivo to be able to reference parts of the typings of @react-spring/core into their d.ts files if they want to be able to publish their package. It basiaclly results into Partial<import("@react-spring/core").AnimationConfig> in the produced d.ts at some point. And as a consequence TypeScript complains with the error error TS4023: Exported variable 'htmlDefaultProps' has or is using name 'AnimationConfig' from external module "/tmp/9a4cf066/node_modules/@react-spring/core/dist/index" but cannot be named..

The proposed change exposes AnimationConfig as a type, meaning we still don't expose the class, just its type. It would help into making nivo able to support recent version of @react-spring/*. See related issue on nivo's side: plouc/nivo#2280

Why

What

Checklist

  • Documentation updated
  • Demo added
  • Ready to be merged

Some open-source and largely used libraries such as nivo directly bind to the types being declared by `@react-pring/core` in some of their code.

For instance in nivo, the following code:

```ts
import { SpringValues } from '@react-spring/web'

//...
export interface NodeProps<Datum extends object> {
    //...
    animatedProps: SpringValues<NodeAnimatedProps>
    //...
}
```

Implicitely force nivo to be able to reference parts of the typings of `@react-spring/core` into their d.ts files if they want to be able to publish their package. It basiaclly results into `Partial<import("@react-spring/core").AnimationConfig>` in the produced d.ts at some point. And as a consequence TypeScript complains with the error `error TS4023: Exported variable 'htmlDefaultProps' has or is using name 'AnimationConfig' from external module "/tmp/9a4cf066/node_modules/@react-spring/core/dist/index" but cannot be named.`.

The proposed change exposes `AnimationConfig` as a type, meaning we still don't expose the class, just its type. It would help into making nivo able to support recent version of `@react-spring/*`. See related issue on nivo's side: plouc/nivo#2280
@changeset-bot
Copy link

changeset-bot bot commented Mar 29, 2023

🦋 Changeset detected

Latest commit: e578cbe

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@react-spring/core Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

joshuaellis
joshuaellis previously approved these changes Mar 29, 2023
Copy link
Member

@joshuaellis joshuaellis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍🏼 thanks for the contribution, cool library!

@dubzzz
Copy link
Contributor Author

dubzzz commented Mar 29, 2023

Not sure the codesandbox issue is related to my change 🤔
Please let me know if there is something I should change to make it pass.

image

@joshuaellis
Copy link
Member

No it's not you, i need to remove the sandbox CI.

@joshuaellis joshuaellis added the area: core relates to core classes // parts of the library label Mar 29, 2023
@joshuaellis joshuaellis merged commit 218d86b into pmndrs:main Mar 29, 2023
@dubzzz
Copy link
Contributor Author

dubzzz commented Mar 29, 2023

Thank you so much for the quick approval and merge. And of course for this awesome library 👍

@dubzzz dubzzz deleted the export-missing-type branch March 29, 2023 08:21
@dubzzz
Copy link
Contributor Author

dubzzz commented Apr 4, 2023

Hey @joshuaellis, Just wondering, any plan to do a release with this patch?

@joshuaellis
Copy link
Member

Sorry i've been away, this has now been released! :)

@dubzzz
Copy link
Contributor Author

dubzzz commented Apr 7, 2023

Thank you so much

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: core relates to core classes // parts of the library
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants