I want to use the package @types/bootstrap to add type hinting when creating event listeners on Bootstrap components, such as the Carousel.Events.slide enum member:
/* node_modules/@types/bootstrap/.../carousel.d.ts */
enum Events {
slide = 'slide.bs.carousel',
}
/* index.ts */
declare const Carousel: typeof import("bootstrap").Carousel;
myCarouselElement.addEventListener(Carousel.Events.slide, e => {
// compiler knows about 'relatedTarget' from 'carousel.d.ts'
const active = e.relatedTarget;
});
However, since the package exports a regular enum, the emitted JavaScript retains the Carousel.Events.slide call (which doesn't exist in Bootstrap), rather then supplying it with the slide.bs.carousel value. Bad practices aside, I could edit my copy of the carousel.d.ts file and declare Events as a const enum, which would inline the enum value; however, this has its own problems and isn't a suitable solution for the DefinitelyTyped repo.
How should I correctly be importing enums? Can I somehow alias my import as a const enum?