From b5eaa88e9effe4eebf076951217bdaf3be861721 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alejandro=20S=C3=A1nchez?= Date: Thu, 24 Aug 2017 17:18:50 -0600 Subject: [PATCH] Updated leaflet typings to match v1.2.x and to use newer typescript features --- .../esri-leaflet-geocoder-tests.ts | 3 +- types/esri-leaflet-geocoder/index.d.ts | 10 +- types/esri-leaflet/esri-leaflet-tests.ts | 17 +- types/esri-leaflet/index.d.ts | 13 +- types/leaflet-areaselect/index.d.ts | 4 +- .../leaflet-areaselect-tests.ts | 5 +- types/leaflet-areaselect/tslint.json | 4 +- types/leaflet-curve/index.d.ts | 8 +- types/leaflet-curve/leaflet-curve-tests.ts | 46 +- types/leaflet-curve/tslint.json | 1 + types/leaflet-draw/index.d.ts | 5 +- types/leaflet-draw/leaflet-draw-tests.ts | 9 +- types/leaflet-editable/index.d.ts | 74 +- .../leaflet-editable-tests.ts | 15 +- types/leaflet-editable/tslint.json | 1 + types/leaflet-fullscreen/index.d.ts | 4 +- .../leaflet-fullscreen-tests.ts | 2 + types/leaflet-fullscreen/tslint.json | 4 +- types/leaflet-geocoder-mapzen/index.d.ts | 34 +- .../leaflet-geocoder-mapzen-tests.ts | 11 +- types/leaflet-geocoder-mapzen/tslint.json | 1 + types/leaflet-imageoverlay-rotated/index.d.ts | 8 +- .../leaflet-imageoverlay-rotated-tests.ts | 3 + types/leaflet-label/index.d.ts | 130 +- types/leaflet-label/leaflet-label-tests.ts | 5 +- types/leaflet-polylinedecorator/index.d.ts | 5 +- .../leaflet-polylinedecorator-tests.ts | 3 + types/leaflet-providers/index.d.ts | 6 +- .../leaflet-providers-tests.ts | 3 + types/leaflet.awesome-markers/index.d.ts | 50 +- .../leaflet.awesome-markers-tests.ts | 9 +- types/leaflet.awesome-markers/tslint.json | 1 + types/leaflet.fullscreen/index.d.ts | 33 +- .../leaflet.fullscreen-tests.ts | 9 +- types/leaflet.fullscreen/tslint.json | 1 + .../leaflet.gridlayer.googlemutant/index.d.ts | 140 +- .../leaflet.gridlayer.googlemutant-tests.ts | 9 +- types/leaflet.locatecontrol/index.d.ts | 5 +- .../leaflet.locatecontrol-tests.ts | 3 + .../index.d.ts | 11 +- ...eaflet.markercluster.layersupport-tests.ts | 3 +- types/leaflet.markercluster/index.d.ts | 9 +- .../leaflet.markercluster-tests.ts | 3 +- types/leaflet.pm/index.d.ts | 5 +- types/leaflet.pm/leaflet.pm-tests.ts | 3 + types/leaflet/index.d.ts | 2961 ++++++++--------- types/leaflet/leaflet-tests.ts | 6 +- types/proj4leaflet/index.d.ts | 19 +- types/proj4leaflet/proj4leaflet-tests.ts | 6 +- types/react-leaflet/index.d.ts | 98 +- types/react-leaflet/react-leaflet-tests.tsx | 60 +- 51 files changed, 1939 insertions(+), 1939 deletions(-) create mode 100644 types/leaflet-curve/tslint.json create mode 100644 types/leaflet-editable/tslint.json create mode 100644 types/leaflet-geocoder-mapzen/tslint.json create mode 100644 types/leaflet.awesome-markers/tslint.json create mode 100644 types/leaflet.fullscreen/tslint.json diff --git a/types/esri-leaflet-geocoder/esri-leaflet-geocoder-tests.ts b/types/esri-leaflet-geocoder/esri-leaflet-geocoder-tests.ts index a79e8f068f..09b6c94288 100644 --- a/types/esri-leaflet-geocoder/esri-leaflet-geocoder-tests.ts +++ b/types/esri-leaflet-geocoder/esri-leaflet-geocoder-tests.ts @@ -1,4 +1,5 @@ -import * as L from 'esri-leaflet-geocoder'; +import * as L from 'leaflet'; +import 'esri-leaflet-geocoder'; const map = L.map('map').setView([45.5165, -122.6764], 12); const tiles = L.esri.basemapLayer("Streets").addTo(map); diff --git a/types/esri-leaflet-geocoder/index.d.ts b/types/esri-leaflet-geocoder/index.d.ts index 50c1ff779b..593f7cbb0b 100644 --- a/types/esri-leaflet-geocoder/index.d.ts +++ b/types/esri-leaflet-geocoder/index.d.ts @@ -4,13 +4,11 @@ // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.4 -import * as leaflet from 'leaflet'; -import * as esriLeaflet from 'esri-leaflet'; +import * as L from 'leaflet'; +import 'esri-leaflet'; -export = L; - -declare global { - namespace L.esri.Geocoding { +declare module 'leaflet' { + namespace esri.Geocoding { type GeosearchConstructor = new (options?: GeosearchObject) => Geosearch; type Geosearch = GeosearchControl & Evented; diff --git a/types/esri-leaflet/esri-leaflet-tests.ts b/types/esri-leaflet/esri-leaflet-tests.ts index d0f1249232..89520101a3 100644 --- a/types/esri-leaflet/esri-leaflet-tests.ts +++ b/types/esri-leaflet/esri-leaflet-tests.ts @@ -4,14 +4,17 @@ // tslint:disable:only-arrow-functions // tslint:disable:space-before-function-paren -let latlng: L.LatLng = new L.LatLng(0, 0); -let latlngbounds: L.LatLngBounds = new L.LatLngBounds(latlng, latlng); -let map: L.Map = new L.Map('map'); +import * as L from 'leaflet'; +import 'esri-leaflet'; -let marker: L.Marker = new L.Marker(latlng); -let polygon: L.Polygon = new L.Polygon([latlng, latlng]); -let polyline: L.Polyline = new L.Polyline([latlng, latlng]); -let geojson: L.GeoJSON = new L.GeoJSON(); +const latlng: L.LatLng = new L.LatLng(0, 0); +const latlngbounds: L.LatLngBounds = new L.LatLngBounds(latlng, latlng); +const map: L.Map = new L.Map('map'); + +const marker: L.Marker = new L.Marker(latlng); +const polygon: L.Polygon = new L.Polygon([latlng, latlng]); +const polyline: L.Polyline = new L.Polyline([latlng, latlng]); +const geojson: L.GeoJSON = new L.GeoJSON(); let basemapLayer: L.esri.BasemapLayer; basemapLayer = L.esri.basemapLayer('Streets'); diff --git a/types/esri-leaflet/index.d.ts b/types/esri-leaflet/index.d.ts index a79322983e..07cab832e0 100644 --- a/types/esri-leaflet/index.d.ts +++ b/types/esri-leaflet/index.d.ts @@ -2,10 +2,11 @@ // Project: http://esri.github.io/esri-leaflet // Definitions by: strajuser // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.3 -/// +import * as L from 'leaflet'; -declare namespace L { +declare module 'leaflet' { namespace esri { type CallbackHandler = (error: any, metadata: any) => void; @@ -834,11 +835,7 @@ declare namespace L { * @returns {FeatureLayer} */ function featureLayer(options: FeatureLayerOptions): FeatureLayer; - } -} -declare namespace L { - namespace esri { type FeatureCallbackHandler = (error?: any, featureCollection?: any, response?: any) => void; type ResponseCallbackHandler = (error?: any, response?: any) => void; @@ -1621,7 +1618,3 @@ declare namespace L { function find(options: FindOptions | MapService): Find; } } - -declare module 'esri-leaflet' { - export = L.esri; -} diff --git a/types/leaflet-areaselect/index.d.ts b/types/leaflet-areaselect/index.d.ts index 7c3fe5a476..50b0202f6a 100644 --- a/types/leaflet-areaselect/index.d.ts +++ b/types/leaflet-areaselect/index.d.ts @@ -3,9 +3,9 @@ // Definitions by: André Wallat // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -/// +import * as L from 'leaflet'; -declare namespace L { +declare module 'leaflet' { function areaSelect(box: AreaSelectOptions): AreaSelect; interface AreaSelectOptions { diff --git a/types/leaflet-areaselect/leaflet-areaselect-tests.ts b/types/leaflet-areaselect/leaflet-areaselect-tests.ts index b5d4785257..e285a17432 100644 --- a/types/leaflet-areaselect/leaflet-areaselect-tests.ts +++ b/types/leaflet-areaselect/leaflet-areaselect-tests.ts @@ -1,6 +1,9 @@ +import * as L from 'leaflet'; +import 'leaflet-areaselect'; + const map = L.map('map', {center: L.latLng(-37.7772, 175.2756), zoom: 15 }); let area: L.AreaSelect; -let dim: L.Dimension = { width: 1, height: 2 }; +const dim: L.Dimension = { width: 1, height: 2 }; area = L.areaSelect({}); diff --git a/types/leaflet-areaselect/tslint.json b/types/leaflet-areaselect/tslint.json index d88586e5bd..4e88071852 100644 --- a/types/leaflet-areaselect/tslint.json +++ b/types/leaflet-areaselect/tslint.json @@ -1,3 +1 @@ -{ - "extends": "dtslint/dt.json" -} +{"extends": "dtslint/dt.json"} diff --git a/types/leaflet-curve/index.d.ts b/types/leaflet-curve/index.d.ts index b15f701f81..58e4551dec 100644 --- a/types/leaflet-curve/index.d.ts +++ b/types/leaflet-curve/index.d.ts @@ -1,13 +1,13 @@ -// Type definitions for leaflet-curve 0.0.1 +// Type definitions for leaflet-curve 0.1 // Project: https://github.com/onikiienko/Leaflet.curve // Definitions by: Onikiienko // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -/// +import * as L from 'leaflet'; -declare namespace L { +declare module 'leaflet' { /** * Drawing Bezier curves and other complex shapes. */ - function curve(path: any[], options?: L.PathOptions): Path; + function curve(path: any[], options?: PathOptions): Path; } diff --git a/types/leaflet-curve/leaflet-curve-tests.ts b/types/leaflet-curve/leaflet-curve-tests.ts index 3d8b319e63..7390f82b9d 100644 --- a/types/leaflet-curve/leaflet-curve-tests.ts +++ b/types/leaflet-curve/leaflet-curve-tests.ts @@ -1,29 +1,31 @@ -var osmUrl = 'http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', - osmAttrib = '© OpenStreetMap contributors', - osm = L.tileLayer(osmUrl, {maxZoom: 18, attribution: osmAttrib}), - map = new L.Map('map', {layers: [osm], center: new L.LatLng(-37.7772, 175.2756), zoom: 15 }), - objectToSetOnMap = { - "color": "black", - start: { - x: 37.64903402157866, - y: -3.6474609375000004 - }, - vertex: { - x: 38.839707613545144, - y: -1.9555664062500002 - }, - end: { - x: 39.977120098439634, - y: -3.6474609375000004 - } - }; +import * as L from 'leaflet'; +import 'leaflet-curve'; +const osmUrl = 'http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png'; +const osmAttrib = '© OpenStreetMap contributors'; +const osm = L.tileLayer(osmUrl, {maxZoom: 18, attribution: osmAttrib}); +const map = new L.Map('map', {layers: [osm], center: new L.LatLng(-37.7772, 175.2756), zoom: 15 }); +const objectToSetOnMap = { + color: 'black', + start: { + x: 37.64903402157866, + y: -3.6474609375000004 + }, + vertex: { + x: 38.839707613545144, + y: -1.9555664062500002 + }, + end: { + x: 39.977120098439634, + y: -3.6474609375000004 + } +}; L.curve( [ - 'M',[objectToSetOnMap.start.x, objectToSetOnMap.start.y], - 'C',[objectToSetOnMap.start.x, objectToSetOnMap.start.y], [objectToSetOnMap.vertex.x, objectToSetOnMap.vertex.y], [objectToSetOnMap.end.x, objectToSetOnMap.end.y], - 'T',[objectToSetOnMap.end.x, objectToSetOnMap.end.y] + 'M', [objectToSetOnMap.start.x, objectToSetOnMap.start.y], + 'C', [objectToSetOnMap.start.x, objectToSetOnMap.start.y], [objectToSetOnMap.vertex.x, objectToSetOnMap.vertex.y], [objectToSetOnMap.end.x, objectToSetOnMap.end.y], + 'T', [objectToSetOnMap.end.x, objectToSetOnMap.end.y] ], {color: objectToSetOnMap.color} ).addTo(map); diff --git a/types/leaflet-curve/tslint.json b/types/leaflet-curve/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/leaflet-curve/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/leaflet-draw/index.d.ts b/types/leaflet-draw/index.d.ts index 7d791f62ae..5ae8c81605 100644 --- a/types/leaflet-draw/index.d.ts +++ b/types/leaflet-draw/index.d.ts @@ -2,10 +2,11 @@ // Project: https://github.com/Leaflet/Leaflet.draw // Definitions by: Matt Guest , Ryan Blace // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.3 -/// +import * as L from 'leaflet'; -declare namespace L { +declare module 'leaflet' { interface MapOptions { drawControl?: boolean; } diff --git a/types/leaflet-draw/leaflet-draw-tests.ts b/types/leaflet-draw/leaflet-draw-tests.ts index 80e175732f..e63006edce 100644 --- a/types/leaflet-draw/leaflet-draw-tests.ts +++ b/types/leaflet-draw/leaflet-draw-tests.ts @@ -1,3 +1,6 @@ +import * as L from 'leaflet'; +import 'leaflet-draw'; + const osmUrl = 'http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png'; const osmAttrib = '© OpenStreetMap contributors'; const osm = L.tileLayer(osmUrl, {maxZoom: 18, attribution: osmAttrib}); @@ -42,8 +45,8 @@ map.on(L.Draw.Event.CREATED, (e: L.DrawEvents.Created) => { drawnItems.addLayer(layer); }); -let examplePolygon: L.LatLngLiteral[] = [{lng: 0, lat: 0}, {lng: 10, lat: 0}, {lng: 10, lat: 10}, {lng: 0, lat: 10}, {lng: 0, lat: 0}]; -let examplePolygonArea: number = L.GeometryUtil.geodesicArea(examplePolygon); +const examplePolygon: L.LatLngLiteral[] = [{lng: 0, lat: 0}, {lng: 10, lat: 0}, {lng: 10, lat: 10}, {lng: 0, lat: 10}, {lng: 0, lat: 0}]; +const examplePolygonArea: number = L.GeometryUtil.geodesicArea(examplePolygon); L.GeometryUtil.readableArea(examplePolygonArea, true); function testBooleanControlOptions() { @@ -104,7 +107,7 @@ function testExampleControlOptions() { circle: false, // Turns off this drawing tool rectangle: { shapeOptions: { - clickable: false + // clickable: false // clickabkle is not a polyline option according to leaflet docs } }, marker: { diff --git a/types/leaflet-editable/index.d.ts b/types/leaflet-editable/index.d.ts index f66b45a9b8..ee42cb1fb1 100644 --- a/types/leaflet-editable/index.d.ts +++ b/types/leaflet-editable/index.d.ts @@ -2,38 +2,39 @@ // Project: https://github.com/yohanboniface/Leaflet.Editable // Definitions by: Dominic Alie // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.2 -import * as Leaflet from "leaflet"; +import * as Leaflet from 'leaflet'; -declare global { namespace L { +declare module 'leaflet' { /** * Make geometries editable in Leaflet. * * This is not a plug and play UI, and will not. This is a minimal, lightweight, and fully extendable API to * control editing of geometries. So you can easily build your own UI with your own needs and choices. */ - export interface EditableStatic { + interface EditableStatic { new (map: Map, options: EditOptions): Editable; } /** * Options to pass to L.Editable when instanciating. */ - export interface EditOptions { + interface EditOptions { /** * Class to be used when creating a new Polyline. */ - polylineClass?: Object; + polylineClass?: object; /** * Class to be used when creating a new Polygon. */ - polygonClass?: Object; + polygonClass?: object; /** * Class to be used when creating a new Marker. */ - markerClass?: Object; + markerClass?: object; /** * CSS class to be added to the map container while drawing. @@ -43,42 +44,42 @@ declare global { namespace L { /** * Layer used to store edit tools (vertex, line guide…). */ - editLayer?: Leaflet.LayerGroup; + editLayer?: LayerGroup; /** * Default layer used to store drawn features (marker, polyline…). */ - featuresLayer?: Leaflet.LayerGroup; + featuresLayer?: LayerGroup; /** * Class to be used as vertex, for path editing. */ - vertexMarkerClass?: Object; + vertexMarkerClass?: object; /** * Class to be used as middle vertex, pulled by the user to create a new point in the middle of a path. */ - middleMarkerClass?: Object; + middleMarkerClass?: object; /** * Class to be used as Polyline editor. */ - polylineEditorClass?: Object; + polylineEditorClass?: object; /** * Class to be used as Polygon editor. */ - polygonEditorClass?: Object; + polygonEditorClass?: object; /** * Class to be used as Marker editor. */ - markerEditorClass?: Object; + markerEditorClass?: object; /** * Options to be passed to the line guides. */ - lineGuideOptions?: Object; + lineGuideOptions?: object; /** * Set this to true if you don't want middle markers. @@ -92,7 +93,7 @@ declare global { namespace L { * This is not a plug and play UI, and will not. This is a minimal, lightweight, and fully extendable API to * control editing of geometries. So you can easily build your own UI with your own needs and choices. */ - export interface Editable extends Mixin.LeafletMixinEvents { + interface Editable extends Mixin.LeafletMixinEvents { /** * Options to pass to L.Editable when instanciating. */ @@ -104,20 +105,20 @@ declare global { namespace L { * Start drawing a polyline. If latlng is given, a first point will be added. In any case, continuing on user * click. If options is given, it will be passed to the polyline class constructor. */ - startPolyline(latLng?: LatLng, options?: Leaflet.PolylineOptions): L.Polyline; + startPolyline(latLng?: LatLng, options?: PolylineOptions): Polyline; /** * Start drawing a polygon. If latlng is given, a first point will be added. In any case, continuing on user * click. If options is given, it will be passed to the polygon class constructor. */ - startPolygon(latLng?: LatLng, options?: Leaflet.PolylineOptions): L.Polygon; + startPolygon(latLng?: LatLng, options?: PolylineOptions): Polygon; /** * Start adding a marker. If latlng is given, the marker will be shown first at this point. In any case, it * will follow the user mouse, and will have a final latlng on next click (or touch). If options is given, * it will be passed to the marker class constructor. */ - startMarker(latLng?: LatLng, options?: Leaflet.MarkerOptions): L.Marker; + startMarker(latLng?: LatLng, options?: MarkerOptions): Marker; /** * When you need to stop any ongoing drawing, without needing to know which editor is active. @@ -125,14 +126,14 @@ declare global { namespace L { stopDrawing(): void; } - export var Editable: EditableStatic; + let Editable: EditableStatic; /** * EditableMixin is included to L.Polyline, L.Polygon and L.Marker. It adds the following methods to them. * * When editing is enabled, the editor is accessible on the instance with the editor property. */ - export interface EditableMixin { + interface EditableMixin { /** * Enable editing, by creating an editor if not existing, and then calling enable on it. */ @@ -154,7 +155,7 @@ declare global { namespace L { editEnabled(): boolean; } - export interface Map { + interface Map { /** * Whether to create a L.Editable instance at map init or not. */ @@ -171,11 +172,11 @@ declare global { namespace L { editTools: Editable; } - export interface Polyline extends EditableMixin { - } + // tslint:disable-next-line:no-empty-interface + interface Polyline extends EditableMixin {} namespace Map { - export interface MapOptions { + interface MapOptions { /** * Whether to create a L.Editable instance at map init or not. */ @@ -192,7 +193,7 @@ declare global { namespace L { * When editing a feature (marker, polyline…), an editor is attached to it. This editor basically knows * how to handle the edition. */ - export interface BaseEditor { + interface BaseEditor { /** * Set up the drawing tools for the feature to be editable. */ @@ -208,7 +209,7 @@ declare global { namespace L { * Inherit from L.Editable.BaseEditor. * Inherited by L.Editable.PolylineEditor and L.Editable.PolygonEditor. */ - export interface PathEditor extends BaseEditor { + interface PathEditor extends BaseEditor { /** * Rebuild edit elements (vertex, middlemarker, etc.). */ @@ -218,7 +219,7 @@ declare global { namespace L { /** * Inherit from L.Editable.PathEditor. */ - export interface PolylineEditor extends PathEditor { + interface PolylineEditor extends PathEditor { /** * Set up drawing tools to continue the line forward. */ @@ -233,7 +234,7 @@ declare global { namespace L { /** * Inherit from L.Editable.PathEditor. */ - export interface PolygonEditor extends PathEditor { + interface PolygonEditor extends PathEditor { /** * Set up drawing tools for creating a new hole on the polygon. If the latlng param is given, a first * point is created. @@ -244,15 +245,12 @@ declare global { namespace L { /** * Inherit from L.Editable.BaseEditor. */ - export interface MarkerEditor extends BaseEditor { - } + // tslint:disable-next-line:no-empty-interface + interface MarkerEditor extends BaseEditor {} - export interface Marker extends EditableMixin, MarkerEditor { - } + interface Marker extends EditableMixin, MarkerEditor {} - export interface Polyline extends EditableMixin, PolylineEditor { - } + interface Polyline extends EditableMixin, PolylineEditor {} - export interface Polygon extends EditableMixin, PolygonEditor { - } -} } + interface Polygon extends EditableMixin, PolygonEditor {} +} diff --git a/types/leaflet-editable/leaflet-editable-tests.ts b/types/leaflet-editable/leaflet-editable-tests.ts index 09728add47..23bcc988fb 100644 --- a/types/leaflet-editable/leaflet-editable-tests.ts +++ b/types/leaflet-editable/leaflet-editable-tests.ts @@ -1,3 +1,6 @@ +import * as L from 'leaflet'; +import 'leaflet-editable'; + class MarkerClass { } class MarkerEditorClass { } class MiddleMarkerClass { } @@ -7,7 +10,7 @@ class PolylineClass { } class PolylineEditorClass { } class VertexMarkerClass { } -var map: L.Map = L.map('div', { +const map: L.Map = L.map('div', { editable: true, editOptions: { drawingCSSClass: 'css-class', @@ -26,16 +29,16 @@ var map: L.Map = L.map('div', { } }); -var currentPoly: L.Polygon|L.Polyline| L.Marker = map.editTools.currentPolygon; +const currentPoly: L.Polygon|L.Polyline| L.Marker = map.editTools.currentPolygon; map.editTools.stopDrawing(); -var marker: L.Marker = map.editTools.startMarker(L.latLng(0, 0), { draggable: true }); +const marker: L.Marker = map.editTools.startMarker(L.latLng(0, 0), { draggable: true }); marker.disable(); marker.enable(); marker.toggleEdit(); -var enabled: boolean = marker.editEnabled(); +let enabled: boolean = marker.editEnabled(); -var polyline: L.Polyline = map.editTools.startPolyline(L.latLng(0, 0), { noClip: true }); +const polyline: L.Polyline = map.editTools.startPolyline(L.latLng(0, 0), { noClip: true }); polyline.continueBackward(); polyline.continueForward(); polyline.disable(); @@ -44,7 +47,7 @@ enabled = polyline.editEnabled(); polyline.reset(); polyline.toggleEdit(); -var polygon: L.Polygon = map.editTools.startPolygon(L.latLng(0, 0), { noClip: true }); +const polygon: L.Polygon = map.editTools.startPolygon(L.latLng(0, 0), { noClip: true }); polygon.continueBackward(); polygon.continueForward(); polygon.disable(); diff --git a/types/leaflet-editable/tslint.json b/types/leaflet-editable/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/leaflet-editable/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/leaflet-fullscreen/index.d.ts b/types/leaflet-fullscreen/index.d.ts index 168fae8a28..bf354e9155 100644 --- a/types/leaflet-fullscreen/index.d.ts +++ b/types/leaflet-fullscreen/index.d.ts @@ -3,9 +3,9 @@ // Definitions by: Denis Carriere // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -/// +import * as L from 'leaflet'; -declare namespace L { +declare module 'leaflet' { interface MapOptions { fullscreenControl?: true | {pseudoFullscreen: boolean}; } diff --git a/types/leaflet-fullscreen/leaflet-fullscreen-tests.ts b/types/leaflet-fullscreen/leaflet-fullscreen-tests.ts index 661f1bc208..efc611c193 100644 --- a/types/leaflet-fullscreen/leaflet-fullscreen-tests.ts +++ b/types/leaflet-fullscreen/leaflet-fullscreen-tests.ts @@ -1,3 +1,5 @@ +import * as L from 'leaflet'; + const map = L.map('map', { center: [51.505, -0.09], zoom: 13, diff --git a/types/leaflet-fullscreen/tslint.json b/types/leaflet-fullscreen/tslint.json index f93cf8562a..4e88071852 100644 --- a/types/leaflet-fullscreen/tslint.json +++ b/types/leaflet-fullscreen/tslint.json @@ -1,3 +1 @@ -{ - "extends": "dtslint/dt.json" -} +{"extends": "dtslint/dt.json"} diff --git a/types/leaflet-geocoder-mapzen/index.d.ts b/types/leaflet-geocoder-mapzen/index.d.ts index 390a751360..d4f8b445d9 100644 --- a/types/leaflet-geocoder-mapzen/index.d.ts +++ b/types/leaflet-geocoder-mapzen/index.d.ts @@ -1,23 +1,24 @@ -// Type definitions for leaflet-geocoder-mapzen v1.6.3 +// Type definitions for leaflet-geocoder-mapzen 1.6 // Project: https://github.com/mapzen/leaflet-geocoder -// Definitions by: Leonard Lausen +// Definitions by: Leonard Lausen // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.2 -import * as Leaflet from "leaflet"; +import * as L from 'leaflet'; -declare global { namespace L { +declare module 'leaflet' { namespace Control { - export interface GeocoderStatic extends Leaflet.ClassStatic { + interface GeocoderStatic extends ClassStatic { /** * Creates a geocoder control. */ new (options?: GeocoderOptions): Geocoder; } - export interface Geocoder extends Leaflet.Control { - } + // tslint:disable-next-line:no-empty-interface + interface Geocoder extends Control {} - export interface GeocoderOptions { + interface GeocoderOptions { /** * Host endpoint for a Pelias-compatible search API. * @@ -32,7 +33,7 @@ declare global { namespace L { * * Default value: false. */ - bounds?: Leaflet.LatLngBounds | boolean; + bounds?: LatLngBounds | boolean; /** * If true, search and autocomplete prioritizes results near the center @@ -42,7 +43,7 @@ declare global { namespace L { * * Default value: 'true'. */ - focus?: Leaflet.LatLng | boolean; + focus?: LatLng | boolean; /** * Filters results by layers (documentation). @@ -69,7 +70,7 @@ declare global { namespace L { * * Default value: null. */ - params?: Object; + params?: object; /** * The position of the control (one of the map corners). @@ -77,7 +78,7 @@ declare global { namespace L { * * Default value: 'topleft'. */ - position?: Leaflet.PositionString; + position?: PositionString; /** * Attribution text to include. @@ -126,7 +127,7 @@ declare global { namespace L { * * Default value: true */ - markers?: Leaflet.MarkerOptions | boolean; + markers?: MarkerOptions | boolean; /** * If true, the input box will expand to take up the full width of the map container. @@ -166,11 +167,10 @@ declare global { namespace L { } } - export namespace control { - + namespace control { /** * Creates a geocoder control. */ - export function geocoder(api_key: string, options?: Control.GeocoderOptions): L.Control.Geocoder; + function geocoder(api_key: string, options?: Control.GeocoderOptions): Control.Geocoder; } -} } +} diff --git a/types/leaflet-geocoder-mapzen/leaflet-geocoder-mapzen-tests.ts b/types/leaflet-geocoder-mapzen/leaflet-geocoder-mapzen-tests.ts index daf6d20bd6..92bb68f1a9 100644 --- a/types/leaflet-geocoder-mapzen/leaflet-geocoder-mapzen-tests.ts +++ b/types/leaflet-geocoder-mapzen/leaflet-geocoder-mapzen-tests.ts @@ -1,7 +1,10 @@ -var osmUrl = 'http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', - osmAttrib = '© OpenStreetMap contributors', - osm = L.tileLayer(osmUrl, {maxZoom: 18, attribution: osmAttrib}), - map = new L.Map('map', {layers: [osm], center: new L.LatLng(-37.7772, 175.2756), zoom: 15 }); +import * as L from 'leaflet'; +import 'leaflet-geocoder-mapzen'; + +const osmUrl = 'http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png'; +const osmAttrib = '© OpenStreetMap contributors'; +const osm = L.tileLayer(osmUrl, {maxZoom: 18, attribution: osmAttrib}); +const map = new L.Map('map', {layers: [osm], center: new L.LatLng(-37.7772, 175.2756), zoom: 15 }); // Add geocoding plugin L.control.geocoder('search-MKZrG6M').addTo(map); diff --git a/types/leaflet-geocoder-mapzen/tslint.json b/types/leaflet-geocoder-mapzen/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/leaflet-geocoder-mapzen/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/leaflet-imageoverlay-rotated/index.d.ts b/types/leaflet-imageoverlay-rotated/index.d.ts index 89dde5e375..6a37345ca5 100644 --- a/types/leaflet-imageoverlay-rotated/index.d.ts +++ b/types/leaflet-imageoverlay-rotated/index.d.ts @@ -3,11 +3,11 @@ // Definitions by: Thomas Kleinke // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -/// +import * as L from 'leaflet'; -declare namespace L { +declare module 'leaflet' { namespace ImageOverlay { - interface Rotated extends L.ImageOverlay { + interface Rotated extends ImageOverlay { reposition( topleft: LatLngExpression, topright: LatLngExpression, @@ -21,6 +21,6 @@ declare namespace L { topleft: LatLngExpression, topright: LatLngExpression, bottomleft: LatLngExpression, - options?: ImageOverlayOptions): L.ImageOverlay.Rotated; + options?: ImageOverlayOptions): ImageOverlay.Rotated; } } diff --git a/types/leaflet-imageoverlay-rotated/leaflet-imageoverlay-rotated-tests.ts b/types/leaflet-imageoverlay-rotated/leaflet-imageoverlay-rotated-tests.ts index 50db445f79..22b4a54ec1 100644 --- a/types/leaflet-imageoverlay-rotated/leaflet-imageoverlay-rotated-tests.ts +++ b/types/leaflet-imageoverlay-rotated/leaflet-imageoverlay-rotated-tests.ts @@ -1,3 +1,6 @@ +import * as L from 'leaflet'; +import 'leaflet-imageoverlay-rotated'; + const topleft = L.latLng(40.52256691873593, -3.7743186950683594); const topright = L.latLng(40.5210255066156, -3.7734764814376835); const bottomleft = L.latLng(40.52180437272552, -3.7768453359603886); diff --git a/types/leaflet-label/index.d.ts b/types/leaflet-label/index.d.ts index e1e96b717a..60f2b6b398 100644 --- a/types/leaflet-label/index.d.ts +++ b/types/leaflet-label/index.d.ts @@ -3,83 +3,79 @@ // Definitions by: Wim Looman // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -import * as Leaflet from "leaflet"; +import * as L from 'leaflet'; -declare global { - namespace L { - interface IconOptions { - labelAnchor?: Point; - } +declare module 'leaflet' { + interface IconOptions { + labelAnchor?: Point; + } - interface PathOptions { - labelAnchor?: Point; - } + interface PathOptions { + labelAnchor?: Point; + } - interface CircleMarkerOptions { - labelAnchor?: Point; - } + interface CircleMarkerOptions { + labelAnchor?: Point; + } - interface Marker { - showLabel(): Marker; - hideLabel(): Marker; - setLabelNoHide(noHide: boolean): void; - bindLabel(content: string, options?: LabelOptions): Marker; - unbindLabel(): Marker; - updateLabelContent(content: string): void; - getLabel(): Label; - setOpacity(opacity: number, labelHasSemiTransparency: boolean): void; - } + interface Marker { + showLabel(): Marker; + hideLabel(): Marker; + setLabelNoHide(noHide: boolean): void; + bindLabel(content: string, options?: LabelOptions): Marker; + unbindLabel(): Marker; + updateLabelContent(content: string): void; + getLabel(): Label; + setOpacity(opacity: number, labelHasSemiTransparency: boolean): void; + } - interface CircleMarker { - showLabel(): CircleMarker; - hideLabel(): CircleMarker; - setLabelNoHide(noHide: boolean): void; - bindLabel(content: string, options?: LabelOptions): CircleMarker; - unbindLabel(): CircleMarker; - updateLabelContent(content: string): void; - getLabel(): Label; - } + interface CircleMarker { + showLabel(): CircleMarker; + hideLabel(): CircleMarker; + setLabelNoHide(noHide: boolean): void; + bindLabel(content: string, options?: LabelOptions): CircleMarker; + unbindLabel(): CircleMarker; + updateLabelContent(content: string): void; + getLabel(): Label; + } - interface FeatureGroup { - clearLayers(): FeatureGroup; - bindLabel(content: string, options?: LabelOptions): FeatureGroup; - unbindLabel(): FeatureGroup; - updateLabelContent(content: string): FeatureGroup; - } + interface FeatureGroup { + clearLayers(): FeatureGroup; + bindLabel(content: string, options?: LabelOptions): FeatureGroup; + unbindLabel(): FeatureGroup; + updateLabelContent(content: string): FeatureGroup; + } - interface Path { - bindLabel(content: string, options?: LabelOptions): Path; - unbindLabel(): Path; - updateLabelContent(content: string): void; - } + interface Path { + bindLabel(content: string, options?: LabelOptions): Path; + unbindLabel(): Path; + updateLabelContent(content: string): void; + } - interface LabelOptions { - className?: string; - clickable?: boolean; - direction?: string; // 'left' | 'right' | 'auto'; - pane?: string; - noHide?: boolean; - offset?: Point; - opacity?: number; - zoomAnimation?: boolean; - } + interface LabelOptions { + className?: string; + clickable?: boolean; + direction?: string; // 'left' | 'right' | 'auto'; + pane?: string; + noHide?: boolean; + offset?: Point; + opacity?: number; + zoomAnimation?: boolean; + } - interface LabelStatic extends ClassStatic { - new(options?: LabelOptions): Label; - } + interface LabelStatic extends ClassStatic { + new(options?: LabelOptions): Label; + } - const Label: LabelStatic; + const Label: LabelStatic; - interface Label extends IEventPowered