davidjbradshaw / iframe-resizer

Keep iFrames sized to their content.
https://iframe-resizer.com
Other
6.62k stars 977 forks source link

Export typescript definitions #1279

Open monobasic opened 1 week ago

monobasic commented 1 week ago

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 commented 1 week ago

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 commented 1 week ago

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 commented 1 week ago

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 commented 6 days ago

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

monobasic commented 6 days ago

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 commented 5 days ago

@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.