iframe-resizer icon indicating copy to clipboard operation
iframe-resizer copied to clipboard

Export typescript definitions

Open monobasic opened this issue 1 year ago • 6 comments

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

monobasic avatar Jul 01 '24 12:07 monobasic

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

davidjbradshaw avatar Jul 01 '24 13:07 davidjbradshaw

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'

monobasic avatar Jul 01 '24 19:07 monobasic

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 avatar Jul 01 '24 20:07 davidjbradshaw

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

davidjbradshaw avatar Jul 02 '24 12:07 davidjbradshaw

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 avatar Jul 02 '24 12:07 monobasic

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

monobasic avatar Jul 03 '24 08:07 monobasic