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

Export typescript definitions #1279

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

monobasic
Copy link

IMO this should be enough to make the definitions importable/usable in third party Typescript applications, using the iframe-resizer as an npm dependency.

@davidjbradshaw
Copy link
Owner

I just read the TS docs and if I have read it correctly, it says we should get rid of the namespace if we export everything like this. Does that make sense?

https://www.typescriptlang.org/docs/handbook/namespaces-and-modules.html#needless-namespacing

@monobasic
Copy link
Author

monobasic commented Jul 1, 2024

Ah yes you're right! I've also removed the namespace for the React module. Hope that's ok!
After that, the default exported function and the needed types can be imported like this:
import IframeResizer, { IFrameObject, IFrameComponent } from '@iframe-resizer/react'

@davidjbradshaw
Copy link
Owner

Thanks, I will take a look in the morning when I'm a little less tired. I hope to get version 5.2 out later this week, which will also include #1278, which should finally fix the last perf bottleneck.

@davidjbradshaw
Copy link
Owner

Having slept on this, is removing the namespaces a breaking change?

@monobasic
Copy link
Author

monobasic commented Jul 2, 2024

I would say no, as the namespace was never exported anyways. So it was only relevant for the type definitions inside this files.
(Which as example for the exported function, where connected via the namespace prefix:
image
)

@monobasic
Copy link
Author

monobasic commented Jul 3, 2024

@davidjbradshaw after a chat with Gion, we can also remove the module declarations. As the typescript definition files are bound to the packages via the generated package.json files "types" properties (Done via the rollup package plugin). This way you don't need to manually change the module declarations, should the package names change in the future.

We also re-checked the possible breaking change for the React module and it's not a breaking change. The used "export = ..." declaration from before, is in fact Node's way of definieng a default export.

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