mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-04 14:57:10 +00:00
improve leaflet Util and Class typings
This commit is contained in:
Vendored
+13
-7
@@ -11,10 +11,12 @@ export as namespace L;
|
||||
import * as geojson from 'geojson';
|
||||
|
||||
export class Class {
|
||||
static extend(props: any): any/* how to return constructor of self extended type ? */;
|
||||
static include(props: any): any /* how to return self extended type ? */;
|
||||
static mergeOptions(props: any): any /* how to return self extended type ? */;
|
||||
static addInitHook(initHookFn: () => void): any/* how to return self extended type ? */;
|
||||
static extend(props: any): {new(...args: any[]): any} & typeof Class;
|
||||
static include(props: any): any & typeof Class;
|
||||
static mergeOptions(props: any): any & typeof Class;
|
||||
|
||||
static addInitHook(initHookFn: () => void): any & typeof Class;
|
||||
static addInitHook(methodName: string, ...args: any[]): any & typeof Class;
|
||||
}
|
||||
|
||||
export class Transformation {
|
||||
@@ -1532,8 +1534,12 @@ export namespace Browser {
|
||||
}
|
||||
|
||||
export namespace Util {
|
||||
function extend(dest: any, src?: any): any;
|
||||
function create(proto: any, properties?: any): any;
|
||||
function extend<D extends object, S1 extends object = {}>(dest: D, src?: S1): D & S1;
|
||||
function extend<D extends object, S1 extends object, S2 extends object>(dest: D, src1: S1, src2: S2): D & S1 & S2;
|
||||
function extend<D extends object, S1 extends object, S2 extends object, S3 extends object>(dest: D, src1: S1, src2: S2, src3: S3): D & S1 & S2 & S3;
|
||||
function extend(dest: any, ...src: any[]): any;
|
||||
|
||||
function create(proto: object | null, properties?: PropertyDescriptorMap): any;
|
||||
function bind(fn: () => void, ...obj: any[]): () => void;
|
||||
function stamp(obj: any): number;
|
||||
function throttle(fn: () => void, time: number, context: any): () => void;
|
||||
@@ -1547,7 +1553,7 @@ export namespace Util {
|
||||
function template(str: string, data: any): string;
|
||||
function isArray(obj: any): boolean;
|
||||
function indexOf(array: any[], el: any): number;
|
||||
function requestAnimFrame(fn: () => void, context?: any, immediate?: boolean): number;
|
||||
function requestAnimFrame(fn: (timestamp: number) => void, context?: any, immediate?: boolean): number;
|
||||
function cancelAnimFrame(id: number): void;
|
||||
|
||||
let lastId: number;
|
||||
|
||||
@@ -444,10 +444,13 @@ defaultIcon = new L.Icon.Default({imagePath: 'apath'});
|
||||
|
||||
const myControlClass = L.Control.extend({});
|
||||
const myControl = new myControlClass();
|
||||
const myOtherControlClass = myControlClass.extend({});
|
||||
const myOtherControl = new myOtherControlClass();
|
||||
|
||||
L.Control.include({});
|
||||
L.Control.mergeOptions({});
|
||||
L.Control.addInitHook(() => {});
|
||||
L.Control.addInitHook('method1', 'hello', 1);
|
||||
|
||||
export class MyNewControl extends L.Control {
|
||||
constructor() {
|
||||
@@ -526,8 +529,35 @@ polyline = new L.Polyline(multiPolylineLatLngs);
|
||||
polyline.setLatLngs(multiPolylineLatLngs);
|
||||
const multiPolylineLatLngs2: L.LatLng[][] = polyline.getLatLngs() as L.LatLng[][];
|
||||
|
||||
L.Util.extend({});
|
||||
const obj1 = {
|
||||
prop1: 1,
|
||||
};
|
||||
|
||||
const obj2 = {
|
||||
prop2: '2',
|
||||
};
|
||||
|
||||
const obj3 = {
|
||||
prop3: 'three',
|
||||
};
|
||||
|
||||
const obj4 = {
|
||||
prop4: 'cuatro',
|
||||
};
|
||||
|
||||
const obj5 = {
|
||||
prop5: 'cinque',
|
||||
};
|
||||
|
||||
const extended0: typeof obj1 = L.Util.extend(obj1);
|
||||
const extended1: typeof obj1 & typeof obj2 = L.Util.extend(obj1, obj2);
|
||||
const extended2: typeof obj1 & typeof obj2 & typeof obj3 = L.Util.extend(obj1, obj2, obj3);
|
||||
const extended3: typeof obj1 & typeof obj2 & typeof obj3 & typeof obj4 = L.Util.extend(obj1, obj2, obj3, obj4);
|
||||
const extended4: typeof obj1 & typeof obj2 & typeof obj3 & typeof obj4 & typeof obj5 = L.Util.extend(obj1, obj2, obj3, obj4, obj5);
|
||||
|
||||
L.Util.create({});
|
||||
L.Util.create(null, {foo: {writable: true, value: 'bar'}});
|
||||
|
||||
L.Util.bind(() => {}, {});
|
||||
L.Util.stamp({});
|
||||
L.Util.throttle(() => {}, 123, {});
|
||||
@@ -546,7 +576,7 @@ L.Util.template('template', {});
|
||||
L.Util.isArray({});
|
||||
L.Util.indexOf([], {});
|
||||
L.Util.requestAnimFrame(() => {});
|
||||
L.Util.requestAnimFrame(() => {}, {});
|
||||
L.Util.requestAnimFrame(timestamp => console.log(timestamp), {});
|
||||
L.Util.requestAnimFrame(() => {}, {}, true);
|
||||
L.Util.cancelAnimFrame(1);
|
||||
L.Util.emptyImageUrl;
|
||||
|
||||
Reference in New Issue
Block a user