diff --git a/types/openlayers/index.d.ts b/types/openlayers/index.d.ts index 9a6dd11642..fad339ab44 100644 --- a/types/openlayers/index.d.ts +++ b/types/openlayers/index.d.ts @@ -11,7 +11,7 @@ // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // Definitions partially generated using tsd-jsdoc (https://github.com/englercj/tsd-jsdoc) -declare type GlobalObject = Object; +interface GlobalObject { [key: string]: any; } declare module ol { /** @@ -1385,6 +1385,9 @@ declare module ol { } } + /* From ol/typedefs.js */ + type EventsListenerFunctionType = ((evt: ol.events.Event) => void) | ((evt: ol.events.Event) => boolean); + module extent { /** * Build an extent that includes all given coordinates. @@ -7296,7 +7299,7 @@ declare module ol { * will be an array of keys. * @api stable */ - on(type: (string | string[]), listener: Function, opt_this?: GlobalObject): (ol.EventsKey | ol.EventsKey[]); + on(type: (string | string[]), listener: ol.EventsListenerFunctionType, opt_this?: GlobalObject): (ol.EventsKey | ol.EventsKey[]); /** * Listen once for a certain type of event. @@ -7308,7 +7311,7 @@ declare module ol { * will be an array of keys. * @api stable */ - once(type: (string | string[]), listener: Function, opt_this?: GlobalObject): (ol.EventsKey | ol.EventsKey[]); + once(type: (string | string[]), listener: ol.EventsListenerFunctionType, opt_this?: GlobalObject): (ol.EventsKey | ol.EventsKey[]); /** * Unlisten for a certain type of event. @@ -7318,7 +7321,7 @@ declare module ol { * `listener`. * @api stable */ - un(type: (string | string[]), listener: Function, opt_this?: GlobalObject): void; + un(type: (string | string[]), listener: ol.EventsListenerFunctionType, opt_this?: GlobalObject): void; } /** @@ -10778,7 +10781,7 @@ declare module ol { * Key to use with {@link ol.Observable#unByKey}. * */ - type EventsKey = Object; + type EventsKey = GlobalObject; /** * An array of numbers representing an extent: `[minx, miny, maxx, maxy]`. @@ -11002,12 +11005,12 @@ declare module ol { /** * Number of features; bounds/extent. */ - type WFSFeatureCollectionMetadata = Object; + type WFSFeatureCollectionMetadata = GlobalObject; /** * Total deleted; total inserted; total updated; array of insert ids. */ - type WFSTransactionResponse = Object; + type WFSTransactionResponse = GlobalObject; /** * @param tileCoord Tile coordinate. diff --git a/types/openlayers/openlayers-tests.ts b/types/openlayers/openlayers-tests.ts index 49a9e39178..ff37abb4dc 100644 --- a/types/openlayers/openlayers-tests.ts +++ b/types/openlayers/openlayers-tests.ts @@ -3,12 +3,13 @@ let anyValue: any; let booleanValue: boolean; let canvas: HTMLCanvasElement; let domEventTarget: EventTarget; -let fn: Function; +let fn: () => void; let image: HTMLImageElement; let jsonValue: JSON; +let listener: ol.EventsListenerFunctionType; let numberArray: number[]; let numberValue: number; -let object: Object; +let object: { [key: string]: any }; let stringArray: string[]; let stringValue: string; @@ -584,12 +585,12 @@ observable.dispatchEvent({ type: stringValue, a: numberValue, b: stringValue, c: observable.dispatchEvent(olEvent); observable.dispatchEvent(stringValue); numberValue = observable.getRevision(); -eventKeyMixed = observable.on(stringValue, fn); -eventKeyMixed = observable.on([stringValue, stringValue], fn, {}); -eventKeyMixed = observable.once(stringValue, fn); -eventKeyMixed = observable.once([stringValue, stringValue], fn, {}); -observable.un(stringValue, fn); -observable.un([stringValue, stringValue], fn, {}); +eventKeyMixed = observable.on(stringValue, listener); +eventKeyMixed = observable.on([stringValue, stringValue], listener, {}); +eventKeyMixed = observable.once(stringValue, listener); +eventKeyMixed = observable.once([stringValue, stringValue], listener, {}); +observable.un(stringValue, listener); +observable.un([stringValue, stringValue], listener, {}); // // ol.proj diff --git a/types/openlayers/tslint.json b/types/openlayers/tslint.json index 1c4e20ccb2..e7fec67fe5 100644 --- a/types/openlayers/tslint.json +++ b/types/openlayers/tslint.json @@ -1,8 +1,6 @@ { "extends": "dtslint/dt.json", "rules": { - // It appears somewhat difficult to remove the Function and Object types - "ban-types": false, // Not sure how to work around this, or if it's necessary to "no-declare-current-package": false, "no-internal-module": false,