microsoft/Bing-Maps-V8-TypeScript-Definitions

Circular dependency between modules

kb3eua opened this issue · 1 comments

A circular dependency exists in the top-level Microsoft.Maps module, which is dependent upon both the Directions and DrawingTools modules.

For my project I don't require either of these 2 child modules, but it won't compile without them b/c they're required by the Microsoft.Maps module:

/// <reference path="Modules/Directions.d.ts"/>
/// <reference path="Modules/DrawingTools.d.ts"/>

/**
 *  The Bing Maps V8 developer API.
 */
declare module Microsoft.Maps {
    /** A static class that manages events within the map SDK. */
    export class Events {
        /////////////////////////////////////
        /// addHandler Definitions
        ////////////////////////////////////

        /**
        * Attaches the handler for the event that is thrown by the target. Use the return object to remove the handler using the removeHandler method.
        * @param target The object to attach the event to; Map, IPrimitive, Infobox, Layer, DrawingTools, DrawingManager, DirectionsManager, etc.
        * @param eventName The type of event to attach. Supported Events:
        * drawingChanged, drawingChanging, drawingEnded, drawingModeChanged, drawingStarted
        * @param handler The callback function to handle the event when triggered. 
        * @returns The handler id.
        */
        public static addHandler(target: DrawingTools, eventName: string, handler: (eventArg?: IPrimitive | IDrawingModeChangedData) => void): IHandlerId;

        /**
        * Attaches the handler for the event that is thrown by the target. Use the return object to remove the handler using the removeHandler method.
        * @param target The object to attach the event to; Map, IPrimitive, Infobox, Layer, DrawingTools, DrawingManager, DirectionsManager, etc.
        * @param eventName The type of event to attach. Supported Events:
        * disposed, drawingChanged, drawingChanging, drawingEnded, drawingErased, drawingModeChanged, drawingStarted
        * @param handler The callback function to handle the event when triggered. 
        * @returns The handler id.
        */
        public static addHandler(target: DrawingManager, eventName: string, handler: (eventArg?: IPrimitive | DrawingTools.DrawingMode) => void): IHandlerId;

        /**
        * Attaches the handler for the event that is thrown by the target. Use the return object to remove the handler using the removeHandler method.
        * @param target The object to attach the event to; Map, IPrimitive, Infobox, Layer, DrawingTools, DrawingManager, DirectionsManager, etc.
        * @param eventName The type of event to attach. Supported Events:
        * • directionsError
        * • directionsUpdated
        * @param handler The callback function to handle the event when triggered. 
        * @returns The handler id.
        */
        public static addHandler(target: Directions.DirectionsManager, eventName: string, handler: (eventArg?: Directions.IDirectionsEventArgs | Directions.IDirectionsErrorEventArgs) => void): IHandlerId;
    }
}

I have gone through and modified the definitions such that there are no circular dependencies by extending the Events class from the directions module. This appears to work great in Visual Studio. Hopefully these functions still work correctly in other IDE's. npm and Nuget packages have been updated.