From 9e13e02ace794fba00f44bcf70f41cdca1a56b4e Mon Sep 17 00:00:00 2001 From: Konstantin Burkalev Date: Wed, 15 Jun 2016 15:59:48 +0300 Subject: [PATCH 001/104] Updated definitions for wampy.js v3.0.x --- wampy/wampy-tests.ts | 5 +++-- wampy/wampy.d.ts | 22 +++++++++++++++++----- 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/wampy/wampy-tests.ts b/wampy/wampy-tests.ts index f7dcf9fe52..c0ac8d6656 100644 --- a/wampy/wampy-tests.ts +++ b/wampy/wampy-tests.ts @@ -13,7 +13,8 @@ ws.options({ onConnect: function () { console.log('Yahoo! We are online!'); }, onClose: function () { console.log('See you next time!'); }, onError: function () { console.log('Breakdown happened'); }, - onReconnect: function () { console.log('Reconnecting...'); } + onReconnect: function () { console.log('Reconnecting...'); }, + onReconnectSuccess: function () { console.log('Successfully reconnected!'); } }); ws.connect(); @@ -93,7 +94,7 @@ var status = ws.getOpStatus(); ws.cancel(status.reqId); -var sqrt_f = function (x: number) { return x*x; }; +var sqrt_f = function (x: number, y: any) { return [{}, x*x]; }; ws.register('sqrt.value', sqrt_f); diff --git a/wampy/wampy.d.ts b/wampy/wampy.d.ts index 650a8a91a5..e068b97a25 100644 --- a/wampy/wampy.d.ts +++ b/wampy/wampy.d.ts @@ -1,4 +1,4 @@ -// Type definitions for wampy.js v2.0.1 +// Type definitions for wampy.js v3.0.x // Project: https://github.com/KSDaemon/wampy.js // Definitions by: Konstantin Burkalev // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped @@ -12,10 +12,13 @@ declare module "wampy" { transportEncoding?: string; realm?: string; helloCustomDetails?: any; + onChallenge?: (auth_method: string, challenge_details: string) => string; + authid?: string; onConnect?: () => void; onClose?: () => void; onError?: () => void; onReconnect?: () => void; + onReconnectSuccess?: () => void; ws?: any; msgpackCoder?: any; } @@ -36,7 +39,7 @@ declare module "wampy" { } interface RegisterCallbacksHash extends SuccessErrorCallbacksHash { - rpc: (data: any) => any; + rpc: (data: any, options: any) => any[]; } interface CallSuccessErrorCallbacksHash { @@ -51,8 +54,17 @@ declare module "wampy" { disclose_me?: boolean; } - interface CallAdvancedOptions extends AdvancedOptions { + interface PublishAdvancedOptions extends AdvancedOptions { + exclude_authid?: string | string[]; + exclude_authrole?: string | string[]; + eligible_authid?: string | string[]; + eligible_authrole?: string | string[]; + } + + interface CallAdvancedOptions { + disclose_me?: boolean; receive_progress?: boolean; + timeout?: number; } interface CancelAdvancedOptions { @@ -71,7 +83,7 @@ declare module "wampy" { publish(topicURI: string, payload?: any, callbacks?: SuccessErrorCallbacksHash, - advancedOptions?: AdvancedOptions): Wampy; + advancedOptions?: PublishAdvancedOptions): Wampy; call(topicURI: string, payload?: any, callbacks?: (((data: any) => void) | CallSuccessErrorCallbacksHash), @@ -79,7 +91,7 @@ declare module "wampy" { cancel(reqId: number, callbacks?: ((() => void) | SuccessErrorCallbacksHash), advancedOptions?: CancelAdvancedOptions): Wampy; - register(topicURI: string, callbacks: (((data: any) => any) | RegisterCallbacksHash)): Wampy; + register(topicURI: string, callbacks: (((data: any, options: any) => any[]) | RegisterCallbacksHash)): Wampy; unregister(topicURI: string, callbacks?: ((() => void) | SuccessErrorCallbacksHash)): Wampy; } From b2e1844aba38db3f4181205cf4d49c7b769a56c5 Mon Sep 17 00:00:00 2001 From: efokschaner Date: Sat, 6 Aug 2016 23:26:19 -0700 Subject: [PATCH 002/104] Update definitions for msgpack-lite --- msgpack-lite/index.d.ts | 130 ++++++++++++++++++++++++----- msgpack-lite/msgpack-lite-tests.ts | 76 ++++++++++++++++- msgpack-lite/tsconfig.json | 2 +- 3 files changed, 183 insertions(+), 25 deletions(-) diff --git a/msgpack-lite/index.d.ts b/msgpack-lite/index.d.ts index 400d22b2e7..53ed592afa 100644 --- a/msgpack-lite/index.d.ts +++ b/msgpack-lite/index.d.ts @@ -1,14 +1,72 @@ -// Type definitions for msgpack-lite 0.1.20 +// Type definitions for msgpack-lite v0.1.26 // Project: https://github.com/kawanet/msgpack-lite -// Definitions by: Endel Dreyer +// Definitions by: Endel Dreyer , Edmund Fokschaner // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped /// -declare module "msgpack-lite" { - import { Transform } from "stream"; +declare module 'msgpack-lite' { + import * as stream from 'stream'; namespace MsgpackLite { - interface BufferOptions { codec: any; } + /** + * encode from JS Object to MessagePack + */ + function encode(input: any, options?: EncoderOptions): Buffer; + + /** + * decode from MessagePack to JS Object + */ + function decode(input: Buffer | Uint8Array | Array, options?: DecoderOptions): any; + + /** + * create a stream that encodes from JS Object to MessagePack + */ + function createEncodeStream(options?: EncoderOptions & stream.TransformOptions ): EncodeStream; + + /** + * create a stream that decodes from MessagePack (Buffer) to JS Object + */ + function createDecodeStream(options?: DecoderOptions & stream.TransformOptions): DecodeStream; + + /** + * Codecs allow for Custom Extension Types + * Register a custom extension type number to serialize/deserialize your own class instances. + * https://github.com/kawanet/msgpack-lite#custom-extension-types-codecs + * If you wish to modify the default built-in codec, you can access it at msgpack.codec.preset + */ + function createCodec(options?: CodecOptions): Codec; + + /** + * The default built-in codec + */ + var codec: { + /** + * The default built-in codec + */ + preset: Codec; + }; + + interface Codec { + /** + * Register a custom extension to serialize your own class instances + * + * @param etype an integer within the range of 0 and 127 (0x0 and 0x7F) + * @param Class the constructor of the type you wish to serialize + * @param packer a function that converts an instance of T to bytes + */ + addExtPacker( + etype: number, + Class: new(...args: any[]) => T, + packer: (t: T) => Buffer | Uint8Array): void; + + /** + * Register a custom extension to deserialize your own class instances + * + * @param etype an integer within the range of 0 and 127 (0x0 and 0x7F) + * @param unpacker a function that converts bytes to an instance of T + */ + addExtUnpacker(etype: number, unpacker: (data: Buffer | Uint8Array) => T): void; + } interface Encoder { bufferish: any; @@ -42,29 +100,59 @@ declare module "msgpack-lite" { end: (chunk: any) => void; } - interface EncodeStream extends Transform { + interface EncodeStream extends stream.Transform { encoder: Encoder; } - interface DecodeStream extends Transform { + + interface DecodeStream extends stream.Transform { decoder: Decoder; } - interface Codec { - new (options?: any): Codec; - options: any; - init (): void; - addExtPacker (etype: number, Class: any, packer: (value: any) => any): void; - getExtPacker (value: any): (value: any) => any; - addExtUnpacker (etype: number, unpacker: (value: any) => any): void; - getExtUnpacker (etype: number): (value: any) => any; + interface CodecOptions { + /** + * It includes the preset extensions for JavaScript native objects. + * @see https://github.com/kawanet/msgpack-lite#extension-types + * @default false + */ + preset?: boolean; + /** + * It runs a validation of the value before writing it into buffer. + * This is the default behavior for some old browsers which do not support ArrayBuffer object. + * @default varies + */ + safe?: boolean; + /** + * It uses raw formats instead of bin and str. + * Set true for compatibility with msgpack's old spec. + * @see https://github.com/kawanet/msgpack-lite#compatibility-mode + * @default false + */ + raw?: boolean; + /** + * It decodes msgpack's int64/uint64 formats with int64-buffer object. + * int64-buffer is a cutom integer type with 64 bits of precision instead + * of the built-in IEEE-754 53 bits. See https://github.com/kawanet/int64-buffer + * @default false + */ + int64?: boolean; + /** + * It ties msgpack's bin format with ArrayBuffer object, instead of Buffer object. + * @default false + */ + binarraybuffer?: boolean; + /** + * It returns Uint8Array object when encoding, instead of Buffer object. + */ + uint8array?: boolean; } - export function encode(input: any, options?: BufferOptions): any; - export function decode(input: Buffer | Uint8Array | Array, options?: BufferOptions): any; - export function createEncodeStream (): EncodeStream; - export function createDecodeStream (): DecodeStream; - export function createCodec (options?: any): Codec; - export function codec (): { preset: Codec }; + interface EncoderOptions { + codec?: Codec + } + + interface DecoderOptions { + codec?: Codec + } } export = MsgpackLite; diff --git a/msgpack-lite/msgpack-lite-tests.ts b/msgpack-lite/msgpack-lite-tests.ts index f6d8725754..3608e6bfd9 100644 --- a/msgpack-lite/msgpack-lite-tests.ts +++ b/msgpack-lite/msgpack-lite-tests.ts @@ -1,5 +1,75 @@ +import * as msgpack from 'msgpack-lite'; -import * as msgpack from "msgpack-lite"; +// https://github.com/kawanet/msgpack-lite#encoding-and-decoding-messagepack +function encodingAndDecoding() { + // encode from JS Object to MessagePack (Buffer) + var buffer = msgpack.encode({"foo": "bar"}); -var encoded = msgpack.encode(""); -msgpack.decode(encoded); + // decode from MessagePack (Buffer) to JS Object + var data = msgpack.decode(buffer); // => {"foo": "bar"} +} + +// https://github.com/kawanet/msgpack-lite#writing-to-messagepack-stream +function writingToStream() { + var fs = require("fs"); + + var writeStream = fs.createWriteStream("test.msp"); + var encodeStream = msgpack.createEncodeStream(); + encodeStream.pipe(writeStream); + + // send multiple objects to stream + encodeStream.write({foo: "bar"}); + encodeStream.write({baz: "qux"}); + + // call this once you're done writing to the stream. + encodeStream.end(); +} + +// https://github.com/kawanet/msgpack-lite#reading-from-messagepack-stream +function readingFromStream() { + var fs = require("fs"); + var msgpack = require("msgpack-lite"); + + var readStream = fs.createReadStream("test.msp"); + var decodeStream = msgpack.createDecodeStream(); + + // show multiple objects decoded from stream + readStream.pipe(decodeStream).on("data", console.warn); +} + +// https://github.com/kawanet/msgpack-lite#decoding-messagepack-bytes-array +function decodingBytesArray() { + // decode() accepts Buffer instance per default + msgpack.decode(new Buffer([0x81, 0xA3, 0x66, 0x6F, 0x6F, 0xA3, 0x62, 0x61, 0x72])); + + // decode() also accepts Array instance + msgpack.decode([0x81, 0xA3, 0x66, 0x6F, 0x6F, 0xA3, 0x62, 0x61, 0x72]); + + // decode() accepts raw Uint8Array instance as well + msgpack.decode(new Uint8Array([0x81, 0xA3, 0x66, 0x6F, 0x6F, 0xA3, 0x62, 0x61, 0x72])); +} + +// https://github.com/kawanet/msgpack-lite#custom-extension-types-codecs +function customExtensionTypes() { + var codec = msgpack.createCodec(); + codec.addExtPacker(0x3F, MyVector, myVectorPacker); + codec.addExtUnpacker(0x3F, myVectorUnpacker); + + var data = new MyVector(1, 2); + var encoded = msgpack.encode(data, {codec: codec}); + var decoded = msgpack.decode(encoded, {codec: codec}); + + class MyVector { + constructor(public x: number, public y: number) {} + } + + function myVectorPacker(vector: MyVector) { + var array = [vector.x, vector.y]; + return msgpack.encode(array); // return Buffer serialized + } + + function myVectorUnpacker(buffer: Buffer | Uint8Array): MyVector { + var array = msgpack.decode(buffer); + return new MyVector(array[0], array[1]); // return Object deserialized + } +} diff --git a/msgpack-lite/tsconfig.json b/msgpack-lite/tsconfig.json index 39588c1eef..6070c69ece 100644 --- a/msgpack-lite/tsconfig.json +++ b/msgpack-lite/tsconfig.json @@ -4,7 +4,7 @@ "target": "es6", "noImplicitAny": true, "noImplicitThis": true, - "strictNullChecks": false, + "strictNullChecks": true, "baseUrl": "../", "typeRoots": [ "../" From 0c28d885a4109aa79bff1267eeaf85297807e24d Mon Sep 17 00:00:00 2001 From: efokschaner Date: Sun, 1 Jan 2017 18:14:21 -0800 Subject: [PATCH 003/104] Add tslint.json to msgpack-lite --- msgpack-lite/index.d.ts | 8 ++++---- msgpack-lite/tslint.json | 1 + 2 files changed, 5 insertions(+), 4 deletions(-) create mode 100644 msgpack-lite/tslint.json diff --git a/msgpack-lite/index.d.ts b/msgpack-lite/index.d.ts index 53ed592afa..128be7fad1 100644 --- a/msgpack-lite/index.d.ts +++ b/msgpack-lite/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for msgpack-lite v0.1.26 +// Type definitions for msgpack-lite 0.1 // Project: https://github.com/kawanet/msgpack-lite // Definitions by: Endel Dreyer , Edmund Fokschaner // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped @@ -16,7 +16,7 @@ declare module 'msgpack-lite' { /** * decode from MessagePack to JS Object */ - function decode(input: Buffer | Uint8Array | Array, options?: DecoderOptions): any; + function decode(input: Buffer | Uint8Array | number[], options?: DecoderOptions): any; /** * create a stream that encodes from JS Object to MessagePack @@ -147,11 +147,11 @@ declare module 'msgpack-lite' { } interface EncoderOptions { - codec?: Codec + codec?: Codec; } interface DecoderOptions { - codec?: Codec + codec?: Codec; } } diff --git a/msgpack-lite/tslint.json b/msgpack-lite/tslint.json new file mode 100644 index 0000000000..2221e40e4a --- /dev/null +++ b/msgpack-lite/tslint.json @@ -0,0 +1 @@ +{ "extends": "../tslint.json" } \ No newline at end of file From 261edf6ed5faf327a9f7977ee0c40a4277dd775c Mon Sep 17 00:00:00 2001 From: efokschaner Date: Sat, 7 Jan 2017 06:17:23 -0800 Subject: [PATCH 004/104] Fix no-single-declare-module lint error --- msgpack-lite/index.d.ts | 282 ++++++++++++++--------------- msgpack-lite/msgpack-lite-tests.ts | 1 - 2 files changed, 138 insertions(+), 145 deletions(-) diff --git a/msgpack-lite/index.d.ts b/msgpack-lite/index.d.ts index 128be7fad1..e451267dbc 100644 --- a/msgpack-lite/index.d.ts +++ b/msgpack-lite/index.d.ts @@ -4,156 +4,150 @@ // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped /// -declare module 'msgpack-lite' { - import * as stream from 'stream'; +import * as stream from 'stream'; - namespace MsgpackLite { - /** - * encode from JS Object to MessagePack - */ - function encode(input: any, options?: EncoderOptions): Buffer; +/** + * encode from JS Object to MessagePack + */ +export function encode(input: any, options?: EncoderOptions): Buffer; - /** - * decode from MessagePack to JS Object - */ - function decode(input: Buffer | Uint8Array | number[], options?: DecoderOptions): any; +/** + * decode from MessagePack to JS Object + */ +export function decode(input: Buffer | Uint8Array | number[], options?: DecoderOptions): any; - /** - * create a stream that encodes from JS Object to MessagePack - */ - function createEncodeStream(options?: EncoderOptions & stream.TransformOptions ): EncodeStream; +/** + * create a stream that encodes from JS Object to MessagePack + */ +export function createEncodeStream(options?: EncoderOptions & stream.TransformOptions ): EncodeStream; - /** - * create a stream that decodes from MessagePack (Buffer) to JS Object - */ - function createDecodeStream(options?: DecoderOptions & stream.TransformOptions): DecodeStream; +/** + * create a stream that decodes from MessagePack (Buffer) to JS Object + */ +export function createDecodeStream(options?: DecoderOptions & stream.TransformOptions): DecodeStream; - /** - * Codecs allow for Custom Extension Types - * Register a custom extension type number to serialize/deserialize your own class instances. - * https://github.com/kawanet/msgpack-lite#custom-extension-types-codecs - * If you wish to modify the default built-in codec, you can access it at msgpack.codec.preset - */ - function createCodec(options?: CodecOptions): Codec; +/** + * Codecs allow for Custom Extension Types + * Register a custom extension type number to serialize/deserialize your own class instances. + * https://github.com/kawanet/msgpack-lite#custom-extension-types-codecs + * If you wish to modify the default built-in codec, you can access it at msgpack.codec.preset + */ +export function createCodec(options?: CodecOptions): Codec; - /** - * The default built-in codec - */ - var codec: { - /** - * The default built-in codec - */ - preset: Codec; - }; +/** + * The default built-in codec + */ +export var codec: { + /** + * The default built-in codec + */ + preset: Codec; +}; - interface Codec { - /** - * Register a custom extension to serialize your own class instances - * - * @param etype an integer within the range of 0 and 127 (0x0 and 0x7F) - * @param Class the constructor of the type you wish to serialize - * @param packer a function that converts an instance of T to bytes - */ - addExtPacker( - etype: number, - Class: new(...args: any[]) => T, - packer: (t: T) => Buffer | Uint8Array): void; +export interface Codec { + /** + * Register a custom extension to serialize your own class instances + * + * @param etype an integer within the range of 0 and 127 (0x0 and 0x7F) + * @param Class the constructor of the type you wish to serialize + * @param packer a function that converts an instance of T to bytes + */ + addExtPacker( + etype: number, + Class: new(...args: any[]) => T, + packer: (t: T) => Buffer | Uint8Array): void; - /** - * Register a custom extension to deserialize your own class instances - * - * @param etype an integer within the range of 0 and 127 (0x0 and 0x7F) - * @param unpacker a function that converts bytes to an instance of T - */ - addExtUnpacker(etype: number, unpacker: (data: Buffer | Uint8Array) => T): void; - } - - interface Encoder { - bufferish: any; - maxBufferSize: number; - minBufferSize: number; - offset: number; - start: number; - write: (chunk: any) => void; - fetch: () => void; - flush: () => void; - push: (chunk: any) => void; - pull: () => number; - read: () => number; - reserve: (length: number) => number; - send: (buffer: Buffer) => void; - encode: (chunk: any) => void; - end: (chunk: any) => void; - } - - interface Decoder { - bufferish: any; - offset: number; - fetch: () => void; - flush: () => void; - pull: () => number; - read: () => number; - write: (chunk: any) => void; - reserve: (length: number) => number; - decode: (chunk: any) => void; - push: (chunk: any) => void; - end: (chunk: any) => void; - } - - interface EncodeStream extends stream.Transform { - encoder: Encoder; - } - - interface DecodeStream extends stream.Transform { - decoder: Decoder; - } - - interface CodecOptions { - /** - * It includes the preset extensions for JavaScript native objects. - * @see https://github.com/kawanet/msgpack-lite#extension-types - * @default false - */ - preset?: boolean; - /** - * It runs a validation of the value before writing it into buffer. - * This is the default behavior for some old browsers which do not support ArrayBuffer object. - * @default varies - */ - safe?: boolean; - /** - * It uses raw formats instead of bin and str. - * Set true for compatibility with msgpack's old spec. - * @see https://github.com/kawanet/msgpack-lite#compatibility-mode - * @default false - */ - raw?: boolean; - /** - * It decodes msgpack's int64/uint64 formats with int64-buffer object. - * int64-buffer is a cutom integer type with 64 bits of precision instead - * of the built-in IEEE-754 53 bits. See https://github.com/kawanet/int64-buffer - * @default false - */ - int64?: boolean; - /** - * It ties msgpack's bin format with ArrayBuffer object, instead of Buffer object. - * @default false - */ - binarraybuffer?: boolean; - /** - * It returns Uint8Array object when encoding, instead of Buffer object. - */ - uint8array?: boolean; - } - - interface EncoderOptions { - codec?: Codec; - } - - interface DecoderOptions { - codec?: Codec; - } - } - - export = MsgpackLite; + /** + * Register a custom extension to deserialize your own class instances + * + * @param etype an integer within the range of 0 and 127 (0x0 and 0x7F) + * @param unpacker a function that converts bytes to an instance of T + */ + addExtUnpacker(etype: number, unpacker: (data: Buffer | Uint8Array) => T): void; } + +export interface Encoder { + bufferish: any; + maxBufferSize: number; + minBufferSize: number; + offset: number; + start: number; + write: (chunk: any) => void; + fetch: () => void; + flush: () => void; + push: (chunk: any) => void; + pull: () => number; + read: () => number; + reserve: (length: number) => number; + send: (buffer: Buffer) => void; + encode: (chunk: any) => void; + end: (chunk: any) => void; +} + +export interface Decoder { + bufferish: any; + offset: number; + fetch: () => void; + flush: () => void; + pull: () => number; + read: () => number; + write: (chunk: any) => void; + reserve: (length: number) => number; + decode: (chunk: any) => void; + push: (chunk: any) => void; + end: (chunk: any) => void; +} + +export interface EncodeStream extends stream.Transform { + encoder: Encoder; +} + +export interface DecodeStream extends stream.Transform { + decoder: Decoder; +} + +export interface CodecOptions { + /** + * It includes the preset extensions for JavaScript native objects. + * @see https://github.com/kawanet/msgpack-lite#extension-types + * @default false + */ + preset?: boolean; + /** + * It runs a validation of the value before writing it into buffer. + * This is the default behavior for some old browsers which do not support ArrayBuffer object. + * @default varies + */ + safe?: boolean; + /** + * It uses raw formats instead of bin and str. + * Set true for compatibility with msgpack's old spec. + * @see https://github.com/kawanet/msgpack-lite#compatibility-mode + * @default false + */ + raw?: boolean; + /** + * It decodes msgpack's int64/uint64 formats with int64-buffer object. + * int64-buffer is a cutom integer type with 64 bits of precision instead + * of the built-in IEEE-754 53 bits. See https://github.com/kawanet/int64-buffer + * @default false + */ + int64?: boolean; + /** + * It ties msgpack's bin format with ArrayBuffer object, instead of Buffer object. + * @default false + */ + binarraybuffer?: boolean; + /** + * It returns Uint8Array object when encoding, instead of Buffer object. + */ + uint8array?: boolean; +} + +export interface EncoderOptions { + codec?: Codec; +} + +export interface DecoderOptions { + codec?: Codec; +} \ No newline at end of file diff --git a/msgpack-lite/msgpack-lite-tests.ts b/msgpack-lite/msgpack-lite-tests.ts index 3608e6bfd9..033fde060c 100644 --- a/msgpack-lite/msgpack-lite-tests.ts +++ b/msgpack-lite/msgpack-lite-tests.ts @@ -28,7 +28,6 @@ function writingToStream() { // https://github.com/kawanet/msgpack-lite#reading-from-messagepack-stream function readingFromStream() { var fs = require("fs"); - var msgpack = require("msgpack-lite"); var readStream = fs.createReadStream("test.msp"); var decodeStream = msgpack.createDecodeStream(); From 12aebc4dab8ee03e8a2ef2867f60b70124c728bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ricardo=20De=20Pe=C3=B1a?= Date: Thu, 26 Jan 2017 16:25:02 -0500 Subject: [PATCH 005/104] Update index.d.ts added missing `context` prop. ref: https://nodejs.org/dist/latest-v6.x/docs/api/repl.html#repl_global_and_local_scope --- node/v6/index.d.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/node/v6/index.d.ts b/node/v6/index.d.ts index 2f4d36202d..826bd1108b 100644 --- a/node/v6/index.d.ts +++ b/node/v6/index.d.ts @@ -1368,6 +1368,8 @@ declare module "repl" { defineCommand(keyword: string, cmd: Function | { help: string, action: Function }): void; displayPrompt(preserveCursor?: boolean): void; + context: any; + /** * events.EventEmitter * 1. exit From c3722d57d50e9787c8e39b5dc2081dd340768f57 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A1mal=20Rasmussen?= Date: Fri, 27 Jan 2017 14:54:02 +0100 Subject: [PATCH 006/104] Export lodash-es types as named exports in index.d.ts --- lodash-es/index.d.ts | 284 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 284 insertions(+) diff --git a/lodash-es/index.d.ts b/lodash-es/index.d.ts index 71f98587ff..1c5cdc044c 100644 --- a/lodash-es/index.d.ts +++ b/lodash-es/index.d.ts @@ -2,3 +2,287 @@ // Project: http://lodash.com/ // Definitions by: Stephen Lautier // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +export { default as add } from './add'; +export { default as after } from './after'; +export { default as ary } from './ary'; +export { default as assign } from './assign'; +export { default as assignIn } from './assignIn'; +export { default as assignInWith } from './assignInWith'; +export { default as assignWith } from './assignWith'; +export { default as at } from './at'; +export { default as attempt } from './attempt'; +export { default as before } from './before'; +export { default as bind } from './bind'; +export { default as bindAll } from './bindAll'; +export { default as bindKey } from './bindKey'; +export { default as camelCase } from './camelCase'; +export { default as capitalize } from './capitalize'; +export { default as castArray } from './castArray'; +export { default as ceil } from './ceil'; +export { default as chain } from './chain'; +export { default as chunk } from './chunk'; +export { default as clamp } from './clamp'; +export { default as clone } from './clone'; +export { default as cloneDeep } from './cloneDeep'; +export { default as cloneDeepWith } from './cloneDeepWith'; +export { default as cloneWith } from './cloneWith'; +export { default as compact } from './compact'; +export { default as concat } from './concat'; +export { default as constant } from './constant'; +export { default as countBy } from './countBy'; +export { default as create } from './create'; +export { default as curry } from './curry'; +export { default as curryRight } from './curryRight'; +export { default as debounce } from './debounce'; +export { default as deburr } from './deburr'; +export { default as defaults } from './defaults'; +export { default as defaultsDeep } from './defaultsDeep'; +export { default as defer } from './defer'; +export { default as delay } from './delay'; +export { default as difference } from './difference'; +export { default as differenceBy } from './differenceBy'; +export { default as differenceWith } from './differenceWith'; +export { default as drop } from './drop'; +export { default as dropRight } from './dropRight'; +export { default as dropRightWhile } from './dropRightWhile'; +export { default as dropWhile } from './dropWhile'; +export { default as each } from './each'; +export { default as eachRight } from './eachRight'; +export { default as endsWith } from './endsWith'; +export { default as eq } from './eq'; +export { default as escape } from './escape'; +export { default as escapeRegExp } from './escapeRegExp'; +export { default as every } from './every'; +export { default as extend } from './extend'; +export { default as extendWith } from './extendWith'; +export { default as fill } from './fill'; +export { default as filter } from './filter'; +export { default as find } from './find'; +export { default as findIndex } from './findIndex'; +export { default as findKey } from './findKey'; +export { default as findLast } from './findLast'; +export { default as findLastIndex } from './findLastIndex'; +export { default as findLastKey } from './findLastKey'; +export { default as first } from './first'; +export { default as flatMap } from './flatMap'; +export { default as flatten } from './flatten'; +export { default as flattenDeep } from './flattenDeep'; +export { default as flattenDepth } from './flattenDepth'; +export { default as flip } from './flip'; +export { default as floor } from './floor'; +export { default as flow } from './flow'; +export { default as flowRight } from './flowRight'; +export { default as forEach } from './forEach'; +export { default as forEachRight } from './forEachRight'; +export { default as forIn } from './forIn'; +export { default as forInRight } from './forInRight'; +export { default as forOwn } from './forOwn'; +export { default as forOwnRight } from './forOwnRight'; +export { default as fromPairs } from './fromPairs'; +export { default as functions } from './functions'; +export { default as functionsIn } from './functionsIn'; +export { default as get } from './get'; +export { default as groupBy } from './groupBy'; +export { default as gt } from './gt'; +export { default as gte } from './gte'; +export { default as has } from './has'; +export { default as hasIn } from './hasIn'; +export { default as head } from './head'; +export { default as identity } from './identity'; +export { default as inRange } from './inRange'; +export { default as includes } from './includes'; +export { default as indexOf } from './indexOf'; +export { default as initial } from './initial'; +export { default as intersection } from './intersection'; +export { default as intersectionBy } from './intersectionBy'; +export { default as intersectionWith } from './intersectionWith'; +export { default as invert } from './invert'; +export { default as invertBy } from './invertBy'; +export { default as invoke } from './invoke'; +export { default as invokeMap } from './invokeMap'; +export { default as isArguments } from './isArguments'; +export { default as isArray } from './isArray'; +export { default as isArrayBuffer } from './isArrayBuffer'; +export { default as isArrayLike } from './isArrayLike'; +export { default as isArrayLikeObject } from './isArrayLikeObject'; +export { default as isBoolean } from './isBoolean'; +export { default as isBuffer } from './isBuffer'; +export { default as isDate } from './isDate'; +export { default as isElement } from './isElement'; +export { default as isEmpty } from './isEmpty'; +export { default as isEqual } from './isEqual'; +export { default as isEqualWith } from './isEqualWith'; +export { default as isError } from './isError'; +export { default as isFinite } from './isFinite'; +export { default as isFunction } from './isFunction'; +export { default as isInteger } from './isInteger'; +export { default as isLength } from './isLength'; +export { default as isMap } from './isMap'; +export { default as isMatch } from './isMatch'; +export { default as isMatchWith } from './isMatchWith'; +export { default as isNaN } from './isNaN'; +export { default as isNative } from './isNative'; +export { default as isNil } from './isNil'; +export { default as isNull } from './isNull'; +export { default as isNumber } from './isNumber'; +export { default as isObject } from './isObject'; +export { default as isObjectLike } from './isObjectLike'; +export { default as isPlainObject } from './isPlainObject'; +export { default as isRegExp } from './isRegExp'; +export { default as isSafeInteger } from './isSafeInteger'; +export { default as isSet } from './isSet'; +export { default as isString } from './isString'; +export { default as isSymbol } from './isSymbol'; +export { default as isTypedArray } from './isTypedArray'; +export { default as isUndefined } from './isUndefined'; +export { default as isWeakMap } from './isWeakMap'; +export { default as isWeakSet } from './isWeakSet'; +export { default as iteratee } from './iteratee'; +export { default as join } from './join'; +export { default as kebabCase } from './kebabCase'; +export { default as keyBy } from './keyBy'; +export { default as keys } from './keys'; +export { default as keysIn } from './keysIn'; +export { default as last } from './last'; +export { default as lastIndexOf } from './lastIndexOf'; +export { default as lowerCase } from './lowerCase'; +export { default as lowerFirst } from './lowerFirst'; +export { default as lt } from './lt'; +export { default as lte } from './lte'; +export { default as map } from './map'; +export { default as mapKeys } from './mapKeys'; +export { default as mapValues } from './mapValues'; +export { default as matches } from './matches'; +export { default as matchesProperty } from './matchesProperty'; +export { default as max } from './max'; +export { default as maxBy } from './maxBy'; +export { default as mean } from './mean'; +export { default as meanBy } from './meanBy'; +export { default as memoize } from './memoize'; +export { default as merge } from './merge'; +export { default as mergeWith } from './mergeWith'; +export { default as method } from './method'; +export { default as methodOf } from './methodOf'; +export { default as min } from './min'; +export { default as minBy } from './minBy'; +export { default as mixin } from './mixin'; +export { default as negate } from './negate'; +export { default as noop } from './noop'; +export { default as now } from './now'; +export { default as nthArg } from './nthArg'; +export { default as omit } from './omit'; +export { default as omitBy } from './omitBy'; +export { default as once } from './once'; +export { default as orderBy } from './orderBy'; +export { default as over } from './over'; +export { default as overArgs } from './overArgs'; +export { default as overEvery } from './overEvery'; +export { default as overSome } from './overSome'; +export { default as pad } from './pad'; +export { default as padEnd } from './padEnd'; +export { default as padStart } from './padStart'; +export { default as parseInt } from './parseInt'; +export { default as partial } from './partial'; +export { default as partialRight } from './partialRight'; +export { default as partition } from './partition'; +export { default as pick } from './pick'; +export { default as pickBy } from './pickBy'; +export { default as property } from './property'; +export { default as propertyOf } from './propertyOf'; +export { default as pull } from './pull'; +export { default as pullAll } from './pullAll'; +export { default as pullAllBy } from './pullAllBy'; +export { default as pullAt } from './pullAt'; +export { default as random } from './random'; +export { default as range } from './range'; +export { default as rangeRight } from './rangeRight'; +export { default as rearg } from './rearg'; +export { default as reduce } from './reduce'; +export { default as reduceRight } from './reduceRight'; +export { default as reject } from './reject'; +export { default as remove } from './remove'; +export { default as repeat } from './repeat'; +export { default as replace } from './replace'; +export { default as rest } from './rest'; +export { default as result } from './result'; +export { default as reverse } from './reverse'; +export { default as round } from './round'; +export { default as sample } from './sample'; +export { default as sampleSize } from './sampleSize'; +export { default as set } from './set'; +export { default as setWith } from './setWith'; +export { default as shuffle } from './shuffle'; +export { default as size } from './size'; +export { default as slice } from './slice'; +export { default as snakeCase } from './snakeCase'; +export { default as some } from './some'; +export { default as sortBy } from './sortBy'; +export { default as sortedIndex } from './sortedIndex'; +export { default as sortedIndexBy } from './sortedIndexBy'; +export { default as sortedIndexOf } from './sortedIndexOf'; +export { default as sortedLastIndex } from './sortedLastIndex'; +export { default as sortedLastIndexBy } from './sortedLastIndexBy'; +export { default as sortedLastIndexOf } from './sortedLastIndexOf'; +export { default as sortedUniq } from './sortedUniq'; +export { default as sortedUniqBy } from './sortedUniqBy'; +export { default as split } from './split'; +export { default as spread } from './spread'; +export { default as startCase } from './startCase'; +export { default as startsWith } from './startsWith'; +export { default as subtract } from './subtract'; +export { default as sum } from './sum'; +export { default as sumBy } from './sumBy'; +export { default as tail } from './tail'; +export { default as take } from './take'; +export { default as takeRight } from './takeRight'; +export { default as takeRightWhile } from './takeRightWhile'; +export { default as takeWhile } from './takeWhile'; +export { default as tap } from './tap'; +export { default as template } from './template'; +export { default as throttle } from './throttle'; +export { default as thru } from './thru'; +export { default as times } from './times'; +export { default as toArray } from './toArray'; +export { default as toInteger } from './toInteger'; +export { default as toLength } from './toLength'; +export { default as toLower } from './toLower'; +export { default as toNumber } from './toNumber'; +export { default as toPairs } from './toPairs'; +export { default as toPairsIn } from './toPairsIn'; +export { default as toPath } from './toPath'; +export { default as toPlainObject } from './toPlainObject'; +export { default as toSafeInteger } from './toSafeInteger'; +export { default as toString } from './toString'; +export { default as toUpper } from './toUpper'; +export { default as transform } from './transform'; +export { default as trim } from './trim'; +export { default as trimEnd } from './trimEnd'; +export { default as trimStart } from './trimStart'; +export { default as truncate } from './truncate'; +export { default as unary } from './unary'; +export { default as unescape } from './unescape'; +export { default as union } from './union'; +export { default as unionBy } from './unionBy'; +export { default as unionWith } from './unionWith'; +export { default as uniq } from './uniq'; +export { default as uniqBy } from './uniqBy'; +export { default as uniqWith } from './uniqWith'; +export { default as uniqueId } from './uniqueId'; +export { default as unset } from './unset'; +export { default as unzip } from './unzip'; +export { default as unzipWith } from './unzipWith'; +export { default as update } from './update'; +export { default as upperCase } from './upperCase'; +export { default as upperFirst } from './upperFirst'; +export { default as values } from './values'; +export { default as valuesIn } from './valuesIn'; +export { default as without } from './without'; +export { default as words } from './words'; +export { default as wrap } from './wrap'; +export { default as xor } from './xor'; +export { default as xorBy } from './xorBy'; +export { default as xorWith } from './xorWith'; +export { default as zip } from './zip'; +export { default as zipObject } from './zipObject'; +export { default as zipWith } from './zipWith'; From 16e5b26b3da67b6f1f693af4666db65c10596dbe Mon Sep 17 00:00:00 2001 From: Arne Schubert Date: Fri, 27 Jan 2017 17:22:50 +0100 Subject: [PATCH 007/104] Refactor td for leaflet and geojson --- geojson/geojson-tests.ts | 127 +- geojson/index.d.ts | 90 +- geojson/tslint.json | 1 + leaflet/index.d.ts | 2701 +++++++++++++++++++------------------- leaflet/leaflet-tests.ts | 30 + leaflet/tslint.json | 1 + 6 files changed, 1547 insertions(+), 1403 deletions(-) create mode 100644 geojson/tslint.json create mode 100644 leaflet/tslint.json diff --git a/geojson/geojson-tests.ts b/geojson/geojson-tests.ts index dc3432f48c..50b5f7b396 100644 --- a/geojson/geojson-tests.ts +++ b/geojson/geojson-tests.ts @@ -1,26 +1,27 @@ -var featureCollection: GeoJSON.FeatureCollection = { +import GeometryObject = GeoJSON.GeometryObject; +let featureCollection: GeoJSON.FeatureCollection = { type: "FeatureCollection", - features: [ - { + features: [ + { type: "Feature", geometry: { - type: "Point", + type: "Point", coordinates: [102.0, 0.5] }, properties: { prop0: "value0" } }, - { + { type: "Feature", geometry: { type: "LineString", coordinates: [ - [102.0, 0.0], - [103.0, 1.0], - [104.0, 0.0], + [102.0, 0.0], + [103.0, 1.0], + [104.0, 0.0], [105.0, 1.0] ] }, @@ -29,7 +30,7 @@ var featureCollection: GeoJSON.FeatureCollection = { prop1: 0.0 } }, - { + { type: "Feature", geometry: { type: "Polygon", @@ -52,9 +53,9 @@ var featureCollection: GeoJSON.FeatureCollection = { type: "proj4" } } -} +}; -var feature: GeoJSON.Feature = { +let featureWithPolygon: GeoJSON.Feature = { type: "Feature", bbox: [-180.0, -90.0, 180.0, 90.0], geometry: { @@ -67,29 +68,29 @@ var feature: GeoJSON.Feature = { }; -var point: GeoJSON.Point = { +let point: GeoJSON.Point = { type: "Point", coordinates: [100.0, 0.0] }; // This type is commonly used in the turf package -var pointCoordinates: number[] = point.coordinates +let pointCoordinates: number[] = point.coordinates; -var lineString: GeoJSON.LineString = { +let lineString: GeoJSON.LineString = { type: "LineString", coordinates: [ [100.0, 0.0], [101.0, 1.0] ] }; -var polygon: GeoJSON.Polygon = { +let polygon: GeoJSON.Polygon = { type: "Polygon", coordinates: [ [ [100.0, 0.0], [101.0, 0.0], [101.0, 1.0], [100.0, 1.0], [100.0, 0.0] ] ] }; -var polygonWithHole: GeoJSON.Polygon = { +let polygonWithHole: GeoJSON.Polygon = { type: "Polygon", coordinates: [ [ [100.0, 0.0], [101.0, 0.0], [101.0, 1.0], [100.0, 1.0], [100.0, 0.0] ], @@ -97,12 +98,12 @@ var polygonWithHole: GeoJSON.Polygon = { ] }; -var multiPoint: GeoJSON.MultiPoint = { +let multiPoint: GeoJSON.MultiPoint = { type: "MultiPoint", coordinates: [ [100.0, 0.0], [101.0, 1.0] ] }; -var multiLineString: GeoJSON.MultiLineString = { +let multiLineString: GeoJSON.MultiLineString = { type: "MultiLineString", coordinates: [ [ [100.0, 0.0], [101.0, 1.0] ], @@ -110,25 +111,103 @@ var multiLineString: GeoJSON.MultiLineString = { ] }; -var multiPolygon: GeoJSON.MultiPolygon = { +let multiPolygon: GeoJSON.MultiPolygon = { type: "MultiPolygon", coordinates: [ [[[102.0, 2.0], [103.0, 2.0], [103.0, 3.0], [102.0, 3.0], [102.0, 2.0]]], [[[100.0, 0.0], [101.0, 0.0], [101.0, 1.0], [100.0, 1.0], [100.0, 0.0]], [[100.2, 0.2], [100.8, 0.2], [100.8, 0.8], [100.2, 0.8], [100.2, 0.2]]] ] -} +}; -var geometryCollection: GeoJSON.GeometryCollection = { +let geometryCollection: GeoJSON.GeometryCollection = { type: "GeometryCollection", "geometries": [ - { + { type: "Point", coordinates: [100.0, 0.0] }, - { + { type: "LineString", coordinates: [ [101.0, 0.0], [102.0, 1.0] ] } ] -} \ No newline at end of file +}; + +let feature: GeoJSON.Feature = { + type: "Feature", + geometry: lineString, + properties: null +}; +feature = { + type: "Feature", + geometry: polygon, + properties: null +}; +feature = { + type: "Feature", + geometry: polygonWithHole, + properties: null +}; +feature = { + type: "Feature", + geometry: multiPoint, + properties: null +}; +feature = { + type: "Feature", + geometry: multiLineString, + properties: null +}; +feature = { + type: "Feature", + geometry: multiPolygon, + properties: null +}; +feature = { + type: "Feature", + geometry: geometryCollection, + properties: null +}; + +featureCollection = { + type: "FeatureCollection", + features: [ + { + type: "Feature", + geometry: lineString, + properties: {test: 'OK'} + }, { + type: "Feature", + geometry: polygon, + properties: {test: 'OK'} + }, { + type: "Feature", + geometry: polygonWithHole, + properties: {test: 'OK'} + }, { + type: "Feature", + geometry: multiPoint, + properties: {test: 'OK'} + }, { + type: "Feature", + geometry: multiLineString, + properties: {test: 'OK'} + }, { + type: "Feature", + geometry: multiPolygon, + properties: {test: 'OK'} + }, { + type: "Feature", + geometry: geometryCollection, + properties: {test: 'OK'} + } + ], + crs: { + type: "link", + properties: { + href: "http://example.com/crs/42", + type: "proj4" + } + } +}; diff --git a/geojson/index.d.ts b/geojson/index.d.ts index f6261d81fe..b38106aae7 100644 --- a/geojson/index.d.ts +++ b/geojson/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for GeoJSON Format Specification +// Type definitions for GeoJSON Format Specification Revision 1.0 // Project: http://geojson.org/ // Definitions by: Jacob Bruun // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped @@ -8,8 +8,7 @@ declare namespace GeoJSON { /*** * http://geojson.org/geojson-spec.html#geojson-objects */ - export interface GeoJsonObject - { + export interface GeoJsonObject { type: string; bbox?: number[]; crs?: CoordinateReferenceSystem; @@ -18,116 +17,107 @@ declare namespace GeoJSON { /*** * http://geojson.org/geojson-spec.html#positions */ - export type Position = number[] + export type Position = number[]; /*** * http://geojson.org/geojson-spec.html#geometry-objects */ - export interface GeometryObject extends GeoJsonObject - { - coordinates: any + export interface DirectGeometryObject extends GeoJsonObject { + coordinates: Position[][][] | Position[][] | Position[] | Position; } + /** + * GeometryObject supports geometry collection as well + */ + export type GeometryObject = DirectGeometryObject | GeometryCollection; /*** * http://geojson.org/geojson-spec.html#point */ - export interface Point extends GeometryObject - { - type: 'Point' - coordinates: Position + export interface Point extends DirectGeometryObject { + type: 'Point'; + coordinates: Position; } /*** * http://geojson.org/geojson-spec.html#multipoint */ - export interface MultiPoint extends GeometryObject - { - type: 'MultiPoint' - coordinates: Position[] + export interface MultiPoint extends DirectGeometryObject { + type: 'MultiPoint'; + coordinates: Position[]; } /*** * http://geojson.org/geojson-spec.html#linestring */ - export interface LineString extends GeometryObject - { - type: 'LineString' - coordinates: Position[] + export interface LineString extends DirectGeometryObject { + type: 'LineString'; + coordinates: Position[]; } /*** * http://geojson.org/geojson-spec.html#multilinestring */ - export interface MultiLineString extends GeometryObject - { - type: 'MultiLineString' - coordinates: Position[][] + export interface MultiLineString extends DirectGeometryObject { + type: 'MultiLineString'; + coordinates: Position[][]; } /*** * http://geojson.org/geojson-spec.html#polygon */ - export interface Polygon extends GeometryObject - { - type: 'Polygon' - coordinates: Position[][] + export interface Polygon extends DirectGeometryObject { + type: 'Polygon'; + coordinates: Position[][]; } /*** * http://geojson.org/geojson-spec.html#multipolygon */ - export interface MultiPolygon extends GeometryObject - { - type: 'MultiPolygon' - coordinates: Position[][][] + export interface MultiPolygon extends DirectGeometryObject { + type: 'MultiPolygon'; + coordinates: Position[][][]; } /*** * http://geojson.org/geojson-spec.html#geometry-collection */ - export interface GeometryCollection extends GeoJsonObject - { - type: 'GeometryCollection' + export interface GeometryCollection extends GeoJsonObject { + type: 'GeometryCollection'; geometries: GeometryObject[]; } /*** * http://geojson.org/geojson-spec.html#feature-objects */ - export interface Feature extends GeoJsonObject - { - type: 'Feature' + export interface Feature extends GeoJsonObject { + type: 'Feature'; geometry: T; - properties: any; + properties: {} | null; id?: string; } /*** * http://geojson.org/geojson-spec.html#feature-collection-objects */ - export interface FeatureCollection extends GeoJsonObject - { - type: 'FeatureCollection' - features: Feature[]; + export interface FeatureCollection extends GeoJsonObject { + type: 'FeatureCollection'; + features: Array>; } /*** * http://geojson.org/geojson-spec.html#coordinate-reference-system-objects */ - export interface CoordinateReferenceSystem - { + export interface CoordinateReferenceSystem { type: string; properties: any; } - export interface NamedCoordinateReferenceSystem extends CoordinateReferenceSystem - { - properties: { name: string } + export interface NamedCoordinateReferenceSystem extends CoordinateReferenceSystem { + properties: { name: string }; } - export interface LinkedCoordinateReferenceSystem extends CoordinateReferenceSystem - { - properties: { href: string; type: string } + export interface LinkedCoordinateReferenceSystem extends CoordinateReferenceSystem { + properties: { href: string; type: string }; } } diff --git a/geojson/tslint.json b/geojson/tslint.json new file mode 100644 index 0000000000..377cc837d4 --- /dev/null +++ b/geojson/tslint.json @@ -0,0 +1 @@ +{ "extends": "../tslint.json" } diff --git a/leaflet/index.d.ts b/leaflet/index.d.ts index 4112082f54..b62695dd10 100644 --- a/leaflet/index.d.ts +++ b/leaflet/index.d.ts @@ -1,1459 +1,1502 @@ -// Type definitions for Leaflet.js 1.0.2 +// Type definitions for Leaflet.js 1.0 // Project: https://github.com/Leaflet/Leaflet // Definitions by: Alejandro Sánchez // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -/// - type NativeMouseEvent = MouseEvent; type NativeKeyboardEvent = KeyboardEvent; -declare namespace L { - 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 ? */; - } +import * as GeoJSONDefinition from 'geojson'; - export class Transformation { - constructor(a: number, b: number, c: number, d: number); +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 ? */; +} - transform(point: Point, scale?: number): Point; +export class Transformation { + constructor(a: number, b: number, c: number, d: number); - untransform(point: Point, scale?: number): Point; - } + transform(point: Point, scale?: number): Point; - export namespace LineUtil { - export function simplify(points: Array, tolerance: number): Array; + untransform(point: Point, scale?: number): Point; +} - export function simplify(points: Array, tolerance: number): Array; +export namespace LineUtil { + export function simplify(points: PointExpression[], tolerance: number): Point[]; - export function pointToSegmentDistance(p: Point, p1: Point, p2: Point): number; + export function pointToSegmentDistance(p: PointExpression, p1: PointExpression, p2: PointExpression): number; - export function pointToSegmentDistance(p: PointTuple, p1: PointTuple, p2: PointTuple): number; + export function closestPointOnSegment(p: PointExpression, p1: PointExpression, p2: PointExpression): Point; +} - export function closestPointOnSegment(p: Point, p1: Point, p2: Point): Point; +export namespace PolyUtil { + export function clipPolygon(points: PointExpression[], bounds: BoundsExpression, round?: boolean): Point[]; +} - export function closestPointOnSegment(p: PointTuple, p1: PointTuple, p2: PointTuple): Point; - } +export class DomUtil { + /** + * Get Element by its ID or with the given HTML-Element + */ + static get(element: string | HTMLElement): HTMLElement; + static getStyle(el: HTMLElement, styleAttrib: string): string; + static create(tagName: string, className?: string, container?: HTMLElement): HTMLElement; + static remove(el: HTMLElement): void; + static empty(el: HTMLElement): void; + static toFront(el: HTMLElement): void; + static toBack(el: HTMLElement): void; + static hasClass(el: HTMLElement, name: string): boolean; + static addClass(el: HTMLElement, name: string): void; + static removeClass(el: HTMLElement, name: string): void; + static setClass(el: HTMLElement, name: string): void; + static getClass(el: HTMLElement): string; + static setOpacity(el: HTMLElement, opacity: number): void; + static testProp(props: string[]): string | boolean/*=false*/; + static setTransform(el: HTMLElement, offset: Point, scale?: number): void; + static setPosition(el: HTMLElement, position: Point): void; + static getPosition(el: HTMLElement): Point; + static disableTextSelection(): void; + static enableTextSelection(): void; + static disableImageDrag(): void; + static enableImageDrag(): void; + static preventOutline(el: HTMLElement): void; + static restoreOutline(): void; +} - export namespace PolyUtil { - export function clipPolygon(points: Array, bounds: Bounds, round?: boolean): Array; +export abstract class CRS { + latLngToPoint(latlng: LatLngExpression, zoom: number): Point; + pointToLatLng(point: PointExpression, zoom: number): LatLng; + project(latlng: LatLngExpression): Point; + unproject(point: PointExpression): LatLng; + scale(zoom: number): number; + zoom(scale: number): number; + getProjectedBounds(zoom: number): Bounds; + distance(latlng1: LatLngExpression, latlng2: LatLngExpression): number; + wrapLatLng(latlng: LatLngExpression): LatLng; - export function clipPolygon(points: Array, bounds: BoundsLiteral, round?: boolean): Array; - } + code: string; + wrapLng: [number, number]; + wrapLat: [number, number]; + infinite: boolean; +} - export class DomUtil { - static get(id: string): HTMLElement; - static get(id: HTMLElement): HTMLElement; - static getStyle(el: HTMLElement, styleAttrib: string): string; - static create(tagName: String, className?: String, container?: HTMLElement): HTMLElement; - static remove(el: HTMLElement):void; - static empty(el: HTMLElement):void; - static toFront(el: HTMLElement):void; - static toBack(el: HTMLElement):void; - static hasClass(el: HTMLElement, name: String): Boolean; - static addClass(el: HTMLElement, name: String):void; - static removeClass(el: HTMLElement, name: String):void; - static setClass(el: HTMLElement, name: String):void; - static getClass(el: HTMLElement): String; - static setOpacity(el: HTMLElement, opacity: Number):void; - static testProp(props: String[]): String|boolean/*=false*/; - static setTransform(el: HTMLElement, offset: Point, scale?: Number):void; - static setPosition(el: HTMLElement, position: Point):void; - static getPosition(el: HTMLElement): Point; - static disableTextSelection(): void; - static enableTextSelection(): void; - static disableImageDrag(): void; - static enableImageDrag(): void; - static preventOutline(el: HTMLElement): void; - static restoreOutline(): void; - } +export namespace CRS { + export const EPSG3395: CRS; + export const EPSG3857: CRS; + export const EPSG4326: CRS; + export const Earth: CRS; + export const Simple: CRS; +} - export interface CRS { - latLngToPoint(latlng: LatLngExpression, zoom: number): Point; - pointToLatLng(point: PointExpression, zoom: number): LatLng; - project(latlng: LatLngExpression): Point; - unproject(point: PointExpression): LatLng; - scale(zoom: number): number; - zoom(scale: number): number; - getProjectedBounds(zoom: number): Bounds; - distance(latlng1: LatLngExpression, latlng2: LatLngExpression): number; - wrapLatLng(latlng: LatLngExpression): LatLng; +export interface Projection { + project(latlng: LatLngExpression): Point; + unproject(point: PointExpression): LatLng; - code: string; - wrapLng: [number, number]; - wrapLat: [number, number]; - infinite: boolean; - } + bounds: LatLngBounds; +} - export namespace CRS { - export const EPSG3395: CRS; - export const EPSG3857: CRS; - export const EPSG4326: CRS; - export const Earth: CRS; - export const Simple: CRS; - } +export namespace Projection { + export const LonLat: Projection; + export const Mercator: Projection; + export const SphericalMercator: Projection; +} - export interface Projection { - project(latlng: LatLngExpression): Point; - unproject(point: PointExpression): LatLng; +export class LatLng { + constructor(latitude: number, longitude: number, altitude?: number); + constructor(coords: LatLngTuple | [number, number, number] | LatLngLiteral | {lat: number, lng: number, alt?: number}); + equals(otherLatLng: LatLngExpression, maxMargin?: number): boolean; + toString(): string; + distanceTo(otherLatLng: LatLngExpression): number; + wrap(): LatLng; + toBounds(sizeInMeters: number): LatLngBounds; - bounds: LatLngBounds; - } + lat: number; + lng: number; + alt: number; +} - export namespace Projection { - export const LonLat: Projection; - export const Mercator: Projection; - export const SphericalMercator: Projection; - } +export interface LatLngLiteral { + lat: number; + lng: number; +} - export interface LatLng { - equals(otherLatLng: LatLngExpression, maxMargin?: number): boolean; - toString(): string; - distanceTo(otherLatLng: LatLngExpression): number; - wrap(): LatLng; - toBounds(sizeInMeters: number): LatLngBounds; +export type LatLngTuple = [number, number]; - lat: number; - lng: number; - alt: number; - } +type LatLngExpression = LatLng | LatLngLiteral | LatLngTuple; - export interface LatLngLiteral { - lat: number; - lng: number; - } +export function latLng(latitude: number, longitude: number, altitude?: number): LatLng; - export type LatLngTuple = [number, number]; +export function latLng(coords: LatLngTuple | [number, number, number] | LatLngLiteral | {lat: number, lng: number, alt?: number}): LatLng; - type LatLngExpression = LatLng | LatLngLiteral | LatLngTuple; +export class LatLngBounds { + constructor(southWest: LatLngExpression, northEast: LatLngExpression); + constructor(latlngs: LatLngBoundsLiteral); + extend(latlngOrBounds: LatLngExpression | LatLngBoundsExpression): this; + pad(bufferRatio: number): LatLngBounds; // does this modify the current instance or does it return a new one? + getCenter(): LatLng; + getSouthWest(): LatLng; + getNorthEast(): LatLng; + getNorthWest(): LatLng; + getSouthEast(): LatLng; + getWest(): number; + getSouth(): number; + getEast(): number; + getNorth(): number; + contains(otherBoundsOrLatLng: LatLngBoundsExpression | LatLngExpression): boolean; + intersects(otherBounds: LatLngBoundsExpression): boolean; + overlaps(otherBounds: BoundsExpression): boolean; // investigate if this is really bounds and not latlngbounds + toBBoxString(): string; + equals(otherBounds: LatLngBoundsExpression): boolean; + isValid(): boolean; +} - export function latLng(latitude: number, longitude: number, altitude?: number): LatLng; +export type LatLngBoundsLiteral = LatLngTuple[]; - export function latLng(coords: LatLngTuple): LatLng; +type LatLngBoundsExpression = LatLngBounds | LatLngBoundsLiteral; - export function latLng(coords: [number, number, number]): LatLng; +export function latLngBounds(southWest: LatLngExpression, northEast: LatLngExpression): LatLngBounds; - export function latLng(coords: LatLngLiteral): LatLng; +export function latLngBounds(latlngs: LatLngBoundsLiteral): LatLngBounds; - export function latLng(coords: {lat: number, lng: number, alt: number}): LatLng; +export type PointTuple = [number, number]; - export interface LatLngBounds { - extend(latlng: LatLngExpression): this; - extend(otherBounds: LatLngBoundsExpression): this; - pad(bufferRatio: number): LatLngBounds; // does this modify the current instance or does it return a new one? - getCenter(): LatLng; - getSouthWest(): LatLng; - getNorthEast(): LatLng; - getNorthWest(): LatLng; - getSouthEast(): LatLng; - getWest(): number; - getSouth(): number; - getEast(): number; - getNorth(): number; - contains(otherBounds: LatLngBoundsExpression): boolean; - contains(latlng: LatLngExpression): boolean; - intersects(otherBounds: LatLngBoundsExpression): boolean; - overlaps(otherBounds: BoundsExpression): boolean; // investigate if this is really bounds and not latlngbounds - toBBoxString(): string; - equals(otherBounds: LatLngBoundsExpression): boolean; - isValid(): boolean; - } +export class Point { + constructor(x: number, y: number, round?: boolean); + constructor(coords: PointTuple | {x: number, y: number}); + clone(): Point; + add(otherPoint: PointExpression): Point; // investigate if this mutates or returns a new instance + subtract(otherPoint: PointExpression): Point; + divideBy(num: number): Point; + multiplyBy(num: number): Point; + scaleBy(scale: PointExpression): Point; + unscaleBy(scale: PointExpression): Point; + round(): Point; + floor(): Point; + ceil(): Point; + distanceTo(otherPoint: PointExpression): number; + equals(otherPoint: PointExpression): boolean; + contains(otherPoint: PointExpression): boolean; + toString(): string; + x: number; + y: number; +} - export type LatLngBoundsLiteral = Array; +type PointExpression = Point | PointTuple; - type LatLngBoundsExpression = LatLngBounds | LatLngBoundsLiteral; +export function point(x: number, y: number, round?: boolean): Point; - export function latLngBounds(southWest: LatLngExpression, northEast: LatLngExpression): LatLngBounds; +export function point(coords: PointTuple | {x: number, y: number}): Point; - export function latLngBounds(latlngs: LatLngBoundsLiteral): LatLngBounds; +export type BoundsLiteral = PointTuple[]; - export type PointTuple = [number, number]; +export class Bounds { + constructor(topLeft: PointExpression, bottomRight: PointExpression); + constructor(points: Point[] | BoundsLiteral); + extend(point: PointExpression): this; + getCenter(round?: boolean): Point; + getBottomLeft(): Point; + getTopRight(): Point; + getSize(): Point; + contains(pointOrBounds: BoundsExpression | PointExpression): boolean; + intersects(otherBounds: BoundsExpression): boolean; + overlaps(otherBounds: BoundsExpression): boolean; - export interface Point { - clone(): Point; - add(otherPoint: PointExpression): Point; // investigate if this mutates or returns a new instance - subtract(otherPoint: PointExpression): Point; - divideBy(num: number): Point; - multiplyBy(num: number): Point; - scaleBy(scale: PointExpression): Point; - unscaleBy(scale: PointExpression): Point; - round(): Point; - floor(): Point; - ceil(): Point; - distanceTo(otherPoint: PointExpression): number; - equals(otherPoint: PointExpression): boolean; - contains(otherPoint: PointExpression): boolean; - toString(): string; - x: number; - y: number; - } + min: Point; + max: Point; +} - type PointExpression = Point | PointTuple; +type BoundsExpression = Bounds | BoundsLiteral; - export function point(x: number, y: number, round?: boolean): Point; +export function bounds(topLeft: PointExpression, bottomRight: PointExpression): Bounds; - export function point(coords: PointTuple): Point; +export function bounds(points: Point[] | BoundsLiteral): Bounds; - export function point(coords: {x: number, y: number}): Point; +export type EventHandlerFn = (event: Event) => void; - export type BoundsLiteral = Array; +export interface EventHandlerFnMap { + [type: string]: EventHandlerFn; +} - export interface Bounds { - extend(point: PointExpression): this; - getCenter(round?: boolean): Point; - getBottomLeft(): Point; - getTopRight(): Point; - getSize(): Point; - contains(otherBounds: BoundsExpression): boolean; - contains(point: PointExpression): boolean; - intersects(otherBounds: BoundsExpression): boolean; - overlaps(otherBounds: BoundsExpression): boolean; - - min: Point; - max: Point; - } - - type BoundsExpression = Bounds | BoundsLiteral; - - export function bounds(topLeft: PointExpression, bottomRight: PointExpression): Bounds; - - export function bounds(points: Array): Bounds; - - export function bounds(points: BoundsLiteral): Bounds; - - export type EventHandlerFn = (event: Event) => void; - - export type EventHandlerFnMap = {[type: string]: EventHandlerFn}; +/** + * A set of methods shared between event-powered classes (like Map and Marker). + * Generally, events allow you to execute some function when something happens + * with an object (e.g. the user clicks on the map, causing the map to fire + * 'click' event). + */ +export abstract class Evented extends Class { + /** + * Adds a listener function (fn) to a particular event type of the object. + * You can optionally specify the context of the listener (object the this + * keyword will point to). You can also pass several space-separated types + * (e.g. 'click dblclick'). + */ + on(type: string, fn: EventHandlerFn, context?: any): this; /** - * A set of methods shared between event-powered classes (like Map and Marker). - * Generally, events allow you to execute some function when something happens - * with an object (e.g. the user clicks on the map, causing the map to fire - * 'click' event). + * Adds a set of type/listener pairs, e.g. {click: onClick, mousemove: onMouseMove} */ - export abstract class Evented extends Class { - /** - * Adds a listener function (fn) to a particular event type of the object. - * You can optionally specify the context of the listener (object the this - * keyword will point to). You can also pass several space-separated types - * (e.g. 'click dblclick'). - */ - on(type: string, fn: EventHandlerFn, context?: any): this; - - /** - * Adds a set of type/listener pairs, e.g. {click: onClick, mousemove: onMouseMove} - */ - on(eventMap: EventHandlerFnMap): this; - - /** - * Removes a previously added listener function. If no function is specified, - * it will remove all the listeners of that particular event from the object. - * Note that if you passed a custom context to on, you must pass the same context - * to off in order to remove the listener. - */ - off(type: string, fn?: EventHandlerFn, context?: any): this; - - /** - * Removes a set of type/listener pairs. - */ - off(eventMap: EventHandlerFnMap): this; - - /** - * Removes all listeners to all events on the object. - */ - off(): this; - - /** - * Fires an event of the specified type. You can optionally provide a data - * object — the first argument of the listener function will contain its properties. - * The event might can optionally be propagated to event parents. - */ - fire(type: string, data?: any, propagate?: boolean): this; - - /** - * Returns true if a particular event type has any listeners attached to it. - */ - listens(type: string): boolean; - - /** - * Behaves as on(...), except the listener will only get fired once and then removed. - */ - once(type: string, fn: EventHandlerFn, context?: any): this; - - /** - * Behaves as on(...), except the listener will only get fired once and then removed. - */ - once(eventMap: EventHandlerFnMap): this; - - /** - * Adds an event parent - an Evented that will receive propagated events - */ - addEventParent(obj: Evented): this; - - /** - * Removes an event parent, so it will stop receiving propagated events - */ - removeEventParent(obj: Evented): this; - - /** - * Alias for on(...) - * - * Adds a listener function (fn) to a particular event type of the object. - * You can optionally specify the context of the listener (object the this - * keyword will point to). You can also pass several space-separated types - * (e.g. 'click dblclick'). - */ - addEventListener(type: string, fn: EventHandlerFn, context?: any): this; - - /** - * Alias for on(...) - * - * Adds a set of type/listener pairs, e.g. {click: onClick, mousemove: onMouseMove} - */ - addEventListener(eventMap: EventHandlerFnMap): this; - - /** - * Alias for off(...) - * - * Removes a previously added listener function. If no function is specified, - * it will remove all the listeners of that particular event from the object. - * Note that if you passed a custom context to on, you must pass the same context - * to off in order to remove the listener. - */ - removeEventListener(type: string, fn: EventHandlerFn, context?: any): this; - - /** - * Alias for off(...) - * - * Removes a set of type/listener pairs. - */ - removeEventListener(eventMap: EventHandlerFnMap): this; - - /** - * Alias for off() - * - * Removes all listeners to all events on the object. - */ - clearAllEventListeners(): this; - - /** - * Alias for once(...) - * - * Behaves as on(...), except the listener will only get fired once and then removed. - */ - addOneTimeEventListener(type: string, fn: EventHandlerFn, context?: any): this; - - /** - * Alias for once(...) - * - * Behaves as on(...), except the listener will only get fired once and then removed. - */ - addOneTimeEventListener(eventMap: EventHandlerFnMap): this; - - /** - * Alias for fire(...) - * - * Fires an event of the specified type. You can optionally provide a data - * object — the first argument of the listener function will contain its properties. - * The event might can optionally be propagated to event parents. - */ - fireEvent(type: string, data?: any, propagate?: boolean): this; - - /** - * Alias for listens(...) - * - * Returns true if a particular event type has any listeners attached to it. - */ - hasEventListeners(type: string): boolean; - } + on(eventMap: EventHandlerFnMap): this; /** - * A class for making DOM elements draggable (including touch support). - * Used internally for map and marker dragging. Only works for elements - * that were positioned with [`L.DomUtil.setPosition`](#domutil-setposition). + * Removes a previously added listener function. If no function is specified, + * it will remove all the listeners of that particular event from the object. + * Note that if you passed a custom context to on, you must pass the same context + * to off in order to remove the listener. */ - export class Draggable extends Evented { - constructor(element: HTMLElement, dragStartTarget?: HTMLElement, preventOutline?: boolean); - - enable(): void; - - disable(): void; - - finishDrag(): void; - } - - interface LayerOptions { - pane?: string; - } - - interface InteractiveLayerOptions extends LayerOptions { - interactive?: boolean; - } - - export class Layer extends Evented { - constructor(options?: LayerOptions); - addTo(map: Map): this; - remove(): this; - removeFrom(map: Map): this; - getPane(name?: string): HTMLElement; - - // Popup methods - bindPopup(content: string, options?: PopupOptions): this; - bindPopup(content: HTMLElement, options?: PopupOptions): this; - bindPopup(content: (layer: Layer) => Content, options?: PopupOptions): this; - bindPopup(content: Popup): this; - unbindPopup(): this; - openPopup(): this; - openPopup(latlng: LatLngExpression): this; - closePopup(): this; - togglePopup(): this; - isPopupOpen(): boolean; - setPopupContent(content: string): this; - setPopupContent(content: HTMLElement): this; - setPopupContent(content: Popup): this; - getPopup(): Popup; - - // Tooltip methods - bindTooltip(content: string, options?: TooltipOptions): this; - bindTooltip(content: HTMLElement, options?: TooltipOptions): this; - bindTooltip(content: (layer: Layer) => Content, options?: TooltipOptions): this; - bindTooltip(content: Tooltip, options?: TooltipOptions): this; - unbindTooltip(): this; - openTooltip(): this; - openTooltip(latlng: LatLngExpression): this; - closeTooltip(): this; - toggleTooltip(): this; - isTooltipOpen(): boolean; - setTooltipContent(content: string): this; - setTooltipContent(content: HTMLElement): this; - setTooltipContent(content: Tooltip): this; - getTooltip(): Tooltip; - - // Extension methods - onAdd(map: Map): this; - onRemove(map: Map): this; - getEvents(): {[name: string]: (event: Event) => void}; - getAttribution(): string; - beforeAdd(map: Map): this; - } - - export interface GridLayerOptions { - tileSize?: number | Point; - opacity?: number; - updateWhenIdle?: boolean; - updateWhenZooming?: boolean; - updateInterval?: number; - attribution?: string; - zIndex?: number; - bounds?: LatLngBoundsExpression; - minZoom?: number; - maxZoom?: number; - noWrap?: boolean; - pane?: string; - className?: string; - keepBuffer?: number; - } - - export interface GridLayer extends Layer { - bringToFront(): this; - bringToBack(): this; - getAttribution(): string; - getContainer(): HTMLElement; - setOpacity(opacity: number): this; - setZIndex(zIndex: number): this; - isLoading(): boolean; - redraw(): this; - getTileSize(): Point; - } - - export function gridLayer(options?: GridLayerOptions): GridLayer; - - export interface TileLayerOptions extends GridLayerOptions { - minZoom?: number; - maxZoom?: number; - maxNativeZoom?: number; - subdomains?: string | Array; - errorTileUrl?: string; - zoomOffset?: number; - tms?: boolean; - zoomReverse?: boolean; - detectRetina?: boolean; - crossOrigin?: boolean; - [name: string]: any; - } - - export interface TileLayer extends GridLayer { - setUrl(url: string, noRedraw?: boolean): this; - } - - export function tileLayer(urlTemplate: string, options?: TileLayerOptions): TileLayer; - - export interface WMSOptions extends TileLayerOptions { - layers: string; - styles?: string; - format?: string; - transparent?: boolean; - version?: string; - crs?: CRS; - uppercase?: boolean; - } - - export interface WMS extends TileLayer { - setParams(params: any, noRedraw?: boolean): this; - } - - export namespace tileLayer { - export function wms(baseUrl: string, options?: WMSOptions): WMS; - } - - export interface ImageOverlayOptions extends LayerOptions { - opacity?: number; - alt?: string; - interactive?: boolean; - attribution?: string; - crossOrigin?: boolean; - } - - export interface ImageOverlay extends Layer { - setOpacity(opacity: number): this; - bringToFront(): this; - bringToBack(): this; - setUrl(url: string): this; - - /** Update the bounds that this ImageOverlay covers */ - setBounds(bounds: LatLngBounds): this; - - /** Get the bounds that this ImageOverlay covers */ - getBounds(): LatLngBounds; - - /** Get the img element that represents the ImageOverlay on the map */ - getElement(): HTMLImageElement; - } - - export function imageOverlay(imageUrl: string, bounds: LatLngBoundsExpression, options?: ImageOverlayOptions): ImageOverlay; - - export type LineCapShape = 'butt' | 'round' | 'square' | 'inherit'; - - export type LineJoinShape = 'miter' | 'round' | 'bevel' | 'inherit'; - - export type FillRule = 'nonzero' | 'evenodd' | 'inherit'; - - export interface PathOptions extends InteractiveLayerOptions { - stroke?: boolean; - color?: string; - weight?: number; - opacity?: number; - lineCap?: LineCapShape; - lineJoin?: LineJoinShape; - dashArray?: string; - dashOffset?: string; - fill?: boolean; - fillColor?: string; - fillOpacity?: number; - fillRule?: FillRule; - renderer?: Renderer; - className?: string; - } - - export interface Path extends Layer { - redraw(): this; - setStyle(style: PathOptions): this; - bringToFront(): this; - bringToBack(): this; - } - - export interface PolylineOptions extends PathOptions { - smoothFactor?: number; - noClip?: boolean; - } - - interface InternalPolyline extends Path { - getLatLngs(): Array; - setLatLngs(latlngs: Array): this; - isEmpty(): boolean; - getCenter(): LatLng; - getBounds(): LatLngBounds; - addLatLng(latlng: LatLngExpression): this; - addLatLng(latlng: Array): this; // these three overloads aren't explicitly noted in the docs - } - - export interface Polyline extends InternalPolyline { - toGeoJSON(): GeoJSON.LineString | GeoJSON.MultiLineString; - } - - export function polyline(latlngs: Array, options?: PolylineOptions): Polyline; - export function polyline(latlngs: Array>, options?: PolylineOptions): Polyline; - - export interface Polygon extends InternalPolyline { - toGeoJSON(): GeoJSON.Polygon | GeoJSON.MultiPolygon; - } - - export function polygon(latlngs: Array, options?: PolylineOptions): Polygon; - - export function polygon(latlngs: Array>, options?: PolylineOptions): Polygon; - - export interface Rectangle extends Polygon { - setBounds(latLngBounds: LatLngBoundsExpression): this; - } - - export function rectangle(latLngBounds: LatLngBoundsExpression, options?: PolylineOptions): Rectangle; - - export interface CircleMarkerOptions extends PathOptions { - radius?: number; - } - - export interface CircleMarker extends Path { - toGeoJSON(): GeoJSON.Point; - setLatLng(latLng: LatLngExpression): this; - getLatLng(): LatLng; - setRadius(radius: number): this; - getRadius(): number; - } - - export function circleMarker(latlng: LatLngExpression, options?: CircleMarkerOptions): CircleMarker; - - export interface CircleOptions extends PathOptions { - radius?: number; - } - - export interface Circle extends CircleMarker { - setRadius(radius: number): this; - getRadius(): number; - getBounds(): LatLngBounds; - } - - export function circle(latlng: LatLngExpression, options?: CircleOptions): Circle; - export function circle(latlng: LatLngExpression, radius: number, options?: CircleOptions): Circle; - - export interface RendererOptions extends LayerOptions { - padding?: number; - } - - export interface Renderer extends Layer {} - - export interface SVG extends Renderer {} - - export namespace SVG { - export function create(name: string): SVGElement; - - export function pointsToPath(rings: Array, close: boolean): string; - - export function pointsToPath(rings: Array, close: boolean): string; - } - - export function svg(options?: RendererOptions): SVG; - - export interface Canvas extends Renderer {} - - export function canvas(options?: RendererOptions): Canvas; + off(type: string, fn?: EventHandlerFn, context?: any): this; /** - * Used to group several layers and handle them as one. - * If you add it to the map, any layers added or removed from the group will be - * added/removed on the map as well. Extends Layer. + * Removes a set of type/listener pairs. */ - export interface LayerGroup extends Layer { - /** - * Returns a GeoJSON representation of the layer group (as a GeoJSON GeometryCollection). - */ - toGeoJSON(): GeoJSON.GeometryCollection; + off(eventMap: EventHandlerFnMap): this; - /** - * Adds the given layer to the group. - */ - addLayer(layer: Layer): this; + /** + * Removes all listeners to all events on the object. + */ + off(): this; - /** - * Removes the given layer from the group. - */ - removeLayer(layer: Layer): this; + /** + * Fires an event of the specified type. You can optionally provide a data + * object — the first argument of the listener function will contain its properties. + * The event might can optionally be propagated to event parents. + */ + fire(type: string, data?: any, propagate?: boolean): this; - /** - * Removes the layer with the given internal ID from the group. - */ - removeLayer(id: number): this; + /** + * Returns true if a particular event type has any listeners attached to it. + */ + listens(type: string): boolean; - /** - * Returns true if the given layer is currently added to the group. - */ - hasLayer(layer: Layer): boolean; + /** + * Behaves as on(...), except the listener will only get fired once and then removed. + */ + once(type: string, fn: EventHandlerFn, context?: any): this; - /** - * Removes all the layers from the group. - */ - clearLayers(): this; + /** + * Behaves as on(...), except the listener will only get fired once and then removed. + */ + once(eventMap: EventHandlerFnMap): this; - /** - * Calls methodName on every layer contained in this group, passing any additional parameters. - * Has no effect if the layers contained do not implement methodName. - */ - invoke(methodName: string, ...params: Array): this; + /** + * Adds an event parent - an Evented that will receive propagated events + */ + addEventParent(obj: Evented): this; - /** - * Iterates over the layers of the group, - * optionally specifying context of the iterator function. - */ - eachLayer(fn: (layer: Layer) => void, context?: any): this; + /** + * Removes an event parent, so it will stop receiving propagated events + */ + removeEventParent(obj: Evented): this; - /** - * Returns the layer with the given internal ID. - */ - getLayer(id: number): Layer; + /** + * Alias for on(...) + * + * Adds a listener function (fn) to a particular event type of the object. + * You can optionally specify the context of the listener (object the this + * keyword will point to). You can also pass several space-separated types + * (e.g. 'click dblclick'). + */ + addEventListener(type: string, fn: EventHandlerFn, context?: any): this; - /** - * Returns an array of all the layers added to the group. - */ - getLayers(): Array; + /** + * Alias for on(...) + * + * Adds a set of type/listener pairs, e.g. {click: onClick, mousemove: onMouseMove} + */ + addEventListener(eventMap: EventHandlerFnMap): this; - /** - * Calls setZIndex on every layer contained in this group, passing the z-index. - */ - setZIndex(zIndex: number): this; + /** + * Alias for off(...) + * + * Removes a previously added listener function. If no function is specified, + * it will remove all the listeners of that particular event from the object. + * Note that if you passed a custom context to on, you must pass the same context + * to off in order to remove the listener. + */ + removeEventListener(type: string, fn: EventHandlerFn, context?: any): this; - /** - * Returns the internal ID for a layer - */ - getLayerId(layer: Layer): number; + /** + * Alias for off(...) + * + * Removes a set of type/listener pairs. + */ + removeEventListener(eventMap: EventHandlerFnMap): this; + + /** + * Alias for off() + * + * Removes all listeners to all events on the object. + */ + clearAllEventListeners(): this; + + /** + * Alias for once(...) + * + * Behaves as on(...), except the listener will only get fired once and then removed. + */ + addOneTimeEventListener(type: string, fn: EventHandlerFn, context?: any): this; + + /** + * Alias for once(...) + * + * Behaves as on(...), except the listener will only get fired once and then removed. + */ + addOneTimeEventListener(eventMap: EventHandlerFnMap): this; + + /** + * Alias for fire(...) + * + * Fires an event of the specified type. You can optionally provide a data + * object — the first argument of the listener function will contain its properties. + * The event might can optionally be propagated to event parents. + */ + fireEvent(type: string, data?: any, propagate?: boolean): this; + + /** + * Alias for listens(...) + * + * Returns true if a particular event type has any listeners attached to it. + */ + hasEventListeners(type: string): boolean; +} + +/** + * A class for making DOM elements draggable (including touch support). + * Used internally for map and marker dragging. Only works for elements + * that were positioned with [`L.DomUtil.setPosition`](#domutil-setposition). + */ +export class Draggable extends Evented { + constructor(element: HTMLElement, dragStartTarget?: HTMLElement, preventOutline?: boolean); + + enable(): void; + + disable(): void; + + finishDrag(): void; +} + +interface LayerOptions { + pane?: string; +} + +interface InteractiveLayerOptions extends LayerOptions { + interactive?: boolean; +} + +export class Layer extends Evented { + constructor(options?: LayerOptions); + addTo(map: Map): this; + remove(): this; + removeFrom(map: Map): this; + getPane(name?: string): HTMLElement; + + // Popup methods + bindPopup(content: (layer: Layer) => Content | Content | Popup, options?: PopupOptions): this; + unbindPopup(): this; + openPopup(latlng?: LatLngExpression): this; + closePopup(): this; + togglePopup(): this; + isPopupOpen(): boolean; + setPopupContent(content: Content | Popup): this; + getPopup(): Popup; + + // Tooltip methods + bindTooltip(content: (layer: Layer) => Content | Tooltip | Content, options?: TooltipOptions): this; + unbindTooltip(): this; + openTooltip(latlng?: LatLngExpression): this; + closeTooltip(): this; + toggleTooltip(): this; + isTooltipOpen(): boolean; + setTooltipContent(content: Content | Tooltip): this; + getTooltip(): Tooltip; + + // Extension methods + onAdd(map: Map): this; + onRemove(map: Map): this; + getEvents(): {[name: string]: (event: Event) => void}; + getAttribution(): string; + beforeAdd(map: Map): this; +} + +export interface GridLayerOptions { + tileSize?: number | Point; + opacity?: number; + updateWhenIdle?: boolean; + updateWhenZooming?: boolean; + updateInterval?: number; + attribution?: string; + zIndex?: number; + bounds?: LatLngBoundsExpression; + minZoom?: number; + maxZoom?: number; + noWrap?: boolean; + pane?: string; + className?: string; + keepBuffer?: number; +} + +export class GridLayer extends Layer { + constructor(options?: GridLayerOptions); + bringToFront(): this; + bringToBack(): this; + getAttribution(): string; + getContainer(): HTMLElement; + setOpacity(opacity: number): this; + setZIndex(zIndex: number): this; + isLoading(): boolean; + redraw(): this; + getTileSize(): Point; +} + +export function gridLayer(options?: GridLayerOptions): GridLayer; + +export interface TileLayerOptions extends GridLayerOptions { + minZoom?: number; + maxZoom?: number; + maxNativeZoom?: number; + subdomains?: string | string[]; + errorTileUrl?: string; + zoomOffset?: number; + tms?: boolean; + zoomReverse?: boolean; + detectRetina?: boolean; + crossOrigin?: boolean; + [name: string]: any; +} + +export class TileLayer extends GridLayer { + constructor(urlTemplate: string, options?: TileLayerOptions); + setUrl(url: string, noRedraw?: boolean): this; + + options: TileLayerOptions; +} + +export function tileLayer(urlTemplate: string, options?: TileLayerOptions): TileLayer; + + +export namespace TileLayer { + export class WMS extends TileLayer { + constructor(baseUrl: string, options: WMSOptions); + setParams(params: WMSParams, noRedraw?: boolean): this; + + wmsParams: WMSParams; + options: WMSOptions; } +} + +export interface WMSOptions extends TileLayerOptions { + layers: string; + styles?: string; + format?: string; + transparent?: boolean; + version?: string; + crs?: CRS; + uppercase?: boolean; +} + +export interface WMSParams { + format?: string; + layers: string; + request?: string; + service?: string; + styles?: string; + version?: string; + transparent?: boolean; + width?: number; + height?: number; +} + +export namespace tileLayer { + export function wms(baseUrl: string, options?: WMSOptions): TileLayer.WMS; +} + +export interface ImageOverlayOptions extends LayerOptions { + opacity?: number; + alt?: string; + interactive?: boolean; + attribution?: string; + crossOrigin?: boolean; +} + +export class ImageOverlay extends Layer { + constructor(imageUrl: string, bounds: LatLngBoundsExpression, options?: ImageOverlayOptions); + setOpacity(opacity: number): this; + bringToFront(): this; + bringToBack(): this; + setUrl(url: string): this; + + /** Update the bounds that this ImageOverlay covers */ + setBounds(bounds: LatLngBounds): this; + + /** Get the bounds that this ImageOverlay covers */ + getBounds(): LatLngBounds; + + /** Get the img element that represents the ImageOverlay on the map */ + getElement(): HTMLImageElement; + + options: ImageOverlayOptions; +} + +export function imageOverlay(imageUrl: string, bounds: LatLngBoundsExpression, options?: ImageOverlayOptions): ImageOverlay; + +export type LineCapShape = 'butt' | 'round' | 'square' | 'inherit'; + +export type LineJoinShape = 'miter' | 'round' | 'bevel' | 'inherit'; + +export type FillRule = 'nonzero' | 'evenodd' | 'inherit'; + +export interface PathOptions extends InteractiveLayerOptions { + stroke?: boolean; + color?: string; + weight?: number; + opacity?: number; + lineCap?: LineCapShape; + lineJoin?: LineJoinShape; + dashArray?: string; + dashOffset?: string; + fill?: boolean; + fillColor?: string; + fillOpacity?: number; + fillRule?: FillRule; + renderer?: Renderer; + className?: string; +} + +export abstract class Path extends Layer { + redraw(): this; + setStyle(style: PathOptions): this; + bringToFront(): this; + bringToBack(): this; + + options: PathOptions; +} + +export interface PolylineOptions extends PathOptions { + smoothFactor?: number; + noClip?: boolean; +} + +declare class InternalPolyline extends Path { + getLatLngs(): LatLng[]; + setLatLngs(latlngs: LatLngExpression[]): this; + isEmpty(): boolean; + getCenter(): LatLng; + getBounds(): LatLngBounds; + addLatLng(latlng: LatLngExpression | LatLngExpression[]): this; + + options: PolylineOptions; +} + +export class Polyline extends InternalPolyline { + constructor(latlngs: LatLngExpression[], options?: PolylineOptions); + toGeoJSON(): GeoJSONDefinition.Feature; + + feature: GeoJSONDefinition.Feature; +} + +export function polyline(latlngs: LatLngExpression[], options?: PolylineOptions): Polyline; + +export class Polygon extends InternalPolyline { + constructor(latlngs: LatLngExpression[], options?: PolylineOptions); + toGeoJSON(): GeoJSONDefinition.Feature; + + feature: GeoJSONDefinition.Feature; +} + +export function polygon(latlngs: LatLngExpression[], options?: PolylineOptions): Polygon; + +export class Rectangle extends Polygon { + constructor(latLngBounds: LatLngBoundsExpression, options?: PolylineOptions); + setBounds(latLngBounds: LatLngBoundsExpression): this; +} + +export function rectangle(latLngBounds: LatLngBoundsExpression, options?: PolylineOptions): Rectangle; + +export interface CircleMarkerOptions extends PathOptions { + radius?: number; +} + +export class CircleMarker extends Path { + constructor(latlng: LatLngExpression, options?: CircleMarkerOptions); + toGeoJSON(): GeoJSONDefinition.Feature; + setLatLng(latLng: LatLngExpression): this; + getLatLng(): LatLng; + setRadius(radius: number): this; + getRadius(): number; + + options: CircleMarkerOptions; + feature: GeoJSONDefinition.Feature; +} + +export function circleMarker(latlng: LatLngExpression, options?: CircleMarkerOptions): CircleMarker; + + +export class Circle extends CircleMarker { + constructor(latlng: LatLngExpression, options?: CircleMarkerOptions); + constructor(latlng: LatLngExpression, radius: number, options?: CircleMarkerOptions); // deprecated! + getBounds(): LatLngBounds; +} + +export function circle(latlng: LatLngExpression, options?: CircleMarkerOptions): Circle; +export function circle(latlng: LatLngExpression, radius: number, options?: CircleMarkerOptions): Circle; // deprecated! + +export interface RendererOptions extends LayerOptions { + padding?: number; +} + +export class Renderer extends Layer { + constructor(options?: RendererOptions); + + options: RendererOptions; +} + +export class SVG extends Renderer {} + +export namespace SVG { + export function create(name: string): SVGElement; + + export function pointsToPath(rings: PointExpression[], close: boolean): string; +} + +export function svg(options?: RendererOptions): SVG; + +export class Canvas extends Renderer {} + +export function canvas(options?: RendererOptions): Canvas; + +/** + * Used to group several layers and handle them as one. + * If you add it to the map, any layers added or removed from the group will be + * added/removed on the map as well. Extends Layer. + */ +export class LayerGroup extends Layer { + constructor(layers: Layer[]); + /** + * Returns a GeoJSON representation of the layer group (as a GeoJSON GeometryCollection, GeoJSONDefinition.FeatureCollection or Multipoint). + */ + toGeoJSON(): GeoJSONDefinition.FeatureCollection | GeoJSONDefinition.Feature; /** - * Create a layer group, optionally given an initial set of layers. + * Adds the given layer to the group. */ - export function layerGroup(layers: Array): LayerGroup; + addLayer(layer: Layer): this; /** - * Extended LayerGroup that also has mouse events (propagated from - * members of the group) and a shared bindPopup method. + * Removes the layer with the given internal ID or the given layer from the group. */ - export interface FeatureGroup extends LayerGroup { - /** - * Sets the given path options to each layer of the group that has a setStyle method. - */ - setStyle(style: PathOptions): this; - - /** - * Brings the layer group to the top of all other layers - */ - bringToFront(): this; - - /** - * Brings the layer group to the top [sic] of all other layers - */ - bringToBack(): this; - - /** - * Returns the LatLngBounds of the Feature Group (created from - * bounds and coordinates of its children). - */ - getBounds(): LatLngBounds; - } + removeLayer(layer: number | Layer): this; /** - * Create a feature group, optionally given an initial set of layers. + * Returns true if the given layer is currently added to the group. */ - export function featureGroup(layers?: Array): FeatureGroup; + hasLayer(layer: Layer): boolean; - type StyleFunction = (feature: GeoJSON.Feature) => PathOptions; + /** + * Removes all the layers from the group. + */ + clearLayers(): this; - export interface GeoJSONOptions extends LayerOptions { - /** - * A Function defining how GeoJSON points spawn Leaflet layers. - * It is internally called when data is added, passing the GeoJSON point - * feature and its LatLng. - * - * The default is to spawn a default Marker: - * - * ``` - * function(geoJsonPoint, latlng) { + /** + * Calls methodName on every layer contained in this group, passing any additional parameters. + * Has no effect if the layers contained do not implement methodName. + */ + invoke(methodName: string, ...params: any[]): this; + + /** + * Iterates over the layers of the group, + * optionally specifying context of the iterator function. + */ + eachLayer(fn: (layer: Layer) => void, context?: any): this; + + /** + * Returns the layer with the given internal ID. + */ + getLayer(id: number): Layer; + + /** + * Returns an array of all the layers added to the group. + */ + getLayers(): Layer[]; + + /** + * Calls setZIndex on every layer contained in this group, passing the z-index. + */ + setZIndex(zIndex: number): this; + + /** + * Returns the internal ID for a layer + */ + getLayerId(layer: Layer): number; + + feature: GeoJSONDefinition.FeatureCollection | GeoJSONDefinition.Feature; +} + +/** + * Create a layer group, optionally given an initial set of layers. + */ +export function layerGroup(layers: Layer[]): LayerGroup; + +/** + * Extended LayerGroup that also has mouse events (propagated from + * members of the group) and a shared bindPopup method. + */ +export class FeatureGroup extends LayerGroup { + /** + * Sets the given path options to each layer of the group that has a setStyle method. + */ + setStyle(style: PathOptions): this; + + /** + * Brings the layer group to the top of all other layers + */ + bringToFront(): this; + + /** + * Brings the layer group to the top [sic] of all other layers + */ + bringToBack(): this; + + /** + * Returns the LatLngBounds of the Feature Group (created from + * bounds and coordinates of its children). + */ + getBounds(): LatLngBounds; +} + +/** + * Create a feature group, optionally given an initial set of layers. + */ +export function featureGroup(layers?: Layer[]): FeatureGroup; + +type StyleFunction = (feature: GeoJSONDefinition.Feature) => PathOptions; + +export interface GeoJSONOptions extends LayerOptions { + /** + * A Function defining how GeoJSON points spawn Leaflet layers. + * It is internally called when data is added, passing the GeoJSON point + * feature and its LatLng. + * + * The default is to spawn a default Marker: + * + * ``` + * function(geoJsonPoint, latlng) { * return L.marker(latlng); * } - * ``` - */ - pointToLayer?: (geoJsonPoint: GeoJSON.Feature, latlng: LatLng) => Layer; // should import GeoJSON typings + * ``` + */ + pointToLayer?: (geoJsonPoint: GeoJSONDefinition.Feature, latlng: LatLng) => Layer; // should import GeoJSON typings - /** - * A Function defining the Path options for styling GeoJSON lines and polygons, - * called internally when data is added. - * - * The default value is to not override any defaults: - * - * ``` - * function (geoJsonFeature) { + /** + * A Function defining the Path options for styling GeoJSON lines and polygons, + * called internally when data is added. + * + * The default value is to not override any defaults: + * + * ``` + * function (geoJsonFeature) { * return {} * } - * ``` - */ - style?: StyleFunction; + * ``` + */ + style?: StyleFunction; - /** - * A Function that will be called once for each created Feature, after it - * has been created and styled. Useful for attaching events and popups to features. - * - * The default is to do nothing with the newly created layers: - * - * ``` - * function (feature, layer) {} - * ``` - */ - onEachFeature?: (feature: GeoJSON.Feature, layer: Layer) => void; + /** + * A Function that will be called once for each created Feature, after it + * has been created and styled. Useful for attaching events and popups to features. + * + * The default is to do nothing with the newly created layers: + * + * ``` + * function (feature, layer) {} + * ``` + */ + onEachFeature?: (feature: GeoJSONDefinition.Feature, layer: Layer) => void; - /** - * A Function that will be used to decide whether to show a feature or not. - * - * The default is to show all features: - * - * ``` - * function (geoJsonFeature) { + /** + * A Function that will be used to decide whether to show a feature or not. + * + * The default is to show all features: + * + * ``` + * function (geoJsonFeature) { * return true; * } - * ``` - */ - filter?: (geoJsonFeature: GeoJSON.Feature) => boolean; - - /** - * A Function that will be used for converting GeoJSON coordinates to LatLngs. - * The default is the coordsToLatLng static method. - */ - coordsToLatLng?: (coords: [number, number] | [number, number, number]) => LatLng; // check if LatLng has an altitude property - } - - export class GeoJSON { - /** - * Creates a Layer from a given GeoJSON feature. Can use a custom pointToLayer - * and/or coordsToLatLng functions if provided as options. - */ - static geometryToLayer(featureData: GeoJSON.Feature, options?: GeoJSONOptions): Layer; - - /** - * Creates a LatLng object from an array of 2 numbers (longitude, latitude) or - * 3 numbers (longitude, latitude, altitude) used in GeoJSON for points. - */ - static coordsToLatLng(coords: [number, number] | [number, number, number]): LatLng; - - /** - * Creates a multidimensional array of LatLngs from a GeoJSON coordinates array. - * levelsDeep specifies the nesting level (0 is for an array of points, 1 for an array of - * arrays of points, etc., 0 by default). - * Can use a custom coordsToLatLng function. - */ - static coordsToLatLngs( - coords: any[], - levelsDeep?: number, - coordsToLatLng?: (coords: [number, number] | [number, number, number]) => LatLng): any[]; // Using any[] to avoid artificially limiting valid calls - - /** - * Reverse of coordsToLatLng - */ - static latLngToCoords(latlng: LatLng): [number, number, number]; // A three tuple can be assigned to a two or three tuple - - - /** - * Reverse of coordsToLatLngs closed determines whether the first point should be - * appended to the end of the array to close the feature, only used when levelsDeep is 0. - * False by default. - */ - static latLngsToCoords(latlngs: any[], levelsDeep?: number, closed?: boolean): any[]; // Using any[] to avoid artificially limiting valid calls - - /** - * Normalize GeoJSON geometries/features into GeoJSON features. - */ - static asFeature(geojson: GeoJSON.GeometryObject): GeoJSON.Feature; - - static asFeature(geojson: GeoJSON.Feature): GeoJSON.Feature; - - } + * ``` + */ + filter?: (geoJsonFeature: GeoJSONDefinition.Feature) => boolean; /** - * Represents a GeoJSON object or an array of GeoJSON objects. - * Allows you to parse GeoJSON data and display it on the map. Extends FeatureGroup. + * A Function that will be used for converting GeoJSON coordinates to LatLngs. + * The default is the coordsToLatLng static method. */ - export interface GeoJSON extends FeatureGroup { - /** - * Adds a GeoJSON object to the layer. - */ - addData(data: GeoJSON.GeoJsonObject): Layer; + coordsToLatLng?: (coords: [number, number] | [number, number, number]) => LatLng; // check if LatLng has an altitude property +} - /** - * Resets the given vector layer's style to the original GeoJSON style, - * useful for resetting style after hover events. - */ - resetStyle(layer: Layer): Layer; - - /** - * Changes styles of GeoJSON vector layers with the given style function. - */ - setStyle(style: StyleFunction): this; - - } +/** + * Represents a GeoJSON object or an array of GeoJSON objects. + * Allows you to parse GeoJSON data and display it on the map. Extends FeatureGroup. + */ +export class GeoJSON { + /** + * Creates a Layer from a given GeoJSON feature. Can use a custom pointToLayer + * and/or coordsToLatLng functions if provided as options. + */ + static geometryToLayer(featureData: GeoJSONDefinition.Feature, options?: GeoJSONOptions): Layer; /** - * Creates a GeoJSON layer. - * - * Optionally accepts an object in GeoJSON format to display on the - * map (you can alternatively add it later with addData method) and - * an options object. + * Creates a LatLng object from an array of 2 numbers (longitude, latitude) or + * 3 numbers (longitude, latitude, altitude) used in GeoJSON for points. */ - export function geoJSON(geojson?: GeoJSON.GeoJsonObject, options?: GeoJSONOptions): GeoJSON; + static coordsToLatLng(coords: [number, number] | [number, number, number]): LatLng; - type Zoom = boolean | 'center'; + /** + * Creates a multidimensional array of LatLngs from a GeoJSON coordinates array. + * levelsDeep specifies the nesting level (0 is for an array of points, 1 for an array of + * arrays of points, etc., 0 by default). + * Can use a custom coordsToLatLng function. + */ + static coordsToLatLngs( + coords: any[], + levelsDeep?: number, + coordsToLatLng?: (coords: [number, number] | [number, number, number]) => LatLng): any[]; // Using any[] to avoid artificially limiting valid calls - export interface MapOptions { - preferCanvas?: boolean; + /** + * Reverse of coordsToLatLng + */ + static latLngToCoords(latlng: LatLng): [number, number, number]; // A three tuple can be assigned to a two or three tuple - // Control options - attributionControl?: boolean; - zoomControl?: boolean; - // Interaction options - closePopupOnClick?: boolean; - zoomSnap?: number; - zoomDelta?: number; - trackResize?: boolean; - boxZoom?: boolean; - doubleClickZoom?: Zoom; - dragging?: boolean; + /** + * Reverse of coordsToLatLngs closed determines whether the first point should be + * appended to the end of the array to close the feature, only used when levelsDeep is 0. + * False by default. + */ + static latLngsToCoords(latlngs: any[], levelsDeep?: number, closed?: boolean): any[]; // Using any[] to avoid artificially limiting valid calls - // Map state options - crs?: CRS; - center?: LatLngExpression; - zoom?: number; - minZoom?: number; - maxZoom?: number; - layers?: Array; - maxBounds?: LatLngBoundsExpression; - renderer?: Renderer; + /** + * Normalize GeoJSON geometries/features into GeoJSON features. + */ + static asFeature(geojson: GeoJSONDefinition.Feature | GeoJSONDefinition.GeometryObject): GeoJSONDefinition.Feature; - // Animation options - fadeAnimation?: boolean; - markerZoomAnimation?: boolean; - transform3DLimit?: number; - zoomAnimation?: boolean; - zoomAnimationThreshold?: number; + constructor(geojson?: GeoJSONDefinition.GeoJsonObject, options?: GeoJSONOptions) + /** + * Adds a GeoJSON object to the layer. + */ + addData(data: GeoJSONDefinition.GeoJsonObject): Layer; - // Panning inertia options - inertia?: boolean; - inertiaDeceleration?: number; - inertiaMaxSpeed?: number; - easeLinearity?: number; - worldCopyJump?: boolean; - maxBoundsViscosity?: number; + /** + * Resets the given vector layer's style to the original GeoJSON style, + * useful for resetting style after hover events. + */ + resetStyle(layer: Layer): Layer; - // Keyboard navigation options - keyboard?: boolean; - keyboardPanDelta?: number; + /** + * Changes styles of GeoJSON vector layers with the given style function. + */ + setStyle(style: StyleFunction): this; - // Mousewheel options - scrollWheelZoom?: Zoom; - wheelDebounceTime?: number; - wheelPxPerZoomLevel?: number; + options: GeoJSONOptions; - // Touch interaction options - tap?: boolean; - tapTolerance?: number; - touchZoom?: Zoom; - bounceAtZoomLimits?: boolean; +} + +/** + * Creates a GeoJSON layer. + * + * Optionally accepts an object in GeoJSON format to display on the + * map (you can alternatively add it later with addData method) and + * an options object. + */ +export function geoJSON(geojson?: GeoJSONDefinition.GeoJsonObject, options?: GeoJSONOptions): GeoJSON; + +type Zoom = boolean | 'center'; + +export interface MapOptions { + preferCanvas?: boolean; + + // Control options + attributionControl?: boolean; + zoomControl?: boolean; + + // Interaction options + closePopupOnClick?: boolean; + zoomSnap?: number; + zoomDelta?: number; + trackResize?: boolean; + boxZoom?: boolean; + doubleClickZoom?: Zoom; + dragging?: boolean; + + // Map state options + crs?: CRS; + center?: LatLngExpression; + zoom?: number; + minZoom?: number; + maxZoom?: number; + layers?: Layer[]; + maxBounds?: LatLngBoundsExpression; + renderer?: Renderer; + + // Animation options + fadeAnimation?: boolean; + markerZoomAnimation?: boolean; + transform3DLimit?: number; + zoomAnimation?: boolean; + zoomAnimationThreshold?: number; + + // Panning inertia options + inertia?: boolean; + inertiaDeceleration?: number; + inertiaMaxSpeed?: number; + easeLinearity?: number; + worldCopyJump?: boolean; + maxBoundsViscosity?: number; + + // Keyboard navigation options + keyboard?: boolean; + keyboardPanDelta?: number; + + // Mousewheel options + scrollWheelZoom?: Zoom; + wheelDebounceTime?: number; + wheelPxPerZoomLevel?: number; + + // Touch interaction options + tap?: boolean; + tapTolerance?: number; + touchZoom?: Zoom; + bounceAtZoomLimits?: boolean; +} + +export type ControlPosition = 'topleft' | 'topright' | 'bottomleft' | 'bottomright'; + +export interface ControlOptions { + position?: ControlPosition; +} + +export class Control extends Class { + constructor(options?: ControlOptions); + getPosition(): ControlPosition; + setPosition(position: ControlPosition): this; + getContainer(): HTMLElement; + addTo(map: Map): this; + remove(): this; + + // Extension methods + onAdd(map: Map): HTMLElement; + onRemove(map: Map): void; + + options: ControlOptions; +} + +export namespace Control { + export interface ZoomOptions extends ControlOptions { + zoomInText?: string; + zoomInTitle?: string; + zoomOutText?: string; + zoomOutTitle?: string; } - export type ControlPosition = 'topleft' | 'topright' | 'bottomleft' | 'bottomright'; - - export interface ControlOptions { - position?: ControlPosition; + export class Zoom extends Control { + constructor(options?: ZoomOptions); + options: ZoomOptions; } - export class Control extends Class { - constructor (options?: ControlOptions); - getPosition(): ControlPosition; - setPosition(position: ControlPosition): this; - getContainer(): HTMLElement; - addTo(map: Map): this; - remove(): this; - - // Extension methods - onAdd(map: Map): HTMLElement; - onRemove(map: Map): void; + export interface AttributionOptions extends ControlOptions { + prefix?: string | boolean; } - export namespace Control { - export interface ZoomOptions extends ControlOptions { - zoomInText?: string; - zoomInTitle?: string; - zoomOutText?: string; - zoomOutTitle?: string; - } - - export interface Zoom extends Control {} - - export interface AttributionOptions extends ControlOptions { - prefix?: string | boolean; - } - - export interface Attribution extends Control { - setPrefix(prefix: string): this; - addAttribution(text: string): this; - removeAttribution(text: string): this; - } - - export interface LayersOptions extends ControlOptions { - collapsed?: boolean; - autoZIndex?: boolean; - hideSingleBase?: boolean; - } - - export interface Layers extends Control { - addBaseLayer(layer: Layer, name: string): this; - addOverlay(layer: Layer, name: string): this; - removeLayer(layer: Layer): this; - expand(): this; - collapse(): this; - } - - export interface ScaleOptions extends ControlOptions { - maxWidth?: number; - metric?: boolean; - imperial?: boolean; - updateWhenIdle?: boolean; - } - - export interface Scale extends Control {} + export class Attribution extends Control { + constructor(options?: AttributionOptions); + setPrefix(prefix: string): this; + addAttribution(text: string): this; + removeAttribution(text: string): this; + options: AttributionOptions; } - export namespace control { - export function zoom(options: Control.ZoomOptions): Control.Zoom; - - export function attribution(options: Control.AttributionOptions): Control.Attribution; - - type LayersObject = {[name: string]: Layer}; - - export function layers(baseLayers?: LayersObject, overlays?: LayersObject, options?: Control.LayersOptions): Control.Layers; - - export function scale(options?: Control.ScaleOptions): Control.Scale; + export interface LayersOptions extends ControlOptions { + collapsed?: boolean; + autoZIndex?: boolean; + hideSingleBase?: boolean; } - interface DivOverlayOptions { - offset?: PointExpression; - zoomAnimation?: boolean; - className?: string; - pane?: string; + interface LayersObject { + [name: string]: Layer; } - export interface PopupOptions extends DivOverlayOptions { - maxWidth?: number; - minWidth?: number; - maxHeight?: number; - autoPan?: boolean; - autoPanPaddingTopLeft?: PointExpression; - autoPanPaddingBottomRight?: PointExpression; - autoPanPadding?: PointExpression; - keepInView?: boolean; - closeButton?: boolean; - autoClose?: boolean; - closeOnClick?: boolean; - } - - type Content = string | HTMLElement; - - export interface Popup extends Layer { - getLatLng(): LatLng; - setLatLng(latlng: LatLngExpression): this; - getContent(): Content; - setContent(htmlContent: string): this; - setContent(htmlContent: HTMLElement): this; - setContent(htmlContent: (source: Layer) => Content): this; - getElement(): Content; - update(): void; - isOpen(): boolean; - bringToFront(): this; - bringToBack(): this; - openOn(map: Map): this; - } - - export function popup(options?: PopupOptions, source?: Layer): Popup; - - export type Direction = 'right' | 'left' | 'top' | 'bottom' | 'center' | 'auto'; - - export interface TooltipOptions extends DivOverlayOptions { - pane?: string; - offset?: PointExpression; - direction?: Direction; - permanent?: boolean; - sticky?: boolean; - interactive?: boolean; - opacity?: number; - } - - export interface Tooltip extends Layer {} - - export function tooltip(options?: TooltipOptions, source?: Layer): Tooltip; - - export interface ZoomOptions { - animate?: boolean; - } - - export interface PanOptions { - animate?: boolean; - duration?: number; - easeLinearity?: number; - noMoveStart?: boolean; - } - - export interface ZoomPanOptions extends ZoomOptions, PanOptions {} - - export interface FitBoundsOptions extends ZoomOptions, PanOptions { - paddingTopLeft?: PointExpression; - paddingBottomRight?: PointExpression; - padding?: PointExpression; - maxZoom?: number; - } - - export interface LocateOptions { - watch?: boolean; - setView?: boolean; - maxZoom?: number; - timeout?: number; - maximumAge?: number; - enableHighAccuracy?: boolean; - } - - export interface Handler { - enable(): this; - disable(): this; - enabled(): boolean; - - // Extension methods - addHooks(): void; - removeHooks(): void; - } - - export interface Event { - type: string; - target: any; - } - - export interface MouseEvent extends Event { - latlng: LatLng; - layerPoint: Point; - containerPoint: Point; - originalEvent: NativeMouseEvent; - } - - export interface KeyboardEvent extends Event { - originalEvent: NativeKeyboardEvent; - } - - export interface LocationEvent extends Event { - latlng: LatLng; - bounds: LatLngBounds; - accuracy: number; - altitude: number; - altitudeAccuracy: number; - heading: number; - speed: number; - timestamp: number; - } - - export interface ErrorEvent extends Event { - message: string; - code: number; - } - - export interface LayerEvent extends Event { - layer: Layer; - } - - export interface LayersControlEvent extends LayerEvent { - name: string; - } - - export interface TileEvent extends Event { - tile: HTMLImageElement; - coords: Point; // apparently not a normal point, since docs say it has z (zoom) - } - - export interface TileErrorEvent extends TileEvent { - error: Error; - } - - export interface ResizeEvent extends Event { - oldSize: Point; - newSize: Point; - } - - export interface GeoJSONEvent extends Event { - layer: Layer; - properties: any; - geometryType: string; - id: string; - } - - export interface PopupEvent extends Event { - popup: Popup; - } - - export interface TooltipEvent extends Event { - tooltip: Tooltip; - } - - export interface DragEndEvent extends Event { - distance: number; - } - - export interface ZoomAnimEvent extends Event { - center: LatLng; - zoom: number; - noUpdate: boolean; - } - - export namespace DomEvent { - export function on(el: HTMLElement, types: string, fn: (ev: Event) => any, context?: any): typeof DomEvent; - - export function on(el: HTMLElement, eventMap: {[eventName: string]: Function}, context?: any): typeof DomEvent; - - export function off(el: HTMLElement, types: string, fn: (ev: Event) => any, context?: any): typeof DomEvent; - - export function off(el: HTMLElement, eventMap: {[eventName: string]: Function}, context?: any): typeof DomEvent; - - export function stopPropagation(ev: Event): typeof DomEvent; - - export function disableScrollPropagation(el: HTMLElement): typeof DomEvent; - - export function disableClickPropagation(el: HTMLElement): typeof DomEvent; - - export function preventDefault(ev: Event): typeof DomEvent; - - export function stop(ev: Event): typeof DomEvent; - - export function getMousePosition(ev: Event, container?: HTMLElement): Point; - - export function getWheelDelta(ev: Event): number; - - export function addListener(el: HTMLElement, types: string, fn: (ev: Event) => any, context?: any): typeof DomEvent; - - export function addListener(el: HTMLElement, eventMap: {[eventName: string]: Function}, context?: any): typeof DomEvent; - - export function removeListener(el: HTMLElement, types: string, fn: (ev: Event) => any, context?: any): typeof DomEvent; - - export function removeListener(el: HTMLElement, eventMap: {[eventName: string]: Function}, context?: any): typeof DomEvent; - } - - interface DefaultMapPanes { - mapPane: HTMLElement; - tilePane: HTMLElement; - overlayPane: HTMLElement; - shadowPane: HTMLElement; - markerPane: HTMLElement; - tooltipPane: HTMLElement; - popupPane: HTMLElement; - } - - export interface Map extends Evented { - getRenderer(layer: Path): Renderer; - - // Methods for layers and controls - addControl(control: Control): this; - removeControl(control: Control): this; - addLayer(layer: Layer): this; + export class Layers extends Control { + constructor(baseLayers?: LayersObject, overlays?: LayersObject, options?: Control.LayersOptions); + addBaseLayer(layer: Layer, name: string): this; + addOverlay(layer: Layer, name: string): this; removeLayer(layer: Layer): this; - hasLayer(layer: Layer): boolean; - eachLayer(fn: (layer: Layer) => void, context?: any): this; - openPopup(popup: Popup): this; - openPopup(content: string, latlng: LatLngExpression, options?: PopupOptions): this; - openPopup(content: HTMLElement, latlng: LatLngExpression, options?: PopupOptions): this; - closePopup(popup?: Popup): this; - openTooltip(tooltip: Tooltip): this; - openTooltip(content: string, latlng: LatLngExpression, options?: TooltipOptions): this; - openTooltip(content: HTMLElement, latlng: LatLngExpression, options?: TooltipOptions): this; - closeTooltip(tooltip?: Tooltip): this; - - // Methods for modifying map state - setView(center: LatLngExpression, zoom: number, options?: ZoomPanOptions): this; - setZoom(zoom: number, options?: ZoomPanOptions): this; - zoomIn(delta?: number, options?: ZoomOptions): this; - zoomOut(delta?: number, options?: ZoomOptions): this; - setZoomAround(latlng: LatLngExpression, zoom: number, options?: ZoomOptions): this; - setZoomAround(offset: Point, zoom: number, options?: ZoomOptions): this; - fitBounds(bounds: LatLngBoundsExpression, options?: FitBoundsOptions): this; - fitWorld(options?: FitBoundsOptions): this; - panTo(latlng: LatLngExpression, options?: PanOptions): this; - panBy(offset: PointExpression): this; - setMaxBounds(bounds: LatLngBoundsExpression): this; - setMinZoom(zoom: number): this; - setMaxZoom(zoom: number): this; - panInsideBounds(bounds: LatLngBoundsExpression, options?: PanOptions): this; - invalidateSize(options: ZoomPanOptions): this; - invalidateSize(animate: boolean): this; - stop(): this; - flyTo(latlng: LatLngExpression, zoom?: number, options?: ZoomPanOptions): this; - flyToBounds(bounds: LatLngBoundsExpression, options?: FitBoundsOptions): this; - - // Other methods - addHandler(name: string, HandlerClass: () => Handler): this; // HandlerClass is actually a constructor function, is this the right way? - remove(): this; - createPane(name: string, container?: HTMLElement): HTMLElement; - getPane(pane: string): HTMLElement; - getPane(pane: HTMLElement): HTMLElement; - getPanes(): {[name: string]: HTMLElement} & DefaultMapPanes; - getContainer(): HTMLElement; - whenReady(fn: () => void, context?: any): this; - - // Methods for getting map state - getCenter(): LatLng; - getZoom(): number; - getBounds(): LatLngBounds; - getMinZoom(): number; - getMaxZoom(): number; - getBoundsZoom(bounds: LatLngBoundsExpression, inside?: boolean): number; - getSize(): Point; - getPixelBounds(): Bounds; - getPixelOrigin(): Point; - getPixelWorldBounds(zoom?: number): Bounds; - - // Conversion methods - getZoomScale(toZoom: number, fromZoom: number): number; - getScaleZoom(scale: number, fromZoom: number): number; - project(latlng: LatLngExpression, zoom: number): Point; - unproject(point: PointExpression, zoom: number): LatLng; - layerPointToLatLng(point: PointExpression): LatLng; - latLngToLayerPoint(latlng: LatLngExpression): Point; - wrapLatLng(latlng: LatLngExpression): LatLng; - distance(latlng1: LatLngExpression, latlng2: LatLngExpression): number; - containerPointToLayerPoint(point: PointExpression): Point; - layerPointToContainerPoint(point: PointExpression): Point; - layerPointToContainerPoint(point: PointTuple): Point; - latLngToContainerPoint(latlng: LatLngExpression): Point; - mouseEventToContainerPoint(ev: MouseEvent): Point; - mouseEventToLayerPoint(ev: MouseEvent): Point; - mouseEventToLatLng(ev: MouseEvent): LatLng; - - // Geolocation methods - locate(options?: LocateOptions): this; - stopLocate(): this; - - // Properties - boxZoom: Handler; - doubleClickZoom: Handler; - dragging: Handler; - keyboard: Handler; - scrollWheelZoom: Handler; - tap: Handler; - touchZoom: Handler; + expand(): this; + collapse(): this; + options: LayersOptions; } - export function map(id: string, options?: MapOptions): Map; - - export function map(el: HTMLElement, options?: MapOptions): Map; - - export interface IconOptions extends LayerOptions { - iconUrl: string; - iconRetinaUrl?: string; - iconSize?: PointExpression; - iconAnchor?: PointExpression; - popupAnchor?: PointExpression; - shadowUrl?: string; - shadowRetinaUrl?: string; - shadowSize?: PointExpression; - shadowAnchor?: PointExpression; - className?: string; + export interface ScaleOptions extends ControlOptions { + maxWidth?: number; + metric?: boolean; + imperial?: boolean; + updateWhenIdle?: boolean; } - export interface Icon extends Layer { - createIcon(oldIcon?: HTMLElement): HTMLElement; - createShadow(oldIcon?: HTMLElement): HTMLElement; + export class Scale extends Control { + constructor(options?: Control.ScaleOptions); + options: ScaleOptions; } +} - export interface IconDefault extends Icon { +export namespace control { + export function zoom(options?: Control.ZoomOptions): Control.Zoom; + + export function attribution(options?: Control.AttributionOptions): Control.Attribution; + + export function layers(baseLayers?: Control.LayersObject, overlays?: Control.LayersObject, options?: Control.LayersOptions): Control.Layers; + + export function scale(options?: Control.ScaleOptions): Control.Scale; +} + +interface DivOverlayOptions { + offset?: PointExpression; + zoomAnimation?: boolean; + className?: string; + pane?: string; +} + +export interface PopupOptions extends DivOverlayOptions { + maxWidth?: number; + minWidth?: number; + maxHeight?: number; + autoPan?: boolean; + autoPanPaddingTopLeft?: PointExpression; + autoPanPaddingBottomRight?: PointExpression; + autoPanPadding?: PointExpression; + keepInView?: boolean; + closeButton?: boolean; + autoClose?: boolean; + closeOnClick?: boolean; +} + +type Content = string | HTMLElement; + +export class Popup extends Layer { + constructor(options?: PopupOptions, source?: Layer); + getLatLng(): LatLng; + setLatLng(latlng: LatLngExpression): this; + getContent(): Content; + setContent(htmlContent: (source: Layer) => Content | Content): this; + getElement(): HTMLElement; + update(): void; + isOpen(): boolean; + bringToFront(): this; + bringToBack(): this; + openOn(map: Map): this; + + options: PopupOptions; +} + +export function popup(options?: PopupOptions, source?: Layer): Popup; + +export type Direction = 'right' | 'left' | 'top' | 'bottom' | 'center' | 'auto'; + +export interface TooltipOptions extends DivOverlayOptions { + pane?: string; + offset?: PointExpression; + direction?: Direction; + permanent?: boolean; + sticky?: boolean; + interactive?: boolean; + opacity?: number; +} + +export class Tooltip extends Layer { + constructor(options?: TooltipOptions, source?: Layer); + setOpacity(val: number): void; + getLatLng(): LatLng; + setLatLng(latlng: LatLngExpression): this; + getContent(): Content; + setContent(htmlContent: (source: Layer) => Content | Content): this; + getElement(): HTMLElement; + update(): void; + isOpen(): boolean; + bringToFront(): this; + bringToBack(): this; + + options: TooltipOptions; +} + +export function tooltip(options?: TooltipOptions, source?: Layer): Tooltip; + +export interface ZoomOptions { + animate?: boolean; +} + +export interface PanOptions { + animate?: boolean; + duration?: number; + easeLinearity?: number; + noMoveStart?: boolean; +} + +export interface ZoomPanOptions extends ZoomOptions, PanOptions {} + +export interface FitBoundsOptions extends ZoomOptions, PanOptions { + paddingTopLeft?: PointExpression; + paddingBottomRight?: PointExpression; + padding?: PointExpression; + maxZoom?: number; +} + +export interface LocateOptions { + watch?: boolean; + setView?: boolean; + maxZoom?: number; + timeout?: number; + maximumAge?: number; + enableHighAccuracy?: boolean; +} + +export class Handler extends Class { + constructor(map: Map); + enable(): this; + disable(): this; + enabled(): boolean; + + // Extension methods + addHooks(): void; + removeHooks(): void; +} + +export interface Event { + type: string; + target: any; +} + +export interface MouseEvent extends Event { + latlng: LatLng; + layerPoint: Point; + containerPoint: Point; + originalEvent: NativeMouseEvent; +} + +export interface KeyboardEvent extends Event { + originalEvent: NativeKeyboardEvent; +} + +export interface LocationEvent extends Event { + latlng: LatLng; + bounds: LatLngBounds; + accuracy: number; + altitude: number; + altitudeAccuracy: number; + heading: number; + speed: number; + timestamp: number; +} + +export interface ErrorEvent extends Event { + message: string; + code: number; +} + +export interface LayerEvent extends Event { + layer: Layer; +} + +export interface LayersControlEvent extends LayerEvent { + name: string; +} + +export interface TileEvent extends Event { + tile: HTMLImageElement; + coords: Point; // apparently not a normal point, since docs say it has z (zoom) +} + +export interface TileErrorEvent extends TileEvent { + error: Error; +} + +export interface ResizeEvent extends Event { + oldSize: Point; + newSize: Point; +} + +export interface GeoJSONEvent extends Event { + layer: Layer; + properties: any; + geometryType: string; + id: string; +} + +export interface PopupEvent extends Event { + popup: Popup; +} + +export interface TooltipEvent extends Event { + tooltip: Tooltip; +} + +export interface DragEndEvent extends Event { + distance: number; +} + +export interface ZoomAnimEvent extends Event { + center: LatLng; + zoom: number; + noUpdate: boolean; +} + +export namespace DomEvent { + export function on(el: HTMLElement, types: string, fn: EventHandlerFn, context?: any): typeof DomEvent; + + export function on(el: HTMLElement, eventMap: {[eventName: string]: EventHandlerFn}, context?: any): typeof DomEvent; + + export function off(el: HTMLElement, types: string, fn: EventHandlerFn, context?: any): typeof DomEvent; + + export function off(el: HTMLElement, eventMap: {[eventName: string]: EventHandlerFn}, context?: any): typeof DomEvent; + + export function stopPropagation(ev: Event): typeof DomEvent; + + export function disableScrollPropagation(el: HTMLElement): typeof DomEvent; + + export function disableClickPropagation(el: HTMLElement): typeof DomEvent; + + export function preventDefault(ev: Event): typeof DomEvent; + + export function stop(ev: Event): typeof DomEvent; + + export function getMousePosition(ev: Event, container?: HTMLElement): Point; + + export function getWheelDelta(ev: Event): number; + + export function addListener(el: HTMLElement, types: string, fn: EventHandlerFn, context?: any): typeof DomEvent; + + export function addListener(el: HTMLElement, eventMap: {[eventName: string]: EventHandlerFn}, context?: any): typeof DomEvent; + + export function removeListener(el: HTMLElement, types: string, fn: EventHandlerFn, context?: any): typeof DomEvent; + + export function removeListener(el: HTMLElement, eventMap: {[eventName: string]: EventHandlerFn}, context?: any): typeof DomEvent; +} + +interface DefaultMapPanes { + mapPane: HTMLElement; + tilePane: HTMLElement; + overlayPane: HTMLElement; + shadowPane: HTMLElement; + markerPane: HTMLElement; + tooltipPane: HTMLElement; + popupPane: HTMLElement; +} + +export class Map extends Evented { + constructor(element: string | HTMLElement, options?: MapOptions); + getRenderer(layer: Path): Renderer; + + // Methods for layers and controls + addControl(control: Control): this; + removeControl(control: Control): this; + addLayer(layer: Layer): this; + removeLayer(layer: Layer): this; + hasLayer(layer: Layer): boolean; + eachLayer(fn: (layer: Layer) => void, context?: any): this; + openPopup(popup: Popup): this; + openPopup(content: Content, latlng: LatLngExpression, options?: PopupOptions): this; + closePopup(popup?: Popup): this; + openTooltip(tooltip: Tooltip): this; + openTooltip(content: string | HTMLElement, latlng: LatLngExpression, options?: TooltipOptions): this; + closeTooltip(tooltip?: Tooltip): this; + + // Methods for modifying map state + setView(center: LatLngExpression, zoom: number, options?: ZoomPanOptions): this; + setZoom(zoom: number, options?: ZoomPanOptions): this; + zoomIn(delta?: number, options?: ZoomOptions): this; + zoomOut(delta?: number, options?: ZoomOptions): this; + setZoomAround(position: Point | LatLngExpression, zoom: number, options?: ZoomOptions): this; + fitBounds(bounds: LatLngBoundsExpression, options?: FitBoundsOptions): this; + fitWorld(options?: FitBoundsOptions): this; + panTo(latlng: LatLngExpression, options?: PanOptions): this; + panBy(offset: PointExpression): this; + setMaxBounds(bounds: LatLngBoundsExpression): this; + setMinZoom(zoom: number): this; + setMaxZoom(zoom: number): this; + panInsideBounds(bounds: LatLngBoundsExpression, options?: PanOptions): this; + /** + * Boolean for animate or advanced ZoomPanOptions + */ + invalidateSize(options?: boolean | ZoomPanOptions): this; + stop(): this; + flyTo(latlng: LatLngExpression, zoom?: number, options?: ZoomPanOptions): this; + flyToBounds(bounds: LatLngBoundsExpression, options?: FitBoundsOptions): this; + + // Other methods + addHandler(name: string, HandlerClass: () => Handler): this; // HandlerClass is actually a constructor function, is this the right way? + remove(): this; + createPane(name: string, container?: HTMLElement): HTMLElement; + /** + * Name of the pane or the pane as HTML-Element + */ + getPane(pane: string | HTMLElement): HTMLElement; + getPanes(): {[name: string]: HTMLElement} & DefaultMapPanes; + getContainer(): HTMLElement; + whenReady(fn: () => void, context?: any): this; + + // Methods for getting map state + getCenter(): LatLng; + getZoom(): number; + getBounds(): LatLngBounds; + getMinZoom(): number; + getMaxZoom(): number; + getBoundsZoom(bounds: LatLngBoundsExpression, inside?: boolean): number; + getSize(): Point; + getPixelBounds(): Bounds; + getPixelOrigin(): Point; + getPixelWorldBounds(zoom?: number): Bounds; + + // Conversion methods + getZoomScale(toZoom: number, fromZoom: number): number; + getScaleZoom(scale: number, fromZoom: number): number; + project(latlng: LatLngExpression, zoom: number): Point; + unproject(point: PointExpression, zoom: number): LatLng; + layerPointToLatLng(point: PointExpression): LatLng; + latLngToLayerPoint(latlng: LatLngExpression): Point; + wrapLatLng(latlng: LatLngExpression): LatLng; + distance(latlng1: LatLngExpression, latlng2: LatLngExpression): number; + containerPointToLayerPoint(point: PointExpression): Point; + layerPointToContainerPoint(point: PointExpression): Point; + latLngToContainerPoint(latlng: LatLngExpression): Point; + mouseEventToContainerPoint(ev: MouseEvent): Point; + mouseEventToLayerPoint(ev: MouseEvent): Point; + mouseEventToLatLng(ev: MouseEvent): LatLng; + + // Geolocation methods + locate(options?: LocateOptions): this; + stopLocate(): this; + + // Properties + boxZoom: Handler; + doubleClickZoom: Handler; + dragging: Handler; + keyboard: Handler; + scrollWheelZoom: Handler; + tap: Handler; + touchZoom: Handler; + + options: MapOptions; +} + +/** + * ID of a HTML-Element as string or the HTML-ELement itself + */ +export function map(element: string | HTMLElement, options?: MapOptions): Map; + +export interface IconOptions extends LayerOptions { + iconUrl: string; + iconRetinaUrl?: string; + iconSize?: PointExpression; + iconAnchor?: PointExpression; + popupAnchor?: PointExpression; + shadowUrl?: string; + shadowRetinaUrl?: string; + shadowSize?: PointExpression; + shadowAnchor?: PointExpression; + className?: string; +} + +declare class InternalIcon extends Layer { + constructor(options: IconOptions); + createIcon(oldIcon?: HTMLElement): HTMLElement; +} + +export class Icon extends InternalIcon { + createShadow(oldIcon?: HTMLElement): HTMLElement; + options: IconOptions; +} + +export interface IconDefault extends InternalIcon { + imagePath: string; +} + +export namespace Icon { + export class Default extends InternalIcon { imagePath: string; } - - export class Icon { - constructor(options: IconOptions); - } - - export namespace Icon { - export class Default extends Icon { - constructor(options?: IconOptions); - imagePath: string; - } - } - - export function icon(options: IconOptions): Icon; - - export interface DivIconOptions extends LayerOptions { - html?: string; - bgPos?: PointExpression; - iconSize?: PointExpression; - iconAnchor?: PointExpression; - popupAnchor?: PointExpression; - className?: string; - } - - export class DivIcon extends Icon { - constructor(options?: DivIconOptions); - } - - export function divIcon(options?: DivIconOptions): DivIcon; - - export interface MarkerOptions extends InteractiveLayerOptions { - icon?: Icon; - clickable?: boolean; - draggable?: boolean; - keyboard?: boolean; - title?: string; - alt?: string; - zIndexOffset?: number; - opacity?: number; - riseOnHover?: boolean; - riseOffset?: number; - } - - export class Marker extends Layer { - constructor(latlng: LatLngExpression, options?: MarkerOptions); - getLatLng(): LatLng; - setLatLng(latlng: LatLngExpression): this; - setZIndexOffset(offset: number): this; - setIcon(icon: Icon): this; - setOpacity(opacity: number): this; - getElement(): Element; - - // Properties - dragging: Handler; - } - - export function marker(latlng: LatLngExpression, options?: MarkerOptions): Marker; - - export namespace Browser { - export const ie: boolean; - export const ielt9: boolean; - export const edge: boolean; - export const webkit: boolean; - export const gecko: boolean; - export const android: boolean; - export const android23: boolean; - export const chrome: boolean; - export const safari: boolean; - export const win: boolean; - export const ie3d: boolean; - export const webkit3d: boolean; - export const gecko3d: boolean; - export const opera12: boolean; - export const any3d: boolean; - export const mobile: boolean; - export const mobileWebkit: boolean; - export const mobiWebkit3d: boolean; - export const mobileOpera: boolean; - export const mobileGecko: boolean; - export const touch: boolean; - export const msPointer: boolean; - export const pointer: boolean; - export const retina: boolean; - export const canvas: boolean; - export const vml: boolean; - export const svg: boolean; - } } -declare module 'leaflet' { - export = L; +export function icon(options: IconOptions): Icon; + +export interface DivIconOptions extends LayerOptions { + html?: string; + bgPos?: PointExpression; + iconSize?: PointExpression; + iconAnchor?: PointExpression; + popupAnchor?: PointExpression; + className?: string; +} + +export class DivIcon extends InternalIcon { + constructor(options?: DivIconOptions); + options: DivIconOptions; +} + +export function divIcon(options?: DivIconOptions): DivIcon; + +export interface MarkerOptions extends InteractiveLayerOptions { + icon?: Icon; + clickable?: boolean; + draggable?: boolean; + keyboard?: boolean; + title?: string; + alt?: string; + zIndexOffset?: number; + opacity?: number; + riseOnHover?: boolean; + riseOffset?: number; + + options: DivIconOptions; +} + +export class Marker extends Layer { + constructor(latlng: LatLngExpression, options?: MarkerOptions); + getLatLng(): LatLng; + setLatLng(latlng: LatLngExpression): this; + setZIndexOffset(offset: number): this; + setIcon(icon: Icon): this; + setOpacity(opacity: number): this; + getElement(): HTMLElement; + + // Properties + options: MarkerOptions; + dragging: Handler; +} + +export function marker(latlng: LatLngExpression, options?: MarkerOptions): Marker; + +export namespace Browser { + export const ie: boolean; + export const ielt9: boolean; + export const edge: boolean; + export const webkit: boolean; + export const gecko: boolean; + export const android: boolean; + export const android23: boolean; + export const chrome: boolean; + export const safari: boolean; + export const win: boolean; + export const ie3d: boolean; + export const webkit3d: boolean; + export const gecko3d: boolean; + export const opera12: boolean; + export const any3d: boolean; + export const mobile: boolean; + export const mobileWebkit: boolean; + export const mobiWebkit3d: boolean; + export const mobileOpera: boolean; + export const mobileGecko: boolean; + export const touch: boolean; + export const msPointer: boolean; + export const pointer: boolean; + export const retina: boolean; + export const canvas: boolean; + export const vml: boolean; + export const svg: boolean; } diff --git a/leaflet/leaflet-tests.ts b/leaflet/leaflet-tests.ts index c6dca97f5d..6f9fa242d8 100644 --- a/leaflet/leaflet-tests.ts +++ b/leaflet/leaflet-tests.ts @@ -11,6 +11,14 @@ latLng = L.latLng({lat: 12, lng: 13, alt: 0}); latLng = L.latLng(latLngTuple); latLng = L.latLng([12, 13, 0]); +latLng = new L.LatLng(12, 13); +latLng = new L.LatLng(12, 13, 0); +latLng = new L.LatLng(latLngLiteral); +latLng = new L.LatLng({lat: 12, lng: 13, alt: 0}); +latLng = new L.LatLng(latLngTuple); +latLng = new L.LatLng([12, 13, 0]); + + const latLngBoundsLiteral: L.LatLngBoundsLiteral = [[12, 13], latLngTuple]; let latLngBounds: L.LatLngBounds; @@ -18,6 +26,10 @@ latLngBounds = L.latLngBounds(latLng, latLng); latLngBounds = L.latLngBounds(latLngLiteral, latLngLiteral); latLngBounds = L.latLngBounds(latLngTuple, latLngTuple); +latLngBounds = new L.LatLngBounds(latLng, latLng); +latLngBounds = new L.LatLngBounds(latLngLiteral, latLngLiteral); +latLngBounds = new L.LatLngBounds(latLngTuple, latLngTuple); + const pointTuple: L.PointTuple = [0, 0]; let point: L.Point; @@ -26,6 +38,11 @@ point = L.point(12, 13, true); point = L.point(pointTuple); point = L.point({x: 12, y: 13}); +point = new L.Point(12, 13); +point = new L.Point(12, 13, true); +point = new L.Point(pointTuple); +point = new L.Point({x: 12, y: 13}); + let distance: number; point.distanceTo(point); point.distanceTo(pointTuple); @@ -44,6 +61,11 @@ bounds = L.bounds(pointTuple, pointTuple); bounds = L.bounds([point, point]); bounds = L.bounds(boundsLiteral); +bounds = new L.Bounds(point, point); +bounds = new L.Bounds(pointTuple, pointTuple); +bounds = new L.Bounds([point, point]); +bounds = new L.Bounds(boundsLiteral); + let points: Array; points = L.LineUtil.simplify([point, point], 1); points = L.LineUtil.simplify([pointTuple, pointTuple], 2); @@ -143,6 +165,10 @@ map = L.map('foo', mapOptions); map = L.map(htmlElement); map = L.map(htmlElement, mapOptions); +map = new L.Map('foo', mapOptions); +map = new L.Map(htmlElement); +map = new L.Map(htmlElement, mapOptions); + let doesItHaveLayer: boolean; doesItHaveLayer = map.hasLayer(L.tileLayer('')); @@ -230,6 +256,10 @@ tileLayer = L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png'); tileLayer = L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png', tileLayerOptions); tileLayer = L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png?{foo}&{bar}&{abc}', {foo: 'bar', bar: (data: any) => 'foo', abc: () => ''}); +tileLayer = new L.TileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png'); +tileLayer = new L.TileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png', tileLayerOptions); +tileLayer = new L.TileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png?{foo}&{bar}&{abc}', {foo: 'bar', bar: (data: any) => 'foo', abc: () => ''}); + let eventHandler = () => {}; let domEvent: Event = {} as Event; L.DomEvent diff --git a/leaflet/tslint.json b/leaflet/tslint.json new file mode 100644 index 0000000000..377cc837d4 --- /dev/null +++ b/leaflet/tslint.json @@ -0,0 +1 @@ +{ "extends": "../tslint.json" } From 42361f5fa86df2dc0aab1d5d792359346f94410a Mon Sep 17 00:00:00 2001 From: Arne Schubert Date: Fri, 27 Jan 2017 17:55:47 +0100 Subject: [PATCH 008/104] Re-add namespace and module declaration, because other modules have dependence on that --- leaflet/index.d.ts | 2702 ++++++++++++++++++++++---------------------- 1 file changed, 1361 insertions(+), 1341 deletions(-) diff --git a/leaflet/index.d.ts b/leaflet/index.d.ts index b62695dd10..cc742ce504 100644 --- a/leaflet/index.d.ts +++ b/leaflet/index.d.ts @@ -3,1500 +3,1520 @@ // Definitions by: Alejandro Sánchez // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +/// + type NativeMouseEvent = MouseEvent; type NativeKeyboardEvent = KeyboardEvent; -import * as GeoJSONDefinition 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 ? */; -} - -export class Transformation { - constructor(a: number, b: number, c: number, d: number); - - transform(point: Point, scale?: number): Point; - - untransform(point: Point, scale?: number): Point; -} - -export namespace LineUtil { - export function simplify(points: PointExpression[], tolerance: number): Point[]; - - export function pointToSegmentDistance(p: PointExpression, p1: PointExpression, p2: PointExpression): number; - - export function closestPointOnSegment(p: PointExpression, p1: PointExpression, p2: PointExpression): Point; -} - -export namespace PolyUtil { - export function clipPolygon(points: PointExpression[], bounds: BoundsExpression, round?: boolean): Point[]; -} - -export class DomUtil { - /** - * Get Element by its ID or with the given HTML-Element - */ - static get(element: string | HTMLElement): HTMLElement; - static getStyle(el: HTMLElement, styleAttrib: string): string; - static create(tagName: string, className?: string, container?: HTMLElement): HTMLElement; - static remove(el: HTMLElement): void; - static empty(el: HTMLElement): void; - static toFront(el: HTMLElement): void; - static toBack(el: HTMLElement): void; - static hasClass(el: HTMLElement, name: string): boolean; - static addClass(el: HTMLElement, name: string): void; - static removeClass(el: HTMLElement, name: string): void; - static setClass(el: HTMLElement, name: string): void; - static getClass(el: HTMLElement): string; - static setOpacity(el: HTMLElement, opacity: number): void; - static testProp(props: string[]): string | boolean/*=false*/; - static setTransform(el: HTMLElement, offset: Point, scale?: number): void; - static setPosition(el: HTMLElement, position: Point): void; - static getPosition(el: HTMLElement): Point; - static disableTextSelection(): void; - static enableTextSelection(): void; - static disableImageDrag(): void; - static enableImageDrag(): void; - static preventOutline(el: HTMLElement): void; - static restoreOutline(): void; -} - -export abstract class CRS { - latLngToPoint(latlng: LatLngExpression, zoom: number): Point; - pointToLatLng(point: PointExpression, zoom: number): LatLng; - project(latlng: LatLngExpression): Point; - unproject(point: PointExpression): LatLng; - scale(zoom: number): number; - zoom(scale: number): number; - getProjectedBounds(zoom: number): Bounds; - distance(latlng1: LatLngExpression, latlng2: LatLngExpression): number; - wrapLatLng(latlng: LatLngExpression): LatLng; - - code: string; - wrapLng: [number, number]; - wrapLat: [number, number]; - infinite: boolean; -} - -export namespace CRS { - export const EPSG3395: CRS; - export const EPSG3857: CRS; - export const EPSG4326: CRS; - export const Earth: CRS; - export const Simple: CRS; -} - -export interface Projection { - project(latlng: LatLngExpression): Point; - unproject(point: PointExpression): LatLng; - - bounds: LatLngBounds; -} - -export namespace Projection { - export const LonLat: Projection; - export const Mercator: Projection; - export const SphericalMercator: Projection; -} - -export class LatLng { - constructor(latitude: number, longitude: number, altitude?: number); - constructor(coords: LatLngTuple | [number, number, number] | LatLngLiteral | {lat: number, lng: number, alt?: number}); - equals(otherLatLng: LatLngExpression, maxMargin?: number): boolean; - toString(): string; - distanceTo(otherLatLng: LatLngExpression): number; - wrap(): LatLng; - toBounds(sizeInMeters: number): LatLngBounds; - - lat: number; - lng: number; - alt: number; -} - -export interface LatLngLiteral { - lat: number; - lng: number; -} - -export type LatLngTuple = [number, number]; - -type LatLngExpression = LatLng | LatLngLiteral | LatLngTuple; - -export function latLng(latitude: number, longitude: number, altitude?: number): LatLng; - -export function latLng(coords: LatLngTuple | [number, number, number] | LatLngLiteral | {lat: number, lng: number, alt?: number}): LatLng; - -export class LatLngBounds { - constructor(southWest: LatLngExpression, northEast: LatLngExpression); - constructor(latlngs: LatLngBoundsLiteral); - extend(latlngOrBounds: LatLngExpression | LatLngBoundsExpression): this; - pad(bufferRatio: number): LatLngBounds; // does this modify the current instance or does it return a new one? - getCenter(): LatLng; - getSouthWest(): LatLng; - getNorthEast(): LatLng; - getNorthWest(): LatLng; - getSouthEast(): LatLng; - getWest(): number; - getSouth(): number; - getEast(): number; - getNorth(): number; - contains(otherBoundsOrLatLng: LatLngBoundsExpression | LatLngExpression): boolean; - intersects(otherBounds: LatLngBoundsExpression): boolean; - overlaps(otherBounds: BoundsExpression): boolean; // investigate if this is really bounds and not latlngbounds - toBBoxString(): string; - equals(otherBounds: LatLngBoundsExpression): boolean; - isValid(): boolean; -} - -export type LatLngBoundsLiteral = LatLngTuple[]; - -type LatLngBoundsExpression = LatLngBounds | LatLngBoundsLiteral; - -export function latLngBounds(southWest: LatLngExpression, northEast: LatLngExpression): LatLngBounds; - -export function latLngBounds(latlngs: LatLngBoundsLiteral): LatLngBounds; - -export type PointTuple = [number, number]; - -export class Point { - constructor(x: number, y: number, round?: boolean); - constructor(coords: PointTuple | {x: number, y: number}); - clone(): Point; - add(otherPoint: PointExpression): Point; // investigate if this mutates or returns a new instance - subtract(otherPoint: PointExpression): Point; - divideBy(num: number): Point; - multiplyBy(num: number): Point; - scaleBy(scale: PointExpression): Point; - unscaleBy(scale: PointExpression): Point; - round(): Point; - floor(): Point; - ceil(): Point; - distanceTo(otherPoint: PointExpression): number; - equals(otherPoint: PointExpression): boolean; - contains(otherPoint: PointExpression): boolean; - toString(): string; - x: number; - y: number; -} - -type PointExpression = Point | PointTuple; - -export function point(x: number, y: number, round?: boolean): Point; - -export function point(coords: PointTuple | {x: number, y: number}): Point; - -export type BoundsLiteral = PointTuple[]; - -export class Bounds { - constructor(topLeft: PointExpression, bottomRight: PointExpression); - constructor(points: Point[] | BoundsLiteral); - extend(point: PointExpression): this; - getCenter(round?: boolean): Point; - getBottomLeft(): Point; - getTopRight(): Point; - getSize(): Point; - contains(pointOrBounds: BoundsExpression | PointExpression): boolean; - intersects(otherBounds: BoundsExpression): boolean; - overlaps(otherBounds: BoundsExpression): boolean; - - min: Point; - max: Point; -} - -type BoundsExpression = Bounds | BoundsLiteral; - -export function bounds(topLeft: PointExpression, bottomRight: PointExpression): Bounds; - -export function bounds(points: Point[] | BoundsLiteral): Bounds; - -export type EventHandlerFn = (event: Event) => void; - -export interface EventHandlerFnMap { - [type: string]: EventHandlerFn; -} - -/** - * A set of methods shared between event-powered classes (like Map and Marker). - * Generally, events allow you to execute some function when something happens - * with an object (e.g. the user clicks on the map, causing the map to fire - * 'click' event). - */ -export abstract class Evented extends Class { - /** - * Adds a listener function (fn) to a particular event type of the object. - * You can optionally specify the context of the listener (object the this - * keyword will point to). You can also pass several space-separated types - * (e.g. 'click dblclick'). - */ - on(type: string, fn: EventHandlerFn, context?: any): this; - - /** - * Adds a set of type/listener pairs, e.g. {click: onClick, mousemove: onMouseMove} - */ - on(eventMap: EventHandlerFnMap): this; - - /** - * Removes a previously added listener function. If no function is specified, - * it will remove all the listeners of that particular event from the object. - * Note that if you passed a custom context to on, you must pass the same context - * to off in order to remove the listener. - */ - off(type: string, fn?: EventHandlerFn, context?: any): this; - - /** - * Removes a set of type/listener pairs. - */ - off(eventMap: EventHandlerFnMap): this; - - /** - * Removes all listeners to all events on the object. - */ - off(): this; - - /** - * Fires an event of the specified type. You can optionally provide a data - * object — the first argument of the listener function will contain its properties. - * The event might can optionally be propagated to event parents. - */ - fire(type: string, data?: any, propagate?: boolean): this; - - /** - * Returns true if a particular event type has any listeners attached to it. - */ - listens(type: string): boolean; - - /** - * Behaves as on(...), except the listener will only get fired once and then removed. - */ - once(type: string, fn: EventHandlerFn, context?: any): this; - - /** - * Behaves as on(...), except the listener will only get fired once and then removed. - */ - once(eventMap: EventHandlerFnMap): this; - - /** - * Adds an event parent - an Evented that will receive propagated events - */ - addEventParent(obj: Evented): this; - - /** - * Removes an event parent, so it will stop receiving propagated events - */ - removeEventParent(obj: Evented): this; - - /** - * Alias for on(...) - * - * Adds a listener function (fn) to a particular event type of the object. - * You can optionally specify the context of the listener (object the this - * keyword will point to). You can also pass several space-separated types - * (e.g. 'click dblclick'). - */ - addEventListener(type: string, fn: EventHandlerFn, context?: any): this; - - /** - * Alias for on(...) - * - * Adds a set of type/listener pairs, e.g. {click: onClick, mousemove: onMouseMove} - */ - addEventListener(eventMap: EventHandlerFnMap): this; - - /** - * Alias for off(...) - * - * Removes a previously added listener function. If no function is specified, - * it will remove all the listeners of that particular event from the object. - * Note that if you passed a custom context to on, you must pass the same context - * to off in order to remove the listener. - */ - removeEventListener(type: string, fn: EventHandlerFn, context?: any): this; - - /** - * Alias for off(...) - * - * Removes a set of type/listener pairs. - */ - removeEventListener(eventMap: EventHandlerFnMap): this; - - /** - * Alias for off() - * - * Removes all listeners to all events on the object. - */ - clearAllEventListeners(): this; - - /** - * Alias for once(...) - * - * Behaves as on(...), except the listener will only get fired once and then removed. - */ - addOneTimeEventListener(type: string, fn: EventHandlerFn, context?: any): this; - - /** - * Alias for once(...) - * - * Behaves as on(...), except the listener will only get fired once and then removed. - */ - addOneTimeEventListener(eventMap: EventHandlerFnMap): this; - - /** - * Alias for fire(...) - * - * Fires an event of the specified type. You can optionally provide a data - * object — the first argument of the listener function will contain its properties. - * The event might can optionally be propagated to event parents. - */ - fireEvent(type: string, data?: any, propagate?: boolean): this; - - /** - * Alias for listens(...) - * - * Returns true if a particular event type has any listeners attached to it. - */ - hasEventListeners(type: string): boolean; -} - -/** - * A class for making DOM elements draggable (including touch support). - * Used internally for map and marker dragging. Only works for elements - * that were positioned with [`L.DomUtil.setPosition`](#domutil-setposition). - */ -export class Draggable extends Evented { - constructor(element: HTMLElement, dragStartTarget?: HTMLElement, preventOutline?: boolean); - - enable(): void; - - disable(): void; - - finishDrag(): void; -} - -interface LayerOptions { - pane?: string; -} - -interface InteractiveLayerOptions extends LayerOptions { - interactive?: boolean; -} - -export class Layer extends Evented { - constructor(options?: LayerOptions); - addTo(map: Map): this; - remove(): this; - removeFrom(map: Map): this; - getPane(name?: string): HTMLElement; - - // Popup methods - bindPopup(content: (layer: Layer) => Content | Content | Popup, options?: PopupOptions): this; - unbindPopup(): this; - openPopup(latlng?: LatLngExpression): this; - closePopup(): this; - togglePopup(): this; - isPopupOpen(): boolean; - setPopupContent(content: Content | Popup): this; - getPopup(): Popup; - - // Tooltip methods - bindTooltip(content: (layer: Layer) => Content | Tooltip | Content, options?: TooltipOptions): this; - unbindTooltip(): this; - openTooltip(latlng?: LatLngExpression): this; - closeTooltip(): this; - toggleTooltip(): this; - isTooltipOpen(): boolean; - setTooltipContent(content: Content | Tooltip): this; - getTooltip(): Tooltip; - - // Extension methods - onAdd(map: Map): this; - onRemove(map: Map): this; - getEvents(): {[name: string]: (event: Event) => void}; - getAttribution(): string; - beforeAdd(map: Map): this; -} - -export interface GridLayerOptions { - tileSize?: number | Point; - opacity?: number; - updateWhenIdle?: boolean; - updateWhenZooming?: boolean; - updateInterval?: number; - attribution?: string; - zIndex?: number; - bounds?: LatLngBoundsExpression; - minZoom?: number; - maxZoom?: number; - noWrap?: boolean; - pane?: string; - className?: string; - keepBuffer?: number; -} - -export class GridLayer extends Layer { - constructor(options?: GridLayerOptions); - bringToFront(): this; - bringToBack(): this; - getAttribution(): string; - getContainer(): HTMLElement; - setOpacity(opacity: number): this; - setZIndex(zIndex: number): this; - isLoading(): boolean; - redraw(): this; - getTileSize(): Point; -} - -export function gridLayer(options?: GridLayerOptions): GridLayer; - -export interface TileLayerOptions extends GridLayerOptions { - minZoom?: number; - maxZoom?: number; - maxNativeZoom?: number; - subdomains?: string | string[]; - errorTileUrl?: string; - zoomOffset?: number; - tms?: boolean; - zoomReverse?: boolean; - detectRetina?: boolean; - crossOrigin?: boolean; - [name: string]: any; -} - -export class TileLayer extends GridLayer { - constructor(urlTemplate: string, options?: TileLayerOptions); - setUrl(url: string, noRedraw?: boolean): this; - - options: TileLayerOptions; -} - -export function tileLayer(urlTemplate: string, options?: TileLayerOptions): TileLayer; - - -export namespace TileLayer { - export class WMS extends TileLayer { - constructor(baseUrl: string, options: WMSOptions); - setParams(params: WMSParams, noRedraw?: boolean): this; - - wmsParams: WMSParams; - options: WMSOptions; +// Import to avoid conflicts with the GeoJSON class of leaflet +import GeoJSONFeature = GeoJSON.Feature; +import GeoJSONLineString = GeoJSON.LineString; +import GeoJSONMultiLineString = GeoJSON.MultiLineString; +import GeoJSONPolygon = GeoJSON.Polygon; +import GeoJSONMultiPolygon = GeoJSON.MultiPolygon; +import GeoJSONFeatureCollection = GeoJSON.FeatureCollection; +import GeoJSONGeometryObject = GeoJSON.GeometryObject; +import GeoJSONGeometryCollection = GeoJSON.GeometryCollection; +import GeoJSONPoint = GeoJSON.Point; +import GeoJSONMultiPoint = GeoJSON.MultiPoint; +import GeoJSONGeoJsonObject = GeoJSON.GeoJsonObject; + +declare namespace L { + 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 ? */; } -} -export interface WMSOptions extends TileLayerOptions { - layers: string; - styles?: string; - format?: string; - transparent?: boolean; - version?: string; - crs?: CRS; - uppercase?: boolean; -} + export class Transformation { + constructor(a: number, b: number, c: number, d: number); -export interface WMSParams { - format?: string; - layers: string; - request?: string; - service?: string; - styles?: string; - version?: string; - transparent?: boolean; - width?: number; - height?: number; -} + transform(point: Point, scale?: number): Point; -export namespace tileLayer { - export function wms(baseUrl: string, options?: WMSOptions): TileLayer.WMS; -} + untransform(point: Point, scale?: number): Point; + } -export interface ImageOverlayOptions extends LayerOptions { - opacity?: number; - alt?: string; - interactive?: boolean; - attribution?: string; - crossOrigin?: boolean; -} + export namespace LineUtil { + export function simplify(points: PointExpression[], tolerance: number): Point[]; -export class ImageOverlay extends Layer { - constructor(imageUrl: string, bounds: LatLngBoundsExpression, options?: ImageOverlayOptions); - setOpacity(opacity: number): this; - bringToFront(): this; - bringToBack(): this; - setUrl(url: string): this; + export function pointToSegmentDistance(p: PointExpression, p1: PointExpression, p2: PointExpression): number; - /** Update the bounds that this ImageOverlay covers */ - setBounds(bounds: LatLngBounds): this; + export function closestPointOnSegment(p: PointExpression, p1: PointExpression, p2: PointExpression): Point; + } - /** Get the bounds that this ImageOverlay covers */ - getBounds(): LatLngBounds; + export namespace PolyUtil { + export function clipPolygon(points: PointExpression[], bounds: BoundsExpression, round?: boolean): Point[]; + } - /** Get the img element that represents the ImageOverlay on the map */ - getElement(): HTMLImageElement; + export class DomUtil { + /** + * Get Element by its ID or with the given HTML-Element + */ + static get(element: string | HTMLElement): HTMLElement; + static getStyle(el: HTMLElement, styleAttrib: string): string; + static create(tagName: string, className?: string, container?: HTMLElement): HTMLElement; + static remove(el: HTMLElement): void; + static empty(el: HTMLElement): void; + static toFront(el: HTMLElement): void; + static toBack(el: HTMLElement): void; + static hasClass(el: HTMLElement, name: string): boolean; + static addClass(el: HTMLElement, name: string): void; + static removeClass(el: HTMLElement, name: string): void; + static setClass(el: HTMLElement, name: string): void; + static getClass(el: HTMLElement): string; + static setOpacity(el: HTMLElement, opacity: number): void; + static testProp(props: string[]): string | boolean/*=false*/; + static setTransform(el: HTMLElement, offset: Point, scale?: number): void; + static setPosition(el: HTMLElement, position: Point): void; + static getPosition(el: HTMLElement): Point; + static disableTextSelection(): void; + static enableTextSelection(): void; + static disableImageDrag(): void; + static enableImageDrag(): void; + static preventOutline(el: HTMLElement): void; + static restoreOutline(): void; + } - options: ImageOverlayOptions; -} + export abstract class CRS { + latLngToPoint(latlng: LatLngExpression, zoom: number): Point; + pointToLatLng(point: PointExpression, zoom: number): LatLng; + project(latlng: LatLngExpression): Point; + unproject(point: PointExpression): LatLng; + scale(zoom: number): number; + zoom(scale: number): number; + getProjectedBounds(zoom: number): Bounds; + distance(latlng1: LatLngExpression, latlng2: LatLngExpression): number; + wrapLatLng(latlng: LatLngExpression): LatLng; -export function imageOverlay(imageUrl: string, bounds: LatLngBoundsExpression, options?: ImageOverlayOptions): ImageOverlay; + code: string; + wrapLng: [number, number]; + wrapLat: [number, number]; + infinite: boolean; + } -export type LineCapShape = 'butt' | 'round' | 'square' | 'inherit'; + export namespace CRS { + export const EPSG3395: CRS; + export const EPSG3857: CRS; + export const EPSG4326: CRS; + export const Earth: CRS; + export const Simple: CRS; + } -export type LineJoinShape = 'miter' | 'round' | 'bevel' | 'inherit'; + export interface Projection { + project(latlng: LatLngExpression): Point; + unproject(point: PointExpression): LatLng; -export type FillRule = 'nonzero' | 'evenodd' | 'inherit'; + bounds: LatLngBounds; + } -export interface PathOptions extends InteractiveLayerOptions { - stroke?: boolean; - color?: string; - weight?: number; - opacity?: number; - lineCap?: LineCapShape; - lineJoin?: LineJoinShape; - dashArray?: string; - dashOffset?: string; - fill?: boolean; - fillColor?: string; - fillOpacity?: number; - fillRule?: FillRule; - renderer?: Renderer; - className?: string; -} + export namespace Projection { + export const LonLat: Projection; + export const Mercator: Projection; + export const SphericalMercator: Projection; + } -export abstract class Path extends Layer { - redraw(): this; - setStyle(style: PathOptions): this; - bringToFront(): this; - bringToBack(): this; + export class LatLng { + constructor(latitude: number, longitude: number, altitude?: number); + constructor(coords: LatLngTuple | [number, number, number] | LatLngLiteral | {lat: number, lng: number, alt?: number}); + equals(otherLatLng: LatLngExpression, maxMargin?: number): boolean; + toString(): string; + distanceTo(otherLatLng: LatLngExpression): number; + wrap(): LatLng; + toBounds(sizeInMeters: number): LatLngBounds; - options: PathOptions; -} + lat: number; + lng: number; + alt: number; + } -export interface PolylineOptions extends PathOptions { - smoothFactor?: number; - noClip?: boolean; -} + export interface LatLngLiteral { + lat: number; + lng: number; + } -declare class InternalPolyline extends Path { - getLatLngs(): LatLng[]; - setLatLngs(latlngs: LatLngExpression[]): this; - isEmpty(): boolean; - getCenter(): LatLng; - getBounds(): LatLngBounds; - addLatLng(latlng: LatLngExpression | LatLngExpression[]): this; + export type LatLngTuple = [number, number]; - options: PolylineOptions; -} + type LatLngExpression = LatLng | LatLngLiteral | LatLngTuple; -export class Polyline extends InternalPolyline { - constructor(latlngs: LatLngExpression[], options?: PolylineOptions); - toGeoJSON(): GeoJSONDefinition.Feature; + export function latLng(latitude: number, longitude: number, altitude?: number): LatLng; - feature: GeoJSONDefinition.Feature; -} + export function latLng(coords: LatLngTuple | [number, number, number] | LatLngLiteral | {lat: number, lng: number, alt?: number}): LatLng; -export function polyline(latlngs: LatLngExpression[], options?: PolylineOptions): Polyline; + export class LatLngBounds { + constructor(southWest: LatLngExpression, northEast: LatLngExpression); + constructor(latlngs: LatLngBoundsLiteral); + extend(latlngOrBounds: LatLngExpression | LatLngBoundsExpression): this; + pad(bufferRatio: number): LatLngBounds; // does this modify the current instance or does it return a new one? + getCenter(): LatLng; + getSouthWest(): LatLng; + getNorthEast(): LatLng; + getNorthWest(): LatLng; + getSouthEast(): LatLng; + getWest(): number; + getSouth(): number; + getEast(): number; + getNorth(): number; + contains(otherBoundsOrLatLng: LatLngBoundsExpression | LatLngExpression): boolean; + intersects(otherBounds: LatLngBoundsExpression): boolean; + overlaps(otherBounds: BoundsExpression): boolean; // investigate if this is really bounds and not latlngbounds + toBBoxString(): string; + equals(otherBounds: LatLngBoundsExpression): boolean; + isValid(): boolean; + } -export class Polygon extends InternalPolyline { - constructor(latlngs: LatLngExpression[], options?: PolylineOptions); - toGeoJSON(): GeoJSONDefinition.Feature; + export type LatLngBoundsLiteral = LatLngTuple[]; - feature: GeoJSONDefinition.Feature; -} + type LatLngBoundsExpression = LatLngBounds | LatLngBoundsLiteral; -export function polygon(latlngs: LatLngExpression[], options?: PolylineOptions): Polygon; + export function latLngBounds(southWest: LatLngExpression, northEast: LatLngExpression): LatLngBounds; -export class Rectangle extends Polygon { - constructor(latLngBounds: LatLngBoundsExpression, options?: PolylineOptions); - setBounds(latLngBounds: LatLngBoundsExpression): this; -} + export function latLngBounds(latlngs: LatLngBoundsLiteral): LatLngBounds; -export function rectangle(latLngBounds: LatLngBoundsExpression, options?: PolylineOptions): Rectangle; + export type PointTuple = [number, number]; -export interface CircleMarkerOptions extends PathOptions { - radius?: number; -} + export class Point { + constructor(x: number, y: number, round?: boolean); + constructor(coords: PointTuple | {x: number, y: number}); + clone(): Point; + add(otherPoint: PointExpression): Point; // investigate if this mutates or returns a new instance + subtract(otherPoint: PointExpression): Point; + divideBy(num: number): Point; + multiplyBy(num: number): Point; + scaleBy(scale: PointExpression): Point; + unscaleBy(scale: PointExpression): Point; + round(): Point; + floor(): Point; + ceil(): Point; + distanceTo(otherPoint: PointExpression): number; + equals(otherPoint: PointExpression): boolean; + contains(otherPoint: PointExpression): boolean; + toString(): string; + x: number; + y: number; + } -export class CircleMarker extends Path { - constructor(latlng: LatLngExpression, options?: CircleMarkerOptions); - toGeoJSON(): GeoJSONDefinition.Feature; - setLatLng(latLng: LatLngExpression): this; - getLatLng(): LatLng; - setRadius(radius: number): this; - getRadius(): number; + type PointExpression = Point | PointTuple; - options: CircleMarkerOptions; - feature: GeoJSONDefinition.Feature; -} + export function point(x: number, y: number, round?: boolean): Point; -export function circleMarker(latlng: LatLngExpression, options?: CircleMarkerOptions): CircleMarker; + export function point(coords: PointTuple | {x: number, y: number}): Point; + export type BoundsLiteral = PointTuple[]; -export class Circle extends CircleMarker { - constructor(latlng: LatLngExpression, options?: CircleMarkerOptions); - constructor(latlng: LatLngExpression, radius: number, options?: CircleMarkerOptions); // deprecated! - getBounds(): LatLngBounds; -} + export class Bounds { + constructor(topLeft: PointExpression, bottomRight: PointExpression); + constructor(points: Point[] | BoundsLiteral); + extend(point: PointExpression): this; + getCenter(round?: boolean): Point; + getBottomLeft(): Point; + getTopRight(): Point; + getSize(): Point; + contains(pointOrBounds: BoundsExpression | PointExpression): boolean; + intersects(otherBounds: BoundsExpression): boolean; + overlaps(otherBounds: BoundsExpression): boolean; -export function circle(latlng: LatLngExpression, options?: CircleMarkerOptions): Circle; -export function circle(latlng: LatLngExpression, radius: number, options?: CircleMarkerOptions): Circle; // deprecated! + min: Point; + max: Point; + } -export interface RendererOptions extends LayerOptions { - padding?: number; -} + type BoundsExpression = Bounds | BoundsLiteral; -export class Renderer extends Layer { - constructor(options?: RendererOptions); + export function bounds(topLeft: PointExpression, bottomRight: PointExpression): Bounds; - options: RendererOptions; -} + export function bounds(points: Point[] | BoundsLiteral): Bounds; -export class SVG extends Renderer {} + export type EventHandlerFn = (event: Event) => void; -export namespace SVG { - export function create(name: string): SVGElement; + export interface EventHandlerFnMap { + [type: string]: EventHandlerFn; + } - export function pointsToPath(rings: PointExpression[], close: boolean): string; -} - -export function svg(options?: RendererOptions): SVG; - -export class Canvas extends Renderer {} - -export function canvas(options?: RendererOptions): Canvas; - -/** - * Used to group several layers and handle them as one. - * If you add it to the map, any layers added or removed from the group will be - * added/removed on the map as well. Extends Layer. - */ -export class LayerGroup extends Layer { - constructor(layers: Layer[]); /** - * Returns a GeoJSON representation of the layer group (as a GeoJSON GeometryCollection, GeoJSONDefinition.FeatureCollection or Multipoint). + * A set of methods shared between event-powered classes (like Map and Marker). + * Generally, events allow you to execute some function when something happens + * with an object (e.g. the user clicks on the map, causing the map to fire + * 'click' event). */ - toGeoJSON(): GeoJSONDefinition.FeatureCollection | GeoJSONDefinition.Feature; + export abstract class Evented extends Class { + /** + * Adds a listener function (fn) to a particular event type of the object. + * You can optionally specify the context of the listener (object the this + * keyword will point to). You can also pass several space-separated types + * (e.g. 'click dblclick'). + */ + on(type: string, fn: EventHandlerFn, context?: any): this; + + /** + * Adds a set of type/listener pairs, e.g. {click: onClick, mousemove: onMouseMove} + */ + on(eventMap: EventHandlerFnMap): this; + + /** + * Removes a previously added listener function. If no function is specified, + * it will remove all the listeners of that particular event from the object. + * Note that if you passed a custom context to on, you must pass the same context + * to off in order to remove the listener. + */ + off(type: string, fn?: EventHandlerFn, context?: any): this; + + /** + * Removes a set of type/listener pairs. + */ + off(eventMap: EventHandlerFnMap): this; + + /** + * Removes all listeners to all events on the object. + */ + off(): this; + + /** + * Fires an event of the specified type. You can optionally provide a data + * object — the first argument of the listener function will contain its properties. + * The event might can optionally be propagated to event parents. + */ + fire(type: string, data?: any, propagate?: boolean): this; + + /** + * Returns true if a particular event type has any listeners attached to it. + */ + listens(type: string): boolean; + + /** + * Behaves as on(...), except the listener will only get fired once and then removed. + */ + once(type: string, fn: EventHandlerFn, context?: any): this; + + /** + * Behaves as on(...), except the listener will only get fired once and then removed. + */ + once(eventMap: EventHandlerFnMap): this; + + /** + * Adds an event parent - an Evented that will receive propagated events + */ + addEventParent(obj: Evented): this; + + /** + * Removes an event parent, so it will stop receiving propagated events + */ + removeEventParent(obj: Evented): this; + + /** + * Alias for on(...) + * + * Adds a listener function (fn) to a particular event type of the object. + * You can optionally specify the context of the listener (object the this + * keyword will point to). You can also pass several space-separated types + * (e.g. 'click dblclick'). + */ + addEventListener(type: string, fn: EventHandlerFn, context?: any): this; + + /** + * Alias for on(...) + * + * Adds a set of type/listener pairs, e.g. {click: onClick, mousemove: onMouseMove} + */ + addEventListener(eventMap: EventHandlerFnMap): this; + + /** + * Alias for off(...) + * + * Removes a previously added listener function. If no function is specified, + * it will remove all the listeners of that particular event from the object. + * Note that if you passed a custom context to on, you must pass the same context + * to off in order to remove the listener. + */ + removeEventListener(type: string, fn: EventHandlerFn, context?: any): this; + + /** + * Alias for off(...) + * + * Removes a set of type/listener pairs. + */ + removeEventListener(eventMap: EventHandlerFnMap): this; + + /** + * Alias for off() + * + * Removes all listeners to all events on the object. + */ + clearAllEventListeners(): this; + + /** + * Alias for once(...) + * + * Behaves as on(...), except the listener will only get fired once and then removed. + */ + addOneTimeEventListener(type: string, fn: EventHandlerFn, context?: any): this; + + /** + * Alias for once(...) + * + * Behaves as on(...), except the listener will only get fired once and then removed. + */ + addOneTimeEventListener(eventMap: EventHandlerFnMap): this; + + /** + * Alias for fire(...) + * + * Fires an event of the specified type. You can optionally provide a data + * object — the first argument of the listener function will contain its properties. + * The event might can optionally be propagated to event parents. + */ + fireEvent(type: string, data?: any, propagate?: boolean): this; + + /** + * Alias for listens(...) + * + * Returns true if a particular event type has any listeners attached to it. + */ + hasEventListeners(type: string): boolean; + } /** - * Adds the given layer to the group. + * A class for making DOM elements draggable (including touch support). + * Used internally for map and marker dragging. Only works for elements + * that were positioned with [`L.DomUtil.setPosition`](#domutil-setposition). */ - addLayer(layer: Layer): this; + export class Draggable extends Evented { + constructor(element: HTMLElement, dragStartTarget?: HTMLElement, preventOutline?: boolean); + + enable(): void; + + disable(): void; + + finishDrag(): void; + } + + interface LayerOptions { + pane?: string; + } + + interface InteractiveLayerOptions extends LayerOptions { + interactive?: boolean; + } + + export class Layer extends Evented { + constructor(options?: LayerOptions); + addTo(map: Map): this; + remove(): this; + removeFrom(map: Map): this; + getPane(name?: string): HTMLElement; + + // Popup methods + bindPopup(content: (layer: Layer) => Content | Content | Popup, options?: PopupOptions): this; + unbindPopup(): this; + openPopup(latlng?: LatLngExpression): this; + closePopup(): this; + togglePopup(): this; + isPopupOpen(): boolean; + setPopupContent(content: Content | Popup): this; + getPopup(): Popup; + + // Tooltip methods + bindTooltip(content: (layer: Layer) => Content | Tooltip | Content, options?: TooltipOptions): this; + unbindTooltip(): this; + openTooltip(latlng?: LatLngExpression): this; + closeTooltip(): this; + toggleTooltip(): this; + isTooltipOpen(): boolean; + setTooltipContent(content: Content | Tooltip): this; + getTooltip(): Tooltip; + + // Extension methods + onAdd(map: Map): this; + onRemove(map: Map): this; + getEvents(): {[name: string]: (event: Event) => void}; + getAttribution(): string; + beforeAdd(map: Map): this; + } + + export interface GridLayerOptions { + tileSize?: number | Point; + opacity?: number; + updateWhenIdle?: boolean; + updateWhenZooming?: boolean; + updateInterval?: number; + attribution?: string; + zIndex?: number; + bounds?: LatLngBoundsExpression; + minZoom?: number; + maxZoom?: number; + noWrap?: boolean; + pane?: string; + className?: string; + keepBuffer?: number; + } + + export class GridLayer extends Layer { + constructor(options?: GridLayerOptions); + bringToFront(): this; + bringToBack(): this; + getAttribution(): string; + getContainer(): HTMLElement; + setOpacity(opacity: number): this; + setZIndex(zIndex: number): this; + isLoading(): boolean; + redraw(): this; + getTileSize(): Point; + } + + export function gridLayer(options?: GridLayerOptions): GridLayer; + + export interface TileLayerOptions extends GridLayerOptions { + minZoom?: number; + maxZoom?: number; + maxNativeZoom?: number; + subdomains?: string | string[]; + errorTileUrl?: string; + zoomOffset?: number; + tms?: boolean; + zoomReverse?: boolean; + detectRetina?: boolean; + crossOrigin?: boolean; + [name: string]: any; + } + + export class TileLayer extends GridLayer { + constructor(urlTemplate: string, options?: TileLayerOptions); + setUrl(url: string, noRedraw?: boolean): this; + + options: TileLayerOptions; + } + + export function tileLayer(urlTemplate: string, options?: TileLayerOptions): TileLayer; + + + export namespace TileLayer { + export class WMS extends TileLayer { + constructor(baseUrl: string, options: WMSOptions); + setParams(params: WMSParams, noRedraw?: boolean): this; + + wmsParams: WMSParams; + options: WMSOptions; + } + } + + export interface WMSOptions extends TileLayerOptions { + layers: string; + styles?: string; + format?: string; + transparent?: boolean; + version?: string; + crs?: CRS; + uppercase?: boolean; + } + + export interface WMSParams { + format?: string; + layers: string; + request?: string; + service?: string; + styles?: string; + version?: string; + transparent?: boolean; + width?: number; + height?: number; + } + + export namespace tileLayer { + export function wms(baseUrl: string, options?: WMSOptions): TileLayer.WMS; + } + + export interface ImageOverlayOptions extends LayerOptions { + opacity?: number; + alt?: string; + interactive?: boolean; + attribution?: string; + crossOrigin?: boolean; + } + + export class ImageOverlay extends Layer { + constructor(imageUrl: string, bounds: LatLngBoundsExpression, options?: ImageOverlayOptions); + setOpacity(opacity: number): this; + bringToFront(): this; + bringToBack(): this; + setUrl(url: string): this; + + /** Update the bounds that this ImageOverlay covers */ + setBounds(bounds: LatLngBounds): this; + + /** Get the bounds that this ImageOverlay covers */ + getBounds(): LatLngBounds; + + /** Get the img element that represents the ImageOverlay on the map */ + getElement(): HTMLImageElement; + + options: ImageOverlayOptions; + } + + export function imageOverlay(imageUrl: string, bounds: LatLngBoundsExpression, options?: ImageOverlayOptions): ImageOverlay; + + export type LineCapShape = 'butt' | 'round' | 'square' | 'inherit'; + + export type LineJoinShape = 'miter' | 'round' | 'bevel' | 'inherit'; + + export type FillRule = 'nonzero' | 'evenodd' | 'inherit'; + + export interface PathOptions extends InteractiveLayerOptions { + stroke?: boolean; + color?: string; + weight?: number; + opacity?: number; + lineCap?: LineCapShape; + lineJoin?: LineJoinShape; + dashArray?: string; + dashOffset?: string; + fill?: boolean; + fillColor?: string; + fillOpacity?: number; + fillRule?: FillRule; + renderer?: Renderer; + className?: string; + } + + export abstract class Path extends Layer { + redraw(): this; + setStyle(style: PathOptions): this; + bringToFront(): this; + bringToBack(): this; + + options: PathOptions; + } + + export interface PolylineOptions extends PathOptions { + smoothFactor?: number; + noClip?: boolean; + } + + class InternalPolyline extends Path { + getLatLngs(): LatLng[]; + setLatLngs(latlngs: LatLngExpression[]): this; + isEmpty(): boolean; + getCenter(): LatLng; + getBounds(): LatLngBounds; + addLatLng(latlng: LatLngExpression | LatLngExpression[]): this; + + options: PolylineOptions; + } + + export class Polyline extends InternalPolyline { + constructor(latlngs: LatLngExpression[], options?: PolylineOptions); + toGeoJSON(): GeoJSONFeature; + + feature: GeoJSONFeature; + } + + export function polyline(latlngs: LatLngExpression[], options?: PolylineOptions): Polyline; + + export class Polygon extends InternalPolyline { + constructor(latlngs: LatLngExpression[], options?: PolylineOptions); + toGeoJSON(): GeoJSONFeature; + + feature: GeoJSONFeature; + } + + export function polygon(latlngs: LatLngExpression[], options?: PolylineOptions): Polygon; + + export class Rectangle extends Polygon { + constructor(latLngBounds: LatLngBoundsExpression, options?: PolylineOptions); + setBounds(latLngBounds: LatLngBoundsExpression): this; + } + + export function rectangle(latLngBounds: LatLngBoundsExpression, options?: PolylineOptions): Rectangle; + + export interface CircleMarkerOptions extends PathOptions { + radius?: number; + } + + export class CircleMarker extends Path { + constructor(latlng: LatLngExpression, options?: CircleMarkerOptions); + toGeoJSON(): GeoJSONFeature; + setLatLng(latLng: LatLngExpression): this; + getLatLng(): LatLng; + setRadius(radius: number): this; + getRadius(): number; + + options: CircleMarkerOptions; + feature: GeoJSONFeature; + } + + export function circleMarker(latlng: LatLngExpression, options?: CircleMarkerOptions): CircleMarker; + + + export class Circle extends CircleMarker { + constructor(latlng: LatLngExpression, options?: CircleMarkerOptions); + constructor(latlng: LatLngExpression, radius: number, options?: CircleMarkerOptions); // deprecated! + getBounds(): LatLngBounds; + } + + export function circle(latlng: LatLngExpression, options?: CircleMarkerOptions): Circle; + export function circle(latlng: LatLngExpression, radius: number, options?: CircleMarkerOptions): Circle; // deprecated! + + export interface RendererOptions extends LayerOptions { + padding?: number; + } + + export class Renderer extends Layer { + constructor(options?: RendererOptions); + + options: RendererOptions; + } + + export class SVG extends Renderer {} + + export namespace SVG { + export function create(name: string): SVGElement; + + export function pointsToPath(rings: PointExpression[], close: boolean): string; + } + + export function svg(options?: RendererOptions): SVG; + + export class Canvas extends Renderer {} + + export function canvas(options?: RendererOptions): Canvas; /** - * Removes the layer with the given internal ID or the given layer from the group. + * Used to group several layers and handle them as one. + * If you add it to the map, any layers added or removed from the group will be + * added/removed on the map as well. Extends Layer. */ - removeLayer(layer: number | Layer): this; + export class LayerGroup extends Layer { + constructor(layers: Layer[]); + /** + * Returns a GeoJSON representation of the layer group (as a GeoJSON GeometryCollection, GeoJSONFeatureCollection or Multipoint). + */ + toGeoJSON(): GeoJSONFeatureCollection | GeoJSONFeature; + + /** + * Adds the given layer to the group. + */ + addLayer(layer: Layer): this; + + /** + * Removes the layer with the given internal ID or the given layer from the group. + */ + removeLayer(layer: number | Layer): this; + + /** + * Returns true if the given layer is currently added to the group. + */ + hasLayer(layer: Layer): boolean; + + /** + * Removes all the layers from the group. + */ + clearLayers(): this; + + /** + * Calls methodName on every layer contained in this group, passing any additional parameters. + * Has no effect if the layers contained do not implement methodName. + */ + invoke(methodName: string, ...params: any[]): this; + + /** + * Iterates over the layers of the group, + * optionally specifying context of the iterator function. + */ + eachLayer(fn: (layer: Layer) => void, context?: any): this; + + /** + * Returns the layer with the given internal ID. + */ + getLayer(id: number): Layer; + + /** + * Returns an array of all the layers added to the group. + */ + getLayers(): Layer[]; + + /** + * Calls setZIndex on every layer contained in this group, passing the z-index. + */ + setZIndex(zIndex: number): this; + + /** + * Returns the internal ID for a layer + */ + getLayerId(layer: Layer): number; + + feature: GeoJSONFeatureCollection | GeoJSONFeature; + } /** - * Returns true if the given layer is currently added to the group. + * Create a layer group, optionally given an initial set of layers. */ - hasLayer(layer: Layer): boolean; + export function layerGroup(layers: Layer[]): LayerGroup; /** - * Removes all the layers from the group. + * Extended LayerGroup that also has mouse events (propagated from + * members of the group) and a shared bindPopup method. */ - clearLayers(): this; + export class FeatureGroup extends LayerGroup { + /** + * Sets the given path options to each layer of the group that has a setStyle method. + */ + setStyle(style: PathOptions): this; + + /** + * Brings the layer group to the top of all other layers + */ + bringToFront(): this; + + /** + * Brings the layer group to the top [sic] of all other layers + */ + bringToBack(): this; + + /** + * Returns the LatLngBounds of the Feature Group (created from + * bounds and coordinates of its children). + */ + getBounds(): LatLngBounds; + } /** - * Calls methodName on every layer contained in this group, passing any additional parameters. - * Has no effect if the layers contained do not implement methodName. + * Create a feature group, optionally given an initial set of layers. */ - invoke(methodName: string, ...params: any[]): this; + export function featureGroup(layers?: Layer[]): FeatureGroup; - /** - * Iterates over the layers of the group, - * optionally specifying context of the iterator function. - */ - eachLayer(fn: (layer: Layer) => void, context?: any): this; + type StyleFunction = (feature: GeoJSONFeature) => PathOptions; - /** - * Returns the layer with the given internal ID. - */ - getLayer(id: number): Layer; - - /** - * Returns an array of all the layers added to the group. - */ - getLayers(): Layer[]; - - /** - * Calls setZIndex on every layer contained in this group, passing the z-index. - */ - setZIndex(zIndex: number): this; - - /** - * Returns the internal ID for a layer - */ - getLayerId(layer: Layer): number; - - feature: GeoJSONDefinition.FeatureCollection | GeoJSONDefinition.Feature; -} - -/** - * Create a layer group, optionally given an initial set of layers. - */ -export function layerGroup(layers: Layer[]): LayerGroup; - -/** - * Extended LayerGroup that also has mouse events (propagated from - * members of the group) and a shared bindPopup method. - */ -export class FeatureGroup extends LayerGroup { - /** - * Sets the given path options to each layer of the group that has a setStyle method. - */ - setStyle(style: PathOptions): this; - - /** - * Brings the layer group to the top of all other layers - */ - bringToFront(): this; - - /** - * Brings the layer group to the top [sic] of all other layers - */ - bringToBack(): this; - - /** - * Returns the LatLngBounds of the Feature Group (created from - * bounds and coordinates of its children). - */ - getBounds(): LatLngBounds; -} - -/** - * Create a feature group, optionally given an initial set of layers. - */ -export function featureGroup(layers?: Layer[]): FeatureGroup; - -type StyleFunction = (feature: GeoJSONDefinition.Feature) => PathOptions; - -export interface GeoJSONOptions extends LayerOptions { - /** - * A Function defining how GeoJSON points spawn Leaflet layers. - * It is internally called when data is added, passing the GeoJSON point - * feature and its LatLng. - * - * The default is to spawn a default Marker: - * - * ``` - * function(geoJsonPoint, latlng) { + export interface GeoJSONOptions extends LayerOptions { + /** + * A Function defining how GeoJSON points spawn Leaflet layers. + * It is internally called when data is added, passing the GeoJSON point + * feature and its LatLng. + * + * The default is to spawn a default Marker: + * + * ``` + * function(geoJsonPoint, latlng) { * return L.marker(latlng); * } - * ``` - */ - pointToLayer?: (geoJsonPoint: GeoJSONDefinition.Feature, latlng: LatLng) => Layer; // should import GeoJSON typings + * ``` + */ + pointToLayer?: (geoJsonPoint: GeoJSONFeature, latlng: LatLng) => Layer; // should import GeoJSON typings - /** - * A Function defining the Path options for styling GeoJSON lines and polygons, - * called internally when data is added. - * - * The default value is to not override any defaults: - * - * ``` - * function (geoJsonFeature) { + /** + * A Function defining the Path options for styling GeoJSON lines and polygons, + * called internally when data is added. + * + * The default value is to not override any defaults: + * + * ``` + * function (geoJsonFeature) { * return {} * } - * ``` - */ - style?: StyleFunction; + * ``` + */ + style?: StyleFunction; - /** - * A Function that will be called once for each created Feature, after it - * has been created and styled. Useful for attaching events and popups to features. - * - * The default is to do nothing with the newly created layers: - * - * ``` - * function (feature, layer) {} - * ``` - */ - onEachFeature?: (feature: GeoJSONDefinition.Feature, layer: Layer) => void; + /** + * A Function that will be called once for each created Feature, after it + * has been created and styled. Useful for attaching events and popups to features. + * + * The default is to do nothing with the newly created layers: + * + * ``` + * function (feature, layer) {} + * ``` + */ + onEachFeature?: (feature: GeoJSONFeature, layer: Layer) => void; - /** - * A Function that will be used to decide whether to show a feature or not. - * - * The default is to show all features: - * - * ``` - * function (geoJsonFeature) { + /** + * A Function that will be used to decide whether to show a feature or not. + * + * The default is to show all features: + * + * ``` + * function (geoJsonFeature) { * return true; * } - * ``` - */ - filter?: (geoJsonFeature: GeoJSONDefinition.Feature) => boolean; + * ``` + */ + filter?: (geoJsonFeature: GeoJSONFeature) => boolean; - /** - * A Function that will be used for converting GeoJSON coordinates to LatLngs. - * The default is the coordsToLatLng static method. - */ - coordsToLatLng?: (coords: [number, number] | [number, number, number]) => LatLng; // check if LatLng has an altitude property -} - -/** - * Represents a GeoJSON object or an array of GeoJSON objects. - * Allows you to parse GeoJSON data and display it on the map. Extends FeatureGroup. - */ -export class GeoJSON { - /** - * Creates a Layer from a given GeoJSON feature. Can use a custom pointToLayer - * and/or coordsToLatLng functions if provided as options. - */ - static geometryToLayer(featureData: GeoJSONDefinition.Feature, options?: GeoJSONOptions): Layer; - - /** - * Creates a LatLng object from an array of 2 numbers (longitude, latitude) or - * 3 numbers (longitude, latitude, altitude) used in GeoJSON for points. - */ - static coordsToLatLng(coords: [number, number] | [number, number, number]): LatLng; - - /** - * Creates a multidimensional array of LatLngs from a GeoJSON coordinates array. - * levelsDeep specifies the nesting level (0 is for an array of points, 1 for an array of - * arrays of points, etc., 0 by default). - * Can use a custom coordsToLatLng function. - */ - static coordsToLatLngs( - coords: any[], - levelsDeep?: number, - coordsToLatLng?: (coords: [number, number] | [number, number, number]) => LatLng): any[]; // Using any[] to avoid artificially limiting valid calls - - /** - * Reverse of coordsToLatLng - */ - static latLngToCoords(latlng: LatLng): [number, number, number]; // A three tuple can be assigned to a two or three tuple - - - /** - * Reverse of coordsToLatLngs closed determines whether the first point should be - * appended to the end of the array to close the feature, only used when levelsDeep is 0. - * False by default. - */ - static latLngsToCoords(latlngs: any[], levelsDeep?: number, closed?: boolean): any[]; // Using any[] to avoid artificially limiting valid calls - - /** - * Normalize GeoJSON geometries/features into GeoJSON features. - */ - static asFeature(geojson: GeoJSONDefinition.Feature | GeoJSONDefinition.GeometryObject): GeoJSONDefinition.Feature; - - constructor(geojson?: GeoJSONDefinition.GeoJsonObject, options?: GeoJSONOptions) - /** - * Adds a GeoJSON object to the layer. - */ - addData(data: GeoJSONDefinition.GeoJsonObject): Layer; - - /** - * Resets the given vector layer's style to the original GeoJSON style, - * useful for resetting style after hover events. - */ - resetStyle(layer: Layer): Layer; - - /** - * Changes styles of GeoJSON vector layers with the given style function. - */ - setStyle(style: StyleFunction): this; - - options: GeoJSONOptions; - -} - -/** - * Creates a GeoJSON layer. - * - * Optionally accepts an object in GeoJSON format to display on the - * map (you can alternatively add it later with addData method) and - * an options object. - */ -export function geoJSON(geojson?: GeoJSONDefinition.GeoJsonObject, options?: GeoJSONOptions): GeoJSON; - -type Zoom = boolean | 'center'; - -export interface MapOptions { - preferCanvas?: boolean; - - // Control options - attributionControl?: boolean; - zoomControl?: boolean; - - // Interaction options - closePopupOnClick?: boolean; - zoomSnap?: number; - zoomDelta?: number; - trackResize?: boolean; - boxZoom?: boolean; - doubleClickZoom?: Zoom; - dragging?: boolean; - - // Map state options - crs?: CRS; - center?: LatLngExpression; - zoom?: number; - minZoom?: number; - maxZoom?: number; - layers?: Layer[]; - maxBounds?: LatLngBoundsExpression; - renderer?: Renderer; - - // Animation options - fadeAnimation?: boolean; - markerZoomAnimation?: boolean; - transform3DLimit?: number; - zoomAnimation?: boolean; - zoomAnimationThreshold?: number; - - // Panning inertia options - inertia?: boolean; - inertiaDeceleration?: number; - inertiaMaxSpeed?: number; - easeLinearity?: number; - worldCopyJump?: boolean; - maxBoundsViscosity?: number; - - // Keyboard navigation options - keyboard?: boolean; - keyboardPanDelta?: number; - - // Mousewheel options - scrollWheelZoom?: Zoom; - wheelDebounceTime?: number; - wheelPxPerZoomLevel?: number; - - // Touch interaction options - tap?: boolean; - tapTolerance?: number; - touchZoom?: Zoom; - bounceAtZoomLimits?: boolean; -} - -export type ControlPosition = 'topleft' | 'topright' | 'bottomleft' | 'bottomright'; - -export interface ControlOptions { - position?: ControlPosition; -} - -export class Control extends Class { - constructor(options?: ControlOptions); - getPosition(): ControlPosition; - setPosition(position: ControlPosition): this; - getContainer(): HTMLElement; - addTo(map: Map): this; - remove(): this; - - // Extension methods - onAdd(map: Map): HTMLElement; - onRemove(map: Map): void; - - options: ControlOptions; -} - -export namespace Control { - export interface ZoomOptions extends ControlOptions { - zoomInText?: string; - zoomInTitle?: string; - zoomOutText?: string; - zoomOutTitle?: string; + /** + * A Function that will be used for converting GeoJSON coordinates to LatLngs. + * The default is the coordsToLatLng static method. + */ + coordsToLatLng?: (coords: [number, number] | [number, number, number]) => LatLng; // check if LatLng has an altitude property } - export class Zoom extends Control { - constructor(options?: ZoomOptions); - options: ZoomOptions; + /** + * Represents a GeoJSON object or an array of GeoJSON objects. + * Allows you to parse GeoJSON data and display it on the map. Extends FeatureGroup. + */ + export class GeoJSON { + /** + * Creates a Layer from a given GeoJSON feature. Can use a custom pointToLayer + * and/or coordsToLatLng functions if provided as options. + */ + static geometryToLayer(featureData: GeoJSONFeature, options?: GeoJSONOptions): Layer; + + /** + * Creates a LatLng object from an array of 2 numbers (longitude, latitude) or + * 3 numbers (longitude, latitude, altitude) used in GeoJSON for points. + */ + static coordsToLatLng(coords: [number, number] | [number, number, number]): LatLng; + + /** + * Creates a multidimensional array of LatLngs from a GeoJSON coordinates array. + * levelsDeep specifies the nesting level (0 is for an array of points, 1 for an array of + * arrays of points, etc., 0 by default). + * Can use a custom coordsToLatLng function. + */ + static coordsToLatLngs( + coords: any[], + levelsDeep?: number, + coordsToLatLng?: (coords: [number, number] | [number, number, number]) => LatLng): any[]; // Using any[] to avoid artificially limiting valid calls + + /** + * Reverse of coordsToLatLng + */ + static latLngToCoords(latlng: LatLng): [number, number, number]; // A three tuple can be assigned to a two or three tuple + + + /** + * Reverse of coordsToLatLngs closed determines whether the first point should be + * appended to the end of the array to close the feature, only used when levelsDeep is 0. + * False by default. + */ + static latLngsToCoords(latlngs: any[], levelsDeep?: number, closed?: boolean): any[]; // Using any[] to avoid artificially limiting valid calls + + /** + * Normalize GeoJSON geometries/features into GeoJSON features. + */ + static asFeature(geojson: GeoJSONFeature | GeoJSONGeometryObject): GeoJSONFeature; + + constructor(geojson?: GeoJSONGeoJsonObject, options?: GeoJSONOptions) + /** + * Adds a GeoJSON object to the layer. + */ + addData(data: GeoJSONGeoJsonObject): Layer; + + /** + * Resets the given vector layer's style to the original GeoJSON style, + * useful for resetting style after hover events. + */ + resetStyle(layer: Layer): Layer; + + /** + * Changes styles of GeoJSON vector layers with the given style function. + */ + setStyle(style: StyleFunction): this; + + options: GeoJSONOptions; + } - export interface AttributionOptions extends ControlOptions { - prefix?: string | boolean; + /** + * Creates a GeoJSON layer. + * + * Optionally accepts an object in GeoJSON format to display on the + * map (you can alternatively add it later with addData method) and + * an options object. + */ + export function geoJSON(geojson?: GeoJSONGeoJsonObject, options?: GeoJSONOptions): GeoJSON; + + type Zoom = boolean | 'center'; + + export interface MapOptions { + preferCanvas?: boolean; + + // Control options + attributionControl?: boolean; + zoomControl?: boolean; + + // Interaction options + closePopupOnClick?: boolean; + zoomSnap?: number; + zoomDelta?: number; + trackResize?: boolean; + boxZoom?: boolean; + doubleClickZoom?: Zoom; + dragging?: boolean; + + // Map state options + crs?: CRS; + center?: LatLngExpression; + zoom?: number; + minZoom?: number; + maxZoom?: number; + layers?: Layer[]; + maxBounds?: LatLngBoundsExpression; + renderer?: Renderer; + + // Animation options + fadeAnimation?: boolean; + markerZoomAnimation?: boolean; + transform3DLimit?: number; + zoomAnimation?: boolean; + zoomAnimationThreshold?: number; + + // Panning inertia options + inertia?: boolean; + inertiaDeceleration?: number; + inertiaMaxSpeed?: number; + easeLinearity?: number; + worldCopyJump?: boolean; + maxBoundsViscosity?: number; + + // Keyboard navigation options + keyboard?: boolean; + keyboardPanDelta?: number; + + // Mousewheel options + scrollWheelZoom?: Zoom; + wheelDebounceTime?: number; + wheelPxPerZoomLevel?: number; + + // Touch interaction options + tap?: boolean; + tapTolerance?: number; + touchZoom?: Zoom; + bounceAtZoomLimits?: boolean; } - export class Attribution extends Control { - constructor(options?: AttributionOptions); - setPrefix(prefix: string): this; - addAttribution(text: string): this; - removeAttribution(text: string): this; - options: AttributionOptions; + export type ControlPosition = 'topleft' | 'topright' | 'bottomleft' | 'bottomright'; + + export interface ControlOptions { + position?: ControlPosition; } - export interface LayersOptions extends ControlOptions { - collapsed?: boolean; - autoZIndex?: boolean; - hideSingleBase?: boolean; + export class Control extends Class { + constructor(options?: ControlOptions); + getPosition(): ControlPosition; + setPosition(position: ControlPosition): this; + getContainer(): HTMLElement; + addTo(map: Map): this; + remove(): this; + + // Extension methods + onAdd(map: Map): HTMLElement; + onRemove(map: Map): void; + + options: ControlOptions; } - interface LayersObject { - [name: string]: Layer; + export namespace Control { + export interface ZoomOptions extends ControlOptions { + zoomInText?: string; + zoomInTitle?: string; + zoomOutText?: string; + zoomOutTitle?: string; + } + + export class Zoom extends Control { + constructor(options?: ZoomOptions); + options: ZoomOptions; + } + + export interface AttributionOptions extends ControlOptions { + prefix?: string | boolean; + } + + export class Attribution extends Control { + constructor(options?: AttributionOptions); + setPrefix(prefix: string): this; + addAttribution(text: string): this; + removeAttribution(text: string): this; + options: AttributionOptions; + } + + export interface LayersOptions extends ControlOptions { + collapsed?: boolean; + autoZIndex?: boolean; + hideSingleBase?: boolean; + } + + interface LayersObject { + [name: string]: Layer; + } + + export class Layers extends Control { + constructor(baseLayers?: LayersObject, overlays?: LayersObject, options?: Control.LayersOptions); + addBaseLayer(layer: Layer, name: string): this; + addOverlay(layer: Layer, name: string): this; + removeLayer(layer: Layer): this; + expand(): this; + collapse(): this; + options: LayersOptions; + } + + export interface ScaleOptions extends ControlOptions { + maxWidth?: number; + metric?: boolean; + imperial?: boolean; + updateWhenIdle?: boolean; + } + + export class Scale extends Control { + constructor(options?: Control.ScaleOptions); + options: ScaleOptions; + } } - export class Layers extends Control { - constructor(baseLayers?: LayersObject, overlays?: LayersObject, options?: Control.LayersOptions); - addBaseLayer(layer: Layer, name: string): this; - addOverlay(layer: Layer, name: string): this; - removeLayer(layer: Layer): this; - expand(): this; - collapse(): this; - options: LayersOptions; + export namespace control { + export function zoom(options?: Control.ZoomOptions): Control.Zoom; + + export function attribution(options?: Control.AttributionOptions): Control.Attribution; + + export function layers(baseLayers?: Control.LayersObject, overlays?: Control.LayersObject, options?: Control.LayersOptions): Control.Layers; + + export function scale(options?: Control.ScaleOptions): Control.Scale; } - export interface ScaleOptions extends ControlOptions { + interface DivOverlayOptions { + offset?: PointExpression; + zoomAnimation?: boolean; + className?: string; + pane?: string; + } + + export interface PopupOptions extends DivOverlayOptions { maxWidth?: number; - metric?: boolean; - imperial?: boolean; - updateWhenIdle?: boolean; + minWidth?: number; + maxHeight?: number; + autoPan?: boolean; + autoPanPaddingTopLeft?: PointExpression; + autoPanPaddingBottomRight?: PointExpression; + autoPanPadding?: PointExpression; + keepInView?: boolean; + closeButton?: boolean; + autoClose?: boolean; + closeOnClick?: boolean; } - export class Scale extends Control { - constructor(options?: Control.ScaleOptions); - options: ScaleOptions; + type Content = string | HTMLElement; + + export class Popup extends Layer { + constructor(options?: PopupOptions, source?: Layer); + getLatLng(): LatLng; + setLatLng(latlng: LatLngExpression): this; + getContent(): Content; + setContent(htmlContent: (source: Layer) => Content | Content): this; + getElement(): HTMLElement; + update(): void; + isOpen(): boolean; + bringToFront(): this; + bringToBack(): this; + openOn(map: Map): this; + + options: PopupOptions; } -} -export namespace control { - export function zoom(options?: Control.ZoomOptions): Control.Zoom; + export function popup(options?: PopupOptions, source?: Layer): Popup; - export function attribution(options?: Control.AttributionOptions): Control.Attribution; + export type Direction = 'right' | 'left' | 'top' | 'bottom' | 'center' | 'auto'; - export function layers(baseLayers?: Control.LayersObject, overlays?: Control.LayersObject, options?: Control.LayersOptions): Control.Layers; + export interface TooltipOptions extends DivOverlayOptions { + pane?: string; + offset?: PointExpression; + direction?: Direction; + permanent?: boolean; + sticky?: boolean; + interactive?: boolean; + opacity?: number; + } - export function scale(options?: Control.ScaleOptions): Control.Scale; -} + export class Tooltip extends Layer { + constructor(options?: TooltipOptions, source?: Layer); + setOpacity(val: number): void; + getLatLng(): LatLng; + setLatLng(latlng: LatLngExpression): this; + getContent(): Content; + setContent(htmlContent: (source: Layer) => Content | Content): this; + getElement(): HTMLElement; + update(): void; + isOpen(): boolean; + bringToFront(): this; + bringToBack(): this; -interface DivOverlayOptions { - offset?: PointExpression; - zoomAnimation?: boolean; - className?: string; - pane?: string; -} + options: TooltipOptions; + } -export interface PopupOptions extends DivOverlayOptions { - maxWidth?: number; - minWidth?: number; - maxHeight?: number; - autoPan?: boolean; - autoPanPaddingTopLeft?: PointExpression; - autoPanPaddingBottomRight?: PointExpression; - autoPanPadding?: PointExpression; - keepInView?: boolean; - closeButton?: boolean; - autoClose?: boolean; - closeOnClick?: boolean; -} + export function tooltip(options?: TooltipOptions, source?: Layer): Tooltip; -type Content = string | HTMLElement; + export interface ZoomOptions { + animate?: boolean; + } -export class Popup extends Layer { - constructor(options?: PopupOptions, source?: Layer); - getLatLng(): LatLng; - setLatLng(latlng: LatLngExpression): this; - getContent(): Content; - setContent(htmlContent: (source: Layer) => Content | Content): this; - getElement(): HTMLElement; - update(): void; - isOpen(): boolean; - bringToFront(): this; - bringToBack(): this; - openOn(map: Map): this; + export interface PanOptions { + animate?: boolean; + duration?: number; + easeLinearity?: number; + noMoveStart?: boolean; + } - options: PopupOptions; -} + export interface ZoomPanOptions extends ZoomOptions, PanOptions {} -export function popup(options?: PopupOptions, source?: Layer): Popup; + export interface FitBoundsOptions extends ZoomOptions, PanOptions { + paddingTopLeft?: PointExpression; + paddingBottomRight?: PointExpression; + padding?: PointExpression; + maxZoom?: number; + } -export type Direction = 'right' | 'left' | 'top' | 'bottom' | 'center' | 'auto'; + export interface LocateOptions { + watch?: boolean; + setView?: boolean; + maxZoom?: number; + timeout?: number; + maximumAge?: number; + enableHighAccuracy?: boolean; + } -export interface TooltipOptions extends DivOverlayOptions { - pane?: string; - offset?: PointExpression; - direction?: Direction; - permanent?: boolean; - sticky?: boolean; - interactive?: boolean; - opacity?: number; -} + export class Handler extends Class { + constructor(map: Map); + enable(): this; + disable(): this; + enabled(): boolean; -export class Tooltip extends Layer { - constructor(options?: TooltipOptions, source?: Layer); - setOpacity(val: number): void; - getLatLng(): LatLng; - setLatLng(latlng: LatLngExpression): this; - getContent(): Content; - setContent(htmlContent: (source: Layer) => Content | Content): this; - getElement(): HTMLElement; - update(): void; - isOpen(): boolean; - bringToFront(): this; - bringToBack(): this; + // Extension methods + addHooks(): void; + removeHooks(): void; + } - options: TooltipOptions; -} + export interface Event { + type: string; + target: any; + } -export function tooltip(options?: TooltipOptions, source?: Layer): Tooltip; + export interface MouseEvent extends Event { + latlng: LatLng; + layerPoint: Point; + containerPoint: Point; + originalEvent: NativeMouseEvent; + } -export interface ZoomOptions { - animate?: boolean; -} + export interface KeyboardEvent extends Event { + originalEvent: NativeKeyboardEvent; + } -export interface PanOptions { - animate?: boolean; - duration?: number; - easeLinearity?: number; - noMoveStart?: boolean; -} + export interface LocationEvent extends Event { + latlng: LatLng; + bounds: LatLngBounds; + accuracy: number; + altitude: number; + altitudeAccuracy: number; + heading: number; + speed: number; + timestamp: number; + } -export interface ZoomPanOptions extends ZoomOptions, PanOptions {} + export interface ErrorEvent extends Event { + message: string; + code: number; + } -export interface FitBoundsOptions extends ZoomOptions, PanOptions { - paddingTopLeft?: PointExpression; - paddingBottomRight?: PointExpression; - padding?: PointExpression; - maxZoom?: number; -} + export interface LayerEvent extends Event { + layer: Layer; + } -export interface LocateOptions { - watch?: boolean; - setView?: boolean; - maxZoom?: number; - timeout?: number; - maximumAge?: number; - enableHighAccuracy?: boolean; -} + export interface LayersControlEvent extends LayerEvent { + name: string; + } -export class Handler extends Class { - constructor(map: Map); - enable(): this; - disable(): this; - enabled(): boolean; + export interface TileEvent extends Event { + tile: HTMLImageElement; + coords: Point; // apparently not a normal point, since docs say it has z (zoom) + } - // Extension methods - addHooks(): void; - removeHooks(): void; -} + export interface TileErrorEvent extends TileEvent { + error: Error; + } -export interface Event { - type: string; - target: any; -} + export interface ResizeEvent extends Event { + oldSize: Point; + newSize: Point; + } -export interface MouseEvent extends Event { - latlng: LatLng; - layerPoint: Point; - containerPoint: Point; - originalEvent: NativeMouseEvent; -} + export interface GeoJSONEvent extends Event { + layer: Layer; + properties: any; + geometryType: string; + id: string; + } -export interface KeyboardEvent extends Event { - originalEvent: NativeKeyboardEvent; -} + export interface PopupEvent extends Event { + popup: Popup; + } -export interface LocationEvent extends Event { - latlng: LatLng; - bounds: LatLngBounds; - accuracy: number; - altitude: number; - altitudeAccuracy: number; - heading: number; - speed: number; - timestamp: number; -} + export interface TooltipEvent extends Event { + tooltip: Tooltip; + } -export interface ErrorEvent extends Event { - message: string; - code: number; -} + export interface DragEndEvent extends Event { + distance: number; + } -export interface LayerEvent extends Event { - layer: Layer; -} + export interface ZoomAnimEvent extends Event { + center: LatLng; + zoom: number; + noUpdate: boolean; + } -export interface LayersControlEvent extends LayerEvent { - name: string; -} + export namespace DomEvent { + export function on(el: HTMLElement, types: string, fn: EventHandlerFn, context?: any): typeof DomEvent; -export interface TileEvent extends Event { - tile: HTMLImageElement; - coords: Point; // apparently not a normal point, since docs say it has z (zoom) -} + export function on(el: HTMLElement, eventMap: {[eventName: string]: EventHandlerFn}, context?: any): typeof DomEvent; -export interface TileErrorEvent extends TileEvent { - error: Error; -} + export function off(el: HTMLElement, types: string, fn: EventHandlerFn, context?: any): typeof DomEvent; -export interface ResizeEvent extends Event { - oldSize: Point; - newSize: Point; -} + export function off(el: HTMLElement, eventMap: {[eventName: string]: EventHandlerFn}, context?: any): typeof DomEvent; -export interface GeoJSONEvent extends Event { - layer: Layer; - properties: any; - geometryType: string; - id: string; -} + export function stopPropagation(ev: Event): typeof DomEvent; -export interface PopupEvent extends Event { - popup: Popup; -} + export function disableScrollPropagation(el: HTMLElement): typeof DomEvent; -export interface TooltipEvent extends Event { - tooltip: Tooltip; -} + export function disableClickPropagation(el: HTMLElement): typeof DomEvent; -export interface DragEndEvent extends Event { - distance: number; -} + export function preventDefault(ev: Event): typeof DomEvent; -export interface ZoomAnimEvent extends Event { - center: LatLng; - zoom: number; - noUpdate: boolean; -} + export function stop(ev: Event): typeof DomEvent; -export namespace DomEvent { - export function on(el: HTMLElement, types: string, fn: EventHandlerFn, context?: any): typeof DomEvent; + export function getMousePosition(ev: Event, container?: HTMLElement): Point; - export function on(el: HTMLElement, eventMap: {[eventName: string]: EventHandlerFn}, context?: any): typeof DomEvent; + export function getWheelDelta(ev: Event): number; - export function off(el: HTMLElement, types: string, fn: EventHandlerFn, context?: any): typeof DomEvent; + export function addListener(el: HTMLElement, types: string, fn: EventHandlerFn, context?: any): typeof DomEvent; - export function off(el: HTMLElement, eventMap: {[eventName: string]: EventHandlerFn}, context?: any): typeof DomEvent; + export function addListener(el: HTMLElement, eventMap: {[eventName: string]: EventHandlerFn}, context?: any): typeof DomEvent; - export function stopPropagation(ev: Event): typeof DomEvent; + export function removeListener(el: HTMLElement, types: string, fn: EventHandlerFn, context?: any): typeof DomEvent; - export function disableScrollPropagation(el: HTMLElement): typeof DomEvent; + export function removeListener(el: HTMLElement, eventMap: {[eventName: string]: EventHandlerFn}, context?: any): typeof DomEvent; + } - export function disableClickPropagation(el: HTMLElement): typeof DomEvent; + interface DefaultMapPanes { + mapPane: HTMLElement; + tilePane: HTMLElement; + overlayPane: HTMLElement; + shadowPane: HTMLElement; + markerPane: HTMLElement; + tooltipPane: HTMLElement; + popupPane: HTMLElement; + } - export function preventDefault(ev: Event): typeof DomEvent; + export class Map extends Evented { + constructor(element: string | HTMLElement, options?: MapOptions); + getRenderer(layer: Path): Renderer; - export function stop(ev: Event): typeof DomEvent; + // Methods for layers and controls + addControl(control: Control): this; + removeControl(control: Control): this; + addLayer(layer: Layer): this; + removeLayer(layer: Layer): this; + hasLayer(layer: Layer): boolean; + eachLayer(fn: (layer: Layer) => void, context?: any): this; + openPopup(popup: Popup): this; + openPopup(content: Content, latlng: LatLngExpression, options?: PopupOptions): this; + closePopup(popup?: Popup): this; + openTooltip(tooltip: Tooltip): this; + openTooltip(content: string | HTMLElement, latlng: LatLngExpression, options?: TooltipOptions): this; + closeTooltip(tooltip?: Tooltip): this; - export function getMousePosition(ev: Event, container?: HTMLElement): Point; + // Methods for modifying map state + setView(center: LatLngExpression, zoom: number, options?: ZoomPanOptions): this; + setZoom(zoom: number, options?: ZoomPanOptions): this; + zoomIn(delta?: number, options?: ZoomOptions): this; + zoomOut(delta?: number, options?: ZoomOptions): this; + setZoomAround(position: Point | LatLngExpression, zoom: number, options?: ZoomOptions): this; + fitBounds(bounds: LatLngBoundsExpression, options?: FitBoundsOptions): this; + fitWorld(options?: FitBoundsOptions): this; + panTo(latlng: LatLngExpression, options?: PanOptions): this; + panBy(offset: PointExpression): this; + setMaxBounds(bounds: LatLngBoundsExpression): this; + setMinZoom(zoom: number): this; + setMaxZoom(zoom: number): this; + panInsideBounds(bounds: LatLngBoundsExpression, options?: PanOptions): this; + /** + * Boolean for animate or advanced ZoomPanOptions + */ + invalidateSize(options?: boolean | ZoomPanOptions): this; + stop(): this; + flyTo(latlng: LatLngExpression, zoom?: number, options?: ZoomPanOptions): this; + flyToBounds(bounds: LatLngBoundsExpression, options?: FitBoundsOptions): this; - export function getWheelDelta(ev: Event): number; + // Other methods + addHandler(name: string, HandlerClass: () => Handler): this; // HandlerClass is actually a constructor function, is this the right way? + remove(): this; + createPane(name: string, container?: HTMLElement): HTMLElement; + /** + * Name of the pane or the pane as HTML-Element + */ + getPane(pane: string | HTMLElement): HTMLElement; + getPanes(): {[name: string]: HTMLElement} & DefaultMapPanes; + getContainer(): HTMLElement; + whenReady(fn: () => void, context?: any): this; - export function addListener(el: HTMLElement, types: string, fn: EventHandlerFn, context?: any): typeof DomEvent; + // Methods for getting map state + getCenter(): LatLng; + getZoom(): number; + getBounds(): LatLngBounds; + getMinZoom(): number; + getMaxZoom(): number; + getBoundsZoom(bounds: LatLngBoundsExpression, inside?: boolean): number; + getSize(): Point; + getPixelBounds(): Bounds; + getPixelOrigin(): Point; + getPixelWorldBounds(zoom?: number): Bounds; - export function addListener(el: HTMLElement, eventMap: {[eventName: string]: EventHandlerFn}, context?: any): typeof DomEvent; + // Conversion methods + getZoomScale(toZoom: number, fromZoom: number): number; + getScaleZoom(scale: number, fromZoom: number): number; + project(latlng: LatLngExpression, zoom: number): Point; + unproject(point: PointExpression, zoom: number): LatLng; + layerPointToLatLng(point: PointExpression): LatLng; + latLngToLayerPoint(latlng: LatLngExpression): Point; + wrapLatLng(latlng: LatLngExpression): LatLng; + distance(latlng1: LatLngExpression, latlng2: LatLngExpression): number; + containerPointToLayerPoint(point: PointExpression): Point; + layerPointToContainerPoint(point: PointExpression): Point; + latLngToContainerPoint(latlng: LatLngExpression): Point; + mouseEventToContainerPoint(ev: MouseEvent): Point; + mouseEventToLayerPoint(ev: MouseEvent): Point; + mouseEventToLatLng(ev: MouseEvent): LatLng; - export function removeListener(el: HTMLElement, types: string, fn: EventHandlerFn, context?: any): typeof DomEvent; + // Geolocation methods + locate(options?: LocateOptions): this; + stopLocate(): this; - export function removeListener(el: HTMLElement, eventMap: {[eventName: string]: EventHandlerFn}, context?: any): typeof DomEvent; -} + // Properties + boxZoom: Handler; + doubleClickZoom: Handler; + dragging: Handler; + keyboard: Handler; + scrollWheelZoom: Handler; + tap: Handler; + touchZoom: Handler; -interface DefaultMapPanes { - mapPane: HTMLElement; - tilePane: HTMLElement; - overlayPane: HTMLElement; - shadowPane: HTMLElement; - markerPane: HTMLElement; - tooltipPane: HTMLElement; - popupPane: HTMLElement; -} + options: MapOptions; + } -export class Map extends Evented { - constructor(element: string | HTMLElement, options?: MapOptions); - getRenderer(layer: Path): Renderer; - - // Methods for layers and controls - addControl(control: Control): this; - removeControl(control: Control): this; - addLayer(layer: Layer): this; - removeLayer(layer: Layer): this; - hasLayer(layer: Layer): boolean; - eachLayer(fn: (layer: Layer) => void, context?: any): this; - openPopup(popup: Popup): this; - openPopup(content: Content, latlng: LatLngExpression, options?: PopupOptions): this; - closePopup(popup?: Popup): this; - openTooltip(tooltip: Tooltip): this; - openTooltip(content: string | HTMLElement, latlng: LatLngExpression, options?: TooltipOptions): this; - closeTooltip(tooltip?: Tooltip): this; - - // Methods for modifying map state - setView(center: LatLngExpression, zoom: number, options?: ZoomPanOptions): this; - setZoom(zoom: number, options?: ZoomPanOptions): this; - zoomIn(delta?: number, options?: ZoomOptions): this; - zoomOut(delta?: number, options?: ZoomOptions): this; - setZoomAround(position: Point | LatLngExpression, zoom: number, options?: ZoomOptions): this; - fitBounds(bounds: LatLngBoundsExpression, options?: FitBoundsOptions): this; - fitWorld(options?: FitBoundsOptions): this; - panTo(latlng: LatLngExpression, options?: PanOptions): this; - panBy(offset: PointExpression): this; - setMaxBounds(bounds: LatLngBoundsExpression): this; - setMinZoom(zoom: number): this; - setMaxZoom(zoom: number): this; - panInsideBounds(bounds: LatLngBoundsExpression, options?: PanOptions): this; /** - * Boolean for animate or advanced ZoomPanOptions + * ID of a HTML-Element as string or the HTML-ELement itself */ - invalidateSize(options?: boolean | ZoomPanOptions): this; - stop(): this; - flyTo(latlng: LatLngExpression, zoom?: number, options?: ZoomPanOptions): this; - flyToBounds(bounds: LatLngBoundsExpression, options?: FitBoundsOptions): this; + export function map(element: string | HTMLElement, options?: MapOptions): Map; - // Other methods - addHandler(name: string, HandlerClass: () => Handler): this; // HandlerClass is actually a constructor function, is this the right way? - remove(): this; - createPane(name: string, container?: HTMLElement): HTMLElement; - /** - * Name of the pane or the pane as HTML-Element - */ - getPane(pane: string | HTMLElement): HTMLElement; - getPanes(): {[name: string]: HTMLElement} & DefaultMapPanes; - getContainer(): HTMLElement; - whenReady(fn: () => void, context?: any): this; + export interface IconOptions extends LayerOptions { + iconUrl: string; + iconRetinaUrl?: string; + iconSize?: PointExpression; + iconAnchor?: PointExpression; + popupAnchor?: PointExpression; + shadowUrl?: string; + shadowRetinaUrl?: string; + shadowSize?: PointExpression; + shadowAnchor?: PointExpression; + className?: string; + } - // Methods for getting map state - getCenter(): LatLng; - getZoom(): number; - getBounds(): LatLngBounds; - getMinZoom(): number; - getMaxZoom(): number; - getBoundsZoom(bounds: LatLngBoundsExpression, inside?: boolean): number; - getSize(): Point; - getPixelBounds(): Bounds; - getPixelOrigin(): Point; - getPixelWorldBounds(zoom?: number): Bounds; + class InternalIcon extends Layer { + constructor(options: IconOptions); + createIcon(oldIcon?: HTMLElement): HTMLElement; + } - // Conversion methods - getZoomScale(toZoom: number, fromZoom: number): number; - getScaleZoom(scale: number, fromZoom: number): number; - project(latlng: LatLngExpression, zoom: number): Point; - unproject(point: PointExpression, zoom: number): LatLng; - layerPointToLatLng(point: PointExpression): LatLng; - latLngToLayerPoint(latlng: LatLngExpression): Point; - wrapLatLng(latlng: LatLngExpression): LatLng; - distance(latlng1: LatLngExpression, latlng2: LatLngExpression): number; - containerPointToLayerPoint(point: PointExpression): Point; - layerPointToContainerPoint(point: PointExpression): Point; - latLngToContainerPoint(latlng: LatLngExpression): Point; - mouseEventToContainerPoint(ev: MouseEvent): Point; - mouseEventToLayerPoint(ev: MouseEvent): Point; - mouseEventToLatLng(ev: MouseEvent): LatLng; + export class Icon extends InternalIcon { + createShadow(oldIcon?: HTMLElement): HTMLElement; + options: IconOptions; + } - // Geolocation methods - locate(options?: LocateOptions): this; - stopLocate(): this; - - // Properties - boxZoom: Handler; - doubleClickZoom: Handler; - dragging: Handler; - keyboard: Handler; - scrollWheelZoom: Handler; - tap: Handler; - touchZoom: Handler; - - options: MapOptions; -} - -/** - * ID of a HTML-Element as string or the HTML-ELement itself - */ -export function map(element: string | HTMLElement, options?: MapOptions): Map; - -export interface IconOptions extends LayerOptions { - iconUrl: string; - iconRetinaUrl?: string; - iconSize?: PointExpression; - iconAnchor?: PointExpression; - popupAnchor?: PointExpression; - shadowUrl?: string; - shadowRetinaUrl?: string; - shadowSize?: PointExpression; - shadowAnchor?: PointExpression; - className?: string; -} - -declare class InternalIcon extends Layer { - constructor(options: IconOptions); - createIcon(oldIcon?: HTMLElement): HTMLElement; -} - -export class Icon extends InternalIcon { - createShadow(oldIcon?: HTMLElement): HTMLElement; - options: IconOptions; -} - -export interface IconDefault extends InternalIcon { - imagePath: string; -} - -export namespace Icon { - export class Default extends InternalIcon { + export interface IconDefault extends InternalIcon { imagePath: string; } + + export namespace Icon { + export class Default extends InternalIcon { + imagePath: string; + } + } + + export function icon(options: IconOptions): Icon; + + export interface DivIconOptions extends LayerOptions { + html?: string; + bgPos?: PointExpression; + iconSize?: PointExpression; + iconAnchor?: PointExpression; + popupAnchor?: PointExpression; + className?: string; + } + + export class DivIcon extends InternalIcon { + constructor(options?: DivIconOptions); + options: DivIconOptions; + } + + export function divIcon(options?: DivIconOptions): DivIcon; + + export interface MarkerOptions extends InteractiveLayerOptions { + icon?: Icon; + clickable?: boolean; + draggable?: boolean; + keyboard?: boolean; + title?: string; + alt?: string; + zIndexOffset?: number; + opacity?: number; + riseOnHover?: boolean; + riseOffset?: number; + + options: DivIconOptions; + } + + export class Marker extends Layer { + constructor(latlng: LatLngExpression, options?: MarkerOptions); + getLatLng(): LatLng; + setLatLng(latlng: LatLngExpression): this; + setZIndexOffset(offset: number): this; + setIcon(icon: Icon): this; + setOpacity(opacity: number): this; + getElement(): HTMLElement; + + // Properties + options: MarkerOptions; + dragging: Handler; + } + + export function marker(latlng: LatLngExpression, options?: MarkerOptions): Marker; + + export namespace Browser { + export const ie: boolean; + export const ielt9: boolean; + export const edge: boolean; + export const webkit: boolean; + export const gecko: boolean; + export const android: boolean; + export const android23: boolean; + export const chrome: boolean; + export const safari: boolean; + export const win: boolean; + export const ie3d: boolean; + export const webkit3d: boolean; + export const gecko3d: boolean; + export const opera12: boolean; + export const any3d: boolean; + export const mobile: boolean; + export const mobileWebkit: boolean; + export const mobiWebkit3d: boolean; + export const mobileOpera: boolean; + export const mobileGecko: boolean; + export const touch: boolean; + export const msPointer: boolean; + export const pointer: boolean; + export const retina: boolean; + export const canvas: boolean; + export const vml: boolean; + export const svg: boolean; + } + } -export function icon(options: IconOptions): Icon; - -export interface DivIconOptions extends LayerOptions { - html?: string; - bgPos?: PointExpression; - iconSize?: PointExpression; - iconAnchor?: PointExpression; - popupAnchor?: PointExpression; - className?: string; -} - -export class DivIcon extends InternalIcon { - constructor(options?: DivIconOptions); - options: DivIconOptions; -} - -export function divIcon(options?: DivIconOptions): DivIcon; - -export interface MarkerOptions extends InteractiveLayerOptions { - icon?: Icon; - clickable?: boolean; - draggable?: boolean; - keyboard?: boolean; - title?: string; - alt?: string; - zIndexOffset?: number; - opacity?: number; - riseOnHover?: boolean; - riseOffset?: number; - - options: DivIconOptions; -} - -export class Marker extends Layer { - constructor(latlng: LatLngExpression, options?: MarkerOptions); - getLatLng(): LatLng; - setLatLng(latlng: LatLngExpression): this; - setZIndexOffset(offset: number): this; - setIcon(icon: Icon): this; - setOpacity(opacity: number): this; - getElement(): HTMLElement; - - // Properties - options: MarkerOptions; - dragging: Handler; -} - -export function marker(latlng: LatLngExpression, options?: MarkerOptions): Marker; - -export namespace Browser { - export const ie: boolean; - export const ielt9: boolean; - export const edge: boolean; - export const webkit: boolean; - export const gecko: boolean; - export const android: boolean; - export const android23: boolean; - export const chrome: boolean; - export const safari: boolean; - export const win: boolean; - export const ie3d: boolean; - export const webkit3d: boolean; - export const gecko3d: boolean; - export const opera12: boolean; - export const any3d: boolean; - export const mobile: boolean; - export const mobileWebkit: boolean; - export const mobiWebkit3d: boolean; - export const mobileOpera: boolean; - export const mobileGecko: boolean; - export const touch: boolean; - export const msPointer: boolean; - export const pointer: boolean; - export const retina: boolean; - export const canvas: boolean; - export const vml: boolean; - export const svg: boolean; +declare module 'leaflet' { + export = L; } From 8f325c6f72b7f7b6d7e1fa5c07d946b03aaab30d Mon Sep 17 00:00:00 2001 From: Arne Schubert Date: Fri, 27 Jan 2017 18:23:21 +0100 Subject: [PATCH 009/104] Remove the unneccesary import in test --- geojson/geojson-tests.ts | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/geojson/geojson-tests.ts b/geojson/geojson-tests.ts index 50b5f7b396..fb9ce24a0b 100644 --- a/geojson/geojson-tests.ts +++ b/geojson/geojson-tests.ts @@ -1,6 +1,3 @@ - - -import GeometryObject = GeoJSON.GeometryObject; let featureCollection: GeoJSON.FeatureCollection = { type: "FeatureCollection", features: [ @@ -134,7 +131,7 @@ let geometryCollection: GeoJSON.GeometryCollection = { ] }; -let feature: GeoJSON.Feature = { +let feature: GeoJSON.Feature = { type: "Feature", geometry: lineString, properties: null From 4190c1de72c53cff39f4db1b13a7fd1d55438ae0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20Helfensd=C3=B6rfer?= Date: Fri, 27 Jan 2017 20:03:15 +0100 Subject: [PATCH 010/104] Updated jquery.noty to current version --- jquery.noty/index.d.ts | 69 ++++++++++++++++++++++++------------------ 1 file changed, 39 insertions(+), 30 deletions(-) diff --git a/jquery.noty/index.d.ts b/jquery.noty/index.d.ts index 85fc2fca4c..c85db008fa 100644 --- a/jquery.noty/index.d.ts +++ b/jquery.noty/index.d.ts @@ -11,51 +11,60 @@ interface NotyOptions { theme?: string; type?: string; /** Text to show. Can be html or string. */ - text?: string; + text?: string; /** If you want to use queue feature set this true. */ - dismissQueue?: boolean; - /** The note`s optional template like '
' */ - template?: string; - animation?: NotyAnimationOptions; - /** Delay for closing event. Set false for sticky notifications */ - timeout?: any; - /** Adds notification to the beginning of queue when set to true */ - force?: boolean; - modal?: boolean; + dismissQueue?: boolean; + /** adds notification to the beginning of queue when set to true */ + force?: boolean; /** You can set max visible notification for dismissQueue true option */ maxVisible?: number; - /** To close all notifications before show */ - killer?: boolean; + /** The note`s optional template like '
' */ + template?: string; + /** Delay for closing event. Set false for sticky notifications */ + timeout?: any; + /** displays a progress bar */ + progressBar?: boolean; + + animation?: NotyAnimationOptions; + /** ['click', 'button', 'hover', 'backdrop'] // backdrop click will close all notifications */ closeWith?: any[]; + + /** if true adds an overlay */ + modal?: boolean; + /** if true closes all notifications and shows itself */ + killer?: boolean; + callback?: NotyCallbackOptions; - /** An array of buttons or false to hide them */ + + /** an array of buttons, for creating confirmation dialogs. */ buttons?: any; } interface NotyAnimationOptions { - open?: any; - close?: any; - easing?: string; - speed?: number; + open?: any; + close?: any; + easing?: string; + speed?: number; } interface NotyCallbackOptions { - onShow?: Function; - afterShow?: Function; - onClose?: Function; - afterClose?: Function; + onShow?: Function; + afterShow?: Function; + onClose?: Function; + afterClose?: Function; + onCloseClick?: Function; } interface NotyStatic { - (notyOptions: NotyOptions); - defaults: NotyOptions; + (notyOptions: NotyOptions); + defaults: NotyOptions; - get(id: any); - close(id: any); - clearQueue(); - closeAll(); - setText(id: any, text: string); - setType(id: any, type: string); + get(id: any); + close(id: any); + clearQueue(); + closeAll(); + setText(id: any, text: string); + setType(id: any, type: string); } interface Noty { @@ -72,7 +81,7 @@ interface Noty { } interface JQueryStatic { - noty: NotyStatic; + noty: NotyStatic; } interface JQuery { From 3f8ae530b91b19d0875aa533d99ec0868a92af3e Mon Sep 17 00:00:00 2001 From: Jacob Baskin Date: Thu, 26 Jan 2017 14:24:01 -0500 Subject: [PATCH 011/104] Add typings for react-native-datepicker --- react-native-datepicker/index.d.ts | 33 +++++++++++++++ .../react-native-datepicker-tests.tsx | 42 +++++++++++++++++++ react-native-datepicker/tsconfig.json | 24 +++++++++++ react-native-datepicker/tslint.json | 1 + 4 files changed, 100 insertions(+) create mode 100644 react-native-datepicker/index.d.ts create mode 100644 react-native-datepicker/react-native-datepicker-tests.tsx create mode 100644 react-native-datepicker/tsconfig.json create mode 100644 react-native-datepicker/tslint.json diff --git a/react-native-datepicker/index.d.ts b/react-native-datepicker/index.d.ts new file mode 100644 index 0000000000..ef985ecdc5 --- /dev/null +++ b/react-native-datepicker/index.d.ts @@ -0,0 +1,33 @@ +// Type definitions for react-native-datepicker 1.4 +// Project: https://github.com/xgfe/react-native-datepicker +// Definitions by: Jacob Baskin +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +import * as React from 'react'; + +interface DatePickerProps { + mode?: 'date' | 'datetime' | 'time'; + date?: string | Date; + format?: string; + minDate?: string | Date; + maxDate?: string | Date; + height?: number; + duration?: number; + confirmBtnText?: string; + cancelBtnText?: string; + showIcon?: boolean; + disabled?: boolean; + onDateChange?: (dateStr: string, date: Date) => void; + placeholder?: string; + modalOnResponderTerminationRequest?: (e: any) => boolean; + is24Hour?: boolean; + style?: any; + customStyles?: any; + minuteInterval?: number; +} + +declare class DatePicker extends React.Component { + constructor(props: DatePickerProps); +} + +export default DatePicker; diff --git a/react-native-datepicker/react-native-datepicker-tests.tsx b/react-native-datepicker/react-native-datepicker-tests.tsx new file mode 100644 index 0000000000..eb423fd554 --- /dev/null +++ b/react-native-datepicker/react-native-datepicker-tests.tsx @@ -0,0 +1,42 @@ +import * as React from 'react'; +import DatePicker from 'react-native-datepicker'; + +interface MyDatePickerState { + date: string; +} + +export default class MyDatePicker extends React.Component<{}, MyDatePickerState> { + constructor(props: {}) { + super(props); + this.state = {date: "2016-05-15"}; + } + + render() { + return ( + {this.setState({date});}} + /> + ); + } +} + diff --git a/react-native-datepicker/tsconfig.json b/react-native-datepicker/tsconfig.json new file mode 100644 index 0000000000..ffbef033e1 --- /dev/null +++ b/react-native-datepicker/tsconfig.json @@ -0,0 +1,24 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6", + "dom" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true, + "jsx": "react" + }, + "files": [ + "index.d.ts", + "react-native-datepicker-tests.tsx" + ] +} diff --git a/react-native-datepicker/tslint.json b/react-native-datepicker/tslint.json new file mode 100644 index 0000000000..377cc837d4 --- /dev/null +++ b/react-native-datepicker/tslint.json @@ -0,0 +1 @@ +{ "extends": "../tslint.json" } From 8f4b8ffc92f6e0e8f457bedac824796b0ff954fa Mon Sep 17 00:00:00 2001 From: Jacob Baskin Date: Fri, 27 Jan 2017 14:51:52 -0500 Subject: [PATCH 012/104] Use TS 2.1 only for react-native-datepicker typings. --- react-native-datepicker/index.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/react-native-datepicker/index.d.ts b/react-native-datepicker/index.d.ts index ef985ecdc5..232f2f56d1 100644 --- a/react-native-datepicker/index.d.ts +++ b/react-native-datepicker/index.d.ts @@ -2,6 +2,7 @@ // Project: https://github.com/xgfe/react-native-datepicker // Definitions by: Jacob Baskin // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.1 import * as React from 'react'; From 8fda71eadaf23d11c577ec4737c32dbac5a9e389 Mon Sep 17 00:00:00 2001 From: Arne Schubert Date: Sat, 28 Jan 2017 11:09:19 +0100 Subject: [PATCH 013/104] set no-single-declare-module to false in tslint.json --- geojson/tslint.json | 7 ++++++- leaflet/tslint.json | 7 ++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/geojson/tslint.json b/geojson/tslint.json index 377cc837d4..0b14fdec0d 100644 --- a/geojson/tslint.json +++ b/geojson/tslint.json @@ -1 +1,6 @@ -{ "extends": "../tslint.json" } +{ + "extends": "../tslint.json", + "rules": { + "no-single-declare-module": false + } +} diff --git a/leaflet/tslint.json b/leaflet/tslint.json index 377cc837d4..0b14fdec0d 100644 --- a/leaflet/tslint.json +++ b/leaflet/tslint.json @@ -1 +1,6 @@ -{ "extends": "../tslint.json" } +{ + "extends": "../tslint.json", + "rules": { + "no-single-declare-module": false + } +} From 6ab0599be2ea516a3821c58cea01cdb81d204927 Mon Sep 17 00:00:00 2001 From: Rich Buggy Date: Sun, 29 Jan 2017 12:49:30 +1100 Subject: [PATCH 014/104] Added Lambda Proxy and API Gateway Event definitions --- aws-lambda/aws-lambda-tests.ts | 47 +++++++++++++++++++++++++++++++++ aws-lambda/index.d.ts | 48 +++++++++++++++++++++++++++++++++- 2 files changed, 94 insertions(+), 1 deletion(-) diff --git a/aws-lambda/aws-lambda-tests.ts b/aws-lambda/aws-lambda-tests.ts index 0d8d9bd47f..fb09beda8a 100644 --- a/aws-lambda/aws-lambda-tests.ts +++ b/aws-lambda/aws-lambda-tests.ts @@ -6,11 +6,48 @@ var anyObj: any = { abc: 123 }; var num: number = 5; var error: Error = new Error(); var b: boolean = true; +var apiGwEvt: AWSLambda.APIGatewayEvent; var clientCtx: AWSLambda.ClientContext; var clientContextEnv: AWSLambda.ClientContextEnv; var clientContextClient: AWSLambda.ClientContextClient; var context: AWSLambda.Context; var identity: AWSLambda.CognitoIdentity; +var proxyResult: AWSLambda.ProxyResult; + +/* API Gateway Event */ +str = apiGwEvt.body; +str = apiGwEvt.headers["example"]; +str = apiGwEvt.httpMethod; +b = apiGwEvt.isBase64Encoded; +str = apiGwEvt.path; +str = apiGwEvt.pathParameters["example"]; +str = apiGwEvt.queryStringParameters["example"]; +str = apiGwEvt.stageVariables["example"]; +str = apiGwEvt.requestContext.accountId; +str = apiGwEvt.requestContext.apiId; +str = apiGwEvt.requestContext.httpMethod; +str = apiGwEvt.requestContext.identity.accessKey; +str = apiGwEvt.requestContext.identity.accountId; +str = apiGwEvt.requestContext.identity.apiKey; +str = apiGwEvt.requestContext.identity.caller; +str = apiGwEvt.requestContext.identity.cognitoAuthenticationProvider; +str = apiGwEvt.requestContext.identity.cognitoAuthenticationType; +str = apiGwEvt.requestContext.identity.cognitoIdentityId; +str = apiGwEvt.requestContext.identity.cognitoIdentityPoolId; +str = apiGwEvt.requestContext.identity.sourceIp; +str = apiGwEvt.requestContext.identity.user; +str = apiGwEvt.requestContext.identity.userAgent; +str = apiGwEvt.requestContext.identity.userArn; +str = apiGwEvt.requestContext.stage; +str = apiGwEvt.requestContext.requestId; +str = apiGwEvt.requestContext.resourceId; +str = apiGwEvt.requestContext.resourcePath; +str = apiGwEvt.resource; + +/* Lambda Proxy Result */ +num = proxyResult.statusCode; +str = proxyResult.headers["example"]; +str = proxyResult.body /* Context */ b = context.callbackWaitsForEmptyEventLoop; @@ -54,6 +91,15 @@ function callback(cb: AWSLambda.Callback) { cb(error); cb(null, anyObj); } + +/* Proxy Callback */ +function proxyCallback(cb: AWSLambda.ProxyCallback) { + cb(); + cb(null); + cb(error); + cb(null, proxyResult); +} + /* Compatibility functions */ context.done(); context.done(error); @@ -66,3 +112,4 @@ context.fail(str); /* Handler */ let handler: AWSLambda.Handler = (event: any, context: AWSLambda.Context, cb: AWSLambda.Callback) => {}; +let proxyHandler: AWSLambda.ProxyHandler = (event: AWSLambda.APIGatewayEvent, context: AWSLambda.Context, cb: AWSLambda.ProxyCallback) => {}; diff --git a/aws-lambda/index.d.ts b/aws-lambda/index.d.ts index 1aa41b9e62..e8b70db7bd 100644 --- a/aws-lambda/index.d.ts +++ b/aws-lambda/index.d.ts @@ -1,8 +1,44 @@ // Type definitions for AWS Lambda // Project: http://docs.aws.amazon.com/lambda -// Definitions by: James Darbyshire , Michael Skarum , Stef Heyenrath , Toby Hede +// Definitions by: James Darbyshire , Michael Skarum , Stef Heyenrath , Toby Hede , Rich Buggy // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// API Gateway "event" +interface APIGatewayEvent { + body: string | null; + headers: { [name: string]: string }; + httpMethod: string; + isBase64Encoded: boolean; + path: string; + pathParameters: { [name: string]: string } | null; + queryStringParameters: { [name: string]: string } | null; + stageVariables: { [name: string]: string } | null; + requestContext: { + accountId: string; + apiId: string; + httpMethod: string; + identity: { + accessKey: string | null; + accountId: string | null; + apiKey: string | null; + caller: string | null; + cognitoAuthenticationProvider: string | null; + cognitoAuthenticationType: string | null; + cognitoIdentityId: string | null; + cognitoIdentityPoolId: string | null; + sourceIp: string; + user: string | null; + userAgent: string | null; + userArn: string | null; + }, + stage: string; + requestId: string; + resourceId: string; + resourcePath: string; + }; + resource: string; +} + // Context // http://docs.aws.amazon.com/lambda/latest/dg/nodejs-prog-model-context.html interface Context { @@ -58,6 +94,14 @@ interface ClientContextEnv { locale: string; } +interface ProxyResult { + statusCode: number; + headers?: { + [header: string]: string; + }, + body: string; +} + /** * AWS Lambda handler function. * http://docs.aws.amazon.com/lambda/latest/dg/nodejs-prog-model-handler.html @@ -67,6 +111,7 @@ interface ClientContextEnv { * @param callback – optional callback to return information to the caller, otherwise return value is null. */ export type Handler = (event: any, context: Context, callback?: Callback) => void; +export type ProxyHandler = (event: APIGatewayEvent, context: Context, callback?: ProxyCallback) => void; /** * Optional callback parameter. @@ -76,5 +121,6 @@ export type Handler = (event: any, context: Context, callback?: Callback) => vo * @param result – an optional parameter that you can use to provide the result of a successful function execution. The result provided must be JSON.stringify compatible. */ export type Callback = (error?: Error, result?: any) => void; +export type ProxyCallback = (error?: Error, result?: ProxyResult) => void; export as namespace AWSLambda; From 876977386de369e12b8fb27c5eaaa94fbb2174eb Mon Sep 17 00:00:00 2001 From: Arne Schubert Date: Mon, 30 Jan 2017 19:25:53 +0100 Subject: [PATCH 015/104] do not export internal interface DirectGeometryObject --- geojson/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/geojson/index.d.ts b/geojson/index.d.ts index b38106aae7..7c825d2541 100644 --- a/geojson/index.d.ts +++ b/geojson/index.d.ts @@ -22,7 +22,7 @@ declare namespace GeoJSON { /*** * http://geojson.org/geojson-spec.html#geometry-objects */ - export interface DirectGeometryObject extends GeoJsonObject { + interface DirectGeometryObject extends GeoJsonObject { coordinates: Position[][][] | Position[][] | Position[] | Position; } /** From d93b846ef26cf417d8760bc62b33ec42ba948401 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20Helfensd=C3=B6rfer?= Date: Mon, 30 Jan 2017 19:49:19 +0100 Subject: [PATCH 016/104] Update index.d.ts --- jquery.noty/index.d.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/jquery.noty/index.d.ts b/jquery.noty/index.d.ts index c85db008fa..f4bfe4bcb9 100644 --- a/jquery.noty/index.d.ts +++ b/jquery.noty/index.d.ts @@ -1,6 +1,6 @@ -// Type definitions for jQuery.noty v2.0 +// Type definitions for jQuery.noty v2.4 // Project: http://needim.github.io/noty/ -// Definitions by: Aaron King +// Definitions by: Aaron King , Tim Helfensdörfer // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // Project by: Nedim Carter @@ -26,8 +26,8 @@ interface NotyOptions { progressBar?: boolean; animation?: NotyAnimationOptions; - /** ['click', 'button', 'hover', 'backdrop'] // backdrop click will close all notifications */ - closeWith?: any[]; + /** backdrop click will close all notifications */ + closeWith?: ('click' | 'button' | 'hover' | 'backdrop')[]; /** if true adds an overlay */ modal?: boolean; From 198607775436e894f035e731f5b16c93268aaa46 Mon Sep 17 00:00:00 2001 From: Arne Schubert Date: Mon, 30 Jan 2017 21:04:00 +0100 Subject: [PATCH 017/104] Make typings for literals as array of two tuples --- leaflet/index.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/leaflet/index.d.ts b/leaflet/index.d.ts index cc742ce504..342b674783 100644 --- a/leaflet/index.d.ts +++ b/leaflet/index.d.ts @@ -165,7 +165,7 @@ declare namespace L { isValid(): boolean; } - export type LatLngBoundsLiteral = LatLngTuple[]; + export type LatLngBoundsLiteral = LatLngTuple[]; // Must be [LatLngTuple, LatLngTuple], cant't change because Map.setMaxBounds type LatLngBoundsExpression = LatLngBounds | LatLngBoundsLiteral; @@ -202,7 +202,7 @@ declare namespace L { export function point(coords: PointTuple | {x: number, y: number}): Point; - export type BoundsLiteral = PointTuple[]; + export type BoundsLiteral = [PointTuple, PointTuple]; export class Bounds { constructor(topLeft: PointExpression, bottomRight: PointExpression); From 580dd62cca2be873b9d32df51408d8bd024d6810 Mon Sep 17 00:00:00 2001 From: Arne Schubert Date: Mon, 30 Jan 2017 21:16:57 +0100 Subject: [PATCH 018/104] Suppress lints by comment --- leaflet/index.d.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/leaflet/index.d.ts b/leaflet/index.d.ts index 342b674783..4097c728b4 100644 --- a/leaflet/index.d.ts +++ b/leaflet/index.d.ts @@ -252,6 +252,7 @@ declare namespace L { */ on(eventMap: EventHandlerFnMap): this; + /* tslint:disable:unified-signatures */ // With an eventMap there are no additional arguments allowed /** * Removes a previously added listener function. If no function is specified, * it will remove all the listeners of that particular event from the object. @@ -264,7 +265,7 @@ declare namespace L { * Removes a set of type/listener pairs. */ off(eventMap: EventHandlerFnMap): this; - + /* tslint:enable */ /** * Removes all listeners to all events on the object. */ @@ -1152,7 +1153,9 @@ declare namespace L { noMoveStart?: boolean; } + /* tslint:disable:no-empty-interface */ // This is not empty, it extends two interfaces into one... export interface ZoomPanOptions extends ZoomOptions, PanOptions {} + /* tslint:enable */ export interface FitBoundsOptions extends ZoomOptions, PanOptions { paddingTopLeft?: PointExpression; From f0e7d94f828b72b647e5d83d07f82d0e04901b10 Mon Sep 17 00:00:00 2001 From: Arne Schubert Date: Mon, 30 Jan 2017 21:18:53 +0100 Subject: [PATCH 019/104] Remove unused interface IconDefault --- leaflet/index.d.ts | 4 ---- 1 file changed, 4 deletions(-) diff --git a/leaflet/index.d.ts b/leaflet/index.d.ts index 4097c728b4..2b5dda86c8 100644 --- a/leaflet/index.d.ts +++ b/leaflet/index.d.ts @@ -1429,10 +1429,6 @@ declare namespace L { options: IconOptions; } - export interface IconDefault extends InternalIcon { - imagePath: string; - } - export namespace Icon { export class Default extends InternalIcon { imagePath: string; From 1dcc3a708cfe890597f65515984cf3110bda5a43 Mon Sep 17 00:00:00 2001 From: Arne Schubert Date: Mon, 30 Jan 2017 21:20:31 +0100 Subject: [PATCH 020/104] Remove unneccesary line --- leaflet/leaflet-tests.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/leaflet/leaflet-tests.ts b/leaflet/leaflet-tests.ts index 6f9fa242d8..0c1122f6fc 100644 --- a/leaflet/leaflet-tests.ts +++ b/leaflet/leaflet-tests.ts @@ -18,7 +18,6 @@ latLng = new L.LatLng({lat: 12, lng: 13, alt: 0}); latLng = new L.LatLng(latLngTuple); latLng = new L.LatLng([12, 13, 0]); - const latLngBoundsLiteral: L.LatLngBoundsLiteral = [[12, 13], latLngTuple]; let latLngBounds: L.LatLngBounds; From 0fe579c085350626053c54a4c277e498c7ba740e Mon Sep 17 00:00:00 2001 From: Arne Schubert Date: Mon, 30 Jan 2017 21:45:21 +0100 Subject: [PATCH 021/104] Add minNativeZoom from v1.0.2, add missing getElelemt methods --- leaflet/index.d.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/leaflet/index.d.ts b/leaflet/index.d.ts index 2b5dda86c8..fe28a52f32 100644 --- a/leaflet/index.d.ts +++ b/leaflet/index.d.ts @@ -469,6 +469,7 @@ declare namespace L { minZoom?: number; maxZoom?: number; maxNativeZoom?: number; + minNativeZoom?: number; subdomains?: string | string[]; errorTileUrl?: string; zoomOffset?: number; @@ -598,6 +599,7 @@ declare namespace L { getCenter(): LatLng; getBounds(): LatLngBounds; addLatLng(latlng: LatLngExpression | LatLngExpression[]): this; + getElement(): HTMLElement; options: PolylineOptions; } @@ -638,6 +640,7 @@ declare namespace L { getLatLng(): LatLng; setRadius(radius: number): this; getRadius(): number; + getElement(): HTMLElement; options: CircleMarkerOptions; feature: GeoJSONFeature; From 52c346b4a22c992cc70d5d579ba0a1ef5356e75f Mon Sep 17 00:00:00 2001 From: Arne Schubert Date: Mon, 30 Jan 2017 21:45:46 +0100 Subject: [PATCH 022/104] GeoJSON has to extend FeatureGroup --- leaflet/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/leaflet/index.d.ts b/leaflet/index.d.ts index fe28a52f32..91dc413c26 100644 --- a/leaflet/index.d.ts +++ b/leaflet/index.d.ts @@ -854,7 +854,7 @@ declare namespace L { * Represents a GeoJSON object or an array of GeoJSON objects. * Allows you to parse GeoJSON data and display it on the map. Extends FeatureGroup. */ - export class GeoJSON { + export class GeoJSON extends FeatureGroup { /** * Creates a Layer from a given GeoJSON feature. Can use a custom pointToLayer * and/or coordsToLatLng functions if provided as options. From 1eed6a55807cfbe403366af86aadbb844ee7be66 Mon Sep 17 00:00:00 2001 From: Arne Schubert Date: Mon, 30 Jan 2017 21:49:35 +0100 Subject: [PATCH 023/104] Set last missing content type --- leaflet/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/leaflet/index.d.ts b/leaflet/index.d.ts index 91dc413c26..24f6c70c90 100644 --- a/leaflet/index.d.ts +++ b/leaflet/index.d.ts @@ -1323,7 +1323,7 @@ declare namespace L { openPopup(content: Content, latlng: LatLngExpression, options?: PopupOptions): this; closePopup(popup?: Popup): this; openTooltip(tooltip: Tooltip): this; - openTooltip(content: string | HTMLElement, latlng: LatLngExpression, options?: TooltipOptions): this; + openTooltip(content: Content, latlng: LatLngExpression, options?: TooltipOptions): this; closeTooltip(tooltip?: Tooltip): this; // Methods for modifying map state From 725847349d3593cc9859c6039d9977a996b4bdf0 Mon Sep 17 00:00:00 2001 From: Arne Schubert Date: Mon, 30 Jan 2017 22:23:03 +0100 Subject: [PATCH 024/104] The Path interface has to have the getElement method --- leaflet/index.d.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/leaflet/index.d.ts b/leaflet/index.d.ts index 24f6c70c90..06f45f2caa 100644 --- a/leaflet/index.d.ts +++ b/leaflet/index.d.ts @@ -583,6 +583,7 @@ declare namespace L { setStyle(style: PathOptions): this; bringToFront(): this; bringToBack(): this; + getElement(): HTMLElement; options: PathOptions; } @@ -599,7 +600,6 @@ declare namespace L { getCenter(): LatLng; getBounds(): LatLngBounds; addLatLng(latlng: LatLngExpression | LatLngExpression[]): this; - getElement(): HTMLElement; options: PolylineOptions; } @@ -640,7 +640,6 @@ declare namespace L { getLatLng(): LatLng; setRadius(radius: number): this; getRadius(): number; - getElement(): HTMLElement; options: CircleMarkerOptions; feature: GeoJSONFeature; From a2bc79cdf4ed2bb4b9720777f289152b4960b8cf Mon Sep 17 00:00:00 2001 From: Arne Schubert Date: Mon, 30 Jan 2017 22:24:19 +0100 Subject: [PATCH 025/104] Remove extra blanks --- leaflet/index.d.ts | 3 --- 1 file changed, 3 deletions(-) diff --git a/leaflet/index.d.ts b/leaflet/index.d.ts index 06f45f2caa..bf6f9103a1 100644 --- a/leaflet/index.d.ts +++ b/leaflet/index.d.ts @@ -489,7 +489,6 @@ declare namespace L { export function tileLayer(urlTemplate: string, options?: TileLayerOptions): TileLayer; - export namespace TileLayer { export class WMS extends TileLayer { constructor(baseUrl: string, options: WMSOptions); @@ -647,7 +646,6 @@ declare namespace L { export function circleMarker(latlng: LatLngExpression, options?: CircleMarkerOptions): CircleMarker; - export class Circle extends CircleMarker { constructor(latlng: LatLngExpression, options?: CircleMarkerOptions); constructor(latlng: LatLngExpression, radius: number, options?: CircleMarkerOptions); // deprecated! @@ -882,7 +880,6 @@ declare namespace L { */ static latLngToCoords(latlng: LatLng): [number, number, number]; // A three tuple can be assigned to a two or three tuple - /** * Reverse of coordsToLatLngs closed determines whether the first point should be * appended to the end of the array to close the feature, only used when levelsDeep is 0. From 08870e953fdf89da51a8683546589e9efe0d24ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A1mal=20Rasmussen?= Date: Tue, 31 Jan 2017 09:52:27 +0100 Subject: [PATCH 026/104] Move typescript version definition to the top of the file --- lodash-es/index.d.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lodash-es/index.d.ts b/lodash-es/index.d.ts index c49a824f4c..e344736795 100644 --- a/lodash-es/index.d.ts +++ b/lodash-es/index.d.ts @@ -2,6 +2,7 @@ // Project: http://lodash.com/ // Definitions by: Stephen Lautier // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.1 export { default as add } from './add'; export { default as after } from './after'; @@ -286,5 +287,3 @@ export { default as xorWith } from './xorWith'; export { default as zip } from './zip'; export { default as zipObject } from './zipObject'; export { default as zipWith } from './zipWith'; - -// TypeScript Version: 2.1 From dc2a51cbd5555de2c6a89a7356a9d79550c2b2bb Mon Sep 17 00:00:00 2001 From: 421p Date: Tue, 31 Jan 2017 10:53:01 +0200 Subject: [PATCH 027/104] update wampy.d.ts to work with in-browser typescript --- wampy/wampy.d.ts | 198 +++++++++++++++++++++++------------------------ 1 file changed, 99 insertions(+), 99 deletions(-) diff --git a/wampy/wampy.d.ts b/wampy/wampy.d.ts index e068b97a25..261c521aff 100644 --- a/wampy/wampy.d.ts +++ b/wampy/wampy.d.ts @@ -3,103 +3,103 @@ // Definitions by: Konstantin Burkalev // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -declare module "wampy" { - - interface WampyOptions { - autoReconnect?: boolean; - reconnectInterval?: number; - maxRetries?: number; - transportEncoding?: string; - realm?: string; - helloCustomDetails?: any; - onChallenge?: (auth_method: string, challenge_details: string) => string; - authid?: string; - onConnect?: () => void; - onClose?: () => void; - onError?: () => void; - onReconnect?: () => void; - onReconnectSuccess?: () => void; - ws?: any; - msgpackCoder?: any; - } - - interface WampyOpStatus { - code: number; - description: string; - reqId?: number; - } - - interface SuccessErrorCallbacksHash { - onSuccess?: (data: any) => void; - onError?: (err: string) => void; - } - - interface SubscribeCallbacksHash extends SuccessErrorCallbacksHash { - onEvent: (data: any) => void; - } - - interface RegisterCallbacksHash extends SuccessErrorCallbacksHash { - rpc: (data: any, options: any) => any[]; - } - - interface CallSuccessErrorCallbacksHash { - onSuccess: (data: any) => any; - onError?: (err: string) => void; - } - - interface AdvancedOptions { - exclude?: number | number[]; - eligible?: number | number[]; - exclude_me?: boolean; - disclose_me?: boolean; - } - - interface PublishAdvancedOptions extends AdvancedOptions { - exclude_authid?: string | string[]; - exclude_authrole?: string | string[]; - eligible_authid?: string | string[]; - eligible_authrole?: string | string[]; - } - - interface CallAdvancedOptions { - disclose_me?: boolean; - receive_progress?: boolean; - timeout?: number; - } - - interface CancelAdvancedOptions { - mode?: "skip" | "kill" | "killnowait"; - } - - interface Wampy { - options(opts?: WampyOptions): WampyOptions | Wampy; - getOpStatus(): WampyOpStatus; - getSessionId(): number; - connect(url?: string): Wampy; - disconnect(): Wampy; - abort(): Wampy; - subscribe(topicURI: string, callbacks: (((data: any) => void) | SubscribeCallbacksHash)): Wampy; - unsubscribe(topicURI: string, callbacks?: (((data: any) => void) | SubscribeCallbacksHash)): Wampy; - publish(topicURI: string, - payload?: any, - callbacks?: SuccessErrorCallbacksHash, - advancedOptions?: PublishAdvancedOptions): Wampy; - call(topicURI: string, - payload?: any, - callbacks?: (((data: any) => void) | CallSuccessErrorCallbacksHash), - advancedOptions?: CallAdvancedOptions): Wampy; - cancel(reqId: number, - callbacks?: ((() => void) | SuccessErrorCallbacksHash), - advancedOptions?: CancelAdvancedOptions): Wampy; - register(topicURI: string, callbacks: (((data: any, options: any) => any[]) | RegisterCallbacksHash)): Wampy; - unregister(topicURI: string, callbacks?: ((() => void) | SuccessErrorCallbacksHash)): Wampy; - } - - interface WampyInstance { - new(url?: string, options?: WampyOptions): Wampy; - } - - var wampy: WampyInstance; - - export default wampy; +interface WampyOptions { + autoReconnect?: boolean; + reconnectInterval?: number; + maxRetries?: number; + transportEncoding?: string; + realm?: string; + helloCustomDetails?: any; + onChallenge?: (auth_method: string, challenge_details: string) => string; + authid?: string; + onConnect?: () => void; + onClose?: () => void; + onError?: () => void; + onReconnect?: () => void; + onReconnectSuccess?: () => void; + ws?: any; + msgpackCoder?: any; } + +interface WampyOpStatus { + code: number; + description: string; + reqId?: number; +} + +interface SuccessErrorCallbacksHash { + onSuccess?: (data: any) => void; + onError?: (err: string) => void; +} + +interface SubscribeCallbacksHash extends SuccessErrorCallbacksHash { + onEvent: (data: any) => void; +} + +interface RegisterCallbacksHash extends SuccessErrorCallbacksHash { + rpc: (data: any, options: any) => any[]; +} + +interface CallSuccessErrorCallbacksHash { + onSuccess: (data: any) => any; + onError?: (err: string) => void; +} + +interface AdvancedOptions { + exclude?: number | number[]; + eligible?: number | number[]; + exclude_me?: boolean; + disclose_me?: boolean; +} + +interface PublishAdvancedOptions extends AdvancedOptions { + exclude_authid?: string | string[]; + exclude_authrole?: string | string[]; + eligible_authid?: string | string[]; + eligible_authrole?: string | string[]; +} + +interface CallAdvancedOptions { + disclose_me?: boolean; + receive_progress?: boolean; + timeout?: number; +} + +interface CancelAdvancedOptions { + mode?: "skip" | "kill" | "killnowait"; +} + +interface Wampy { + new (url?: string, options?: WampyOptions): Wampy; + options(opts?: WampyOptions): WampyOptions | Wampy; + getOpStatus(): WampyOpStatus; + getSessionId(): number; + connect(url?: string): Wampy; + disconnect(): Wampy; + abort(): Wampy; + subscribe(topicURI: string, callbacks: (((data: any) => void) | SubscribeCallbacksHash)): Wampy; + unsubscribe(topicURI: string, callbacks?: (((data: any) => void) | SubscribeCallbacksHash)): Wampy; + publish(topicURI: string, + payload?: any, + callbacks?: SuccessErrorCallbacksHash, + advancedOptions?: PublishAdvancedOptions): Wampy; + call(topicURI: string, + payload?: any, + callbacks?: (((data: any) => void) | CallSuccessErrorCallbacksHash), + advancedOptions?: CallAdvancedOptions): Wampy; + cancel(reqId: number, + callbacks?: ((() => void) | SuccessErrorCallbacksHash), + advancedOptions?: CancelAdvancedOptions): Wampy; + register(topicURI: string, callbacks: (((data: any, options: any) => any[]) | RegisterCallbacksHash)): Wampy; + unregister(topicURI: string, callbacks?: ((() => void) | SuccessErrorCallbacksHash)): Wampy; +} + + +declare var wampy: Wampy; + +declare module 'wampy' +{ + export = wampy +} + + From 8f873ba3566630dad1b62d080d93145de2dc5784 Mon Sep 17 00:00:00 2001 From: Rohit Kumar Date: Tue, 31 Jan 2017 18:01:53 +0530 Subject: [PATCH 028/104] Add FusionCharts definition for Charts, Widgets, Maps, PowerCharts and themes - Also fixed the linting issue. --- fusioncharts/fusioncharts-tests.ts | 2 ++ fusioncharts/fusioncharts.charts.d.ts | 7 +++++++ fusioncharts/fusioncharts.gantt.d.ts | 7 +++++++ fusioncharts/fusioncharts.maps.d.ts | 7 +++++++ fusioncharts/fusioncharts.powercharts.d.ts | 7 +++++++ fusioncharts/fusioncharts.ssgrid.d.ts | 7 +++++++ fusioncharts/fusioncharts.treemap.d.ts | 7 +++++++ fusioncharts/fusioncharts.widgets.d.ts | 7 +++++++ fusioncharts/fusioncharts.zoomscatter.d.ts | 7 +++++++ fusioncharts/index.d.ts | 14 +++++++------- fusioncharts/maps/fusioncharts.usa.d.ts | 7 +++++++ fusioncharts/maps/fusioncharts.world.d.ts | 7 +++++++ fusioncharts/themes/fusioncharts.theme.carbon.d.ts | 7 +++++++ fusioncharts/themes/fusioncharts.theme.fint.d.ts | 7 +++++++ fusioncharts/themes/fusioncharts.theme.ocean.d.ts | 7 +++++++ fusioncharts/themes/fusioncharts.theme.zune.d.ts | 7 +++++++ fusioncharts/tsconfig.json | 14 ++++++++++++++ fusioncharts/tslint.json | 1 + 18 files changed, 122 insertions(+), 7 deletions(-) create mode 100644 fusioncharts/fusioncharts.charts.d.ts create mode 100644 fusioncharts/fusioncharts.gantt.d.ts create mode 100644 fusioncharts/fusioncharts.maps.d.ts create mode 100644 fusioncharts/fusioncharts.powercharts.d.ts create mode 100644 fusioncharts/fusioncharts.ssgrid.d.ts create mode 100644 fusioncharts/fusioncharts.treemap.d.ts create mode 100644 fusioncharts/fusioncharts.widgets.d.ts create mode 100644 fusioncharts/fusioncharts.zoomscatter.d.ts create mode 100644 fusioncharts/maps/fusioncharts.usa.d.ts create mode 100644 fusioncharts/maps/fusioncharts.world.d.ts create mode 100644 fusioncharts/themes/fusioncharts.theme.carbon.d.ts create mode 100644 fusioncharts/themes/fusioncharts.theme.fint.d.ts create mode 100644 fusioncharts/themes/fusioncharts.theme.ocean.d.ts create mode 100644 fusioncharts/themes/fusioncharts.theme.zune.d.ts create mode 100644 fusioncharts/tslint.json diff --git a/fusioncharts/fusioncharts-tests.ts b/fusioncharts/fusioncharts-tests.ts index 9bbf640225..77b912ba18 100644 --- a/fusioncharts/fusioncharts-tests.ts +++ b/fusioncharts/fusioncharts-tests.ts @@ -1,3 +1,5 @@ +import * as FusionCharts from "fusioncharts"; + FusionCharts.addEventListener('ready',(eventObject)=>{ eventObject.stopPropagation(); }); diff --git a/fusioncharts/fusioncharts.charts.d.ts b/fusioncharts/fusioncharts.charts.d.ts new file mode 100644 index 0000000000..214f9d79c2 --- /dev/null +++ b/fusioncharts/fusioncharts.charts.d.ts @@ -0,0 +1,7 @@ +interface FusionCharts { + type: string; +} + +declare var charts: (H: FusionCharts) => FusionCharts; +export = charts; +export as namespace charts; diff --git a/fusioncharts/fusioncharts.gantt.d.ts b/fusioncharts/fusioncharts.gantt.d.ts new file mode 100644 index 0000000000..7af79ff354 --- /dev/null +++ b/fusioncharts/fusioncharts.gantt.d.ts @@ -0,0 +1,7 @@ +interface FusionCharts { + type: string; +} + +declare var gantt: (H: FusionCharts) => FusionCharts; +export = gantt; +export as namespace gantt; diff --git a/fusioncharts/fusioncharts.maps.d.ts b/fusioncharts/fusioncharts.maps.d.ts new file mode 100644 index 0000000000..8610b8405f --- /dev/null +++ b/fusioncharts/fusioncharts.maps.d.ts @@ -0,0 +1,7 @@ +interface FusionCharts { + type: string; +} + +declare var maps: (H: FusionCharts) => FusionCharts; +export = maps; +export as namespace maps; diff --git a/fusioncharts/fusioncharts.powercharts.d.ts b/fusioncharts/fusioncharts.powercharts.d.ts new file mode 100644 index 0000000000..432cc4ce24 --- /dev/null +++ b/fusioncharts/fusioncharts.powercharts.d.ts @@ -0,0 +1,7 @@ +interface FusionCharts { + type: string; +} + +declare var powercharts: (H: FusionCharts) => FusionCharts; +export = powercharts; +export as namespace powercharts; diff --git a/fusioncharts/fusioncharts.ssgrid.d.ts b/fusioncharts/fusioncharts.ssgrid.d.ts new file mode 100644 index 0000000000..f74376410d --- /dev/null +++ b/fusioncharts/fusioncharts.ssgrid.d.ts @@ -0,0 +1,7 @@ +interface FusionCharts { + type: string; +} + +declare var ssgrid: (H: FusionCharts) => FusionCharts; +export = ssgrid; +export as namespace ssgrid; diff --git a/fusioncharts/fusioncharts.treemap.d.ts b/fusioncharts/fusioncharts.treemap.d.ts new file mode 100644 index 0000000000..f8f80059ed --- /dev/null +++ b/fusioncharts/fusioncharts.treemap.d.ts @@ -0,0 +1,7 @@ +interface FusionCharts { + type: string; +} + +declare var treemap: (H: FusionCharts) => FusionCharts; +export = treemap; +export as namespace treemap; diff --git a/fusioncharts/fusioncharts.widgets.d.ts b/fusioncharts/fusioncharts.widgets.d.ts new file mode 100644 index 0000000000..052216721d --- /dev/null +++ b/fusioncharts/fusioncharts.widgets.d.ts @@ -0,0 +1,7 @@ +interface FusionCharts { + type: string; +} + +declare var widgets: (H: FusionCharts) => FusionCharts; +export = widgets; +export as namespace widgets; diff --git a/fusioncharts/fusioncharts.zoomscatter.d.ts b/fusioncharts/fusioncharts.zoomscatter.d.ts new file mode 100644 index 0000000000..07e58585bb --- /dev/null +++ b/fusioncharts/fusioncharts.zoomscatter.d.ts @@ -0,0 +1,7 @@ +interface FusionCharts { + type: string; +} + +declare var zoomscatter: (H: FusionCharts) => FusionCharts; +export = zoomscatter; +export as namespace zoomscatter; diff --git a/fusioncharts/index.d.ts b/fusioncharts/index.d.ts index dc053859b9..9c46955075 100644 --- a/fusioncharts/index.d.ts +++ b/fusioncharts/index.d.ts @@ -1,6 +1,6 @@ -// Type definitions for FusionCharts 3.11.2 +// Type definitions for fusioncharts 3.11 // Project: http://www.fusioncharts.com -// Definitions by: Shivaraj KV +// Definitions by: Rohit Kumar , Shivaraj KV // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped @@ -136,9 +136,9 @@ declare namespace FusionCharts { outputTo(callback: (message: any) => any): void; - enable(state:any,outputTo?:(message: any) =>any,outputFormat?:any):void + enable(state: any, outputTo?: (message: any) => any, outputFormat?: any): void; - enableFirebugLite():any; + enableFirebugLite(): any; } interface FusionCharts { @@ -154,7 +154,7 @@ declare namespace FusionCharts { configureLink(param: {} | any[], level?: number): void; - setChartAttribute(attributes: ChartObject | String, value?: string): void; + setChartAttribute(attributes: ChartObject | string, value?: string): void; getChartAttribute(attribute?: string | string[]): ChartObject; @@ -273,7 +273,7 @@ declare namespace FusionCharts { formatNumber(num: number, type?: string, config?: {}): Element; - setCurrentRenderer(name: string): void + setCurrentRenderer(name: string): void; getCurrentRenderer(): string; @@ -285,7 +285,7 @@ declare namespace FusionCharts { options: {}; - debugger:Debugger; + debugger: Debugger; } diff --git a/fusioncharts/maps/fusioncharts.usa.d.ts b/fusioncharts/maps/fusioncharts.usa.d.ts new file mode 100644 index 0000000000..159ad8ab80 --- /dev/null +++ b/fusioncharts/maps/fusioncharts.usa.d.ts @@ -0,0 +1,7 @@ +interface FusionCharts { + type: string; +} + +declare var usa: (H: FusionCharts) => FusionCharts; +export = usa; +export as namespace usa; diff --git a/fusioncharts/maps/fusioncharts.world.d.ts b/fusioncharts/maps/fusioncharts.world.d.ts new file mode 100644 index 0000000000..889afc5a7d --- /dev/null +++ b/fusioncharts/maps/fusioncharts.world.d.ts @@ -0,0 +1,7 @@ +interface FusionCharts { + type: string; +} + +declare var world: (H: FusionCharts) => FusionCharts; +export = world; +export as namespace world; diff --git a/fusioncharts/themes/fusioncharts.theme.carbon.d.ts b/fusioncharts/themes/fusioncharts.theme.carbon.d.ts new file mode 100644 index 0000000000..0be2ca7334 --- /dev/null +++ b/fusioncharts/themes/fusioncharts.theme.carbon.d.ts @@ -0,0 +1,7 @@ +interface FusionCharts { + type: string; +} + +declare var carbon: (H: FusionCharts) => FusionCharts; +export = carbon; +export as namespace carbon; diff --git a/fusioncharts/themes/fusioncharts.theme.fint.d.ts b/fusioncharts/themes/fusioncharts.theme.fint.d.ts new file mode 100644 index 0000000000..8c76253ee6 --- /dev/null +++ b/fusioncharts/themes/fusioncharts.theme.fint.d.ts @@ -0,0 +1,7 @@ +interface FusionCharts { + type: string; +} + +declare var fint: (H: FusionCharts) => FusionCharts; +export = fint; +export as namespace fint; diff --git a/fusioncharts/themes/fusioncharts.theme.ocean.d.ts b/fusioncharts/themes/fusioncharts.theme.ocean.d.ts new file mode 100644 index 0000000000..f0dd57aa03 --- /dev/null +++ b/fusioncharts/themes/fusioncharts.theme.ocean.d.ts @@ -0,0 +1,7 @@ +interface FusionCharts { + type: string; +} + +declare var ocean: (H: FusionCharts) => FusionCharts; +export = ocean; +export as namespace ocean; diff --git a/fusioncharts/themes/fusioncharts.theme.zune.d.ts b/fusioncharts/themes/fusioncharts.theme.zune.d.ts new file mode 100644 index 0000000000..23c04014c7 --- /dev/null +++ b/fusioncharts/themes/fusioncharts.theme.zune.d.ts @@ -0,0 +1,7 @@ +interface FusionCharts { + type: string; +} + +declare var zune: (H: FusionCharts) => FusionCharts; +export = zune; +export as namespace zune; diff --git a/fusioncharts/tsconfig.json b/fusioncharts/tsconfig.json index dc4436d64c..970238d9a8 100644 --- a/fusioncharts/tsconfig.json +++ b/fusioncharts/tsconfig.json @@ -18,6 +18,20 @@ }, "files": [ "index.d.ts", + "fusioncharts.charts.d.ts", + "fusioncharts.powercharts.d.ts", + "fusioncharts.widgets.d.ts", + "fusioncharts.maps.d.ts", + "fusioncharts.zoomscatter.d.ts", + "fusioncharts.ssgrid.d.ts", + "fusioncharts.gantt.d.ts", + "fusioncharts.treemap.d.ts", + "maps/fusioncharts.usa.d.ts", + "maps/fusioncharts.world.d.ts", + "themes/fusioncharts.theme.carbon.d.ts", + "themes/fusioncharts.theme.fint.d.ts", + "themes/fusioncharts.theme.ocean.d.ts", + "themes/fusioncharts.theme.zune.d.ts", "fusioncharts-tests.ts" ] } \ No newline at end of file diff --git a/fusioncharts/tslint.json b/fusioncharts/tslint.json new file mode 100644 index 0000000000..377cc837d4 --- /dev/null +++ b/fusioncharts/tslint.json @@ -0,0 +1 @@ +{ "extends": "../tslint.json" } From c1d3c066bf68a9b0fe357800e424df5ece7e4eee Mon Sep 17 00:00:00 2001 From: Drew Noakes Date: Tue, 31 Jan 2017 22:46:21 +0000 Subject: [PATCH 029/104] Consistent delimiters. --- react-modal/index.d.ts | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/react-modal/index.d.ts b/react-modal/index.d.ts index e5db7d66f0..80958ae918 100644 --- a/react-modal/index.d.ts +++ b/react-modal/index.d.ts @@ -12,20 +12,20 @@ declare module "react-modal" { style?: { content?: { [key: string]: any; - }, + }; overlay?: { [key: string]: any; - } - }, - appElement?: HTMLElement | {}, - onAfterOpen?: Function, - onRequestClose?: Function, - closeTimeoutMS?: number, - ariaHideApp?: boolean, - shouldCloseOnOverlayClick?: boolean, - overlayClassName?: string, - className?: string - contentLabel?: string + }; + }; + appElement?: HTMLElement | {}; + onAfterOpen?: Function; + onRequestClose?: Function; + closeTimeoutMS?: number; + ariaHideApp?: boolean; + shouldCloseOnOverlayClick?: boolean; + overlayClassName?: string; + className?: string; + contentLabel?: string; } let ReactModal: React.ClassicComponentClass; export = ReactModal; From d998af2ff33295d7bc63644086646ba1300f2ad7 Mon Sep 17 00:00:00 2001 From: Drew Noakes Date: Tue, 31 Jan 2017 22:47:04 +0000 Subject: [PATCH 030/104] Specify function type. --- react-modal/index.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/react-modal/index.d.ts b/react-modal/index.d.ts index 80958ae918..13e4a94a0c 100644 --- a/react-modal/index.d.ts +++ b/react-modal/index.d.ts @@ -18,8 +18,8 @@ declare module "react-modal" { }; }; appElement?: HTMLElement | {}; - onAfterOpen?: Function; - onRequestClose?: Function; + onAfterOpen?: () => void; + onRequestClose?: () => void; closeTimeoutMS?: number; ariaHideApp?: boolean; shouldCloseOnOverlayClick?: boolean; From e20443bdf764432446cdae94347359dab22e1ace Mon Sep 17 00:00:00 2001 From: Drew Noakes Date: Tue, 31 Jan 2017 22:49:32 +0000 Subject: [PATCH 031/104] Add documentation. --- react-modal/index.d.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/react-modal/index.d.ts b/react-modal/index.d.ts index 13e4a94a0c..1a3826004a 100644 --- a/react-modal/index.d.ts +++ b/react-modal/index.d.ts @@ -8,7 +8,9 @@ declare module "react-modal" { interface ReactModal { + /* Boolean describing if the modal should be shown or not. Defaults to false. */ isOpen: boolean; + /* Object indicating styles to be used for the modal, divided into overlay and content styles. */ style?: { content?: { [key: string]: any; @@ -17,14 +19,23 @@ declare module "react-modal" { [key: string]: any; }; }; + /* Set this to properly hide your application from assistive screenreaders and other assistive technologies while the modal is open. */ appElement?: HTMLElement | {}; + /* Function that will be run after the modal has opened. */ onAfterOpen?: () => void; + /* Function that will be run when the modal is requested to be closed, prior to actually closing. */ onRequestClose?: () => void; + /* Number indicating the milliseconds to wait before closing the modal. Defaults to zero (no timeout). */ closeTimeoutMS?: number; + /* Boolean indicating if the appElement should be hidden. Defaults to true. */ ariaHideApp?: boolean; + /* Boolean indicating if the overlay should close the modal. Defaults to true. */ shouldCloseOnOverlayClick?: boolean; + /* String className to be applied to the overlay. */ overlayClassName?: string; + /* String className to be applied to the modal content. */ className?: string; + /* String indicating how the content container should be announced to screenreaders. */ contentLabel?: string; } let ReactModal: React.ClassicComponentClass; From ae31538dc212e9a37c3463c091b37f328d9935ab Mon Sep 17 00:00:00 2001 From: Drew Noakes Date: Tue, 31 Jan 2017 22:51:06 +0000 Subject: [PATCH 032/104] Add static members. --- react-modal/index.d.ts | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/react-modal/index.d.ts b/react-modal/index.d.ts index 1a3826004a..7dc83f7d79 100644 --- a/react-modal/index.d.ts +++ b/react-modal/index.d.ts @@ -7,10 +7,7 @@ /// declare module "react-modal" { - interface ReactModal { - /* Boolean describing if the modal should be shown or not. Defaults to false. */ - isOpen: boolean; - /* Object indicating styles to be used for the modal, divided into overlay and content styles. */ + interface Styles { style?: { content?: { [key: string]: any; @@ -19,6 +16,12 @@ declare module "react-modal" { [key: string]: any; }; }; + } + interface ReactModal { + /* Boolean describing if the modal should be shown or not. Defaults to false. */ + isOpen: boolean; + /* Object indicating styles to be used for the modal, divided into overlay and content styles. */ + style?: Styles; /* Set this to properly hide your application from assistive screenreaders and other assistive technologies while the modal is open. */ appElement?: HTMLElement | {}; /* Function that will be run after the modal has opened. */ @@ -38,6 +41,11 @@ declare module "react-modal" { /* String indicating how the content container should be announced to screenreaders. */ contentLabel?: string; } - let ReactModal: React.ClassicComponentClass; + let ReactModal: React.ClassicComponentClass & { + /* Override styles for all modals. */ + defaultStyles: Styles; + /* Call this to properly hide your application from assistive screenreaders and other assistive technologies while the modal is open. */ + setAppElement(appElement: HTMLElement): void; + }; export = ReactModal; } From c6e9076a946fb67ce462ffea6c4e9bd1bc16eadb Mon Sep 17 00:00:00 2001 From: Drew Noakes Date: Tue, 31 Jan 2017 22:52:13 +0000 Subject: [PATCH 033/104] Add missing members. --- react-modal/index.d.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/react-modal/index.d.ts b/react-modal/index.d.ts index 7dc83f7d79..1d24ebc85b 100644 --- a/react-modal/index.d.ts +++ b/react-modal/index.d.ts @@ -34,12 +34,18 @@ declare module "react-modal" { ariaHideApp?: boolean; /* Boolean indicating if the overlay should close the modal. Defaults to true. */ shouldCloseOnOverlayClick?: boolean; + /* String className to be applied to the portal. Defaults to "ReactModalPortal". */ + portalClassName?: string; /* String className to be applied to the overlay. */ overlayClassName?: string; /* String className to be applied to the modal content. */ className?: string; /* String indicating how the content container should be announced to screenreaders. */ contentLabel?: string; + /* String indicating the role of the modal, allowing the 'dialog' role to be applied if desired. */ + role?: string; + /* Function that will be called to get the parent element that the modal will be attached to. */ + parentSelector?: () => HTMLElement; } let ReactModal: React.ClassicComponentClass & { /* Override styles for all modals. */ From e4bf1668726965be0860a89ede5667ace3240e1b Mon Sep 17 00:00:00 2001 From: Drew Noakes Date: Tue, 31 Jan 2017 22:52:28 +0000 Subject: [PATCH 034/104] Bump react-modal version to 1.6.5. --- react-modal/index.d.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/react-modal/index.d.ts b/react-modal/index.d.ts index 1d24ebc85b..115e36730b 100644 --- a/react-modal/index.d.ts +++ b/react-modal/index.d.ts @@ -1,6 +1,7 @@ -// Type definitions for react-modal v1.6.1 +// Type definitions for react-modal v1.6.5 // Project: https://github.com/reactjs/react-modal // Definitions by: Rajab Shakirov +// Definitions by: Drew Noakes // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.1 From 05478eb92a04b36ea25246d0806b4ff2fd04b415 Mon Sep 17 00:00:00 2001 From: Jakub Pistek Date: Tue, 31 Jan 2017 19:51:29 +0100 Subject: [PATCH 035/104] Update ngStorage to latest version --- ngstorage/index.d.ts | 34 ++++++++---------- ngstorage/ngstorage-tests.ts | 68 ++++++++++++++++++------------------ ngstorage/tsconfig.json | 2 +- 3 files changed, 50 insertions(+), 54 deletions(-) diff --git a/ngstorage/index.d.ts b/ngstorage/index.d.ts index b8fcf023c8..15fb3c0481 100644 --- a/ngstorage/index.d.ts +++ b/ngstorage/index.d.ts @@ -1,29 +1,25 @@ -// Type definitions for ngstorage 0.3.10 +// Type definitions for ngstorage 0.3.11 // Project: https://github.com/gsklee/ngStorage // Definitions by: Jakub Pistek // Definitions: https://github.com/kubiq/DefinitelyTyped -import * as angular from 'angular'; +declare module 'ngstorage' { -declare module 'angular' { - export namespace storage { + interface IStorageService { + $default(items: {}): IStorageService; + $reset(items?: {}): IStorageService; + $apply(): void; + $sync(): void; + get(key: string): T; + } - export interface IStorageService { - $default(items: {}): IStorageService; - $reset(items?: {}): IStorageService; - $apply(): void; - $sync(): void; - get(key: string): T; - } + interface IStorageProvider extends angular.IServiceProvider { - export interface IStorageProvider extends angular.IServiceProvider { + get(key: string): T; + set(key: string, value: T): T; - get(key: string): T; - set(key: string, value: T): T; - - setKeyPrefix(prefix: string): void; - setSerializer(serializer: (value: any) => string): void; - setDeserializer(deserializer: (value: string) => any): void; - } + setKeyPrefix(prefix: string): void; + setSerializer(serializer: (value: any) => string): void; + setDeserializer(deserializer: (value: string) => any): void; } } diff --git a/ngstorage/ngstorage-tests.ts b/ngstorage/ngstorage-tests.ts index 924d017a66..abddf19bb7 100644 --- a/ngstorage/ngstorage-tests.ts +++ b/ngstorage/ngstorage-tests.ts @@ -1,9 +1,9 @@ -/// +/// +import {IStorageService, IStorageProvider} from "ngstorage"; var app: any; - -app.controller('LocalCtrl', function ($localStorage: angular.storage.IStorageService) { +app.controller('LocalCtrl', function ($localStorage: IStorageService) { $localStorage.$default({ counter: 1 @@ -12,15 +12,15 @@ app.controller('LocalCtrl', function ($localStorage: angular.storage.IStorageSer $localStorage.$reset({ counter: 1 }); - + $localStorage.$reset(); $localStorage.$apply(); - + $localStorage.$sync(); }); -app.controller('SessionCtrl', function ($sessionStorage: angular.storage.IStorageService) { +app.controller('SessionCtrl', function ($sessionStorage: IStorageService) { $sessionStorage.$default({ counter: 1 @@ -29,50 +29,50 @@ app.controller('SessionCtrl', function ($sessionStorage: angular.storage.IStorag $sessionStorage.$reset({ counter: 1 }); - + $sessionStorage.$reset(); $sessionStorage.$apply(); - + $sessionStorage.$sync(); }); -app.config(['$localStorageProvider', function ($localStorageProvider: angular.storage.IStorageProvider) { +app.config(['$localStorageProvider', function ($localStorageProvider: IStorageProvider) { - $localStorageProvider.setKeyPrefix('NewPrefix'); + $localStorageProvider.setKeyPrefix('NewPrefix'); - $localStorageProvider.get('MyKey'); + $localStorageProvider.get('MyKey'); - $localStorageProvider.set('MyKey', { counter: 'value' }); + $localStorageProvider.set('MyKey', {counter: 'value'}); - var mySerializer = function (value:any):string { - return value.toString(); - }; + var mySerializer = function (value: any): string { + return value.toString(); + }; - var myDeserializer = function (value:string):any { - return value; - }; + var myDeserializer = function (value: string): any { + return value; + }; - $localStorageProvider.setSerializer(mySerializer); - $localStorageProvider.setDeserializer(myDeserializer); - } -]).config(['$sessionStorageProvider', function ($sessionStorageProvider: angular.storage.IStorageProvider) { + $localStorageProvider.setSerializer(mySerializer); + $localStorageProvider.setDeserializer(myDeserializer); +} +]).config(['$sessionStorageProvider', function ($sessionStorageProvider: IStorageProvider) { - $sessionStorageProvider.setKeyPrefix('NewPrefix'); + $sessionStorageProvider.setKeyPrefix('NewPrefix'); - $sessionStorageProvider.get('MyKey'); + $sessionStorageProvider.get('MyKey'); - $sessionStorageProvider.set('MyKey', { counter: 'value' }); + $sessionStorageProvider.set('MyKey', {counter: 'value'}); - var mySerializer = function (value:any):string { - return value.toString(); - }; + var mySerializer = function (value: any): string { + return value.toString(); + }; - var myDeserializer = function (value:string):any { - return value; - }; + var myDeserializer = function (value: string): any { + return value; + }; - $sessionStorageProvider.setSerializer(mySerializer); - $sessionStorageProvider.setDeserializer(myDeserializer); - } + $sessionStorageProvider.setSerializer(mySerializer); + $sessionStorageProvider.setDeserializer(myDeserializer); +} ]); diff --git a/ngstorage/tsconfig.json b/ngstorage/tsconfig.json index 691875db20..a3cdb4a204 100644 --- a/ngstorage/tsconfig.json +++ b/ngstorage/tsconfig.json @@ -20,4 +20,4 @@ "index.d.ts", "ngstorage-tests.ts" ] -} \ No newline at end of file +} From 877d3861dedbeee12e8d9d4a0dbbdc286dccab84 Mon Sep 17 00:00:00 2001 From: Calvin Jeong Date: Wed, 1 Feb 2017 14:44:58 +1300 Subject: [PATCH 036/104] Updated three/index.d.ts Added extra properties for `Spherical` class. --- three/index.d.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/three/index.d.ts b/three/index.d.ts index 36263993c7..b4b4995ee8 100644 --- a/three/index.d.ts +++ b/three/index.d.ts @@ -3586,6 +3586,10 @@ declare namespace THREE { export class Spherical { constructor(radius?: number, phi?: number, theta?: number); + radius: number; + phi: number; + theta: number; + set(radius: number, phi: number, theta: number): Spherical; clone(): this; copy(other: this): this; From 72698b1b117efb129f80964393ed39ed69009ac2 Mon Sep 17 00:00:00 2001 From: Ryan Gomoto Date: Tue, 31 Jan 2017 19:04:52 -0800 Subject: [PATCH 037/104] Fix bintrees callback signature --- bintrees/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bintrees/index.d.ts b/bintrees/index.d.ts index 9853be67dc..7a7b2c233e 100644 --- a/bintrees/index.d.ts +++ b/bintrees/index.d.ts @@ -5,7 +5,7 @@ declare module 'bintrees' { - type Callback = (err: Error, item: T) => void; + type Callback = (item: T) => void; type Comparator = (a: T, b: T) => number; class Iterator { From b1a2640f60981fa575b6b8339ce385003117404d Mon Sep 17 00:00:00 2001 From: bglee Date: Wed, 1 Feb 2017 13:44:48 +0900 Subject: [PATCH 038/104] add 4 props accessibility?: boolean nextArrow?: HTMLElement | any prevArrow?: HTMLElement | any pauseOnHover?: boolean --- react-slick/index.d.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/react-slick/index.d.ts b/react-slick/index.d.ts index 9bd267cad1..0f8c770ee2 100644 --- a/react-slick/index.d.ts +++ b/react-slick/index.d.ts @@ -6,6 +6,10 @@ /// interface __config { + accessibility?: boolean + nextArrow?: HTMLElement | any + prevArrow?: HTMLElement | any + pauseOnHover?: boolean className?: string adaptiveHeight?: boolean arrows?: boolean From 96996eebbdd326f6925e6da9360e4566e80e882a Mon Sep 17 00:00:00 2001 From: bglee Date: Wed, 1 Feb 2017 13:44:48 +0900 Subject: [PATCH 039/104] add 4 props accessibility?: boolean nextArrow?: HTMLElement | any prevArrow?: HTMLElement | any pauseOnHover?: boolean --- react-slick/index.d.ts | 4 ++++ react-slick/react-slick-tests.tsx | 3 ++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/react-slick/index.d.ts b/react-slick/index.d.ts index 9bd267cad1..0f8c770ee2 100644 --- a/react-slick/index.d.ts +++ b/react-slick/index.d.ts @@ -6,6 +6,10 @@ /// interface __config { + accessibility?: boolean + nextArrow?: HTMLElement | any + prevArrow?: HTMLElement | any + pauseOnHover?: boolean className?: string adaptiveHeight?: boolean arrows?: boolean diff --git a/react-slick/react-slick-tests.tsx b/react-slick/react-slick-tests.tsx index 7b51dbdf3a..2d26b0dcf1 100644 --- a/react-slick/react-slick-tests.tsx +++ b/react-slick/react-slick-tests.tsx @@ -10,7 +10,8 @@ class SliderTest extends React.Component, {}> { slidesToShow: 8, slidesToScroll: 1, draggable: false, - infinite: false + infinite: false, + prevArrow: link }; return ( From 863829da136054d403b1d5383d46828f4e729f52 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EC=84=9D=EB=9E=98?= Date: Wed, 1 Feb 2017 17:23:44 +0900 Subject: [PATCH 040/104] add Request.buffer() --- chai-http/index.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/chai-http/index.d.ts b/chai-http/index.d.ts index 567f13e4e7..2e619b6166 100644 --- a/chai-http/index.d.ts +++ b/chai-http/index.d.ts @@ -55,6 +55,7 @@ declare namespace ChaiHttp { send(data: Object): Request; auth(user: string, name: string): Request; field(name: string, val: string): Request; + buffer(): Request; end(callback?: (err: any, res: Response) => void): FinishedRequest; } From fa1585f9a3f7da71b79ff78929f65d88fad2cc08 Mon Sep 17 00:00:00 2001 From: Giedrius Grabauskas Date: Wed, 1 Feb 2017 19:58:01 +0200 Subject: [PATCH 041/104] Fixed ConfigMap object hierarchy Read more here: https://github.com/DefinitelyTyped/DefinitelyTyped/issues/9744 --- systemjs/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/systemjs/index.d.ts b/systemjs/index.d.ts index 428e303442..f759ba3f91 100644 --- a/systemjs/index.d.ts +++ b/systemjs/index.d.ts @@ -29,7 +29,7 @@ declare namespace SystemJSLoader { */ type Transpiler = "plugin-traceur" | "plugin-babel" | "plugin-typescript" | "traceur" | "babel" | "typescript" | boolean; - type ConfigMap = PackageList; + type ConfigMap = PackageList>; type ConfigMeta = PackageList; From 8f90dd420a0a8a55261180cac0606975907f346b Mon Sep 17 00:00:00 2001 From: Giedrius Grabauskas Date: Wed, 1 Feb 2017 20:00:49 +0200 Subject: [PATCH 042/104] Updated systemjs tests Updated SystemJS naming. Added test with ConfigMap hierarchy. --- systemjs/systemjs-tests.ts | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/systemjs/systemjs-tests.ts b/systemjs/systemjs-tests.ts index 3c2f8ebadc..f24c01b537 100644 --- a/systemjs/systemjs-tests.ts +++ b/systemjs/systemjs-tests.ts @@ -1,14 +1,12 @@ +import SystemJS = require('SystemJSjs'); - -import System = require('systemjs'); - -System.config({ +SystemJS.config({ baseURL: '/app' }); -System.import('main.js'); +SystemJS.import('main.js'); -System.config({ +SystemJS.config({ // or 'traceur' or 'typescript' transpiler: 'babel', // or traceurOptions or typescriptOptions @@ -18,22 +16,33 @@ System.config({ }); -System.config({ +SystemJS.config({ map: { traceur: 'path/to/traceur.js' } }); -System.transpiler = 'traceur'; +SystemJS.config({ + map: { + 'local/package': { + x: 'vendor/x.js' + }, + 'another/package': { + x: 'vendor/y.js' + } + } +}); + +SystemJS.transpiler = 'traceur'; // loads './app.js' from the current directory -System.import('./app.js').then(function (m) { +SystemJS.import('./app.js').then(function (m) { console.log(m); }); -System.import('lodash').then(function (_) { +SystemJS.import('lodash').then(function (_) { console.log(_); }); -const clonedSystemJS = new System.constructor(); +const clonedSystemJSJS = new SystemJS.constructor(); From 0455fb3c6d3c75981db3c0acdee2e594e106cc7b Mon Sep 17 00:00:00 2001 From: Giedrius Grabauskas Date: Wed, 1 Feb 2017 20:25:38 +0200 Subject: [PATCH 043/104] Fixed refactoring. --- systemjs/systemjs-tests.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/systemjs/systemjs-tests.ts b/systemjs/systemjs-tests.ts index f24c01b537..53eeba8a2a 100644 --- a/systemjs/systemjs-tests.ts +++ b/systemjs/systemjs-tests.ts @@ -1,4 +1,4 @@ -import SystemJS = require('SystemJSjs'); +import SystemJS = require('Systemjs'); SystemJS.config({ baseURL: '/app' From 16ce688ad7b110afc2ec765f6c264a208bd25a02 Mon Sep 17 00:00:00 2001 From: Giedrius Grabauskas Date: Wed, 1 Feb 2017 20:26:18 +0200 Subject: [PATCH 044/104] Fixed import. --- systemjs/systemjs-tests.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/systemjs/systemjs-tests.ts b/systemjs/systemjs-tests.ts index 53eeba8a2a..fa0ddbedaf 100644 --- a/systemjs/systemjs-tests.ts +++ b/systemjs/systemjs-tests.ts @@ -1,4 +1,4 @@ -import SystemJS = require('Systemjs'); +import SystemJS = require('systemjs'); SystemJS.config({ baseURL: '/app' From ff38bd198b87ba02101af481d5eac8aba3da4bed Mon Sep 17 00:00:00 2001 From: Drew Noakes Date: Wed, 1 Feb 2017 21:39:47 +0000 Subject: [PATCH 045/104] Fix tslint errors 'dt-header' - Expected: foo MAJOR.MINOR (patch version not allowed) - Expected: foo MAJOR.MINOR ('v' not allowed) --- react-modal/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/react-modal/index.d.ts b/react-modal/index.d.ts index 115e36730b..20c8d08f27 100644 --- a/react-modal/index.d.ts +++ b/react-modal/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for react-modal v1.6.5 +// Type definitions for react-modal 1.6 // Project: https://github.com/reactjs/react-modal // Definitions by: Rajab Shakirov // Definitions by: Drew Noakes From fb1f121c408488d14764ad99041267c9d35e876f Mon Sep 17 00:00:00 2001 From: Drew Noakes Date: Wed, 1 Feb 2017 21:40:18 +0000 Subject: [PATCH 046/104] Fix tslint errors 'dt-header' Expected: one of /(, )|(,?\r?\n\/\/\s\s+)/ /\r?\n\/\/ Definitions by: / --- react-modal/index.d.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/react-modal/index.d.ts b/react-modal/index.d.ts index 20c8d08f27..30db228f59 100644 --- a/react-modal/index.d.ts +++ b/react-modal/index.d.ts @@ -1,7 +1,6 @@ // Type definitions for react-modal 1.6 // Project: https://github.com/reactjs/react-modal -// Definitions by: Rajab Shakirov -// Definitions by: Drew Noakes +// Definitions by: Rajab Shakirov , Drew Noakes // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.1 From 34c28a11da363a27d5de601b666c2feca176aa9a Mon Sep 17 00:00:00 2001 From: Drew Noakes Date: Wed, 1 Feb 2017 21:41:16 +0000 Subject: [PATCH 047/104] Fix tslint error 'no-single-declare-module ' MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit File has only 1 module declaration — write it as an external module. --- react-modal/index.d.ts | 93 +++++++++++++++++++++--------------------- 1 file changed, 47 insertions(+), 46 deletions(-) diff --git a/react-modal/index.d.ts b/react-modal/index.d.ts index 30db228f59..68e6f1e2bc 100644 --- a/react-modal/index.d.ts +++ b/react-modal/index.d.ts @@ -6,52 +6,53 @@ /// -declare module "react-modal" { - interface Styles { - style?: { - content?: { - [key: string]: any; - }; - overlay?: { - [key: string]: any; - }; +interface Styles { + style?: { + content?: { + [key: string]: any; + }; + overlay?: { + [key: string]: any; }; - } - interface ReactModal { - /* Boolean describing if the modal should be shown or not. Defaults to false. */ - isOpen: boolean; - /* Object indicating styles to be used for the modal, divided into overlay and content styles. */ - style?: Styles; - /* Set this to properly hide your application from assistive screenreaders and other assistive technologies while the modal is open. */ - appElement?: HTMLElement | {}; - /* Function that will be run after the modal has opened. */ - onAfterOpen?: () => void; - /* Function that will be run when the modal is requested to be closed, prior to actually closing. */ - onRequestClose?: () => void; - /* Number indicating the milliseconds to wait before closing the modal. Defaults to zero (no timeout). */ - closeTimeoutMS?: number; - /* Boolean indicating if the appElement should be hidden. Defaults to true. */ - ariaHideApp?: boolean; - /* Boolean indicating if the overlay should close the modal. Defaults to true. */ - shouldCloseOnOverlayClick?: boolean; - /* String className to be applied to the portal. Defaults to "ReactModalPortal". */ - portalClassName?: string; - /* String className to be applied to the overlay. */ - overlayClassName?: string; - /* String className to be applied to the modal content. */ - className?: string; - /* String indicating how the content container should be announced to screenreaders. */ - contentLabel?: string; - /* String indicating the role of the modal, allowing the 'dialog' role to be applied if desired. */ - role?: string; - /* Function that will be called to get the parent element that the modal will be attached to. */ - parentSelector?: () => HTMLElement; - } - let ReactModal: React.ClassicComponentClass & { - /* Override styles for all modals. */ - defaultStyles: Styles; - /* Call this to properly hide your application from assistive screenreaders and other assistive technologies while the modal is open. */ - setAppElement(appElement: HTMLElement): void; }; - export = ReactModal; } + +interface ReactModal { + /* Boolean describing if the modal should be shown or not. Defaults to false. */ + isOpen: boolean; + /* Object indicating styles to be used for the modal, divided into overlay and content styles. */ + style?: Styles; + /* Set this to properly hide your application from assistive screenreaders and other assistive technologies while the modal is open. */ + appElement?: HTMLElement | {}; + /* Function that will be run after the modal has opened. */ + onAfterOpen?: () => void; + /* Function that will be run when the modal is requested to be closed, prior to actually closing. */ + onRequestClose?: () => void; + /* Number indicating the milliseconds to wait before closing the modal. Defaults to zero (no timeout). */ + closeTimeoutMS?: number; + /* Boolean indicating if the appElement should be hidden. Defaults to true. */ + ariaHideApp?: boolean; + /* Boolean indicating if the overlay should close the modal. Defaults to true. */ + shouldCloseOnOverlayClick?: boolean; + /* String className to be applied to the portal. Defaults to "ReactModalPortal". */ + portalClassName?: string; + /* String className to be applied to the overlay. */ + overlayClassName?: string; + /* String className to be applied to the modal content. */ + className?: string; + /* String indicating how the content container should be announced to screenreaders. */ + contentLabel?: string; + /* String indicating the role of the modal, allowing the 'dialog' role to be applied if desired. */ + role?: string; + /* Function that will be called to get the parent element that the modal will be attached to. */ + parentSelector?: () => HTMLElement; +} + +declare const ReactModal: React.ClassicComponentClass & { + /* Override styles for all modals. */ + defaultStyles: Styles; + /* Call this to properly hide your application from assistive screenreaders and other assistive technologies while the modal is open. */ + setAppElement(appElement: HTMLElement): void; +}; + +export = ReactModal; From 6c1d88d6a9f3d81c993c17333bb04926051442be Mon Sep 17 00:00:00 2001 From: Drew Noakes Date: Wed, 1 Feb 2017 21:42:48 +0000 Subject: [PATCH 048/104] Use 'import' over ' +import * as React from "react"; interface Styles { style?: { From c834c31b814c751322150cb272167e2ac504f946 Mon Sep 17 00:00:00 2001 From: Drew Noakes Date: Wed, 1 Feb 2017 21:41:29 +0000 Subject: [PATCH 049/104] Add tslint file. --- react-modal/tslint.json | 1 + 1 file changed, 1 insertion(+) create mode 100644 react-modal/tslint.json diff --git a/react-modal/tslint.json b/react-modal/tslint.json new file mode 100644 index 0000000000..377cc837d4 --- /dev/null +++ b/react-modal/tslint.json @@ -0,0 +1 @@ +{ "extends": "../tslint.json" } From 70520cc92389c48b24ee7d51ea3a5362712a5eec Mon Sep 17 00:00:00 2001 From: Drew Noakes Date: Wed, 1 Feb 2017 22:03:12 +0000 Subject: [PATCH 050/104] Declare as class and namespace. --- react-modal/index.d.ts | 100 +++++++++++++++++++++-------------------- 1 file changed, 52 insertions(+), 48 deletions(-) diff --git a/react-modal/index.d.ts b/react-modal/index.d.ts index c26442aa76..4e038b416c 100644 --- a/react-modal/index.d.ts +++ b/react-modal/index.d.ts @@ -6,53 +6,57 @@ import * as React from "react"; -interface Styles { - style?: { - content?: { - [key: string]: any; - }; - overlay?: { - [key: string]: any; - }; - }; -} - -interface ReactModal { - /* Boolean describing if the modal should be shown or not. Defaults to false. */ - isOpen: boolean; - /* Object indicating styles to be used for the modal, divided into overlay and content styles. */ - style?: Styles; - /* Set this to properly hide your application from assistive screenreaders and other assistive technologies while the modal is open. */ - appElement?: HTMLElement | {}; - /* Function that will be run after the modal has opened. */ - onAfterOpen?: () => void; - /* Function that will be run when the modal is requested to be closed, prior to actually closing. */ - onRequestClose?: () => void; - /* Number indicating the milliseconds to wait before closing the modal. Defaults to zero (no timeout). */ - closeTimeoutMS?: number; - /* Boolean indicating if the appElement should be hidden. Defaults to true. */ - ariaHideApp?: boolean; - /* Boolean indicating if the overlay should close the modal. Defaults to true. */ - shouldCloseOnOverlayClick?: boolean; - /* String className to be applied to the portal. Defaults to "ReactModalPortal". */ - portalClassName?: string; - /* String className to be applied to the overlay. */ - overlayClassName?: string; - /* String className to be applied to the modal content. */ - className?: string; - /* String indicating how the content container should be announced to screenreaders. */ - contentLabel?: string; - /* String indicating the role of the modal, allowing the 'dialog' role to be applied if desired. */ - role?: string; - /* Function that will be called to get the parent element that the modal will be attached to. */ - parentSelector?: () => HTMLElement; -} - -declare const ReactModal: React.ClassicComponentClass & { - /* Override styles for all modals. */ - defaultStyles: Styles; - /* Call this to properly hide your application from assistive screenreaders and other assistive technologies while the modal is open. */ - setAppElement(appElement: HTMLElement): void; -}; +export as namespace ReactModal; export = ReactModal; + +declare namespace ReactModal { + export interface Styles { + style?: { + content?: { + [key: string]: any; + }; + overlay?: { + [key: string]: any; + }; + }; + } + + export interface Props { + /* Boolean describing if the modal should be shown or not. Defaults to false. */ + isOpen: boolean; + /* Object indicating styles to be used for the modal, divided into overlay and content styles. */ + style?: Styles; + /* Set this to properly hide your application from assistive screenreaders and other assistive technologies while the modal is open. */ + appElement?: HTMLElement | {}; + /* Function that will be run after the modal has opened. */ + onAfterOpen?: () => void; + /* Function that will be run when the modal is requested to be closed, prior to actually closing. */ + onRequestClose?: () => void; + /* Number indicating the milliseconds to wait before closing the modal. Defaults to zero (no timeout). */ + closeTimeoutMS?: number; + /* Boolean indicating if the appElement should be hidden. Defaults to true. */ + ariaHideApp?: boolean; + /* Boolean indicating if the overlay should close the modal. Defaults to true. */ + shouldCloseOnOverlayClick?: boolean; + /* String className to be applied to the portal. Defaults to "ReactModalPortal". */ + portalClassName?: string; + /* String className to be applied to the overlay. */ + overlayClassName?: string; + /* String className to be applied to the modal content. */ + className?: string; + /* String indicating how the content container should be announced to screenreaders. */ + contentLabel?: string; + /* String indicating the role of the modal, allowing the 'dialog' role to be applied if desired. */ + role?: string; + /* Function that will be called to get the parent element that the modal will be attached to. */ + parentSelector?: () => HTMLElement; + } +} + +declare class ReactModal extends React.Component { + /* Override base styles for all instances of this component. */ + static defaultStyles: ReactModal.Styles; + /* Call this to properly hide your application from assistive screenreaders and other assistive technologies while the modal is open. */ + static setAppElement(appElement: HTMLElement): void; +} From cdfe492a002ca86840f926c44f93aeaa33e88f50 Mon Sep 17 00:00:00 2001 From: Homa Wong Date: Wed, 1 Feb 2017 15:57:03 -0800 Subject: [PATCH 051/104] Update index.d.ts --- systemjs/index.d.ts | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/systemjs/index.d.ts b/systemjs/index.d.ts index 428e303442..4dc975ced7 100644 --- a/systemjs/index.d.ts +++ b/systemjs/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for SystemJS 0.19.29 +// Type definitions for SystemJS 0.20.5 // Project: https://github.com/systemjs/systemjs // Definitions by: Ludovic HENIN , Nathan Walker , Giedrius Grabauskas // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped @@ -257,7 +257,7 @@ declare namespace SystemJSLoader { /** * This represents the System base class, which can be extended or reinstantiated to create a custom System instance. */ - constructor: new () => System; + constructor: new() => System; /** * Deletes a module from the registry by normalized name. @@ -270,6 +270,11 @@ declare namespace SystemJSLoader { get(moduleName: string): any; get(moduleName: string): TModule; + /** + * Returns a clone of the internal SystemJS configuration in use. + */ + getConfig(): Config + /** * Returns whether a given module exists in the registry by normalized module name. */ @@ -282,6 +287,12 @@ declare namespace SystemJSLoader { import(moduleName: string, normalizedParentName?: string): Promise; import(moduleName: string, normalizedParentName?: string): Promise; + /** + * Given any object, returns true if the object is either a SystemJS module or native JavaScript module object, and false otherwise. + * Useful for interop scenarios. + */ + isModule(object: any): boolean; + /** * Given a plain JavaScript object, return an equivalent Module object. * Useful when writing a custom instantiate hook or using System.set. @@ -320,7 +331,6 @@ declare namespace SystemJSLoader { */ loads: PackageList; } - } declare var SystemJS: SystemJSLoader.System; From a047ca1d6dbbb05f286ec8b8a533ee84ed293a00 Mon Sep 17 00:00:00 2001 From: Conrad Chan Date: Wed, 1 Feb 2017 19:50:03 -0800 Subject: [PATCH 052/104] add onInputKeyDown to react-select --- react-select/index.d.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/react-select/index.d.ts b/react-select/index.d.ts index e59322d0dc..a7c0f2f17a 100644 --- a/react-select/index.d.ts +++ b/react-select/index.d.ts @@ -246,6 +246,10 @@ declare namespace ReactSelectClass { * onInputChange handler: function (inputValue) {} */ onInputChange?: (inputValue: string) => void; + /** + * onInputKeyDown handler: function (keyboardEvent) {} + */ + onInputKeyDown?: (event: KeyboardEvent) => void; /** * fires when the menu is scrolled to the bottom; can be used to paginate options */ From d095c67aa93626f02bf72bd5b8a2886870496fdb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20SIMOND?= Date: Thu, 2 Feb 2017 13:40:29 +0100 Subject: [PATCH 053/104] Add missing property 'noData' to HighChartsNGConfig HighChartsNGConfig is missing noData property implemented since highcharts-ng#0.0.6 : https://github.com/pablojim/highcharts-ng#version-006 --- highcharts-ng/highcharts-ng-tests.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/highcharts-ng/highcharts-ng-tests.ts b/highcharts-ng/highcharts-ng-tests.ts index 0bf559061b..6f79d6e79a 100644 --- a/highcharts-ng/highcharts-ng-tests.ts +++ b/highcharts-ng/highcharts-ng-tests.ts @@ -33,7 +33,8 @@ class AppController { title: { text: 'My Awesome Chart' }, - loading: true + loading: true, + noData: 'No data here' }; constructor($timeout: ng.ITimeoutService) { var vm = this; From 0d9808c65180cd9ce6b12194064f9cc3fd03f66f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20SIMOND?= Date: Thu, 2 Feb 2017 13:46:24 +0100 Subject: [PATCH 054/104] Add missing property 'noData' to HighChartsNGConfig --- highcharts-ng/index.d.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/highcharts-ng/index.d.ts b/highcharts-ng/index.d.ts index 123799e76c..639d21d88e 100644 --- a/highcharts-ng/index.d.ts +++ b/highcharts-ng/index.d.ts @@ -35,6 +35,8 @@ declare global { }; //function (optional) - setup some logic for the chart func?: (chart: ChartObject) => void; + //no data text (optional) to show if all series are empty + noData?: string; } //Instantiated Chart From c1be6557513d67857fa4de171944b2ff84f837d1 Mon Sep 17 00:00:00 2001 From: Ant Kennedy Date: Thu, 2 Feb 2017 16:41:23 +0000 Subject: [PATCH 055/104] bugfix: WebResponseHeadersDetails missing method WebResponseHeadersDetails interface missing the method field defined in the documentation. https://developer.chrome.com/extensions/webRequest#event-onHeadersReceived --- chrome/index.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/chrome/index.d.ts b/chrome/index.d.ts index 2822dd421e..cd6922f5fb 100644 --- a/chrome/index.d.ts +++ b/chrome/index.d.ts @@ -7267,6 +7267,7 @@ declare namespace chrome.webRequest { interface WebResponseHeadersDetails extends WebResponseDetails { /** Optional. The HTTP response headers that have been received with this response. */ responseHeaders?: HttpHeader[]; + method: string; /** standard HTTP method i.e. GET, POST, PUT, etc. */ } interface WebResponseCacheDetails extends WebResponseHeadersDetails { From 06c9f9019023f3348de341b36af823e69ba1e58a Mon Sep 17 00:00:00 2001 From: Jeff Kenney Date: Thu, 26 Jan 2017 16:16:33 -0800 Subject: [PATCH 056/104] yargs: standardize tests as 4 spaces --- yargs/yargs-tests.ts | 720 +++++++++++++++++++++---------------------- 1 file changed, 360 insertions(+), 360 deletions(-) diff --git a/yargs/yargs-tests.ts b/yargs/yargs-tests.ts index f44e38b545..ae5871f2a3 100644 --- a/yargs/yargs-tests.ts +++ b/yargs/yargs-tests.ts @@ -12,539 +12,539 @@ const stringVal = 'string'; // With yargs, the options be just a hash! function xup() { - var argv = yargs.argv; + var argv = yargs.argv; - if (argv.rif - 5 * argv.xup > 7.138) { - console.log('Plunder more riffiwobbles!'); - } - else { - console.log('Drop the xupptumblers!'); - } + if (argv.rif - 5 * argv.xup > 7.138) { + console.log('Plunder more riffiwobbles!'); + } + else { + console.log('Drop the xupptumblers!'); + } } // And non-hyphenated options too! Just use argv._! function nonopt() { - var argv = yargs.argv; - console.log('(%d,%d)', argv.x, argv.y); - console.log(argv._); + var argv = yargs.argv; + console.log('(%d,%d)', argv.x, argv.y); + console.log(argv._); } // Yargs even counts your booleans! function count() { - var argv = yargs - .count('verbose') - .alias('v', 'verbose') - .argv; + var argv = yargs + .count('verbose') + .alias('v', 'verbose') + .argv; - var VERBOSE_LEVEL: number = argv.verbose; + var VERBOSE_LEVEL: number = argv.verbose; - function WARN() { VERBOSE_LEVEL >= 0 && console.log.apply(console, arguments); } - function INFO() { VERBOSE_LEVEL >= 1 && console.log.apply(console, arguments); } - function DEBUG() { VERBOSE_LEVEL >= 2 && console.log.apply(console, arguments); } + function WARN() { VERBOSE_LEVEL >= 0 && console.log.apply(console, arguments); } + function INFO() { VERBOSE_LEVEL >= 1 && console.log.apply(console, arguments); } + function DEBUG() { VERBOSE_LEVEL >= 2 && console.log.apply(console, arguments); } } // Tell users how to use yer options and make demands. function divide() { - var argv = yargs - .usage('Usage: $0 -x [num] -y [num]') - .demand(['x', 'y']) - .argv; + var argv = yargs + .usage('Usage: $0 -x [num] -y [num]') + .demand(['x', 'y']) + .argv; - console.log(argv.x / argv.y); + console.log(argv.x / argv.y); } // After yer demands have been met, demand more! Ask for non-hypenated arguments! function demand_count() { - var argv = yargs - .demand(2) - .demand(2, false) - .demand(2, 2) - .demand(2, 2, "message") - .argv; - console.dir(argv); + var argv = yargs + .demand(2) + .demand(2, false) + .demand(2, 2) + .demand(2, 2, "message") + .argv; + console.dir(argv); } // EVEN MORE SHIVER ME TIMBERS! function default_singles() { - var argv = yargs - .default('x', 10) - .default('y', 10) - .argv - ; - console.log(argv.x + argv.y); + var argv = yargs + .default('x', 10) + .default('y', 10) + .argv + ; + console.log(argv.x + argv.y); } function default_hash() { - var argv = yargs - .default({ x: 10, y: 10 }) - .argv - ; - console.log(argv.x + argv.y); + var argv = yargs + .default({ x: 10, y: 10 }) + .argv + ; + console.log(argv.x + argv.y); } // And if you really want to get all descriptive about it... function boolean_single() { - var argv = yargs - .boolean('v') - .argv - ; - console.dir(argv.v); - console.dir(argv._); + var argv = yargs + .boolean('v') + .argv + ; + console.dir(argv.v); + console.dir(argv._); } function boolean_double() { - var argv = yargs - .boolean(['x', 'y', 'z']) - .argv - ; - console.dir([argv.x, argv.y, argv.z]); - console.dir(argv._); + var argv = yargs + .boolean(['x', 'y', 'z']) + .argv + ; + console.dir([argv.x, argv.y, argv.z]); + console.dir(argv._); } // Yargs is here to help you... function line_count() { - var argv = yargs - .usage('Count the lines in a file.\nUsage: $0') - .example('$0 -f', 'count the lines in the given file') - .demand('f') - .alias('f', 'file') - .describe('f', 'Load a file') - .argv - ; + var argv = yargs + .usage('Count the lines in a file.\nUsage: $0') + .example('$0 -f', 'count the lines in the given file') + .demand('f') + .alias('f', 'file') + .describe('f', 'Load a file') + .argv + ; } // Below are tests for individual methods. // Not all methods are covered yet, and neither are all possible invocations of methods. function Argv_parsing() { - var argv1 = yargs.argv; - var argv2 = yargs(['-x', '1', '-y', '2']).argv; - var argv3 = yargs.parse(['-x', '1', '-y', '2']); - console.log(argv1.x, argv2.x, argv3.x); + var argv1 = yargs.argv; + var argv2 = yargs(['-x', '1', '-y', '2']).argv; + var argv3 = yargs.parse(['-x', '1', '-y', '2']); + console.log(argv1.x, argv2.x, argv3.x); } function Argv$options() { - var argv1 = yargs - .options('f', { - alias: 'file', - default: '/etc/passwd', - defaultDescription: 'The /etc/passwd file', - group: 'files', - normalize: true, - global: false, - array: true, - nargs: 3 - }) - .argv - ; + var argv1 = yargs + .options('f', { + alias: 'file', + default: '/etc/passwd', + defaultDescription: 'The /etc/passwd file', + group: 'files', + normalize: true, + global: false, + array: true, + nargs: 3 + }) + .argv + ; - var argv2 = yargs - .alias('f', 'file') - .default('f', '/etc/passwd') - .argv - ; + var argv2 = yargs + .alias('f', 'file') + .default('f', '/etc/passwd') + .argv + ; } function Argv$global() { - var argv = yargs - .global('foo') - .global(['bar', 'baz', 'fizz', 'buzz']) + var argv = yargs + .global('foo') + .global(['bar', 'baz', 'fizz', 'buzz']) } function Argv$group() { - var argv = yargs - .group('foo', 'foogroup') - .group(['bing', 'bang', 'buzz'], 'onomatopoeia') + var argv = yargs + .group('foo', 'foogroup') + .group(['bing', 'bang', 'buzz'], 'onomatopoeia') } function Argv$env() { - var argv = yargs - .env('YARGS_PREFIX_') - .env() - .env(true); + var argv = yargs + .env('YARGS_PREFIX_') + .env() + .env(true); } function Argv$array() { - var argv = yargs - .array('foo') - .array(['bar', 'baz']) + var argv = yargs + .array('foo') + .array(['bar', 'baz']) } function Argv$nargs() { - var argv = yargs - .nargs('foo', 12) - .nargs({ 'bing': 3, 'bang': 2, 'buzz': 4 }) + var argv = yargs + .nargs('foo', 12) + .nargs({ 'bing': 3, 'bang': 2, 'buzz': 4 }) } function Argv$choices() { - // example from documentation - var argv = yargs - .alias('i', 'ingredient') - .describe('i', 'choose your sandwich ingredients') - .choices('i', ['peanut-butter', 'jelly', 'banana', 'pickles']) - .help('help') - .argv + // example from documentation + var argv = yargs + .alias('i', 'ingredient') + .describe('i', 'choose your sandwich ingredients') + .choices('i', ['peanut-butter', 'jelly', 'banana', 'pickles']) + .help('help') + .argv } function command() { - var argv = yargs - .usage('npm ') - .command('install', 'tis a mighty fine package to install') - .command('publish', 'shiver me timbers, should you be sharing all that', yargs => - yargs.option('f', { - alias: 'force', - description: 'yar, it usually be a bad idea' - }) - .help('help') - ) - .command("build", "arghh, build it mate", { - tag: { - default: true, - demand: true, - description: "Tag the build, mate!" - }, - publish: { - default: false, - description:"Should i publish?" - } - }) - .command({ - command: "test", - describe: "test package", - builder: { - mateys: { - demand: false - } - }, - handler: (args: any) => { - /* handle me mateys! */ - } - }) - .command("test", "test mateys", { - handler: (args: any) => { - /* handle me mateys! */ - } - }) - .help('help') - .argv; + var argv = yargs + .usage('npm ') + .command('install', 'tis a mighty fine package to install') + .command('publish', 'shiver me timbers, should you be sharing all that', yargs => + yargs.option('f', { + alias: 'force', + description: 'yar, it usually be a bad idea' + }) + .help('help') + ) + .command("build", "arghh, build it mate", { + tag: { + default: true, + demand: true, + description: "Tag the build, mate!" + }, + publish: { + default: false, + description:"Should i publish?" + } + }) + .command({ + command: "test", + describe: "test package", + builder: { + mateys: { + demand: false + } + }, + handler: (args: any) => { + /* handle me mateys! */ + } + }) + .command("test", "test mateys", { + handler: (args: any) => { + /* handle me mateys! */ + } + }) + .help('help') + .argv; - yargs - .command('get', 'make a get HTTP request', function (yargs) { - return yargs.option('url', { - alias: 'u', - default: 'http://yargs.js.org/' - }) - }) - .help() - .argv + yargs + .command('get', 'make a get HTTP request', function (yargs) { + return yargs.option('url', { + alias: 'u', + default: 'http://yargs.js.org/' + }) + }) + .help() + .argv - yargs - .command( - 'get', - 'make a get HTTP request', - function (yargs) { - return yargs.option('u', { - alias: 'url', - describe: 'the URL to make an HTTP request to' - }) - }, - function (argv: { url: string }) { - console.dir(argv.url) - } - ) - .help() - .argv + yargs + .command( + 'get', + 'make a get HTTP request', + function (yargs) { + return yargs.option('u', { + alias: 'url', + describe: 'the URL to make an HTTP request to' + }) + }, + function (argv: { url: string }) { + console.dir(argv.url) + } + ) + .help() + .argv } function completion_sync() { - var argv = yargs - .completion('completion', (current, argv) => { - // 'current' is the current command being completed. - // 'argv' is the parsed arguments so far. - // simply return an array of completions. - return [ - 'foo', - 'bar' - ]; - }) - .argv; + var argv = yargs + .completion('completion', (current, argv) => { + // 'current' is the current command being completed. + // 'argv' is the parsed arguments so far. + // simply return an array of completions. + return [ + 'foo', + 'bar' + ]; + }) + .argv; } function completion_async() { - var argv = yargs - .completion('completion', (current: string, argv: any, done: (completion: string[]) => void) => { - setTimeout(function () { - done([ - 'apple', - 'banana' - ]); - }, 500); - }) - .argv; + var argv = yargs + .completion('completion', (current: string, argv: any, done: (completion: string[]) => void) => { + setTimeout(function () { + done([ + 'apple', + 'banana' + ]); + }, 500); + }) + .argv; } function Argv$help() { - var argv = yargs - .usage("$0 -operand1 number -operand2 number -operation [add|subtract]") - .help() - .argv; + var argv = yargs + .usage("$0 -operand1 number -operand2 number -operation [add|subtract]") + .help() + .argv; } function Argv$showHelpOnFail() { - var argv = yargs - .usage('Count the lines in a file.\nUsage: $0') - .demand('f') - .alias('f', 'file') - .describe('f', 'Load a file') - .showHelpOnFail(false, "Specify --help for available options") - .argv; + var argv = yargs + .usage('Count the lines in a file.\nUsage: $0') + .demand('f') + .alias('f', 'file') + .describe('f', 'Load a file') + .showHelpOnFail(false, "Specify --help for available options") + .argv; } function Argv$showHelp() { - var yargs1 = yargs - .usage("$0 -operand1 number -operand2 number -operation [add|subtract]"); - yargs1.showHelp(); + var yargs1 = yargs + .usage("$0 -operand1 number -operand2 number -operation [add|subtract]"); + yargs1.showHelp(); } function Argv$version() { - var argv1 = yargs - .version(); + var argv1 = yargs + .version(); - var argv2 = yargs - .version('1.0.0'); + var argv2 = yargs + .version('1.0.0'); - var argv3 = yargs - .version('1.0.0', '--version'); + var argv3 = yargs + .version('1.0.0', '--version'); - var argv4 = yargs - .version('1.0.0', '--version', 'description'); + var argv4 = yargs + .version('1.0.0', '--version', 'description'); - var argv5 = yargs - .version(function () { return '1.0.0'; }, '--version', 'description'); + var argv5 = yargs + .version(function () { return '1.0.0'; }, '--version', 'description'); } function Argv$wrap() { - var argv1 = yargs - .wrap(null); + var argv1 = yargs + .wrap(null); - var argv2 = yargs - .wrap(yargs.terminalWidth()); + var argv2 = yargs + .wrap(yargs.terminalWidth()); } function Argv$locale() { - var argv = yargs - .usage('./$0 - follow ye instructions true') - .option('option', { - alias: 'o', - describe: "'tis a mighty fine option", - demand: true - }) - .command('run', "Arrr, ya best be knowin' what yer doin'") - .example('$0 run foo', "shiver me timbers, here's an example for ye") - .help('help') - .wrap(70) - .locale('pirate') - .argv + var argv = yargs + .usage('./$0 - follow ye instructions true') + .option('option', { + alias: 'o', + describe: "'tis a mighty fine option", + demand: true + }) + .command('run', "Arrr, ya best be knowin' what yer doin'") + .example('$0 run foo', "shiver me timbers, here's an example for ye") + .help('help') + .wrap(70) + .locale('pirate') + .argv } function Argv$epilogue() { - var argv = yargs - .epilogue('for more information, find our manual at http://example.com'); + var argv = yargs + .epilogue('for more information, find our manual at http://example.com'); } function Argv$reset() { - var ya = yargs - .usage('$0 command') - .command('hello', 'hello command') - .command('world', 'world command') - .demand(1, 'must provide a valid command'), - argv = yargs.argv, - command = argv._[0]; + var ya = yargs + .usage('$0 command') + .command('hello', 'hello command') + .command('world', 'world command') + .demand(1, 'must provide a valid command'), + argv = yargs.argv, + command = argv._[0]; - if (command === 'hello') { - ya.reset() - .usage('$0 hello') - .help('h') - .example('$0 hello', 'print the hello message!') - .argv + if (command === 'hello') { + ya.reset() + .usage('$0 hello') + .help('h') + .example('$0 hello', 'print the hello message!') + .argv - console.log('hello!'); - } else if (command === 'world') { - ya.reset() - .usage('$0 world') - .help('h') - .example('$0 world', 'print the world message!') - .argv + console.log('hello!'); + } else if (command === 'world') { + ya.reset() + .usage('$0 world') + .help('h') + .example('$0 world', 'print the world message!') + .argv - console.log('world!'); - } else { - ya.showHelp(); - } + console.log('world!'); + } else { + ya.showHelp(); + } } // http://yargs.js.org/docs/#methods-commanddirdirectory-opts function Argv$commandDir() { - var ya = yargs - .commandDir('.') - .argv + var ya = yargs + .commandDir('.') + .argv } // http://yargs.js.org/docs/#methods-commanddirdirectory-opts function Argv$commandDirWithOptions() { - var ya = yargs - .commandDir('.', { - recurse: false, - extensions: ['js'], - visit: (commandObject: any, pathToFile: string, filename: string) => { }, - include: /.*\.js$/, - exclude: /.*\.spec.js$/, - }) - .argv + var ya = yargs + .commandDir('.', { + recurse: false, + extensions: ['js'], + visit: (commandObject: any, pathToFile: string, filename: string) => { }, + include: /.*\.js$/, + exclude: /.*\.spec.js$/, + }) + .argv } function Argv$normalize() { - var ya = yargs - .normalize('path') - .normalize(['user', 'group']) - .argv + var ya = yargs + .normalize('path') + .normalize(['user', 'group']) + .argv } // From http://yargs.js.org/docs/#methods-coercekey-fn function Argv$coerce() { - var ya = yargs - .coerce('file', function (arg: string) { - return fs.readFileSync(arg, 'utf8'); - }) - .argv + var ya = yargs + .coerce('file', function (arg: string) { + return fs.readFileSync(arg, 'utf8'); + }) + .argv } function Argv$coerces() { - var ya = yargs - .coerce({ - date: Date.parse, - json: JSON.parse - }) - .argv + var ya = yargs + .coerce({ + date: Date.parse, + json: JSON.parse + }) + .argv } function Argv$coerceWithKeys() { - var ya = yargs - .coerce(['src', 'dest'], path.resolve) - .argv + var ya = yargs + .coerce(['src', 'dest'], path.resolve) + .argv } // From http://yargs.js.org/docs/#methods-failfn function Argv$fail() { - var ya = yargs - .fail(function (msg, err) { - if (err) throw err // preserve stack - console.error('You broke it!') - console.error(msg) - process.exit(1) - }) - .argv + var ya = yargs + .fail(function (msg, err) { + if (err) throw err // preserve stack + console.error('You broke it!') + console.error(msg) + process.exit(1) + }) + .argv } function Argv$implies() { - var ya = yargs - .implies('foo', 'snuh') - .implies({ - x: 'y' - }) - .argv + var ya = yargs + .implies('foo', 'snuh') + .implies({ + x: 'y' + }) + .argv } function Argv$count() { - var ya = yargs - .count('size') - .count(['w', 'h']) - .argv + var ya = yargs + .count('size') + .count(['w', 'h']) + .argv } function Argv$number() { - var ya = yargs - .number('n') - .number(['width', 'height']) - .argv + var ya = yargs + .number('n') + .number(['width', 'height']) + .argv } function Argv$updateStrings() { - var ya = yargs - .command('run', 'the run command') - .help('help') - .updateStrings({ - 'Commands:': 'My Commands -->\n' - }) - .wrap(null) - .argv + var ya = yargs + .command('run', 'the run command') + .help('help') + .updateStrings({ + 'Commands:': 'My Commands -->\n' + }) + .wrap(null) + .argv } function Argv$default() { - var ya = yargs - .default('random', function randomValue() { - return Math.random() * 256; - }) - .argv + var ya = yargs + .default('random', function randomValue() { + return Math.random() * 256; + }) + .argv } function Argv$configObject() { - var ya = yargs - .config({foo: 1, bar: 2}) - .argv + var ya = yargs + .config({foo: 1, bar: 2}) + .argv } function Argv$configParseFunction() { - var ya = yargs - .config('settings', function (configPath) { - return JSON.parse(fs.readFileSync(configPath, 'utf-8')) - }) - .config('settings', 'description', function (configPath) { - return JSON.parse(fs.readFileSync(configPath, 'utf-8')) - }) - .argv + var ya = yargs + .config('settings', function (configPath) { + return JSON.parse(fs.readFileSync(configPath, 'utf-8')) + }) + .config('settings', 'description', function (configPath) { + return JSON.parse(fs.readFileSync(configPath, 'utf-8')) + }) + .argv } function Argv$helpDescriptionExplicit() { - var ya = yargs - .help('help', 'description', true) - .argv + var ya = yargs + .help('help', 'description', true) + .argv } function Argv$showHelpConsoleLevel() { - yargs.showHelp("log"); //prints to stdout using console.log() + yargs.showHelp("log"); //prints to stdout using console.log() } function Argv$getCompletion() { - var ya = yargs - .option('foobar', {}) - .option('foobaz', {}) - .completion() - .getCompletion(['./test.js', '--foo'], function (completions) { - console.log(completions) - }) - .argv + var ya = yargs + .option('foobar', {}) + .option('foobaz', {}) + .completion() + .getCompletion(['./test.js', '--foo'], function (completions) { + console.log(completions) + }) + .argv } function Argv$pkgConf() { - var ya = yargs - .pkgConf(['key1', 'key2'], 'configFile.json') - .argv + var ya = yargs + .pkgConf(['key1', 'key2'], 'configFile.json') + .argv } function Argv$recommendCommands() { - var ya = yargs - .recommendCommands() - .argv + var ya = yargs + .recommendCommands() + .argv } function Argv$showCompletionScript() { - var ya = yargs - .showCompletionScript() - .argv + var ya = yargs + .showCompletionScript() + .argv } function Argv$skipValidation() { - var ya = yargs - .skipValidation('arg1') - .skipValidation(['arg2', 'arg3']) - .argv + var ya = yargs + .skipValidation('arg1') + .skipValidation(['arg2', 'arg3']) + .argv } function Argv$commandObject() { From 975b1a68393eb8e3748d7cc732de4fd96c8dfdb7 Mon Sep 17 00:00:00 2001 From: Jeff Kenney Date: Thu, 26 Jan 2017 16:17:30 -0800 Subject: [PATCH 057/104] yargs: add demandCommand() and demandOption() --- yargs/index.d.ts | 7 +++++++ yargs/yargs-tests.ts | 22 ++++++++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/yargs/index.d.ts b/yargs/index.d.ts index da23a91f7f..bd512a7773 100644 --- a/yargs/index.d.ts +++ b/yargs/index.d.ts @@ -36,6 +36,12 @@ declare namespace yargs { demand(positionals: number, msg: string): Argv; demand(positionals: number, max: number, msg?: string): Argv; + demandCommand(min: number, minMsg?: string): Argv; + demandCommand(min: number, max?: number, minMsg?: string, maxMsg?: string): Argv; + + demandOption(key: string|string[], msg?: string): Argv; + demandOption(key: string|string[], demand?: boolean): Argv; + require(key: string, msg: string): Argv; require(key: string, required: boolean): Argv; require(keys: number[], msg: string): Argv; @@ -187,6 +193,7 @@ declare namespace yargs { default?: any; defaultDescription?: string; demand?: boolean | string; + demandOption?: boolean | string; desc?: string; describe?: string; description?: string; diff --git a/yargs/yargs-tests.ts b/yargs/yargs-tests.ts index ae5871f2a3..90448bce77 100644 --- a/yargs/yargs-tests.ts +++ b/yargs/yargs-tests.ts @@ -562,6 +562,7 @@ function Argv$commandObject() { default: "myvalue", defaultDescription: "description", demand: true, + demandOption: true, desc: "desc", describe: "describe", description: "description", @@ -577,3 +578,24 @@ function Argv$commandObject() { } }) } + +function Argv$demandCommand() { + var ya = yargs + .demandCommand(1) + .demandCommand(1, 'at least 1 command required') + .demandCommand(1, 2) + .demandCommand(1, 2, 'at least 1 command required') + .demandCommand(1, 2, 'at least 1 command required', 'at most 2 commands required') + .argv; +} + +function Argv$demandOption() { + var ya = yargs + .demandOption('a') + .demandOption('a', 'a is required') + .demandOption('a', true) + .demandOption(['a', 'b']) + .demandOption(['a', 'b'], 'a and b are required') + .demandOption(['a', 'b'], true) + .argv; +} From bb4107dc401097d8143c642b56a4d1228bdca5ee Mon Sep 17 00:00:00 2001 From: Jeff Kenney Date: Thu, 26 Jan 2017 16:01:19 -0800 Subject: [PATCH 058/104] yargs: add conflicts() --- yargs/index.d.ts | 3 +++ yargs/yargs-tests.ts | 9 +++++++++ 2 files changed, 12 insertions(+) diff --git a/yargs/index.d.ts b/yargs/index.d.ts index bd512a7773..1cd96e68e1 100644 --- a/yargs/index.d.ts +++ b/yargs/index.d.ts @@ -109,6 +109,9 @@ declare namespace yargs { config(key: string, parseFn: (configPath: string) => Object): Argv; config(keys: string[], parseFn: (configPath: string) => Object): Argv; + conflicts(key: string, value: string): Argv; + conflicts(conflicts: { [key: string]: string }): Argv; + wrap(columns: number): Argv; strict(): Argv; diff --git a/yargs/yargs-tests.ts b/yargs/yargs-tests.ts index 90448bce77..f68c1113e9 100644 --- a/yargs/yargs-tests.ts +++ b/yargs/yargs-tests.ts @@ -599,3 +599,12 @@ function Argv$demandOption() { .demandOption(['a', 'b'], true) .argv; } + +function Argv$conflicts() { + var ya = yargs + .conflicts('a', 'b') + .conflicts({ + a: 'b' + }) + .argv; +} From 01790850765886569e4c5bf35546ce498240762d Mon Sep 17 00:00:00 2001 From: Jeff Kenney Date: Thu, 26 Jan 2017 16:04:55 -0800 Subject: [PATCH 059/104] yargs: increment version number to v6.6.0, update authors --- yargs/index.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/yargs/index.d.ts b/yargs/index.d.ts index 1cd96e68e1..db205efc09 100644 --- a/yargs/index.d.ts +++ b/yargs/index.d.ts @@ -1,6 +1,6 @@ -// Type definitions for yargs 6.5.0 +// Type definitions for yargs 6.6.0 // Project: https://github.com/chevex/yargs -// Definitions by: Martin Poelstra , Mizunashi Mana , Jeffery Grajkowski +// Definitions by: Martin Poelstra , Mizunashi Mana , Jeffery Grajkowski , Jeff Kenney // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped declare namespace yargs { From 9e263a8d9f5468da2cea5a789c58bf42fc610974 Mon Sep 17 00:00:00 2001 From: Jeff Kenney Date: Fri, 27 Jan 2017 09:32:24 -0800 Subject: [PATCH 060/104] yargs: standardize spaces around union operator --- yargs/index.d.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/yargs/index.d.ts b/yargs/index.d.ts index db205efc09..a704afec94 100644 --- a/yargs/index.d.ts +++ b/yargs/index.d.ts @@ -39,8 +39,8 @@ declare namespace yargs { demandCommand(min: number, minMsg?: string): Argv; demandCommand(min: number, max?: number, minMsg?: string, maxMsg?: string): Argv; - demandOption(key: string|string[], msg?: string): Argv; - demandOption(key: string|string[], demand?: boolean): Argv; + demandOption(key: string | string[], msg?: string): Argv; + demandOption(key: string | string[], demand?: boolean): Argv; require(key: string, msg: string): Argv; require(key: string, required: boolean): Argv; @@ -156,7 +156,7 @@ declare namespace yargs { fail(func: (msg: string, err: Error) => any): Argv; - coerce(key: string|string[], func: (arg: T) => U): Argv; + coerce(key: string | string[], func: (arg: T) => U): Argv; coerce(opts: { [key: string]: (arg: T) => U; }): Argv; getCompletion(args: string[], done: (completions: string[]) => void): Argv; From 2d3c8e8e4481771de2e4feeb9b5ef96f6d162232 Mon Sep 17 00:00:00 2001 From: Jeff Kenney Date: Fri, 27 Jan 2017 09:35:34 -0800 Subject: [PATCH 061/104] yargs: add .editorconfig --- yargs/.editorconfig | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 yargs/.editorconfig diff --git a/yargs/.editorconfig b/yargs/.editorconfig new file mode 100644 index 0000000000..db9b917e06 --- /dev/null +++ b/yargs/.editorconfig @@ -0,0 +1,5 @@ +[*.ts] +indent_style = space +indent_size = 4 +end_of_line = lf +charset = utf-8 From e535a5dfa000f29fd907b9c702b061e8fc0c557f Mon Sep 17 00:00:00 2001 From: Jeff Kenney Date: Fri, 27 Jan 2017 10:17:26 -0800 Subject: [PATCH 062/104] yargs: add deprecated annotation for demand() --- yargs/index.d.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/yargs/index.d.ts b/yargs/index.d.ts index a704afec94..9c581611db 100644 --- a/yargs/index.d.ts +++ b/yargs/index.d.ts @@ -28,6 +28,9 @@ declare namespace yargs { default(key: string, value: any, description?: string): Argv; default(defaults: { [key: string]: any }, description?: string): Argv; + /** + * @deprecated since version 6.6.0 + */ demand(key: string, msg: string): Argv; demand(key: string, required?: boolean): Argv; demand(keys: string[], msg: string): Argv; @@ -42,6 +45,9 @@ declare namespace yargs { demandOption(key: string | string[], msg?: string): Argv; demandOption(key: string | string[], demand?: boolean): Argv; + /** + * @deprecated since version 6.6.0 + */ require(key: string, msg: string): Argv; require(key: string, required: boolean): Argv; require(keys: number[], msg: string): Argv; @@ -49,6 +55,9 @@ declare namespace yargs { require(positionals: number, required: boolean): Argv; require(positionals: number, msg: string): Argv; + /** + * @deprecated since version 6.6.0 + */ required(key: string, msg: string): Argv; required(key: string, required: boolean): Argv; required(keys: number[], msg: string): Argv; @@ -195,6 +204,7 @@ declare namespace yargs { count?: boolean; default?: any; defaultDescription?: string; + /** @deprecated since version 6.6.0 */ demand?: boolean | string; demandOption?: boolean | string; desc?: string; From 7078614fc5d6a55447ed9971c7c36d2b354dd60f Mon Sep 17 00:00:00 2001 From: 421p Date: Thu, 2 Feb 2017 22:19:06 +0200 Subject: [PATCH 063/104] fix arguments in callbacks --- wampy/wampy.d.ts | 49 +++++++++++++++++++++++++++++------------------- 1 file changed, 30 insertions(+), 19 deletions(-) diff --git a/wampy/wampy.d.ts b/wampy/wampy.d.ts index 261c521aff..357591acf9 100644 --- a/wampy/wampy.d.ts +++ b/wampy/wampy.d.ts @@ -3,7 +3,8 @@ // Definitions by: Konstantin Burkalev // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -interface WampyOptions { +interface WampyOptions +{ autoReconnect?: boolean; reconnectInterval?: number; maxRetries?: number; @@ -21,55 +22,65 @@ interface WampyOptions { msgpackCoder?: any; } -interface WampyOpStatus { +interface WampyOpStatus +{ code: number; description: string; reqId?: number; } -interface SuccessErrorCallbacksHash { +interface SuccessErrorCallbacksHash +{ onSuccess?: (data: any) => void; - onError?: (err: string) => void; + onError?: (err: string, details: any) => void; } -interface SubscribeCallbacksHash extends SuccessErrorCallbacksHash { - onEvent: (data: any) => void; +interface SubscribeCallbacksHash extends SuccessErrorCallbacksHash +{ + onEvent: (args: any[], kwargs: any) => void; } -interface RegisterCallbacksHash extends SuccessErrorCallbacksHash { +interface RegisterCallbacksHash extends SuccessErrorCallbacksHash +{ rpc: (data: any, options: any) => any[]; } -interface CallSuccessErrorCallbacksHash { - onSuccess: (data: any) => any; - onError?: (err: string) => void; +interface CallSuccessErrorCallbacksHash +{ + onSuccess: (args: any[], kwargs: any) => any; + onError?: (err: string, details: any, args: any[], kwargs: any) => void; } -interface AdvancedOptions { +interface AdvancedOptions +{ exclude?: number | number[]; eligible?: number | number[]; exclude_me?: boolean; disclose_me?: boolean; } -interface PublishAdvancedOptions extends AdvancedOptions { +interface PublishAdvancedOptions extends AdvancedOptions +{ exclude_authid?: string | string[]; exclude_authrole?: string | string[]; eligible_authid?: string | string[]; eligible_authrole?: string | string[]; } -interface CallAdvancedOptions { +interface CallAdvancedOptions +{ disclose_me?: boolean; receive_progress?: boolean; timeout?: number; } -interface CancelAdvancedOptions { +interface CancelAdvancedOptions +{ mode?: "skip" | "kill" | "killnowait"; } -interface Wampy { +interface Wampy +{ new (url?: string, options?: WampyOptions): Wampy; options(opts?: WampyOptions): WampyOptions | Wampy; getOpStatus(): WampyOpStatus; @@ -77,15 +88,15 @@ interface Wampy { connect(url?: string): Wampy; disconnect(): Wampy; abort(): Wampy; - subscribe(topicURI: string, callbacks: (((data: any) => void) | SubscribeCallbacksHash)): Wampy; - unsubscribe(topicURI: string, callbacks?: (((data: any) => void) | SubscribeCallbacksHash)): Wampy; + subscribe(topicURI: string, callbacks: (((args: any[], kwargs: any) => void) | SubscribeCallbacksHash)): Wampy; + unsubscribe(topicURI: string, callbacks?: (((args: any[], kwargs: any) => void) | SubscribeCallbacksHash)): Wampy; publish(topicURI: string, payload?: any, callbacks?: SuccessErrorCallbacksHash, advancedOptions?: PublishAdvancedOptions): Wampy; call(topicURI: string, payload?: any, - callbacks?: (((data: any) => void) | CallSuccessErrorCallbacksHash), + callbacks?: (((args: any[], kwargs: any) => void) | CallSuccessErrorCallbacksHash), advancedOptions?: CallAdvancedOptions): Wampy; cancel(reqId: number, callbacks?: ((() => void) | SuccessErrorCallbacksHash), @@ -94,7 +105,6 @@ interface Wampy { unregister(topicURI: string, callbacks?: ((() => void) | SuccessErrorCallbacksHash)): Wampy; } - declare var wampy: Wampy; declare module 'wampy' @@ -103,3 +113,4 @@ declare module 'wampy' } + From b802fda7506e1a2be2e7080b2082fd009176a82b Mon Sep 17 00:00:00 2001 From: Benjamin Shope Date: Thu, 2 Feb 2017 16:37:27 -0800 Subject: [PATCH 064/104] Fix draftjs parmater --- draft-js/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/draft-js/index.d.ts b/draft-js/index.d.ts index e02044a006..1805a17ab0 100644 --- a/draft-js/index.d.ts +++ b/draft-js/index.d.ts @@ -458,7 +458,7 @@ declare namespace Draft { entityMap: { [key: string]: RawDraftEntity }; } - function convertFromHTMLtoContentBlocks(html: string, DOMBuilder: Function, blockRenderMap?: DraftBlockRenderMap): Array; + function convertFromHTMLtoContentBlocks(html: string, DOMBuilder?: Function, blockRenderMap?: DraftBlockRenderMap): Array; function convertFromRawToDraftState(rawState: RawDraftContentState): ContentState; function convertFromDraftStateToRaw(contentState: ContentState): RawDraftContentState; } From a73aa9c077a1164913af853b0acdd028cc1d3cd3 Mon Sep 17 00:00:00 2001 From: inuscript Date: Fri, 3 Feb 2017 18:39:39 +0900 Subject: [PATCH 065/104] Add axios to not needed packages --- axios/axios-tests.ts | 107 -------------- axios/index.d.ts | 316 ----------------------------------------- axios/tsconfig.json | 23 --- notNeededPackages.json | 6 + 4 files changed, 6 insertions(+), 446 deletions(-) delete mode 100644 axios/axios-tests.ts delete mode 100644 axios/index.d.ts delete mode 100644 axios/tsconfig.json diff --git a/axios/axios-tests.ts b/axios/axios-tests.ts deleted file mode 100644 index eb98e2710c..0000000000 --- a/axios/axios-tests.ts +++ /dev/null @@ -1,107 +0,0 @@ - - -enum HttpMethod { GET, PUT, POST, DELETE, CONNECT, HEAD, OPTIONS, TRACE, PATCH } -enum ResponseType { arraybuffer, blob, document, json, text } - -interface Repository { - id: number; - name: string; -} - -interface Issue { - id: number; - title: string; -} - -axios.interceptors.request.use(config => { - console.log("Method:" + config.method + " Url:" +config.url); - return config; -}); - - -const requestId: number = axios.interceptors.request.use( - (config) => { - console.log("Method:" + config.method + " Url:" +config.url); - return config; - }, - (error: any) => error); - - -axios.interceptors.request.eject(requestId); -axios.interceptors.request.eject(7); - - -axios.interceptors.response.use(config => { - console.log("Status:" + config.status); - return config; -}); - -const responseId: number = axios.interceptors.response.use( - config => { - console.log("Status:" + config.status); - return config; - }, - (error: any) => error); - -axios.interceptors.response.eject(responseId); - -axios.get("https://api.github.com/repos/mzabriskie/axios") - .then(r => console.log(r.config.method)); - -var getRepoDetails = axios({ - url: "https://api.github.com/repos/mzabriskie/axios", - method: HttpMethod[HttpMethod.GET], - headers: {}, -}).then(r => { - console.log("ID:" + r.data.id + " Name: " + r.data.name); - return r; -}); - -axios.post("http://example.com/", {}, { - transformRequest: (data: any) => data -}); - -axios.post("http://example.com/", { - headers: {'X-Custom-Header': 'foobar'} -}, { - transformRequest: [ - (data: any) => data - ] -}); - -var config: Axios.AxiosXHRConfigBase = {headers: {}}; -config.headers['X-Custom-Header'] = 'baz'; -axios.post("http://example.com/", config); - -var getRepoIssue = axios.get("https://api.github.com/repos/mzabriskie/axios/issues/1"); - -var axiosInstance = axios.create({ - baseURL: "https://api.github.com/repos/mzabriskie/axios/", - timeout: 1000 -}); - -axiosInstance.request({url: "issues/1"}).then(res => { - if (res.headers['content-type'].startsWith('application/json')) { - throw new Error('Unexpected content-type'); - } -}); - -axios.all([getRepoDetails, getRepoDetails]).then(([repo1, repo2]) => { - var sumIds = repo1.data.id + repo2.data.id; - console.log("Sum ID:" + sumIds); - return sumIds; -}); - -var repoSum = (repo1: Axios.AxiosXHR, repo2: Axios.AxiosXHR) => { - var sumIds = repo1.data.id + repo2.data.id; - console.log("Sum ID:" + sumIds); - return sumIds; -}; - -axios.all([getRepoDetails, getRepoDetails]).then(axios.spread(repoSum)); - -axios.defaults.baseURL = 'https://api.example.com'; -axios.defaults.headers.common['Authorization'] = "AUTH_TOKEN"; -axios.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded'; - -axiosInstance.defaults.headers.common['Authorization'] = "AUTH_TOKEN"; \ No newline at end of file diff --git a/axios/index.d.ts b/axios/index.d.ts deleted file mode 100644 index 681fefc806..0000000000 --- a/axios/index.d.ts +++ /dev/null @@ -1,316 +0,0 @@ -// Type definitions for axios 0.9.1 -// Project: https://github.com/mzabriskie/axios -// Definitions by: Marcel Buesing -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped - -declare namespace Axios { - - interface IThenable { - then(onFulfilled?: (value: R) => U | IThenable, onRejected?: (error: any) => U | IThenable): IThenable; - then(onFulfilled?: (value: R) => U | IThenable, onRejected?: (error: any) => void): IThenable; - } - - interface IPromise extends IThenable { - then(onFulfilled?: (value: R) => U | IThenable, onRejected?: (error: any) => U | IThenable): IPromise; - then(onFulfilled?: (value: R) => U | IThenable, onRejected?: (error: any) => void): IPromise; - catch(onRejected?: (error: any) => U | IThenable): IPromise; - } - - /** - * HTTP Basic auth details - */ - interface AxiosHttpBasicAuth { - username: string; - password: string; - } - - /** - * Common axios XHR config interface - * - request body data type - */ - interface AxiosXHRConfigBase { - /** - * will be prepended to `url` unless `url` is absolute. - * It can be convenient to set `baseURL` for an instance - * of axios to pass relative URLs to methods of that instance. - */ - baseURL?: string; - - /** - * custom headers to be sent - */ - headers?: {[key: string]: any}; - - /** - * URL parameters to be sent with the request - */ - params?: Object; - - /** - * optional function in charge of serializing `params` - * (e.g. https://www.npmjs.com/package/qs, http://api.jquery.com/jquery.param/) - */ - paramsSerializer?: (params: Object) => string; - - /** - * specifies the number of milliseconds before the request times out. - * If the request takes longer than `timeout`, the request will be aborted. - */ - timeout?: number; - - /** - * indicates whether or not cross-site Access-Control requests - * should be made using credentials - */ - withCredentials?: boolean; - - /** - * indicates that HTTP Basic auth should be used, and supplies - * credentials. This will set an `Authorization` header, - * overwriting any existing `Authorization` custom headers you have - * set using `headers`. - */ - auth?: AxiosHttpBasicAuth; - - /** - * indicates the type of data that the server will respond with - * options are 'arraybuffer', 'blob', 'document', 'json', 'text' - */ - responseType?: string; - - /** - * name of the cookie to use as a value for xsrf token - */ - xsrfCookieName?: string; - - /** - * name of the http header that carries the xsrf token value - */ - xsrfHeaderName?: string; - - /** - * Change the request data before it is sent to the server. - * This is only applicable for request methods 'PUT', 'POST', and 'PATCH' - * The last function in the array must return a string or an ArrayBuffer - */ - transformRequest?: ((data: T) => U) | [(data: T) => U]; - - /** - * change the response data to be made before it is passed to then/catch - */ - transformResponse?: (data: T) => U; - - /** - * defines whether to resolve or reject the promise for a given HTTP response status code. - * If returns `true` (or is set to `null` or `undefined`), the promise will be resolved; - * otherwise, the promise will be rejected - */ - validateStatus?: (status: number) => boolean | undefined; - } - - /** - * - request body data type - */ - interface AxiosXHRConfig extends AxiosXHRConfigBase { - /** - * server URL that will be used for the request, options are: - * GET, PUT, POST, DELETE, CONNECT, HEAD, OPTIONS, TRACE, PATCH - */ - url: string; - - /** - * request method to be used when making the request - */ - method?: string; - - /** - * data to be sent as the request body - * Only applicable for request methods 'PUT', 'POST', and 'PATCH' - * When no `transformRequest` is set, must be a string, an ArrayBuffer or a hash - */ - data?: T; - } - - interface AxiosXHRConfigDefaults extends AxiosXHRConfigBase { - /** - * custom headers to be sent - */ - headers: { - common: {[index: string]: string}; - patch: {[index: string]: string}; - post: {[index: string]: string}; - put: {[index: string]: string}; - }; - } - - /** - * - expected response type, - * - request body data type - */ - interface AxiosXHR { - /** - * Response that was provided by the server - */ - data: T; - - /** - * HTTP status code from the server response - */ - status: number; - - /** - * HTTP status message from the server response - */ - statusText: string; - - /** - * headers that the server responded with - */ - headers: {[index: string]: any}; - - /** - * config that was provided to `axios` for the request - */ - config: AxiosXHRConfig; - } - - interface Interceptor { - /** - * intercept request before it is sent - */ - request: RequestInterceptor; - - /** - * intercept response of request when it is received. - */ - response: ResponseInterceptor - } - - type InterceptorId = number; - - interface RequestInterceptor { - /** - * - request body data type - */ - - use(fulfilledFn: (config: AxiosXHRConfig) => AxiosXHRConfig): InterceptorId; - - use(fulfilledFn: (config: AxiosXHRConfig) => AxiosXHRConfig, - rejectedFn: (error: any) => any) - : InterceptorId; - - eject(interceptorId: InterceptorId): void; - } - - interface ResponseInterceptor { - /** - * - expected response type - */ - - use(fulfilledFn: (config: Axios.AxiosXHR) => Axios.AxiosXHR): InterceptorId; - - use(fulfilledFn: (config: Axios.AxiosXHR) => Axios.AxiosXHR, - rejectedFn: (error: any) => any) - : InterceptorId; - - eject(interceptorId: InterceptorId): void; - } - - /** - * - expected response type, - * - request body data type - */ - interface AxiosInstance { - - /** - * Send request as configured - */ - (config: AxiosXHRConfig): IPromise>; - - /** - * Send request as configured - */ - new (config: AxiosXHRConfig): IPromise>; - - /** - * Send request as configured - */ - request(config: AxiosXHRConfig): IPromise>; - - /** - * intercept requests or responses before they are handled by then or catch - */ - interceptors: Interceptor; - - /** - * Config defaults - */ - defaults: AxiosXHRConfigDefaults; - - /** - * equivalent to `Promise.all` - */ - all(values: [T1 | IPromise>, T2 | IPromise>, T3 | IPromise>, T4 | IPromise>, T5 | IPromise>, T6 | IPromise>, T7 | IPromise>, T8 | IPromise>, T9 | IPromise>, T10 | IPromise>]): IPromise<[AxiosXHR, AxiosXHR, AxiosXHR, AxiosXHR, AxiosXHR, AxiosXHR, AxiosXHR, AxiosXHR, AxiosXHR, AxiosXHR]>; - all(values: [T1 | IPromise>, T2 | IPromise>, T3 | IPromise>, T4 | IPromise>, T5 | IPromise>, T6 | IPromise>, T7 | IPromise>, T8 | IPromise>, T9 | IPromise>]): IPromise<[AxiosXHR, AxiosXHR, AxiosXHR, AxiosXHR, AxiosXHR, AxiosXHR, AxiosXHR, AxiosXHR, AxiosXHR]>; - all(values: [T1 | IPromise>, T2 | IPromise>, T3 | IPromise>, T4 | IPromise>, T5 | IPromise>, T6 | IPromise>, T7 | IPromise>, T8 | IPromise>]): IPromise<[AxiosXHR, AxiosXHR, AxiosXHR, AxiosXHR, AxiosXHR, AxiosXHR, AxiosXHR, AxiosXHR]>; - all(values: [T1 | IPromise>, T2 | IPromise>, T3 | IPromise>, T4 | IPromise>, T5 | IPromise>, T6 | IPromise>, T7 | IPromise>]): IPromise<[AxiosXHR, AxiosXHR, AxiosXHR, AxiosXHR, AxiosXHR, AxiosXHR, AxiosXHR]>; - all(values: [T1 | IPromise>, T2 | IPromise>, T3 | IPromise>, T4 | IPromise>, T5 | IPromise>, T6 | IPromise>]): IPromise<[AxiosXHR, AxiosXHR, AxiosXHR, AxiosXHR, AxiosXHR, AxiosXHR]>; - all(values: [T1 | IPromise>, T2 | IPromise>, T3 | IPromise>, T4 | IPromise>, T5 | IPromise>]): IPromise<[AxiosXHR, AxiosXHR, AxiosXHR, AxiosXHR, AxiosXHR]>; - all(values: [T1 | IPromise>, T2 | IPromise>, T3 | IPromise>, T4 | IPromise>]): IPromise<[AxiosXHR, AxiosXHR, AxiosXHR, AxiosXHR]>; - all(values: [T1 | IPromise>, T2 | IPromise>, T3 | IPromise>]): IPromise<[AxiosXHR, AxiosXHR, AxiosXHR]>; - all(values: [T1 | IPromise>, T2 | IPromise>]): IPromise<[AxiosXHR, AxiosXHR]>; - - /** - * spread array parameter to `fn`. - * note: alternative to `spread`, destructuring assignment. - */ - spread(fn: (t1: T1, t2: T2) => U): (arr: ([T1, T2])) => U; - - /** - * convenience alias, method = GET - */ - get(url: string, config?: AxiosXHRConfigBase): IPromise>; - - - /** - * convenience alias, method = DELETE - */ - delete(url: string, config?: AxiosXHRConfigBase): IPromise>; - - /** - * convenience alias, method = HEAD - */ - head(url: string, config?: AxiosXHRConfigBase): IPromise>; - - /** - * convenience alias, method = POST - */ - post(url: string, data?: any, config?: AxiosXHRConfigBase): IPromise>; - - /** - * convenience alias, method = PUT - */ - put(url: string, data?: any, config?: AxiosXHRConfigBase): IPromise>; - - /** - * convenience alias, method = PATCH - */ - patch(url: string, data?: any, config?: AxiosXHRConfigBase): IPromise>; - } - - /** - * - expected response type, - */ - interface AxiosStatic extends AxiosInstance { - /** - * create a new instance of axios with a custom config - */ - create(config: AxiosXHRConfigBase): AxiosInstance; - } -} - -declare var axios: Axios.AxiosStatic; - -declare module "axios" { - export = axios; -} diff --git a/axios/tsconfig.json b/axios/tsconfig.json deleted file mode 100644 index 4300cfb925..0000000000 --- a/axios/tsconfig.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "compilerOptions": { - "module": "commonjs", - "lib": [ - "es6", - "dom" - ], - "noImplicitAny": true, - "noImplicitThis": true, - "strictNullChecks": false, - "baseUrl": "../", - "typeRoots": [ - "../" - ], - "types": [], - "noEmit": true, - "forceConsistentCasingInFileNames": true - }, - "files": [ - "index.d.ts", - "axios-tests.ts" - ] -} \ No newline at end of file diff --git a/notNeededPackages.json b/notNeededPackages.json index e671ef4523..46509a1642 100644 --- a/notNeededPackages.json +++ b/notNeededPackages.json @@ -293,6 +293,12 @@ "typingsPackageName": "redux-saga", "sourceRepoURL": "https://github.com/redux-saga/redux-saga", "asOfVersion": "0.10.5" + }, + { + "libraryName": "axios", + "typingsPackageName": "axios", + "sourceRepoURL": "https://github.com/mzabriskie/axios", + "asOfVersion": "0.14.0" } ] } From 495a0e355ecd1bebd45f562bf7f084222eeb49b7 Mon Sep 17 00:00:00 2001 From: Sindre Moen Date: Fri, 3 Feb 2017 14:01:07 +0100 Subject: [PATCH 066/104] =?UTF-8?q?Add=20=E2=80=9Cwhere=E2=80=9D=20selecto?= =?UTF-8?q?r=20version=20of=20Document#populate?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- mongoose/index.d.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/mongoose/index.d.ts b/mongoose/index.d.ts index 56ad48e617..0ede2141a8 100644 --- a/mongoose/index.d.ts +++ b/mongoose/index.d.ts @@ -1,6 +1,6 @@ // Type definitions for Mongoose 4.7.0 // Project: http://mongoosejs.com/ -// Definitions by: simonxca , horiuchi +// Definitions by: simonxca , horiuchi , sindrenm // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped /// @@ -994,10 +994,12 @@ declare module "mongoose" { * call execPopulate(). Passing the same path a second time will overwrite * the previous path options. See Model.populate() for explaination of options. * @param path The path to populate or an options object + * @param names The properties to fetch from the populated document * @param callback When passed, population is invoked */ populate(callback: (err: any, res: this) => void): this; populate(path: string, callback?: (err: any, res: this) => void): this; + populate(path: string, names: string, callback?: (err: any, res: this) => void): this; populate(options: ModelPopulateOptions | ModelPopulateOptions[], callback?: (err: any, res: this) => void): this; /** Gets _id(s) used during population of the given path. If the path was not populated, undefined is returned. */ From 966906150f5b098c91a9c8313c135d9095d2dafe Mon Sep 17 00:00:00 2001 From: Konstantin Burkalev Date: Fri, 3 Feb 2017 16:26:59 +0300 Subject: [PATCH 067/104] Revert "update wampy.d.ts to work with in-browser typescript" --- wampy/wampy.d.ts | 209 ++++++++++++++++++++++------------------------- 1 file changed, 99 insertions(+), 110 deletions(-) diff --git a/wampy/wampy.d.ts b/wampy/wampy.d.ts index 357591acf9..e068b97a25 100644 --- a/wampy/wampy.d.ts +++ b/wampy/wampy.d.ts @@ -3,114 +3,103 @@ // Definitions by: Konstantin Burkalev // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -interface WampyOptions -{ - autoReconnect?: boolean; - reconnectInterval?: number; - maxRetries?: number; - transportEncoding?: string; - realm?: string; - helloCustomDetails?: any; - onChallenge?: (auth_method: string, challenge_details: string) => string; - authid?: string; - onConnect?: () => void; - onClose?: () => void; - onError?: () => void; - onReconnect?: () => void; - onReconnectSuccess?: () => void; - ws?: any; - msgpackCoder?: any; +declare module "wampy" { + + interface WampyOptions { + autoReconnect?: boolean; + reconnectInterval?: number; + maxRetries?: number; + transportEncoding?: string; + realm?: string; + helloCustomDetails?: any; + onChallenge?: (auth_method: string, challenge_details: string) => string; + authid?: string; + onConnect?: () => void; + onClose?: () => void; + onError?: () => void; + onReconnect?: () => void; + onReconnectSuccess?: () => void; + ws?: any; + msgpackCoder?: any; + } + + interface WampyOpStatus { + code: number; + description: string; + reqId?: number; + } + + interface SuccessErrorCallbacksHash { + onSuccess?: (data: any) => void; + onError?: (err: string) => void; + } + + interface SubscribeCallbacksHash extends SuccessErrorCallbacksHash { + onEvent: (data: any) => void; + } + + interface RegisterCallbacksHash extends SuccessErrorCallbacksHash { + rpc: (data: any, options: any) => any[]; + } + + interface CallSuccessErrorCallbacksHash { + onSuccess: (data: any) => any; + onError?: (err: string) => void; + } + + interface AdvancedOptions { + exclude?: number | number[]; + eligible?: number | number[]; + exclude_me?: boolean; + disclose_me?: boolean; + } + + interface PublishAdvancedOptions extends AdvancedOptions { + exclude_authid?: string | string[]; + exclude_authrole?: string | string[]; + eligible_authid?: string | string[]; + eligible_authrole?: string | string[]; + } + + interface CallAdvancedOptions { + disclose_me?: boolean; + receive_progress?: boolean; + timeout?: number; + } + + interface CancelAdvancedOptions { + mode?: "skip" | "kill" | "killnowait"; + } + + interface Wampy { + options(opts?: WampyOptions): WampyOptions | Wampy; + getOpStatus(): WampyOpStatus; + getSessionId(): number; + connect(url?: string): Wampy; + disconnect(): Wampy; + abort(): Wampy; + subscribe(topicURI: string, callbacks: (((data: any) => void) | SubscribeCallbacksHash)): Wampy; + unsubscribe(topicURI: string, callbacks?: (((data: any) => void) | SubscribeCallbacksHash)): Wampy; + publish(topicURI: string, + payload?: any, + callbacks?: SuccessErrorCallbacksHash, + advancedOptions?: PublishAdvancedOptions): Wampy; + call(topicURI: string, + payload?: any, + callbacks?: (((data: any) => void) | CallSuccessErrorCallbacksHash), + advancedOptions?: CallAdvancedOptions): Wampy; + cancel(reqId: number, + callbacks?: ((() => void) | SuccessErrorCallbacksHash), + advancedOptions?: CancelAdvancedOptions): Wampy; + register(topicURI: string, callbacks: (((data: any, options: any) => any[]) | RegisterCallbacksHash)): Wampy; + unregister(topicURI: string, callbacks?: ((() => void) | SuccessErrorCallbacksHash)): Wampy; + } + + interface WampyInstance { + new(url?: string, options?: WampyOptions): Wampy; + } + + var wampy: WampyInstance; + + export default wampy; } - -interface WampyOpStatus -{ - code: number; - description: string; - reqId?: number; -} - -interface SuccessErrorCallbacksHash -{ - onSuccess?: (data: any) => void; - onError?: (err: string, details: any) => void; -} - -interface SubscribeCallbacksHash extends SuccessErrorCallbacksHash -{ - onEvent: (args: any[], kwargs: any) => void; -} - -interface RegisterCallbacksHash extends SuccessErrorCallbacksHash -{ - rpc: (data: any, options: any) => any[]; -} - -interface CallSuccessErrorCallbacksHash -{ - onSuccess: (args: any[], kwargs: any) => any; - onError?: (err: string, details: any, args: any[], kwargs: any) => void; -} - -interface AdvancedOptions -{ - exclude?: number | number[]; - eligible?: number | number[]; - exclude_me?: boolean; - disclose_me?: boolean; -} - -interface PublishAdvancedOptions extends AdvancedOptions -{ - exclude_authid?: string | string[]; - exclude_authrole?: string | string[]; - eligible_authid?: string | string[]; - eligible_authrole?: string | string[]; -} - -interface CallAdvancedOptions -{ - disclose_me?: boolean; - receive_progress?: boolean; - timeout?: number; -} - -interface CancelAdvancedOptions -{ - mode?: "skip" | "kill" | "killnowait"; -} - -interface Wampy -{ - new (url?: string, options?: WampyOptions): Wampy; - options(opts?: WampyOptions): WampyOptions | Wampy; - getOpStatus(): WampyOpStatus; - getSessionId(): number; - connect(url?: string): Wampy; - disconnect(): Wampy; - abort(): Wampy; - subscribe(topicURI: string, callbacks: (((args: any[], kwargs: any) => void) | SubscribeCallbacksHash)): Wampy; - unsubscribe(topicURI: string, callbacks?: (((args: any[], kwargs: any) => void) | SubscribeCallbacksHash)): Wampy; - publish(topicURI: string, - payload?: any, - callbacks?: SuccessErrorCallbacksHash, - advancedOptions?: PublishAdvancedOptions): Wampy; - call(topicURI: string, - payload?: any, - callbacks?: (((args: any[], kwargs: any) => void) | CallSuccessErrorCallbacksHash), - advancedOptions?: CallAdvancedOptions): Wampy; - cancel(reqId: number, - callbacks?: ((() => void) | SuccessErrorCallbacksHash), - advancedOptions?: CancelAdvancedOptions): Wampy; - register(topicURI: string, callbacks: (((data: any, options: any) => any[]) | RegisterCallbacksHash)): Wampy; - unregister(topicURI: string, callbacks?: ((() => void) | SuccessErrorCallbacksHash)): Wampy; -} - -declare var wampy: Wampy; - -declare module 'wampy' -{ - export = wampy -} - - - From 01dc4752d185d4932be5617fa5f94d7717240cc9 Mon Sep 17 00:00:00 2001 From: 421p Date: Fri, 3 Feb 2017 19:35:29 +0200 Subject: [PATCH 068/104] fix tests --- wampy/wampy-tests.ts | 84 ++++++++++++++++++-------------------------- wampy/wampy.d.ts | 2 +- 2 files changed, 35 insertions(+), 51 deletions(-) diff --git a/wampy/wampy-tests.ts b/wampy/wampy-tests.ts index c0ac8d6656..bd414f8c85 100644 --- a/wampy/wampy-tests.ts +++ b/wampy/wampy-tests.ts @@ -1,47 +1,50 @@ /// /// -import Wampy from 'wampy'; +import * as Wampy from 'wampy'; -var ws = new Wampy('http://wamp.router.url', {realm: 'WAMPRealm'}); +let ws = new Wampy('http://wamp.router.url', {realm: 'WAMPRealm'}); ws.options(); ws.options({ reconnectInterval: 1000, maxRetries: 999, - onConnect: function () { console.log('Yahoo! We are online!'); }, - onClose: function () { console.log('See you next time!'); }, - onError: function () { console.log('Breakdown happened'); }, - onReconnect: function () { console.log('Reconnecting...'); }, - onReconnectSuccess: function () { console.log('Successfully reconnected!'); } + onConnect: () => console.log('Yahoo! We are online!'), + onClose: () => console.log('See you next time!'), + onError: () => console.log('Breakdown happened'), + onReconnect: () => console.log('Reconnecting...'), + onReconnectSuccess: () => console.log('Successfully reconnected!') }); ws.connect(); ws.connect('/my-socket-path'); ws.connect('wss://socket.server.com:5000/ws'); -var id: number = ws.getSessionId(); + +let id: number = ws.getSessionId(); + ws.disconnect(); ws.abort(); -ws.subscribe('system.monitor.update', function (data) { +ws.subscribe('system.monitor.update', (args: any[], kwargs: any) => { console.log('Received system.monitor.update event!'); }) - .subscribe('client.message', function (data) { + .subscribe('client.message', function (args: any[], kwargs: any) { console.log('Received client.message event!'); }); -var f1 = function () { console.log('Subscribe processing!'); }; +let f1 = () => console.log('Subscribe processing!'); + ws.unsubscribe('subscribed.topic', f1); ws.unsubscribe('chat.message.received'); ws.call('get.server.time', null, { - onSuccess: function (stime) { + onSuccess: (args: any[], kwargs: any) => { console.log('RPC successfully called'); - console.log('Server time is ' + stime); + console.log('Server time is ' + kwargs); }, - onError: function (err) { + onError: (err: string, details: any, args: any[], kwargs: any) => { console.log('RPC call failed with error ' + err); } }); @@ -54,67 +57,48 @@ ws.publish('chat.message.received', 'user message'); ws.publish('chat.message.received', ['user message1', 'user message2']); ws.publish('user.modified', { field1: 'field1', field2: true, field3: 123 }); ws.publish('user.modified', { field1: 'field1', field2: true, field3: 123 }, { - onSuccess: function () { console.log('User successfully modified'); } + onSuccess: () => console.log('User successfully modified') }); ws.publish('user.modified', { field1: 'field1', field2: true, field3: 123 }, { - onSuccess: function () { console.log('User successfully modified'); }, - onError: function (err) { console.log('User modification failed', err); } + onSuccess: () => console.log('User successfully modified'), + onError: (err: string, details: any) => console.log('User modification failed', err) }); ws.publish('chat.message.received', ['Private message'], null, { eligible: 123456789 }); -ws.call('server.time', null, function (data) { console.log('Server time is ' + data[0]); }); +ws.call('server.time', null, (args: any[], kwargs: any) => console.log('Server time is ' + args[0])); ws.call('start.migration', null, { - onSuccess: function (data) { - console.log('RPC successfully called'); - }, - onError: function (err) { - console.log('RPC call failed!',err); - } + onSuccess: (args: any[], kwargs: any) => console.log('RPC successfully called'), + onError: (err: string, details: any, args: any[], kwargs: any) => console.log('RPC call failed!',err) }); ws.call('restore.backup', { backupFile: 'backup.zip' }, { - onSuccess: function (data) { - console.log('Backup successfully restored'); - }, - onError: function (err) { - console.log('Restore failed!',err); - } + onSuccess: (args: any[], kwargs: any) => console.log('Backup successfully restored'), + onError: (err: string, details: any, args: any[], kwargs: any) => console.log('Restore failed!',err) }); ws.call('start.migration', null, { - onSuccess: function (data) { - console.log('RPC successfully called'); - }, - onError: function (err) { - console.log('RPC call failed!',err); - } + onSuccess: (args: any[], kwargs: any) => console.log('RPC successfully called'), + onError: (err: string, details: any, args: any[], kwargs: any) => console.log('RPC call failed!',err) }); -var status = ws.getOpStatus(); + +let status = ws.getOpStatus(); ws.cancel(status.reqId); -var sqrt_f = function (x: number, y: any) { return [{}, x*x]; }; +let sqrt_f = (x: number, y: any) => [{}, x*x]; ws.register('sqrt.value', sqrt_f); ws.register('sqrt.value', { rpc: sqrt_f, - onSuccess: function (data) { - console.log('RPC successfully registered'); - }, - onError: function (err) { - console.log('RPC registration failed!',err); - } + onSuccess: (data: any) => console.log('RPC successfully registered'), + onError: (err: string, details: any) => console.log('RPC registration failed!',err) }); ws.unregister('sqrt.value'); ws.unregister('sqrt.value', { - onSuccess: function (data) { - console.log('RPC successfully unregistered'); - }, - onError: function (err) { - console.log('RPC unregistration failed!',err); - } + onSuccess: (data: any) => console.log('RPC successfully unregistered'), + onError: (err: string, details: any) => console.log('RPC unregistration failed!', err) }); diff --git a/wampy/wampy.d.ts b/wampy/wampy.d.ts index 357591acf9..f74695503a 100644 --- a/wampy/wampy.d.ts +++ b/wampy/wampy.d.ts @@ -109,7 +109,7 @@ declare var wampy: Wampy; declare module 'wampy' { - export = wampy + export = wampy; } From cec3881ae0ec736fd66366f5475a7356468aec8a Mon Sep 17 00:00:00 2001 From: Alexandre Rieux Date: Sat, 4 Feb 2017 11:00:14 +0000 Subject: [PATCH 069/104] Add bundled module --- mapbox-gl/index.d.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/mapbox-gl/index.d.ts b/mapbox-gl/index.d.ts index 360eb1ce33..2e75704dde 100644 --- a/mapbox-gl/index.d.ts +++ b/mapbox-gl/index.d.ts @@ -986,3 +986,7 @@ declare namespace mapboxgl { declare module 'mapbox-gl' { export = mapboxgl; } + +declare module 'mapbox-gl/dist/mapbox-gl' { + export = mapboxgl; +} From e6bfafb4761b76c61e1d6472b2480eab10765105 Mon Sep 17 00:00:00 2001 From: Warren Seymour Date: Wed, 11 Jan 2017 15:07:21 +0000 Subject: [PATCH 070/104] Add type definition for `hapi-auth-jwt2` --- hapi-auth-jwt2/hapi-auth-jwt2-tests.ts | 41 ++++++++ hapi-auth-jwt2/index.d.ts | 126 +++++++++++++++++++++++++ hapi-auth-jwt2/tsconfig.json | 20 ++++ hapi-auth-jwt2/tslint.json | 1 + 4 files changed, 188 insertions(+) create mode 100644 hapi-auth-jwt2/hapi-auth-jwt2-tests.ts create mode 100644 hapi-auth-jwt2/index.d.ts create mode 100644 hapi-auth-jwt2/tsconfig.json create mode 100644 hapi-auth-jwt2/tslint.json diff --git a/hapi-auth-jwt2/hapi-auth-jwt2-tests.ts b/hapi-auth-jwt2/hapi-auth-jwt2-tests.ts new file mode 100644 index 0000000000..65bc862e64 --- /dev/null +++ b/hapi-auth-jwt2/hapi-auth-jwt2-tests.ts @@ -0,0 +1,41 @@ +import Hapi = require('hapi'); +import hapiAuthJwt2 = require('hapi-auth-jwt2'); + +var server = new Hapi.Server(); +server.connection({port: 8000}); + +interface User { + id: number; + name: string; +} + +interface Users { + [id: number]: User +} + +var users:Users = { + 1: { + id: 1, + name: 'Test User' + } +}; + +var validate = function(decoded: User, request: Hapi.Request, callback: hapiAuthJwt2.ValidateCallback) { + if (!users[decoded.id]) { + return callback(null, false); + } + + return callback(null, true); +} + +server.register(hapiAuthJwt2, function(err) { + server.auth.strategy('jwt', 'jwt', { + key: 'NeverShareYourSecret', + validateFunc: validate, + verifyOptions: { + algorithms: ['HS256'] + } + }); +}); + +server.start(); diff --git a/hapi-auth-jwt2/index.d.ts b/hapi-auth-jwt2/index.d.ts new file mode 100644 index 0000000000..1bcbbc817e --- /dev/null +++ b/hapi-auth-jwt2/index.d.ts @@ -0,0 +1,126 @@ +// Type definitions for hapi-auth-jwt2 7.0 +// Project: http://github.com/dwyl/hapi-auth-jwt2 +// Definitions by: Warren Seymour +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +import {Request, Response} from 'hapi'; + +/** + * A key lookup function + * + * @param decoded the *decoded* but *unverified* JWT received from client + * @param callback the key lookup callback + */ +type KeyLookup = (decoded: any, callback: KeyLookupCallback) => void; + +/** + * Called when key lookup function has completed + * + * @param err an internal error + * @param key the secret key + * @param extraInfo any additional information that you would like + * to use in `validateFunc` which can be accessed via + * `request.plugins['hapi-auth-jwt2'].extraInfo` + */ +type KeyLookupCallback = (err: any, key: string, extraInfo?: any) => void; + +/** + * Called when Validation has completed + * + * @param err an internal error + * @param valid `true` if the JWT was valid, otherwise `false` + * @param credentials alternative credentials to be set instead of `decoded` + */ +type ValidateCallback = (err: any, valid: boolean, credentials?: any) => void; + +/** + * Options passed to `hapi.auth.strategy` when this plugin is used + */ +export interface Options { + /** + * The secret key used to check the signature of the token *or* a *key lookup function* + */ + key?: string | KeyLookup; + + /** + * The function which is run once the Token has been decoded + * + * @param decoded the *decoded* and *verified* JWT received from the client in *request.headers.authorization* + * @param request the original *request* received from the client + * @param callback the validation callback + */ + validateFunc(decoded: {}, request: Request, callback: ValidateCallback): void; + + /** + * Settings to define how tokens are verified by the jsonwebtoken library + */ + verifyOptions?: { + /** + * Ignore expired tokens + */ + ignoreExpiration?: boolean; + + /** + * Do not enforce token audience + */ + audience?: boolean; + + /** + * Do not require the issuer to be valid + */ + issuer?: boolean; + + /** + * List of allowed algorithms + */ + algorithms?: string[]; + }; + + /** + * function called to decorate the response with authentication headers + * before the response headers or payload is written + * + * @param request the Request object + * @param reply is called if an error occurred + */ + responseFunc?(request: Request, reply: (err: any, response: Response) => void): void; + + /** + * If you prefer to pass your token via url, simply add a token url + * parameter to your request or use a custom parameter by setting `urlKey. + * To disable the url parameter set urlKey to `false` or ''. + * @default 'token' + */ + urlKey?: string | boolean; + + /** + * If you prefer to set your own cookie key or your project has a cookie + * called 'token' for another purpose, you can set a custom key for your + * cookie by setting `options.cookieKey='yourkeyhere'`. To disable cookies + * set cookieKey to `false` or ''. + * @default 'token' + */ + cookieKey?: string | boolean; + + /** + * If you want to set a custom key for your header token use the + * `headerKey` option. To disable header token set headerKey to `false` or + * ''. + * @default 'authorization' + */ + headerKey?: string | boolean; + + /** + * Allow custom token type, e.g. `Authorization: 12345678` + */ + tokenType?: string; + + /** + * Set to `true` to receive the complete token (`decoded.header`, + * `decoded.payload` and `decoded.signature`) as decoded argument to key + * lookup and `verifyFunc` callbacks (*not `validateFunc`*) + * @default false + */ + complete?: boolean; +} + +export default function hapiAuthJwt2(): void; diff --git a/hapi-auth-jwt2/tsconfig.json b/hapi-auth-jwt2/tsconfig.json new file mode 100644 index 0000000000..764570cbac --- /dev/null +++ b/hapi-auth-jwt2/tsconfig.json @@ -0,0 +1,20 @@ +{ + "compilerOptions": { + "module": "commonjs", + "target": "es6", + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "hapi-auth-jwt2-tests.ts" + ] +} diff --git a/hapi-auth-jwt2/tslint.json b/hapi-auth-jwt2/tslint.json new file mode 100644 index 0000000000..377cc837d4 --- /dev/null +++ b/hapi-auth-jwt2/tslint.json @@ -0,0 +1 @@ +{ "extends": "../tslint.json" } From 2e14c31a33f42857d1651b7d8b336a519b9431e7 Mon Sep 17 00:00:00 2001 From: Olmo del Corral Date: Mon, 6 Feb 2017 07:36:39 +0100 Subject: [PATCH 071/104] make RouteComponentProps non-optional to smoth strictNullChecks --- react-router/lib/Router.d.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/react-router/lib/Router.d.ts b/react-router/lib/Router.d.ts index dbd2d43fff..95b2e38267 100644 --- a/react-router/lib/Router.d.ts +++ b/react-router/lib/Router.d.ts @@ -86,11 +86,11 @@ export interface InjectedRouter { } export interface RouteComponentProps { - location?: Location; - params?: P & R; - route?: PlainRoute; - router?: InjectedRouter; - routeParams?: R; + location: Location; + params: P & R; + route: PlainRoute; + router: InjectedRouter; + routeParams: R; } export interface RouterProps extends ClassAttributes { From eae4e9814145c51b92401305e3fa1f87170870f4 Mon Sep 17 00:00:00 2001 From: Rohit Kumar Date: Mon, 6 Feb 2017 12:52:39 +0530 Subject: [PATCH 072/104] Fix error in definition for fusioncharts modules. - *ERROR in* Argument of type 'FusionChartStatic' is not assignable to parameter of type 'FusionCharts'. --- fusioncharts/fusioncharts.charts.d.ts | 8 ++++---- fusioncharts/fusioncharts.gantt.d.ts | 8 ++++---- fusioncharts/fusioncharts.maps.d.ts | 8 ++++---- fusioncharts/fusioncharts.powercharts.d.ts | 8 ++++---- fusioncharts/fusioncharts.ssgrid.d.ts | 8 ++++---- fusioncharts/fusioncharts.treemap.d.ts | 8 ++++---- fusioncharts/fusioncharts.widgets.d.ts | 8 ++++---- fusioncharts/fusioncharts.zoomscatter.d.ts | 8 ++++---- fusioncharts/maps/fusioncharts.usa.d.ts | 8 ++++---- fusioncharts/maps/fusioncharts.world.d.ts | 8 ++++---- fusioncharts/themes/fusioncharts.theme.carbon.d.ts | 8 ++++---- fusioncharts/themes/fusioncharts.theme.fint.d.ts | 8 ++++---- fusioncharts/themes/fusioncharts.theme.ocean.d.ts | 8 ++++---- fusioncharts/themes/fusioncharts.theme.zune.d.ts | 8 ++++---- 14 files changed, 56 insertions(+), 56 deletions(-) diff --git a/fusioncharts/fusioncharts.charts.d.ts b/fusioncharts/fusioncharts.charts.d.ts index 214f9d79c2..f06060a054 100644 --- a/fusioncharts/fusioncharts.charts.d.ts +++ b/fusioncharts/fusioncharts.charts.d.ts @@ -1,7 +1,7 @@ -interface FusionCharts { - type: string; -} -declare var charts: (H: FusionCharts) => FusionCharts; +import { FusionChartStatic } from "fusioncharts"; + +declare var charts: (H: FusionChartStatic) => FusionChartStatic; export = charts; export as namespace charts; + diff --git a/fusioncharts/fusioncharts.gantt.d.ts b/fusioncharts/fusioncharts.gantt.d.ts index 7af79ff354..d29fa26f78 100644 --- a/fusioncharts/fusioncharts.gantt.d.ts +++ b/fusioncharts/fusioncharts.gantt.d.ts @@ -1,7 +1,7 @@ -interface FusionCharts { - type: string; -} -declare var gantt: (H: FusionCharts) => FusionCharts; +import { FusionChartStatic } from "fusioncharts"; + +declare var gantt: (H: FusionChartStatic) => FusionChartStatic; export = gantt; export as namespace gantt; + diff --git a/fusioncharts/fusioncharts.maps.d.ts b/fusioncharts/fusioncharts.maps.d.ts index 8610b8405f..1894383758 100644 --- a/fusioncharts/fusioncharts.maps.d.ts +++ b/fusioncharts/fusioncharts.maps.d.ts @@ -1,7 +1,7 @@ -interface FusionCharts { - type: string; -} -declare var maps: (H: FusionCharts) => FusionCharts; +import { FusionChartStatic } from "fusioncharts"; + +declare var maps: (H: FusionChartStatic) => FusionChartStatic; export = maps; export as namespace maps; + diff --git a/fusioncharts/fusioncharts.powercharts.d.ts b/fusioncharts/fusioncharts.powercharts.d.ts index 432cc4ce24..46178c8b8f 100644 --- a/fusioncharts/fusioncharts.powercharts.d.ts +++ b/fusioncharts/fusioncharts.powercharts.d.ts @@ -1,7 +1,7 @@ -interface FusionCharts { - type: string; -} -declare var powercharts: (H: FusionCharts) => FusionCharts; +import { FusionChartStatic } from "fusioncharts"; + +declare var powercharts: (H: FusionChartStatic) => FusionChartStatic; export = powercharts; export as namespace powercharts; + diff --git a/fusioncharts/fusioncharts.ssgrid.d.ts b/fusioncharts/fusioncharts.ssgrid.d.ts index f74376410d..b44f5336c1 100644 --- a/fusioncharts/fusioncharts.ssgrid.d.ts +++ b/fusioncharts/fusioncharts.ssgrid.d.ts @@ -1,7 +1,7 @@ -interface FusionCharts { - type: string; -} -declare var ssgrid: (H: FusionCharts) => FusionCharts; +import { FusionChartStatic } from "fusioncharts"; + +declare var ssgrid: (H: FusionChartStatic) => FusionChartStatic; export = ssgrid; export as namespace ssgrid; + diff --git a/fusioncharts/fusioncharts.treemap.d.ts b/fusioncharts/fusioncharts.treemap.d.ts index f8f80059ed..c555a627bc 100644 --- a/fusioncharts/fusioncharts.treemap.d.ts +++ b/fusioncharts/fusioncharts.treemap.d.ts @@ -1,7 +1,7 @@ -interface FusionCharts { - type: string; -} -declare var treemap: (H: FusionCharts) => FusionCharts; +import { FusionChartStatic } from "fusioncharts"; + +declare var treemap: (H: FusionChartStatic) => FusionChartStatic; export = treemap; export as namespace treemap; + diff --git a/fusioncharts/fusioncharts.widgets.d.ts b/fusioncharts/fusioncharts.widgets.d.ts index 052216721d..a4547b99b7 100644 --- a/fusioncharts/fusioncharts.widgets.d.ts +++ b/fusioncharts/fusioncharts.widgets.d.ts @@ -1,7 +1,7 @@ -interface FusionCharts { - type: string; -} -declare var widgets: (H: FusionCharts) => FusionCharts; +import { FusionChartStatic } from "fusioncharts"; + +declare var widgets: (H: FusionChartStatic) => FusionChartStatic; export = widgets; export as namespace widgets; + diff --git a/fusioncharts/fusioncharts.zoomscatter.d.ts b/fusioncharts/fusioncharts.zoomscatter.d.ts index 07e58585bb..106908b6df 100644 --- a/fusioncharts/fusioncharts.zoomscatter.d.ts +++ b/fusioncharts/fusioncharts.zoomscatter.d.ts @@ -1,7 +1,7 @@ -interface FusionCharts { - type: string; -} -declare var zoomscatter: (H: FusionCharts) => FusionCharts; +import { FusionChartStatic } from "fusioncharts"; + +declare var zoomscatter: (H: FusionChartStatic) => FusionChartStatic; export = zoomscatter; export as namespace zoomscatter; + diff --git a/fusioncharts/maps/fusioncharts.usa.d.ts b/fusioncharts/maps/fusioncharts.usa.d.ts index 159ad8ab80..16ed0d6c91 100644 --- a/fusioncharts/maps/fusioncharts.usa.d.ts +++ b/fusioncharts/maps/fusioncharts.usa.d.ts @@ -1,7 +1,7 @@ -interface FusionCharts { - type: string; -} -declare var usa: (H: FusionCharts) => FusionCharts; +import { FusionChartStatic } from "fusioncharts"; + +declare var usa: (H: FusionChartStatic) => FusionChartStatic; export = usa; export as namespace usa; + diff --git a/fusioncharts/maps/fusioncharts.world.d.ts b/fusioncharts/maps/fusioncharts.world.d.ts index 889afc5a7d..3e545e2556 100644 --- a/fusioncharts/maps/fusioncharts.world.d.ts +++ b/fusioncharts/maps/fusioncharts.world.d.ts @@ -1,7 +1,7 @@ -interface FusionCharts { - type: string; -} -declare var world: (H: FusionCharts) => FusionCharts; +import { FusionChartStatic } from "fusioncharts"; + +declare var world: (H: FusionChartStatic) => FusionChartStatic; export = world; export as namespace world; + diff --git a/fusioncharts/themes/fusioncharts.theme.carbon.d.ts b/fusioncharts/themes/fusioncharts.theme.carbon.d.ts index 0be2ca7334..79ba171231 100644 --- a/fusioncharts/themes/fusioncharts.theme.carbon.d.ts +++ b/fusioncharts/themes/fusioncharts.theme.carbon.d.ts @@ -1,7 +1,7 @@ -interface FusionCharts { - type: string; -} -declare var carbon: (H: FusionCharts) => FusionCharts; +import { FusionChartStatic } from "fusioncharts"; + +declare var carbon: (H: FusionChartStatic) => FusionChartStatic; export = carbon; export as namespace carbon; + diff --git a/fusioncharts/themes/fusioncharts.theme.fint.d.ts b/fusioncharts/themes/fusioncharts.theme.fint.d.ts index 8c76253ee6..cee08aa6b2 100644 --- a/fusioncharts/themes/fusioncharts.theme.fint.d.ts +++ b/fusioncharts/themes/fusioncharts.theme.fint.d.ts @@ -1,7 +1,7 @@ -interface FusionCharts { - type: string; -} -declare var fint: (H: FusionCharts) => FusionCharts; +import { FusionChartStatic } from "fusioncharts"; + +declare var fint: (H: FusionChartStatic) => FusionChartStatic; export = fint; export as namespace fint; + diff --git a/fusioncharts/themes/fusioncharts.theme.ocean.d.ts b/fusioncharts/themes/fusioncharts.theme.ocean.d.ts index f0dd57aa03..8b7e3828c0 100644 --- a/fusioncharts/themes/fusioncharts.theme.ocean.d.ts +++ b/fusioncharts/themes/fusioncharts.theme.ocean.d.ts @@ -1,7 +1,7 @@ -interface FusionCharts { - type: string; -} -declare var ocean: (H: FusionCharts) => FusionCharts; +import { FusionChartStatic } from "fusioncharts"; + +declare var ocean: (H: FusionChartStatic) => FusionChartStatic; export = ocean; export as namespace ocean; + diff --git a/fusioncharts/themes/fusioncharts.theme.zune.d.ts b/fusioncharts/themes/fusioncharts.theme.zune.d.ts index 23c04014c7..06ab4c1787 100644 --- a/fusioncharts/themes/fusioncharts.theme.zune.d.ts +++ b/fusioncharts/themes/fusioncharts.theme.zune.d.ts @@ -1,7 +1,7 @@ -interface FusionCharts { - type: string; -} -declare var zune: (H: FusionCharts) => FusionCharts; +import { FusionChartStatic } from "fusioncharts"; + +declare var zune: (H: FusionChartStatic) => FusionChartStatic; export = zune; export as namespace zune; + From 91647767d2fff5cd269631f9d1eeb2681cfc8d98 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20Kl=C3=B6pf?= Date: Mon, 6 Feb 2017 10:23:50 +0100 Subject: [PATCH 073/104] Fix definitions of serialport --- serialport/index.d.ts | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/serialport/index.d.ts b/serialport/index.d.ts index 60c240bbda..d94ab9d79f 100644 --- a/serialport/index.d.ts +++ b/serialport/index.d.ts @@ -1,24 +1,24 @@ -// Type definitions for serialport 4.0.1 +// Type definitions for serialport 4.0 // Project: https://github.com/EmergingTechnologyAdvisors/node-serialport // Definitions by: Jeremy Foster // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped declare module 'serialport' { class SerialPort { - constructor(path: string, options?: Object, openImmediately?: boolean, callback?: (err: string) => void) - isOpen: boolean; + constructor(path: string, options?: Object, openImmediately?: boolean, callback?: (err: any) => void) + isOpen(): boolean; on(event: string, callback?: (data?: any) => void): void; - open(callback?: () => void): void; - write(buffer: any, callback?: (err: string, bytesWritten: number) => void): void + open(callback?: (err: any) => void): void; + write(buffer: any, callback?: (err: any, bytesWritten: number) => void): void pause(): void; resume(): void; disconnected(err: Error): void; - close(callback?: (err:any) => void): void; - flush(callback?: (err:any) => void): void; - set(options: SerialPort.setOptions, callback: () => void): void; - drain(callback?: (err:any) => void): void; - update(options: SerialPort.updateOptions, callback?: () => void): void; - static list(callback: (err: string, ports: SerialPort.portConfig[]) => void): void; + close(callback?: (err: any) => void): void; + flush(callback?: (err: any) => void): void; + set(options: SerialPort.setOptions, callback: (err: any) => void): void; + drain(callback?: (err: any) => void): void; + update(options: SerialPort.updateOptions, callback?: (err: any) => void): void; + static list(callback: (err: any, ports: SerialPort.portConfig[]) => void): void; static parsers: { readline: (delimiter: string) => void, raw: (emitter: any, buffer: string) => void @@ -49,5 +49,5 @@ declare module 'serialport' { } } - export = SerialPort + export = SerialPort; } From 5b30a7bfe790829931fa3b6f9c9e527334b3b2c4 Mon Sep 17 00:00:00 2001 From: Kagami Sascha Rosylight Date: Mon, 6 Feb 2017 19:40:19 +0900 Subject: [PATCH 074/104] add defaults field --- pg/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pg/index.d.ts b/pg/index.d.ts index 75f3f33dd5..a18c9b6d42 100644 --- a/pg/index.d.ts +++ b/pg/index.d.ts @@ -130,4 +130,4 @@ export declare class Events extends events.EventEmitter { export const types: typeof pgTypes; - +export const defaults: Defaults & ClientConfig; From 3c083f098b71b70cd000a6644cb88574db47a569 Mon Sep 17 00:00:00 2001 From: Kagami Sascha Rosylight Date: Mon, 6 Feb 2017 19:41:21 +0900 Subject: [PATCH 075/104] Update pg-tests.ts --- pg/pg-tests.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pg/pg-tests.ts b/pg/pg-tests.ts index 8936f01ee0..15dfdde3d9 100644 --- a/pg/pg-tests.ts +++ b/pg/pg-tests.ts @@ -7,6 +7,7 @@ var conString = "postgres://username:password@localhost/database"; pg.types.setTypeParser(20, (val) => Number(val)); // Client pooling +pg.defaults.ssl = true; pg.connect(conString, (err, client, done) => { if (err) { return console.error("Error fetching client from pool", err); @@ -71,4 +72,4 @@ pool.connect(function(err, client, done) { pool.on('error', function (err, client) { console.error('idle client error', err.message, err.stack) -}) \ No newline at end of file +}) From b8b063f64b46dbec26bf792b8928060ffe2af7b6 Mon Sep 17 00:00:00 2001 From: Victor Widell Date: Mon, 6 Feb 2017 11:47:15 +0100 Subject: [PATCH 076/104] Made overloads work with union types. https://github.com/Microsoft/TypeScript/issues/1805 --- pg/index.d.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/pg/index.d.ts b/pg/index.d.ts index 75f3f33dd5..b819d6b66b 100644 --- a/pg/index.d.ts +++ b/pg/index.d.ts @@ -96,11 +96,10 @@ export declare class Client extends events.EventEmitter { end(callback?: (err: Error) => void): void; release(): void; - query(queryText: string): Promise; + query(queryTextOrConfig: string | QueryConfig): Promise; query(queryText: string, values: any[]): Promise; - query(queryText: string, callback?: (err: Error, result: QueryResult) => void): Query; - query(config: QueryConfig, callback?: (err: Error, result: QueryResult) => void): Query; + query(queryTextOrConfig: string | QueryConfig, callback?: (err: Error, result: QueryResult) => void): Query; query(queryText: string, values: any[], callback?: (err: Error, result: QueryResult) => void): Query; copyFrom(queryText: string): stream.Writable; From 04f5827aca02436a55129eef6b010e653345e590 Mon Sep 17 00:00:00 2001 From: Bradley Ayers Date: Mon, 6 Feb 2017 23:41:24 +1100 Subject: [PATCH 077/104] Add 'index' parameter to fn in .map and .forEach MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Map — https://github.com/airbnb/enzyme/blob/master/docs/api/ShallowWrapper/map.md - forEach — https://github.com/airbnb/enzyme/blob/master/docs/api/ShallowWrapper/forEach.md --- enzyme/index.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/enzyme/index.d.ts b/enzyme/index.d.ts index 5502b0eb85..eb77ce21eb 100644 --- a/enzyme/index.d.ts +++ b/enzyme/index.d.ts @@ -329,7 +329,7 @@ interface CommonWrapper { * @param fn A callback to be run for every node in the collection. Should expect a ShallowWrapper as the first * argument, and will be run with a context of the original instance. */ - forEach(fn: (wrapper: this) => any): this; + forEach(fn: (wrapper: this, index: number) => any): this; /** * Maps the current array of nodes to another array. Each node is passed in as a ShallowWrapper to the map @@ -339,7 +339,7 @@ interface CommonWrapper { * to the returned array. Should expect a ShallowWrapper as the first argument, and will be run * with a context of the original instance. */ - map(fn: (wrapper: this) => V): V[]; + map(fn: (wrapper: this, index: number) => V): V[]; /** * Applies the provided reducing function to every node in the wrapper to reduce to a single value. Each node From d88d452cf09a8d17161595cf41832e5c8d9ac799 Mon Sep 17 00:00:00 2001 From: Kagami Sascha Rosylight Date: Mon, 6 Feb 2017 23:46:11 +0900 Subject: [PATCH 078/104] resolve most of lint error --- pg/index.d.ts | 41 ++++++++++++++--------------------------- 1 file changed, 14 insertions(+), 27 deletions(-) diff --git a/pg/index.d.ts b/pg/index.d.ts index a18c9b6d42..ca555b1f83 100644 --- a/pg/index.d.ts +++ b/pg/index.d.ts @@ -1,11 +1,9 @@ -// Type definitions for pg 6.1.0 +// Type definitions for pg 6.1 // Project: https://github.com/brianc/node-postgres // Definitions by: Phips Peter // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped /// -/// - import events = require("events"); import stream = require("stream"); @@ -63,41 +61,34 @@ export interface ResultBuilder extends QueryResult { } export declare class Pool extends events.EventEmitter { - - constructor(); - // `new Pool('pg://user@localhost/mydb')` is not allowed. // But it passes type check because of issue: // https://github.com/Microsoft/TypeScript/issues/7485 - constructor(config: PoolConfig); + constructor(config?: PoolConfig); connect(): Promise; connect(callback: (err: Error, client: Client, done: () => void) => void): void; end(): Promise; - query(queryText: string): Promise; - query(queryText: string, values: any[]): Promise; + query(queryText: string, values?: any[]): Promise; query(queryText: string, callback: (err: Error, result: QueryResult) => void): void; query(queryText: string, values: any[], callback: (err: Error, result: QueryResult) => void): void; - public on(event: "error", listener: (err: Error, client: Client) => void): this; - public on(event: "connect", listener: (client: Client) => void): this; - public on(event: "acquire", listener: (client: Client) => void): this; - public on(event: string, listener: Function): this; + on(event: "error", listener: (err: Error, client: Client) => void): this; + on(event: "connect" | "acquire", listener: (client: Client) => void): this; } export declare class Client extends events.EventEmitter { constructor(connection: string); constructor(config: ClientConfig); - connect(callback?: (err:Error) => void): void; + connect(callback?: (err: Error) => void): void; end(callback?: (err: Error) => void): void; release(): void; - query(queryText: string): Promise; - query(queryText: string, values: any[]): Promise; + query(queryText: string, values?: any[]): Promise; query(queryText: string, callback?: (err: Error, result: QueryResult) => void): Query; query(config: QueryConfig, callback?: (err: Error, result: QueryResult) => void): Query; @@ -109,23 +100,19 @@ export declare class Client extends events.EventEmitter { pauseDrain(): void; resumeDrain(): void; - public on(event: "drain", listener: () => void): this; - public on(event: "error", listener: (err: Error) => void): this; - public on(event: "notification", listener: (message: any) => void): this; - public on(event: "notice", listener: (message: any) => void): this; - public on(event: string, listener: Function): this; + on(event: "drain", listener: () => void): this; + on(event: "error", listener: (err: Error) => void): this; + on(event: "notification" | "notice", listener: (message: any) => void): this; } export declare class Query extends events.EventEmitter { - public on(event: "row", listener: (row: any, result?: ResultBuilder) => void): this; - public on(event: "error", listener: (err: Error) => void): this; - public on(event: "end", listener: (result: ResultBuilder) => void): this; - public on(event: string, listener: Function): this; + on(event: "row", listener: (row: any, result?: ResultBuilder) => void): this; + on(event: "error", listener: (err: Error) => void): this; + on(event: "end", listener: (result: ResultBuilder) => void): this; } export declare class Events extends events.EventEmitter { - public on(event: "error", listener: (err: Error, client: Client) => void): this; - public on(event: string, listener: Function): this; + on(event: "error", listener: (err: Error, client: Client) => void): this; } export const types: typeof pgTypes; From dff9fc5ff457c38d71db4766f4373ded428d4fcf Mon Sep 17 00:00:00 2001 From: Kagami Sascha Rosylight Date: Mon, 6 Feb 2017 23:53:51 +0900 Subject: [PATCH 079/104] =?UTF-8?q?Refer=20.md=20file=20directly=20to=20re?= =?UTF-8?q?duce=20heavy=C2=A0load?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The main page of DefinitlyTyped is heavy because of the long list of types. Linking directly to the .md files can help. --- PULL_REQUEST_TEMPLATE.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/PULL_REQUEST_TEMPLATE.md b/PULL_REQUEST_TEMPLATE.md index 4d9a7aab6f..1fc8897d23 100644 --- a/PULL_REQUEST_TEMPLATE.md +++ b/PULL_REQUEST_TEMPLATE.md @@ -3,8 +3,8 @@ Please fill in this template. - [ ] Make your PR against the `master` branch. - [ ] Use a meaningful title for the pull request. Include the name of the package modified. - [ ] Test the change in your own code. (Compile and run.) -- [ ] Follow the advice from the [readme](https://github.com/DefinitelyTyped/DefinitelyTyped#make-a-pull-request). -- [ ] Avoid [common mistakes](https://github.com/DefinitelyTyped/DefinitelyTyped#common-mistakes). +- [ ] Follow the advice from the [readme](https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/README.md#make-a-pull-request). +- [ ] Avoid [common mistakes](https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/README.md#common-mistakes). - [ ] Run `tsc` without errors. - [ ] Run `npm run lint package-name` if a `tslint.json` is present. From 9d060ae3fac10cecc5c3121fd6b3b7263193a6e0 Mon Sep 17 00:00:00 2001 From: Ville Saarinen Date: Mon, 6 Feb 2017 17:15:28 +0200 Subject: [PATCH 080/104] Third parameter to branch() should be optional This is in line with the API documentation, e.g. the example for renderComponent(): https://github.com/acdlite/recompose/blob/master/docs/API.md#rendercomponent --- recompose/index.d.ts | 2 +- recompose/recompose-tests.tsx | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/recompose/index.d.ts b/recompose/index.d.ts index e72302415f..bed45744aa 100644 --- a/recompose/index.d.ts +++ b/recompose/index.d.ts @@ -103,7 +103,7 @@ declare module 'recompose' { export function branch( test: predicate, trueEnhancer: InferableComponentEnhancer, - falseEnhancer: InferableComponentEnhancer + falseEnhancer?: InferableComponentEnhancer ): ComponentEnhancer; // renderComponent: https://github.com/acdlite/recompose/blob/master/docs/API.md#renderComponent diff --git a/recompose/recompose-tests.tsx b/recompose/recompose-tests.tsx index 25b52d70b0..c4c66b3e2c 100644 --- a/recompose/recompose-tests.tsx +++ b/recompose/recompose-tests.tsx @@ -148,13 +148,19 @@ function testBranch() { const innerComponent: React.StatelessComponent = (props: InnerProps) =>
props.update()}>{props.count}
; + const innerComponent2 = () =>
Hello
; const enhancer = branch( (props: OutterProps) => props.toggled, withState("count", "update", 0), withState("count", "update", 100) ); + const enhancer2 = branch( + (props: OutterProps) => props.toggled, + renderComponent(innerComponent), + ) const enhanced: React.ComponentClass = enhancer(innerComponent); + const enhanced2: React.ComponentClass = enhancer2(innerComponent); } function testRenderComponent() { From dffc2b7078db3295252a646dce2697a00552f1a3 Mon Sep 17 00:00:00 2001 From: Ville Saarinen Date: Mon, 6 Feb 2017 17:19:33 +0200 Subject: [PATCH 081/104] Increase version number --- recompose/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/recompose/index.d.ts b/recompose/index.d.ts index bed45744aa..3ff504fab3 100644 --- a/recompose/index.d.ts +++ b/recompose/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Recompose v0.20.2 +// Type definitions for Recompose v0.20.3 // Project: https://github.com/acdlite/recompose // Definitions by: Iskander Sierra // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped From 6fd8c5eecd1bbfc55fc1379edb91e549b8fe741a Mon Sep 17 00:00:00 2001 From: z21cdevo Date: Mon, 6 Feb 2017 17:38:11 +0100 Subject: [PATCH 082/104] use correct settings exdends from daterangepicker definition --- react-bootstrap-daterangepicker/index.d.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/react-bootstrap-daterangepicker/index.d.ts b/react-bootstrap-daterangepicker/index.d.ts index e2ac7d49c6..baec72795b 100644 --- a/react-bootstrap-daterangepicker/index.d.ts +++ b/react-bootstrap-daterangepicker/index.d.ts @@ -5,12 +5,13 @@ // TypeScript Version: 2.1 /// -/// +/// declare namespace ReactBootstrapDaterangepicker { + export interface EventHandler { (event?: any, picker?: any): any; } - export interface Props extends DatepickerOptions { + export interface Props extends daterangepicker.Settings{ onShow?: EventHandler; onHide?: EventHandler; onShowCalendar?: EventHandler; From a3dd726ba33d460a539488394e2b286b0dea9669 Mon Sep 17 00:00:00 2001 From: Kanchalai Tanglertsampan Date: Mon, 6 Feb 2017 17:05:14 -0800 Subject: [PATCH 083/104] Revert "Fix #11566 allows SFC to return null" This reverts commit 81730dfd225b778bfd0f0a7e1524899a372ad37c. --- react/index.d.ts | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/react/index.d.ts b/react/index.d.ts index f25e5c0afd..e39c8c7026 100644 --- a/react/index.d.ts +++ b/react/index.d.ts @@ -204,7 +204,7 @@ declare namespace React { type SFC

= StatelessComponent

; interface StatelessComponent

{ - (props: P & { children?: ReactNode }, context?: any): ReactElement | null; + (props: P & { children?: ReactNode }, context?: any): ReactElement; propTypes?: ValidationMap

; contextTypes?: ValidationMap; defaultProps?: P; @@ -2628,9 +2628,7 @@ declare namespace React { declare global { namespace JSX { - interface JSXElement extends React.ReactElement { } - type Element = JSXElement | null; - + interface Element extends React.ReactElement { } interface ElementClass extends React.Component { render(): JSX.Element; } From 47f5a06ab00097373ee387f9b5ebad6d90d9cae9 Mon Sep 17 00:00:00 2001 From: Kanchalai Tanglertsampan Date: Mon, 6 Feb 2017 17:05:24 -0800 Subject: [PATCH 084/104] Revert "Add tests and fix broken test" This reverts commit d79f340d574873ca4deabd545ee4b9fdab1164ec. --- react-day-picker/index.d.ts | 2 +- react-dom/index.d.ts | 4 ++-- react-input-mask/index.d.ts | 2 +- react-native-scrollable-tab-view/index.d.ts | 18 +++++++++--------- .../react-native-swiper-tests.tsx | 2 +- react/index.d.ts | 4 ++-- react/test/tsx.tsx | 3 --- 7 files changed, 16 insertions(+), 19 deletions(-) diff --git a/react-day-picker/index.d.ts b/react-day-picker/index.d.ts index f2993d95c5..01c5492922 100644 --- a/react-day-picker/index.d.ts +++ b/react-day-picker/index.d.ts @@ -75,7 +75,7 @@ declare namespace ReactDayPicker { toMonth?: Date; localeUtils?: LocaleUtils; locale?: string; - captionElement?: React.ReactElement | null; + captionElement?: React.ReactElement; onDayClick?: (e: React.SyntheticEvent<{}>, day: Date, modifiers: DayModifiers) => any; onDayTouchTap?: (e: React.SyntheticEvent<{}>, day: Date, modifiers: DayModifiers) => any; onDayMouseEnter?: (e: React.SyntheticEvent<{}>, day: Date, modifiers: DayModifiers) => any; diff --git a/react-dom/index.d.ts b/react-dom/index.d.ts index bf0a246211..00520fc6ed 100644 --- a/react-dom/index.d.ts +++ b/react-dom/index.d.ts @@ -28,7 +28,7 @@ declare namespace ReactDOM { container: Element | null, callback?: (component: T) => any): T; function render

( - element: ReactElement

| null, + element: ReactElement

, container: Element | null, callback?: (component?: Component | Element) => any): Component | Element | void; @@ -57,7 +57,7 @@ declare namespace ReactDOM { callback?: () => any): void; function unstable_renderSubtreeIntoContainer

( parentComponent: Component, - element: ReactElement

| null, + element: ReactElement

, container: Element, callback?: (component?: Component | Element) => any): Component | Element | void; } diff --git a/react-input-mask/index.d.ts b/react-input-mask/index.d.ts index c6acce5858..6fc8c6008f 100644 --- a/react-input-mask/index.d.ts +++ b/react-input-mask/index.d.ts @@ -13,7 +13,7 @@ declare namespace reactInputMask { * * `9`: `0-9` * * `a`: `A-Z, a-z` * * `\*`: `A-Z, a-z, 0-9` - * + * * Any character can be escaped with backslash, which usually will appear as double backslash in JS strings. For example, German phone mask with unremoveable prefix +49 will look like `mask="+4\\9 99 999 99"` or `mask={"+4\\\\9 99 999 99"}` */ mask: string; diff --git a/react-native-scrollable-tab-view/index.d.ts b/react-native-scrollable-tab-view/index.d.ts index 9287ede79d..2f22f1bcf4 100644 --- a/react-native-scrollable-tab-view/index.d.ts +++ b/react-native-scrollable-tab-view/index.d.ts @@ -37,9 +37,9 @@ export interface renderTabBarProperties { interface ScrollableTabViewProperties extends React.Props { /** - * tabBarPosition (String) Defaults to "top". + * tabBarPosition (String) Defaults to "top". * "bottom" to position the tab bar below content. - * "overlayTop" or "overlayBottom" for a semitransparent tab bar that overlays content. Custom + * "overlayTop" or "overlayBottom" for a semitransparent tab bar that overlays content. Custom * tab bars must consume a style prop on their outer element to support this feature: style={this.props.style}. */ tabBarPosition?: 'top' | 'bottom' | 'overlayTop' | 'overlayBottom'; @@ -50,27 +50,27 @@ interface ScrollableTabViewProperties extends React.Props { initialPage?: number; /** - * (Integer) - set selected tab(can be buggy see + * (Integer) - set selected tab(can be buggy see * https://github.com/skv-headless/react-native-scrollable-tab-view/issues/126 */ page?: number; /** - * onChangeTab (Function) - function to call when tab changes, should accept 1 argument which is - * an Object containing two keys: i: the index of the tab that is selected, ref: the ref of the + * onChangeTab (Function) - function to call when tab changes, should accept 1 argument which is + * an Object containing two keys: i: the index of the tab that is selected, ref: the ref of the * tab that is selected */ onChangeTab?: (value: onChangeTabProperties) => void; /** - * onScroll (Function) - function to call when the pages are sliding, + * onScroll (Function) - function to call when the pages are sliding, * should accept 1 argument which is an Float number representing the page position in the slide frame. */ onScroll?: (value: number) => void; /** * renderTabBar (Function:ReactComponent) - accept 1 argument props and should return a component - * to use as the tab bar. The component has goToPage, tabs, activeTab and ref added to the props, + * to use as the tab bar. The component has goToPage, tabs, activeTab and ref added to the props, * and should implement setAnimationValue to be able to animate itself along with the tab content. * You can manually pass the props to the TabBar component. */ @@ -82,7 +82,7 @@ interface ScrollableTabViewProperties extends React.Props { style?: ViewStyle; /** - * contentProps (Object) - props that are applied to root ScrollView/ViewPagerAndroid. + * contentProps (Object) - props that are applied to root ScrollView/ViewPagerAndroid. * Note that overriding defaults set by the library may break functionality; see the source for details. */ contentProps?: React.ScrollViewProperties; @@ -98,7 +98,7 @@ interface ScrollableTabViewProperties extends React.Props { locked?: boolean; /** - * prerenderingSiblingsNumber (Integer) - pre-render nearby # sibling, Infinity === render all + * prerenderingSiblingsNumber (Integer) - pre-render nearby # sibling, Infinity === render all * the siblings, default to 0 === render current page. */ prerenderingSiblingsNumber?: number; diff --git a/react-native-swiper/react-native-swiper-tests.tsx b/react-native-swiper/react-native-swiper-tests.tsx index c8dae8511e..93cdfcfd18 100644 --- a/react-native-swiper/react-native-swiper-tests.tsx +++ b/react-native-swiper/react-native-swiper-tests.tsx @@ -18,7 +18,7 @@ class SwiperTest extends React.Component { super(props); } - public render(): React.ReactElement | null { + public render(): React.ReactElement { return ( diff --git a/react/index.d.ts b/react/index.d.ts index e39c8c7026..001484aa15 100644 --- a/react/index.d.ts +++ b/react/index.d.ts @@ -171,7 +171,7 @@ declare namespace React { setState(f: (prevState: S, props: P) => Pick, callback?: () => any): void; setState(state: Pick, callback?: () => any): void; forceUpdate(callBack?: () => any): void; - render(): JSX.Element; + render(): JSX.Element | null; // React.Props is now deprecated, which means that the `children` // property is not available on `P` by default, even though you can @@ -2630,7 +2630,7 @@ declare global { namespace JSX { interface Element extends React.ReactElement { } interface ElementClass extends React.Component { - render(): JSX.Element; + render(): JSX.Element | null; } interface ElementAttributesProperty { props: {}; } diff --git a/react/test/tsx.tsx b/react/test/tsx.tsx index 0b0bc096ae..0531cb52c0 100644 --- a/react/test/tsx.tsx +++ b/react/test/tsx.tsx @@ -32,6 +32,3 @@ StatelessComponent2.defaultProps = { ; - -const CustomComponent = (props: { flag: boolean }) => props.flag ? React.createElement('div') : null; -const UseComponent2 = (f: boolean) => ; From e791b291058bc8e9e7e5e3c4690f32124ea77b36 Mon Sep 17 00:00:00 2001 From: Kanchalai Tanglertsampan Date: Mon, 6 Feb 2017 17:54:17 -0800 Subject: [PATCH 085/104] Fix trailing whitespace that broke test --- react-input-mask/index.d.ts | 2 +- react-native-scrollable-tab-view/index.d.ts | 18 +++++++++--------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/react-input-mask/index.d.ts b/react-input-mask/index.d.ts index 6fc8c6008f..c6acce5858 100644 --- a/react-input-mask/index.d.ts +++ b/react-input-mask/index.d.ts @@ -13,7 +13,7 @@ declare namespace reactInputMask { * * `9`: `0-9` * * `a`: `A-Z, a-z` * * `\*`: `A-Z, a-z, 0-9` - * + * * Any character can be escaped with backslash, which usually will appear as double backslash in JS strings. For example, German phone mask with unremoveable prefix +49 will look like `mask="+4\\9 99 999 99"` or `mask={"+4\\\\9 99 999 99"}` */ mask: string; diff --git a/react-native-scrollable-tab-view/index.d.ts b/react-native-scrollable-tab-view/index.d.ts index 2f22f1bcf4..9287ede79d 100644 --- a/react-native-scrollable-tab-view/index.d.ts +++ b/react-native-scrollable-tab-view/index.d.ts @@ -37,9 +37,9 @@ export interface renderTabBarProperties { interface ScrollableTabViewProperties extends React.Props { /** - * tabBarPosition (String) Defaults to "top". + * tabBarPosition (String) Defaults to "top". * "bottom" to position the tab bar below content. - * "overlayTop" or "overlayBottom" for a semitransparent tab bar that overlays content. Custom + * "overlayTop" or "overlayBottom" for a semitransparent tab bar that overlays content. Custom * tab bars must consume a style prop on their outer element to support this feature: style={this.props.style}. */ tabBarPosition?: 'top' | 'bottom' | 'overlayTop' | 'overlayBottom'; @@ -50,27 +50,27 @@ interface ScrollableTabViewProperties extends React.Props { initialPage?: number; /** - * (Integer) - set selected tab(can be buggy see + * (Integer) - set selected tab(can be buggy see * https://github.com/skv-headless/react-native-scrollable-tab-view/issues/126 */ page?: number; /** - * onChangeTab (Function) - function to call when tab changes, should accept 1 argument which is - * an Object containing two keys: i: the index of the tab that is selected, ref: the ref of the + * onChangeTab (Function) - function to call when tab changes, should accept 1 argument which is + * an Object containing two keys: i: the index of the tab that is selected, ref: the ref of the * tab that is selected */ onChangeTab?: (value: onChangeTabProperties) => void; /** - * onScroll (Function) - function to call when the pages are sliding, + * onScroll (Function) - function to call when the pages are sliding, * should accept 1 argument which is an Float number representing the page position in the slide frame. */ onScroll?: (value: number) => void; /** * renderTabBar (Function:ReactComponent) - accept 1 argument props and should return a component - * to use as the tab bar. The component has goToPage, tabs, activeTab and ref added to the props, + * to use as the tab bar. The component has goToPage, tabs, activeTab and ref added to the props, * and should implement setAnimationValue to be able to animate itself along with the tab content. * You can manually pass the props to the TabBar component. */ @@ -82,7 +82,7 @@ interface ScrollableTabViewProperties extends React.Props { style?: ViewStyle; /** - * contentProps (Object) - props that are applied to root ScrollView/ViewPagerAndroid. + * contentProps (Object) - props that are applied to root ScrollView/ViewPagerAndroid. * Note that overriding defaults set by the library may break functionality; see the source for details. */ contentProps?: React.ScrollViewProperties; @@ -98,7 +98,7 @@ interface ScrollableTabViewProperties extends React.Props { locked?: boolean; /** - * prerenderingSiblingsNumber (Integer) - pre-render nearby # sibling, Infinity === render all + * prerenderingSiblingsNumber (Integer) - pre-render nearby # sibling, Infinity === render all * the siblings, default to 0 === render current page. */ prerenderingSiblingsNumber?: number; From 74ce2d22e797706025dc7c5e21a3b37d14f09ca9 Mon Sep 17 00:00:00 2001 From: Mike Deverell Date: Mon, 6 Feb 2017 22:51:24 -0500 Subject: [PATCH 086/104] add `optionClassName` to `ReactSelectProps` --- react-select/index.d.ts | 4 ++++ react-select/react-select-tests.tsx | 1 + 2 files changed, 5 insertions(+) diff --git a/react-select/index.d.ts b/react-select/index.d.ts index a7c0f2f17a..c3474fdb85 100644 --- a/react-select/index.d.ts +++ b/react-select/index.d.ts @@ -272,6 +272,10 @@ declare namespace ReactSelectClass { * @default false */ openOnFocus?: boolean; + /** + * className to add to each option component + */ + optionClassName?: string; /** * option component to render in dropdown */ diff --git a/react-select/react-select-tests.tsx b/react-select/react-select-tests.tsx index d2704878d9..7840f2ce9e 100644 --- a/react-select/react-select-tests.tsx +++ b/react-select/react-select-tests.tsx @@ -99,6 +99,7 @@ class SelectTest extends React.Component, {}> { className: "test-select", key: "1", options: options, + optionClassName: 'test-select-option', optionRenderer: optionRenderer, autofocus: true, autosize: true, From 906ece8d53c7b1fb9159e6be2aef0dea538bd062 Mon Sep 17 00:00:00 2001 From: Mike Deverell Date: Mon, 6 Feb 2017 22:51:39 -0500 Subject: [PATCH 087/104] add name to contributors list --- react-select/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/react-select/index.d.ts b/react-select/index.d.ts index c3474fdb85..b149fd4c47 100644 --- a/react-select/index.d.ts +++ b/react-select/index.d.ts @@ -1,6 +1,6 @@ // Type definitions for react-select v1.0.0 // Project: https://github.com/JedWatson/react-select -// Definitions by: ESQUIBET Hugo , Gilad Gray , Izaak Baker , Tadas Dailyda , Mark Vujevits +// Definitions by: ESQUIBET Hugo , Gilad Gray , Izaak Baker , Tadas Dailyda , Mark Vujevits , Mike Deverell // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.1 From ec8c18fc630ee0cf41d38aa28c1fb381c97b951b Mon Sep 17 00:00:00 2001 From: Sindre Moen Date: Tue, 7 Feb 2017 09:07:44 +0100 Subject: [PATCH 088/104] Specify TypeScript version 2.1 --- mongoose/index.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/mongoose/index.d.ts b/mongoose/index.d.ts index 0ede2141a8..2c7361a437 100644 --- a/mongoose/index.d.ts +++ b/mongoose/index.d.ts @@ -2,6 +2,7 @@ // Project: http://mongoosejs.com/ // Definitions by: simonxca , horiuchi , sindrenm // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.1 /// /// From 06b31f56fc7f8e83185dd8fe1a94f558254fafa8 Mon Sep 17 00:00:00 2001 From: Jesper Broni Andersen Date: Tue, 7 Feb 2017 16:01:03 +0100 Subject: [PATCH 089/104] angular: Add preAssignBindingsEnabled to ICompileProvider --- angular/index.d.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/angular/index.d.ts b/angular/index.d.ts index 73535e9922..099ac2fc27 100644 --- a/angular/index.d.ts +++ b/angular/index.d.ts @@ -1254,6 +1254,16 @@ declare namespace angular { debugInfoEnabled(): boolean; debugInfoEnabled(enabled: boolean): ICompileProvider; + /** + * Call this method to enable/disable whether directive controllers are assigned bindings before calling the controller's constructor. + * If enabled (true), the compiler assigns the value of each of the bindings to the properties of the controller object before the constructor of this object is called. + * If disabled (false), the compiler calls the constructor first before assigning bindings. + * Defaults to false. + * See: https://docs.angularjs.org/api/ng/provider/$compileProvider#preAssignBindingsEnabled + */ + preAssignBindingsEnabled(): boolean; + preAssignBindingsEnabled(enabled: boolean): ICompileProvider; + /** * Sets the number of times $onChanges hooks can trigger new changes before giving up and assuming that the model is unstable. * Increasing the TTL could have performance implications, so you should not change it without proper justification. From 238d84f545eca19ac05b55405c692dac823ddef3 Mon Sep 17 00:00:00 2001 From: Kagami Sascha Rosylight Date: Wed, 8 Feb 2017 02:34:58 +0900 Subject: [PATCH 090/104] add 'end' event to Client --- pg/index.d.ts | 1 + pg/pg-tests.ts | 1 + 2 files changed, 2 insertions(+) diff --git a/pg/index.d.ts b/pg/index.d.ts index a2178d4823..ed03211e6b 100644 --- a/pg/index.d.ts +++ b/pg/index.d.ts @@ -100,6 +100,7 @@ export declare class Client extends events.EventEmitter { on(event: "drain", listener: () => void): this; on(event: "error", listener: (err: Error) => void): this; on(event: "notification" | "notice", listener: (message: any) => void): this; + on(event: "end", listener: () => void): this; } export declare class Query extends events.EventEmitter { diff --git a/pg/pg-tests.ts b/pg/pg-tests.ts index 15dfdde3d9..c4bbb0316c 100644 --- a/pg/pg-tests.ts +++ b/pg/pg-tests.ts @@ -43,6 +43,7 @@ client.connect((err) => { }); return null; }); +client.on('end', () => console.log("Client was disconnected.")); // client pooling From 52ae53f859138ce8ef37cfca624edfeee27ef367 Mon Sep 17 00:00:00 2001 From: Kagami Sascha Rosylight Date: Wed, 8 Feb 2017 02:36:34 +0900 Subject: [PATCH 091/104] use arrow function on tests --- pg/pg-tests.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/pg/pg-tests.ts b/pg/pg-tests.ts index c4bbb0316c..bdf49ab240 100644 --- a/pg/pg-tests.ts +++ b/pg/pg-tests.ts @@ -4,7 +4,7 @@ import * as pg from "pg"; var conString = "postgres://username:password@localhost/database"; // https://github.com/brianc/node-pg-types -pg.types.setTypeParser(20, (val) => Number(val)); +pg.types.setTypeParser(20, val => Number(val)); // Client pooling pg.defaults.ssl = true; @@ -28,7 +28,7 @@ pg.connect(conString, (err, client, done) => { // Simple var client = new pg.Client(conString); -client.connect((err) => { +client.connect(err => { if (err) { return console.error("Could not connect to postgres", err); } @@ -57,11 +57,11 @@ var config = { }; var pool = new pg.Pool(config); -pool.connect(function(err, client, done) { +pool.connect((err, client, done) => { if(err) { return console.error('error fetching client from pool', err); } - client.query('SELECT $1::int AS number', ['1'], function(err, result) { + client.query('SELECT $1::int AS number', ['1'], (err, result) => { done(); if(err) { @@ -71,6 +71,6 @@ pool.connect(function(err, client, done) { }); }); -pool.on('error', function (err, client) { +pool.on('error', (err, client) => { console.error('idle client error', err.message, err.stack) }) From 4342e2b37f6bd653c100589516062e4422ed7c6b Mon Sep 17 00:00:00 2001 From: Kagami Sascha Rosylight Date: Wed, 8 Feb 2017 02:45:49 +0900 Subject: [PATCH 092/104] restoring callback-less and removing optional --- pg/index.d.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/pg/index.d.ts b/pg/index.d.ts index ed03211e6b..67ed0c355d 100644 --- a/pg/index.d.ts +++ b/pg/index.d.ts @@ -88,8 +88,11 @@ export declare class Client extends events.EventEmitter { end(callback?: (err: Error) => void): void; release(): void; - query(queryTextOrConfig: string | QueryConfig, callback?: (err: Error, result: QueryResult) => void): Query; - query(queryText: string, values: any[], callback?: (err: Error, result: QueryResult) => void): Query; + query(queryTextOrConfig: string | QueryConfig): Promise; + query(queryText: string, values: any[]): Promise; + + query(queryTextOrConfig: string | QueryConfig, callback: (err: Error, result: QueryResult) => void): Query; + query(queryText: string, values: any[], callback: (err: Error, result: QueryResult) => void): Query; copyFrom(queryText: string): stream.Writable; copyTo(queryText: string): stream.Readable; From 01208d2b66a40d7805ffb8d3269cd3443af8275c Mon Sep 17 00:00:00 2001 From: Benjamin Lim Date: Mon, 6 Feb 2017 06:28:22 +0800 Subject: [PATCH 093/104] chore: update tsconfig/tslint config --- webpack/tsconfig.json | 4 ++-- webpack/tslint.json | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) create mode 100644 webpack/tslint.json diff --git a/webpack/tsconfig.json b/webpack/tsconfig.json index f85a099ac3..1a1c5440ce 100644 --- a/webpack/tsconfig.json +++ b/webpack/tsconfig.json @@ -5,7 +5,7 @@ "es6" ], "noImplicitAny": true, - "noImplicitThis": false, + "noImplicitThis": true, "strictNullChecks": true, "baseUrl": "../", "typeRoots": [ @@ -19,4 +19,4 @@ "index.d.ts", "webpack-tests.ts" ] -} \ No newline at end of file +} diff --git a/webpack/tslint.json b/webpack/tslint.json new file mode 100644 index 0000000000..377cc837d4 --- /dev/null +++ b/webpack/tslint.json @@ -0,0 +1 @@ +{ "extends": "../tslint.json" } From 469a20b7a711e75fa08ae5ac4ad452b7ddfedf60 Mon Sep 17 00:00:00 2001 From: Benjamin Lim Date: Mon, 6 Feb 2017 06:28:31 +0800 Subject: [PATCH 094/104] style: fix lint errors --- webpack/index.d.ts | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/webpack/index.d.ts b/webpack/index.d.ts index a557034131..d172cd4bc6 100644 --- a/webpack/index.d.ts +++ b/webpack/index.d.ts @@ -472,7 +472,7 @@ declare namespace webpack { apply(thisArg: Webpack, ...args: any[]): void; } - type UglifyCommentFunction = (astNode: any, comment: any) => boolean + type UglifyCommentFunction = (astNode: any, comment: any) => boolean; interface UglifyPluginOptions extends UglifyJS.MinifyOptions { beautify?: boolean; @@ -810,7 +810,7 @@ declare namespace webpack { data?: any; - callback: loaderCallback | void; + callback: loaderCallback | undefined; /** @@ -861,7 +861,7 @@ declare namespace webpack { * The resource file. * In the example: "/abc/resource.js" */ - resourcePath: string + resourcePath: string; /** * The query of the resource. @@ -898,14 +898,14 @@ declare namespace webpack { * @param request * @param callback */ - resolve(context: string, request: string, callback: (err: Error, result: string) => void): any + resolve(context: string, request: string, callback: (err: Error, result: string) => void): any; /** * Resolve a request like a require expression. * @param context * @param request */ - resolveSync(context: string, request: string): string + resolveSync(context: string, request: string): string; /** @@ -928,7 +928,7 @@ declare namespace webpack { * Add a directory as dependency of the loader result. * @param directory */ - addContextDependency(directory: string): void + addContextDependency(directory: string): void; /** * Remove all dependencies of the loader result. Even initial dependencies and these of other loaders. Consider using pitch. @@ -991,7 +991,7 @@ declare namespace webpack { * @param content * @param sourceMap */ - emitFile(name: string, content: Buffer|String, sourceMap: any): void + emitFile(name: string, content: Buffer|string, sourceMap: any): void; /** From c42802e29d38a7636d2ea5bdd7e43b09b6f5e17f Mon Sep 17 00:00:00 2001 From: Benjamin Lim Date: Mon, 6 Feb 2017 06:41:18 +0800 Subject: [PATCH 095/104] style: fix indentation --- webpack/index.d.ts | 18 ++-- webpack/webpack-tests.ts | 192 +++++++++++++++++++-------------------- 2 files changed, 105 insertions(+), 105 deletions(-) diff --git a/webpack/index.d.ts b/webpack/index.d.ts index d172cd4bc6..09e1a22421 100644 --- a/webpack/index.d.ts +++ b/webpack/index.d.ts @@ -832,16 +832,16 @@ declare namespace webpack { * In the example: * [ * { request: "/abc/loader1.js?xyz", - * path: "/abc/loader1.js", - * query: "?xyz", - * module: [Function] - * }, + * path: "/abc/loader1.js", + * query: "?xyz", + * module: [Function] + * }, * { request: "/abc/node_modules/loader2/index.js", - * path: "/abc/node_modules/loader2/index.js", - * query: "", - * module: [Function] - * } - *] + * path: "/abc/node_modules/loader2/index.js", + * query: "", + * module: [Function] + * } + * ] */ loaders: any[]; diff --git a/webpack/webpack-tests.ts b/webpack/webpack-tests.ts index 7c1f109a2d..be36076307 100644 --- a/webpack/webpack-tests.ts +++ b/webpack/webpack-tests.ts @@ -196,9 +196,9 @@ configuration = { }; configuration = { - resolve: { - root: __dirname - } + resolve: { + root: __dirname + } }; rule = { @@ -289,12 +289,12 @@ plugin = new webpack.optimize.UglifyJsPlugin({ } }); plugin = new webpack.optimize.UglifyJsPlugin({ - sourceMap: false, - comments: true, - beautify: true, - test: 'foo', - exclude: /node_modules/, - include: 'test' + sourceMap: false, + comments: true, + beautify: true, + test: 'foo', + exclude: /node_modules/, + include: 'test' }); plugin = new webpack.optimize.UglifyJsPlugin({ mangle: { @@ -302,9 +302,9 @@ plugin = new webpack.optimize.UglifyJsPlugin({ } }); plugin = new webpack.optimize.UglifyJsPlugin({ - comments: function(astNode: any, comment: any) { - return false; - } + comments: function(astNode: any, comment: any) { + return false; + } }); plugin = new webpack.optimize.CommonsChunkPlugin(options); plugin = new CommonsChunkPlugin({ @@ -383,7 +383,7 @@ plugin = new webpack.NoErrorsPlugin(); plugin = new webpack.NoEmitOnErrorsPlugin(); plugin = new webpack.WatchIgnorePlugin(paths); plugin = new webpack.LoaderOptionsPlugin({ - debug: true + debug: true }); // @@ -412,19 +412,19 @@ compiler.watch({ // watch options: // pass a number to set the polling interval }, function(err, stats) { // ... - }); +}); // or compiler.watch({ // watch options: ignored: 'foo/**/*' }, function(err, stats) { // ... - }); +}); // or compiler.watch({ // watch options: ignored: /node_modules/ }, function(err, stats) { // ... - }); +}); declare function handleFatalError(err: Error): void; declare function handleSoftErrors(errs: string[]): void; @@ -438,26 +438,26 @@ webpack({ return handleFatalError(err); var jsonStats = stats.toJson(); var jsonStatsWithAllOptions = stats.toJson({ - assets: true, - assetsSort: "field", - cached: true, - children: true, - chunks: true, - chunkModules: true, - chunkOrigins: true, - chunksSort: "field", - context: "../src/", - errors: true, - errorDetails: true, - hash: true, - modules: true, - modulesSort: "field", - publicPath: true, - reasons: true, - source: true, - timings: true, - version: true, - warnings: true + assets: true, + assetsSort: "field", + cached: true, + children: true, + chunks: true, + chunkModules: true, + chunkOrigins: true, + chunksSort: "field", + context: "../src/", + errors: true, + errorDetails: true, + hash: true, + modules: true, + modulesSort: "field", + publicPath: true, + reasons: true, + source: true, + timings: true, + version: true, + warnings: true }); if(jsonStats.errors.length > 0) return handleSoftErrors(jsonStats.errors); @@ -491,51 +491,51 @@ rule = { } configuration = { - module: { - rules: [ - { oneOf: [ - { - test: { - and: [ - /a.\.js$/, - /b\.js$/ - ] - }, - loader: "./loader?first" - }, - { - test: [ - require.resolve("./a"), - require.resolve("./c"), - ], - issuer: require.resolve("./b"), - use: [ - "./loader?second-1", - { - loader: "./loader", - options: "second-2" - }, - { - loader: "./loader", - options: { - get: function() { return "second-3"; } - } - } - ] - }, - { - test: { - or: [ - require.resolve("./a"), - require.resolve("./c"), - ] - }, - loader: "./loader", - options: "third" - } - ]} - ] - } + module: { + rules: [ + { oneOf: [ + { + test: { + and: [ + /a.\.js$/, + /b\.js$/ + ] + }, + loader: "./loader?first" + }, + { + test: [ + require.resolve("./a"), + require.resolve("./c"), + ], + issuer: require.resolve("./b"), + use: [ + "./loader?second-1", + { + loader: "./loader", + options: "second-2" + }, + { + loader: "./loader", + options: { + get: function() { return "second-3"; } + } + } + ] + }, + { + test: { + or: [ + require.resolve("./a"), + require.resolve("./c"), + ] + }, + loader: "./loader", + options: "third" + } + ]} + ] + } } const resolve: webpack.Resolve = { @@ -543,35 +543,35 @@ const resolve: webpack.Resolve = { } const performance: webpack.PerformanceOptions = { - hints: 'error', - maxEntrypointSize: 400000, - maxAssetSize: 100000, - assetFilter: function(assetFilename) { - return assetFilename.endsWith('.js'); - }, + hints: 'error', + maxEntrypointSize: 400000, + maxAssetSize: 100000, + assetFilter: function(assetFilename) { + return assetFilename.endsWith('.js'); + }, }; configuration = { - performance, + performance, }; function loader(this: webpack.loader.LoaderContext, source: string, sourcemap: string): void { - this.cacheable(); + this.cacheable(); - this.async(); + this.async(); - this.addDependency(''); + this.addDependency(''); - this.resolve('context', 'request', ( err: Error, result: string) => {}); + this.resolve('context', 'request', ( err: Error, result: string) => {}); - this.emitError('wraning'); + this.emitError('wraning'); - this.callback(null, source); + this.callback(null, source); } module loader { - export const raw: boolean = true; - export const pitch = (remainingRequest: string, precedingRequest: string, data: any) => {}; + export const raw: boolean = true; + export const pitch = (remainingRequest: string, precedingRequest: string, data: any) => {}; } const loaderRef: webpack.loader.Loader = loader; console.log(loaderRef.raw === true); From 7463c5be2d100666880d980478395a0a18a89d8f Mon Sep 17 00:00:00 2001 From: Benjamin Lim Date: Mon, 6 Feb 2017 09:18:30 +0800 Subject: [PATCH 096/104] fix: pass failing tests remove undefined from LoaderContext.callback type --- webpack/index.d.ts | 2 +- webpack/webpack-tests.ts | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/webpack/index.d.ts b/webpack/index.d.ts index 09e1a22421..5f3dcb1688 100644 --- a/webpack/index.d.ts +++ b/webpack/index.d.ts @@ -810,7 +810,7 @@ declare namespace webpack { data?: any; - callback: loaderCallback | undefined; + callback: loaderCallback; /** diff --git a/webpack/webpack-tests.ts b/webpack/webpack-tests.ts index be36076307..0969070323 100644 --- a/webpack/webpack-tests.ts +++ b/webpack/webpack-tests.ts @@ -217,7 +217,8 @@ declare var require: any; declare var path: any; configuration = { plugins: [ - function() { + /** @todo `this` should be typed as webpack.compiler.Compiler (which should be webpack.Compiler), not webpack.Webpack */ + function(this: any) { this.plugin("done", function(stats: any) { require("fs").writeFileSync( path.join(__dirname, "...", "stats.json"), From 2b25f6b2b8bfff0d8d4ee24a39daa1bfceb82a42 Mon Sep 17 00:00:00 2001 From: Benjamin Lim Date: Mon, 6 Feb 2017 09:22:28 +0800 Subject: [PATCH 097/104] chore: remove OccurenceOrderPlugin --- webpack/index.d.ts | 6 ++---- webpack/webpack-tests.ts | 2 +- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/webpack/index.d.ts b/webpack/index.d.ts index 5f3dcb1688..5def0965ff 100644 --- a/webpack/index.d.ts +++ b/webpack/index.d.ts @@ -598,9 +598,7 @@ declare namespace webpack { * Assign the module and chunk ids by occurrence count. Ids that are used often get lower (shorter) ids. * This make ids predictable, reduces to total file size and is recommended. */ - // TODO: This is a typo, and will be removed in Webpack 2. - OccurenceOrderPlugin: optimize.OccurenceOrderPluginStatic; - OccurrenceOrderPlugin: optimize.OccurenceOrderPluginStatic; + OccurrenceOrderPlugin: optimize.OccurrenceOrderPluginStatic; /** * Minimize all JavaScript output of chunks. Loaders are switched into minimizing mode. * You can pass an object containing UglifyJs options. @@ -1027,7 +1025,7 @@ declare namespace webpack { interface MinChunkSizePluginStatic { new (options: any): Plugin; } - interface OccurenceOrderPluginStatic { + interface OccurrenceOrderPluginStatic { new (preferEntry: boolean): Plugin; } interface UglifyJsPluginStatic { diff --git a/webpack/webpack-tests.ts b/webpack/webpack-tests.ts index 0969070323..a536a2713f 100644 --- a/webpack/webpack-tests.ts +++ b/webpack/webpack-tests.ts @@ -280,7 +280,7 @@ plugin = new webpack.BannerPlugin(banner, options); plugin = new webpack.optimize.DedupePlugin(); plugin = new webpack.optimize.LimitChunkCountPlugin(options); plugin = new webpack.optimize.MinChunkSizePlugin(options); -plugin = new webpack.optimize.OccurenceOrderPlugin(preferEntry); +plugin = new webpack.optimize.OccurrenceOrderPlugin(preferEntry); plugin = new webpack.optimize.OccurrenceOrderPlugin(preferEntry); plugin = new webpack.optimize.UglifyJsPlugin(options); plugin = new webpack.optimize.UglifyJsPlugin(); From dca67839219fbffde30a367397bdd54b6a52a68d Mon Sep 17 00:00:00 2001 From: Benjamin Lim Date: Mon, 6 Feb 2017 09:56:31 +0800 Subject: [PATCH 098/104] chore: remove LabeledModulesPlugin BREAKING CHANGE: remove webpack.Dependencies interface --- webpack/index.d.ts | 12 +----------- webpack/webpack-tests.ts | 1 - 2 files changed, 1 insertion(+), 12 deletions(-) diff --git a/webpack/index.d.ts b/webpack/index.d.ts index 5def0965ff..c077ef232a 100644 --- a/webpack/index.d.ts +++ b/webpack/index.d.ts @@ -492,7 +492,7 @@ declare namespace webpack { /** * dependencies namespace */ - dependencies: Dependencies; + dependencies: {}; /** * Replace resources that matches resourceRegExp with newResource. * If newResource is relative, it is resolve relative to the previous resource. @@ -613,13 +613,6 @@ declare namespace webpack { AggressiveMergingPlugin: optimize.AggressiveMergingPluginStatic; } - interface Dependencies { - /** - * Support Labeled Modules. - */ - LabeledModulesPlugin: dependencies.LabeledModulesPluginStatic; - } - interface DirectoryDescriptionFilePluginStatic { new (file: string, files: string[]): Plugin; } @@ -1041,9 +1034,6 @@ declare namespace webpack { } namespace dependencies { - interface LabeledModulesPluginStatic { - new (): Plugin; - } } namespace compiler { diff --git a/webpack/webpack-tests.ts b/webpack/webpack-tests.ts index a536a2713f..9515f6045b 100644 --- a/webpack/webpack-tests.ts +++ b/webpack/webpack-tests.ts @@ -345,7 +345,6 @@ plugin = new CommonsChunkPlugin({ // (3 children must share the module before it's separated) }); plugin = new webpack.optimize.AggressiveMergingPlugin(options); -plugin = new webpack.dependencies.LabeledModulesPlugin(); plugin = new webpack.DefinePlugin(definitions); plugin = new webpack.DefinePlugin({ VERSION: JSON.stringify("5fa3b9"), From f522cb689bda7db05d6cd951820ed43988370cd5 Mon Sep 17 00:00:00 2001 From: Benjamin Lim Date: Tue, 7 Feb 2017 08:23:53 +0800 Subject: [PATCH 099/104] chore: remove ResolverPlugin --- webpack/index.d.ts | 23 ----------------------- webpack/webpack-tests.ts | 20 -------------------- 2 files changed, 43 deletions(-) diff --git a/webpack/index.d.ts b/webpack/index.d.ts index c077ef232a..9801249051 100644 --- a/webpack/index.d.ts +++ b/webpack/index.d.ts @@ -515,10 +515,6 @@ declare namespace webpack { * This can boost performance. Try to profile the build first to determine clever prefetching points. */ PrefetchPlugin: PrefetchPluginStatic; - /** - * Apply a plugin (or array of plugins) to one or more resolvers (as specified in types). - */ - ResolverPlugin: ResolverPluginStatic; /** * Adds a banner to the top of each generated chunk. */ @@ -613,10 +609,6 @@ declare namespace webpack { AggressiveMergingPlugin: optimize.AggressiveMergingPluginStatic; } - interface DirectoryDescriptionFilePluginStatic { - new (file: string, files: string[]): Plugin; - } - interface NormalModuleReplacementPluginStatic { new (resourceRegExp: any, newResource: any): Plugin; } @@ -635,21 +627,6 @@ declare namespace webpack { new (request: any): Plugin; } - interface ResolverPluginStatic { - new (plugins: Plugin[], files?: string[]): Plugin; - DirectoryDescriptionFilePlugin: DirectoryDescriptionFilePluginStatic; - /** - * This plugin will append a path to the module directory to find a match, - * which can be useful if you have a module which has an incorrect “main” entry in its package.json/bower.json etc (e.g. "main": "Gruntfile.js"). - * You can use this plugin as a special case to load the correct file for this module. Example: - */ - FileAppendPlugin: FileAppendPluginStatic; - } - - interface FileAppendPluginStatic { - new (files: string[]): Plugin; - } - interface BannerPluginStatic { new (banner: any, options: any): Plugin; } diff --git a/webpack/webpack-tests.ts b/webpack/webpack-tests.ts index 9515f6045b..e2e643a1da 100644 --- a/webpack/webpack-tests.ts +++ b/webpack/webpack-tests.ts @@ -32,18 +32,6 @@ rule = { query: { mimetype: "image/png" } }; -// -// https://webpack.github.io/docs/using-plugins.html -// - -configuration = { - plugins: [ - new webpack.ResolverPlugin([ - new webpack.ResolverPlugin.DirectoryDescriptionFilePlugin("bower.json", ["main"]) - ], ["normal", "loader"]) - ] -}; - // // http://webpack.github.io/docs/tutorials/getting-started/ // @@ -268,14 +256,6 @@ plugin = new webpack.IgnorePlugin(requestRegExp, contextRegExp); plugin = new webpack.PrefetchPlugin(context, request); plugin = new webpack.PrefetchPlugin(request); -plugin = new webpack.ResolverPlugin(plugins, types); -plugin = new webpack.ResolverPlugin(plugins); -plugin = new webpack.ResolverPlugin([ - new webpack.ResolverPlugin.DirectoryDescriptionFilePlugin("bower.json", ["main"]) -], ["normal", "loader"]); -plugin = new webpack.ResolverPlugin([ - new webpack.ResolverPlugin.FileAppendPlugin(['/dist/compiled-moduled.js']) -]); plugin = new webpack.BannerPlugin(banner, options); plugin = new webpack.optimize.DedupePlugin(); plugin = new webpack.optimize.LimitChunkCountPlugin(options); From f0bebc6824ff1ba77616f660c87928f4eb8a72ad Mon Sep 17 00:00:00 2001 From: Benjamin Lim Date: Tue, 7 Feb 2017 08:31:40 +0800 Subject: [PATCH 100/104] chore: remove overloaded CommonsChunkPlugin constructor https://github.com/webpack/webpack/blob/d7384e2f6a17187e59ec2831b41ee813ec158f14/lib/optimize/CommonsChunkPlugin.js#L10-L25 --- .../extract-text-webpack-plugin-tests.ts | 5 ++++- webpack/index.d.ts | 1 - webpack/webpack-tests.ts | 14 ++++++++------ 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/extract-text-webpack-plugin/extract-text-webpack-plugin-tests.ts b/extract-text-webpack-plugin/extract-text-webpack-plugin-tests.ts index 62e522a348..63177ebde3 100644 --- a/extract-text-webpack-plugin/extract-text-webpack-plugin-tests.ts +++ b/extract-text-webpack-plugin/extract-text-webpack-plugin-tests.ts @@ -58,7 +58,10 @@ configuration = { configuration = { // ... plugins: [ - new optimize.CommonsChunkPlugin("commons", "commons.js"), + new optimize.CommonsChunkPlugin({ + name: "commons", + filename: "commons.js", + }), new ExtractTextPlugin("[name].css") ] }; diff --git a/webpack/index.d.ts b/webpack/index.d.ts index 9801249051..43ced0bce5 100644 --- a/webpack/index.d.ts +++ b/webpack/index.d.ts @@ -1002,7 +1002,6 @@ declare namespace webpack { new (options?: UglifyPluginOptions): Plugin; } interface CommonsChunkPluginStatic { - new (chunkName: string, filenames?: string | string[]): Plugin; new (options?: any): Plugin; } interface AggressiveMergingPluginStatic { diff --git a/webpack/webpack-tests.ts b/webpack/webpack-tests.ts index e2e643a1da..4ed9fc3b31 100644 --- a/webpack/webpack-tests.ts +++ b/webpack/webpack-tests.ts @@ -62,7 +62,10 @@ configuration = { filename: "bundle.js" }, plugins: [ - new webpack.optimize.CommonsChunkPlugin(/* chunkName= */"vendor", /* filename= */"vendor.bundle.js") + new webpack.optimize.CommonsChunkPlugin({ + name: "vendor", + filename: "vendor.bundle.js", + }), ] }; @@ -126,10 +129,6 @@ configuration = { output: { filename: "[name].js" }, - plugins: [ - new CommonsChunkPlugin("admin-commons.js", ["ap1", "ap2"]), - new CommonsChunkPlugin("commons.js", ["p1", "p2", "admin-commons.js"]) - ] }; //