bumbu / svg-pan-zoom

JavaScript library that enables panning and zooming of an SVG in an HTML document, with mouse events or custom JavaScript hooks
https://github.com/ariutta/svg-pan-zoom#demos
BSD 2-Clause "Simplified" License
1.74k stars 390 forks source link

typescript typings without namespace #379

Open mac2000 opened 4 years ago

mac2000 commented 4 years ago

Note that import svgPanZoom from 'svg-pan-zoom' will still work as usual so we are hopefully not breaking anything, but now you can import svgPanZoom, { Options, Instance } from "dist/svg-pan-zoom"; and use interfaces in you code instead of SvgPanZoom.Instance namespaced way which might cause problems in some scenarious

mac2000 commented 4 years ago

Or, as alternative, if namespace is something desired we can try to leave it as is and just "reexport" interfaces, e.g.

before:

declare module "svg-pan-zoom" {
  export = svgPanZoom;
}

after:

export interface Options extends SvgPanZoom.Options {}
export interface CustomEventHandler extends SvgPanZoom.CustomEventHandler {}
export interface CustomEventOptions extends SvgPanZoom.CustomEventOptions {}
export interface Point extends SvgPanZoom.Point {}
export interface PointModifier extends SvgPanZoom.PointModifier {}
export interface Sizes extends SvgPanZoom.Sizes {}
export interface Instance extends SvgPanZoom.Instance {}

export default svgPanZoom;

which should also work, not sure which way you do prefer if any

ariutta commented 3 years ago

Thanks for the pull request! My job has shifted away from front end, so I unfortunately can't keep up with maintenance. Would you be interested in becoming a maintainer?

https://github.com/ariutta/svg-pan-zoom/issues/395