Merge remote-tracking branch 'upstream/master'

This commit is contained in:
clownwilleatme
2017-02-08 09:19:56 +11:00
101 changed files with 2987 additions and 2347 deletions
+2 -2
View File
@@ -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.
+10
View File
@@ -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.
+47
View File
@@ -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) => {};
+47 -1
View File
@@ -1,8 +1,44 @@
// Type definitions for AWS Lambda
// Project: http://docs.aws.amazon.com/lambda
// Definitions by: James Darbyshire <https://github.com/darbio/aws-lambda-typescript>, Michael Skarum <https://github.com/skarum>, Stef Heyenrath <https://github.com/StefH/DefinitelyTyped>, Toby Hede <https://github.com/tobyhede>
// Definitions by: James Darbyshire <https://github.com/darbio/aws-lambda-typescript>, Michael Skarum <https://github.com/skarum>, Stef Heyenrath <https://github.com/StefH/DefinitelyTyped>, Toby Hede <https://github.com/tobyhede>, Rich Buggy <https://github.com/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;
-125
View File
@@ -1,125 +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;
}
function makePromise(val: any) {
return <Axios.IPromise<any>>{
then: () => val,
catch: () => val
};
}
axios.interceptors.request.use<any>(config => {
console.log("Method:" + config.method + " Url:" +config.url);
return config;
});
const requestId: number = axios.interceptors.request.use<any>(
(config) => {
console.log("Method:" + config.method + " Url:" +config.url);
return config;
},
(error: any) => error);
axios.interceptors.request.eject(requestId);
axios.interceptors.request.eject(7);
const requestId2: number = axios.interceptors.request.use<any>(
(config) => {
console.log("Method:" + config.method + " Url:" +config.url);
return makePromise(config);
},
(error: any) => error);
axios.interceptors.response.use<any>(config => {
console.log("Status:" + config.status);
return config;
});
axios.interceptors.response.use<any>(config => {
console.log("Status:" + config.status);
return makePromise(config);
});
const responseId: number = axios.interceptors.response.use<any>(
config => {
console.log("Status:" + config.status);
return config;
},
(error: any) => error);
axios.interceptors.response.eject(responseId);
axios.get<Repository>("https://api.github.com/repos/mzabriskie/axios")
.then(r => console.log(r.config.method));
var getRepoDetails = axios<Repository>({
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<any> = {headers: {}};
config.headers['X-Custom-Header'] = 'baz';
axios.post("http://example.com/", config);
var getRepoIssue = axios.get<Issue>("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<Repository, Repository>([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<Repository>, repo2: Axios.AxiosXHR<Repository>) => {
var sumIds = repo1.data.id + repo2.data.id;
console.log("Sum ID:" + sumIds);
return sumIds;
};
axios.all<Repository, Repository>([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";
-328
View File
@@ -1,328 +0,0 @@
// Type definitions for axios 0.9.1
// Project: https://github.com/mzabriskie/axios
// Definitions by: Marcel Buesing <https://github.com/marcelbuesing>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
declare namespace Axios {
interface IThenable<R> {
then<U>(onFulfilled?: (value: R) => U | IThenable<U>, onRejected?: (error: any) => U | IThenable<U>): IThenable<U>;
then<U>(onFulfilled?: (value: R) => U | IThenable<U>, onRejected?: (error: any) => void): IThenable<U>;
}
interface IPromise<R> extends IThenable<R> {
then<U>(onFulfilled?: (value: R) => U | IThenable<U>, onRejected?: (error: any) => U | IThenable<U>): IPromise<U>;
then<U>(onFulfilled?: (value: R) => U | IThenable<U>, onRejected?: (error: any) => void): IPromise<U>;
catch<U>(onRejected?: (error: any) => U | IThenable<U>): IPromise<U>;
}
/**
* HTTP Basic auth details
*/
interface AxiosHttpBasicAuth {
username: string;
password: string;
}
/**
* Common axios XHR config interface
* <T> - request body data type
*/
interface AxiosXHRConfigBase<T> {
/**
* 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?: (<U>(data: T) => U) | [<U>(data: T) => U];
/**
* change the response data to be made before it is passed to then/catch
*/
transformResponse?: <U>(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;
}
/**
* <T> - request body data type
*/
interface AxiosXHRConfig<T> extends AxiosXHRConfigBase<T> {
/**
* 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<T> extends AxiosXHRConfigBase<T> {
/**
* custom headers to be sent
*/
headers: {
common: {[index: string]: string};
patch: {[index: string]: string};
post: {[index: string]: string};
put: {[index: string]: string};
};
}
/**
* <T> - expected response type,
* <U> - request body data type
*/
interface AxiosXHR<T> {
/**
* 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<T>;
}
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 {
/**
* <U> - request body data type
*/
use<U>(fulfilledFn: (config: AxiosXHRConfig<U>) => AxiosXHRConfig<U>): InterceptorId;
use<U>(fulfilledFn: (config: AxiosXHRConfig<U>) => AxiosXHRConfig<U>,
rejectedFn: (error: any) => any)
: InterceptorId;
use<U>(fulfilledFn: (config: AxiosXHRConfig<U>) => IPromise<AxiosXHRConfig<U>>): InterceptorId;
use<U>(fulfilledFn: (config: AxiosXHRConfig<U>) => IPromise<AxiosXHRConfig<U>>,
rejectedFn: (error: any) => any)
: InterceptorId;
eject(interceptorId: InterceptorId): void;
}
interface ResponseInterceptor {
/**
* <T> - expected response type
*/
use<T>(fulfilledFn: (config: Axios.AxiosXHR<T>) => Axios.AxiosXHR<T>): InterceptorId;
use<T>(fulfilledFn: (config: Axios.AxiosXHR<T>) => IPromise<Axios.AxiosXHR<T>>): InterceptorId;
use<T>(fulfilledFn: (config: Axios.AxiosXHR<T>) => Axios.AxiosXHR<T>,
rejectedFn: (error: any) => any)
: InterceptorId;
use<T>(fulfilledFn: (config: Axios.AxiosXHR<T>) => IPromise<Axios.AxiosXHR<T>>,
rejectedFn: (error: any) => any)
: InterceptorId;
eject(interceptorId: InterceptorId): void;
}
/**
* <T> - expected response type,
* <U> - request body data type
*/
interface AxiosInstance {
/**
* Send request as configured
*/
<T>(config: AxiosXHRConfig<T>): IPromise<AxiosXHR<T>>;
/**
* Send request as configured
*/
new <T>(config: AxiosXHRConfig<T>): IPromise<AxiosXHR<T>>;
/**
* Send request as configured
*/
request<T>(config: AxiosXHRConfig<T>): IPromise<AxiosXHR<T>>;
/**
* intercept requests or responses before they are handled by then or catch
*/
interceptors: Interceptor;
/**
* Config defaults
*/
defaults: AxiosXHRConfigDefaults<any>;
/**
* equivalent to `Promise.all`
*/
all<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>(values: [T1 | IPromise<AxiosXHR<T1>>, T2 | IPromise<AxiosXHR<T2>>, T3 | IPromise<AxiosXHR<T3>>, T4 | IPromise<AxiosXHR<T4>>, T5 | IPromise<AxiosXHR<T5>>, T6 | IPromise<AxiosXHR<T6>>, T7 | IPromise<AxiosXHR<T7>>, T8 | IPromise<AxiosXHR<T8>>, T9 | IPromise<AxiosXHR<T9>>, T10 | IPromise<AxiosXHR<T10>>]): IPromise<[AxiosXHR<T1>, AxiosXHR<T2>, AxiosXHR<T3>, AxiosXHR<T4>, AxiosXHR<T5>, AxiosXHR<T6>, AxiosXHR<T7>, AxiosXHR<T8>, AxiosXHR<T9>, AxiosXHR<T10>]>;
all<T1, T2, T3, T4, T5, T6, T7, T8, T9>(values: [T1 | IPromise<AxiosXHR<T1>>, T2 | IPromise<AxiosXHR<T2>>, T3 | IPromise<AxiosXHR<T3>>, T4 | IPromise<AxiosXHR<T4>>, T5 | IPromise<AxiosXHR<T5>>, T6 | IPromise<AxiosXHR<T6>>, T7 | IPromise<AxiosXHR<T7>>, T8 | IPromise<AxiosXHR<T8>>, T9 | IPromise<AxiosXHR<T9>>]): IPromise<[AxiosXHR<T1>, AxiosXHR<T2>, AxiosXHR<T3>, AxiosXHR<T4>, AxiosXHR<T5>, AxiosXHR<T6>, AxiosXHR<T7>, AxiosXHR<T8>, AxiosXHR<T9>]>;
all<T1, T2, T3, T4, T5, T6, T7, T8>(values: [T1 | IPromise<AxiosXHR<T1>>, T2 | IPromise<AxiosXHR<T2>>, T3 | IPromise<AxiosXHR<T3>>, T4 | IPromise<AxiosXHR<T4>>, T5 | IPromise<AxiosXHR<T5>>, T6 | IPromise<AxiosXHR<T6>>, T7 | IPromise<AxiosXHR<T7>>, T8 | IPromise<AxiosXHR<T8>>]): IPromise<[AxiosXHR<T1>, AxiosXHR<T2>, AxiosXHR<T3>, AxiosXHR<T4>, AxiosXHR<T5>, AxiosXHR<T6>, AxiosXHR<T7>, AxiosXHR<T8>]>;
all<T1, T2, T3, T4, T5, T6, T7>(values: [T1 | IPromise<AxiosXHR<T1>>, T2 | IPromise<AxiosXHR<T2>>, T3 | IPromise<AxiosXHR<T3>>, T4 | IPromise<AxiosXHR<T4>>, T5 | IPromise<AxiosXHR<T5>>, T6 | IPromise<AxiosXHR<T6>>, T7 | IPromise<AxiosXHR<T7>>]): IPromise<[AxiosXHR<T1>, AxiosXHR<T2>, AxiosXHR<T3>, AxiosXHR<T4>, AxiosXHR<T5>, AxiosXHR<T6>, AxiosXHR<T7>]>;
all<T1, T2, T3, T4, T5, T6>(values: [T1 | IPromise<AxiosXHR<T1>>, T2 | IPromise<AxiosXHR<T2>>, T3 | IPromise<AxiosXHR<T3>>, T4 | IPromise<AxiosXHR<T4>>, T5 | IPromise<AxiosXHR<T5>>, T6 | IPromise<AxiosXHR<T6>>]): IPromise<[AxiosXHR<T1>, AxiosXHR<T2>, AxiosXHR<T3>, AxiosXHR<T4>, AxiosXHR<T5>, AxiosXHR<T6>]>;
all<T1, T2, T3, T4, T5>(values: [T1 | IPromise<AxiosXHR<T1>>, T2 | IPromise<AxiosXHR<T2>>, T3 | IPromise<AxiosXHR<T3>>, T4 | IPromise<AxiosXHR<T4>>, T5 | IPromise<AxiosXHR<T5>>]): IPromise<[AxiosXHR<T1>, AxiosXHR<T2>, AxiosXHR<T3>, AxiosXHR<T4>, AxiosXHR<T5>]>;
all<T1, T2, T3, T4>(values: [T1 | IPromise<AxiosXHR<T1>>, T2 | IPromise<AxiosXHR<T2>>, T3 | IPromise<AxiosXHR<T3>>, T4 | IPromise<AxiosXHR<T4>>]): IPromise<[AxiosXHR<T1>, AxiosXHR<T2>, AxiosXHR<T3>, AxiosXHR<T4>]>;
all<T1, T2, T3>(values: [T1 | IPromise<AxiosXHR<T1>>, T2 | IPromise<AxiosXHR<T2>>, T3 | IPromise<AxiosXHR<T3>>]): IPromise<[AxiosXHR<T1>, AxiosXHR<T2>, AxiosXHR<T3>]>;
all<T1, T2>(values: [T1 | IPromise<AxiosXHR<T1>>, T2 | IPromise<AxiosXHR<T2>>]): IPromise<[AxiosXHR<T1>, AxiosXHR<T2>]>;
/**
* spread array parameter to `fn`.
* note: alternative to `spread`, destructuring assignment.
*/
spread<T1, T2, U>(fn: (t1: T1, t2: T2) => U): (arr: ([T1, T2])) => U;
/**
* convenience alias, method = GET
*/
get<T>(url: string, config?: AxiosXHRConfigBase<T>): IPromise<AxiosXHR<T>>;
/**
* convenience alias, method = DELETE
*/
delete<T>(url: string, config?: AxiosXHRConfigBase<T>): IPromise<AxiosXHR<T>>;
/**
* convenience alias, method = HEAD
*/
head<T>(url: string, config?: AxiosXHRConfigBase<T>): IPromise<AxiosXHR<T>>;
/**
* convenience alias, method = POST
*/
post<T>(url: string, data?: any, config?: AxiosXHRConfigBase<T>): IPromise<AxiosXHR<T>>;
/**
* convenience alias, method = PUT
*/
put<T>(url: string, data?: any, config?: AxiosXHRConfigBase<T>): IPromise<AxiosXHR<T>>;
/**
* convenience alias, method = PATCH
*/
patch<T>(url: string, data?: any, config?: AxiosXHRConfigBase<T>): IPromise<AxiosXHR<T>>;
}
/**
* <T> - expected response type,
*/
interface AxiosStatic extends AxiosInstance {
/**
* create a new instance of axios with a custom config
*/
create<T>(config: AxiosXHRConfigBase<T>): AxiosInstance;
}
}
declare var axios: Axios.AxiosStatic;
declare module "axios" {
export = axios;
}
+1 -1
View File
@@ -5,7 +5,7 @@
declare module 'bintrees' {
type Callback = <T>(err: Error, item: T) => void;
type Callback = <T>(item: T) => void;
type Comparator = <T>(a: T, b: T) => number;
class Iterator<T> {
+1
View File
@@ -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;
}
+1
View File
@@ -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 {
+1 -1
View File
@@ -458,7 +458,7 @@ declare namespace Draft {
entityMap: { [key: string]: RawDraftEntity };
}
function convertFromHTMLtoContentBlocks(html: string, DOMBuilder: Function, blockRenderMap?: DraftBlockRenderMap): Array<ContentBlock>;
function convertFromHTMLtoContentBlocks(html: string, DOMBuilder?: Function, blockRenderMap?: DraftBlockRenderMap): Array<ContentBlock>;
function convertFromRawToDraftState(rawState: RawDraftContentState): ContentState;
function convertFromDraftStateToRaw(contentState: ContentState): RawDraftContentState;
}
+2 -2
View File
@@ -329,7 +329,7 @@ interface CommonWrapper<P, S> {
* @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<P, S> {
* to the returned array. Should expect a ShallowWrapper as the first argument, and will be run
* with a context of the original instance.
*/
map<V>(fn: (wrapper: this) => V): V[];
map<V>(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
@@ -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")
]
};
+2
View File
@@ -1,3 +1,5 @@
import * as FusionCharts from "fusioncharts";
FusionCharts.addEventListener('ready',(eventObject)=>{
eventObject.stopPropagation();
});
+7
View File
@@ -0,0 +1,7 @@
import { FusionChartStatic } from "fusioncharts";
declare var charts: (H: FusionChartStatic) => FusionChartStatic;
export = charts;
export as namespace charts;
+7
View File
@@ -0,0 +1,7 @@
import { FusionChartStatic } from "fusioncharts";
declare var gantt: (H: FusionChartStatic) => FusionChartStatic;
export = gantt;
export as namespace gantt;
+7
View File
@@ -0,0 +1,7 @@
import { FusionChartStatic } from "fusioncharts";
declare var maps: (H: FusionChartStatic) => FusionChartStatic;
export = maps;
export as namespace maps;
+7
View File
@@ -0,0 +1,7 @@
import { FusionChartStatic } from "fusioncharts";
declare var powercharts: (H: FusionChartStatic) => FusionChartStatic;
export = powercharts;
export as namespace powercharts;
+7
View File
@@ -0,0 +1,7 @@
import { FusionChartStatic } from "fusioncharts";
declare var ssgrid: (H: FusionChartStatic) => FusionChartStatic;
export = ssgrid;
export as namespace ssgrid;
+7
View File
@@ -0,0 +1,7 @@
import { FusionChartStatic } from "fusioncharts";
declare var treemap: (H: FusionChartStatic) => FusionChartStatic;
export = treemap;
export as namespace treemap;
+7
View File
@@ -0,0 +1,7 @@
import { FusionChartStatic } from "fusioncharts";
declare var widgets: (H: FusionChartStatic) => FusionChartStatic;
export = widgets;
export as namespace widgets;
+7
View File
@@ -0,0 +1,7 @@
import { FusionChartStatic } from "fusioncharts";
declare var zoomscatter: (H: FusionChartStatic) => FusionChartStatic;
export = zoomscatter;
export as namespace zoomscatter;
+7 -7
View File
@@ -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 <https://github.com/shivarajkv>
// Definitions by: Rohit Kumar <https://github.com/rohitkr>, Shivaraj KV <https://github.com/shivarajkv>
// 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;
}
+7
View File
@@ -0,0 +1,7 @@
import { FusionChartStatic } from "fusioncharts";
declare var usa: (H: FusionChartStatic) => FusionChartStatic;
export = usa;
export as namespace usa;
+7
View File
@@ -0,0 +1,7 @@
import { FusionChartStatic } from "fusioncharts";
declare var world: (H: FusionChartStatic) => FusionChartStatic;
export = world;
export as namespace world;
+7
View File
@@ -0,0 +1,7 @@
import { FusionChartStatic } from "fusioncharts";
declare var carbon: (H: FusionChartStatic) => FusionChartStatic;
export = carbon;
export as namespace carbon;
+7
View File
@@ -0,0 +1,7 @@
import { FusionChartStatic } from "fusioncharts";
declare var fint: (H: FusionChartStatic) => FusionChartStatic;
export = fint;
export as namespace fint;
+7
View File
@@ -0,0 +1,7 @@
import { FusionChartStatic } from "fusioncharts";
declare var ocean: (H: FusionChartStatic) => FusionChartStatic;
export = ocean;
export as namespace ocean;
+7
View File
@@ -0,0 +1,7 @@
import { FusionChartStatic } from "fusioncharts";
declare var zune: (H: FusionChartStatic) => FusionChartStatic;
export = zune;
export as namespace zune;
+14
View File
@@ -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"
]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "../tslint.json" }
+102 -26
View File
@@ -1,26 +1,24 @@
var featureCollection: GeoJSON.FeatureCollection<any> = {
let featureCollection: GeoJSON.FeatureCollection<any> = {
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 +27,7 @@ var featureCollection: GeoJSON.FeatureCollection<any> = {
prop1: 0.0
}
},
{
{
type: "Feature",
geometry: {
type: "Polygon",
@@ -52,9 +50,9 @@ var featureCollection: GeoJSON.FeatureCollection<any> = {
type: "proj4"
}
}
}
};
var feature: GeoJSON.Feature<GeoJSON.Polygon> = {
let featureWithPolygon: GeoJSON.Feature<GeoJSON.Polygon> = {
type: "Feature",
bbox: [-180.0, -90.0, 180.0, 90.0],
geometry: {
@@ -67,29 +65,29 @@ var feature: GeoJSON.Feature<GeoJSON.Polygon> = {
};
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 +95,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 +108,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] ]
}
]
}
};
let feature: GeoJSON.Feature<GeoJSON.GeometryObject> = {
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"
}
}
};
+40 -50
View File
@@ -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 <https://github.com/cobster/>
// 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
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<T extends GeometryObject> extends GeoJsonObject
{
type: 'Feature'
export interface Feature<T extends GeometryObject> extends GeoJsonObject {
type: 'Feature';
geometry: T;
properties: any;
properties: {} | null;
id?: string;
}
/***
* http://geojson.org/geojson-spec.html#feature-collection-objects
*/
export interface FeatureCollection<T extends GeometryObject> extends GeoJsonObject
{
type: 'FeatureCollection'
features: Feature<T>[];
export interface FeatureCollection<T extends GeometryObject> extends GeoJsonObject {
type: 'FeatureCollection';
features: Array<Feature<T>>;
}
/***
* 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 };
}
}
+6
View File
@@ -0,0 +1,6 @@
{
"extends": "../tslint.json",
"rules": {
"no-single-declare-module": false
}
}
+41
View File
@@ -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', <hapiAuthJwt2.Options>{
key: 'NeverShareYourSecret',
validateFunc: validate,
verifyOptions: {
algorithms: ['HS256']
}
});
});
server.start();
+126
View File
@@ -0,0 +1,126 @@
// Type definitions for hapi-auth-jwt2 7.0
// Project: http://github.com/dwyl/hapi-auth-jwt2
// Definitions by: Warren Seymour <http://github.com/warrenseymour>
// 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: <tokenType> 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;
@@ -1,13 +1,10 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6",
"dom"
],
"target": "es6",
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": false,
"strictNullChecks": true,
"baseUrl": "../",
"typeRoots": [
"../"
@@ -18,6 +15,6 @@
},
"files": [
"index.d.ts",
"axios-tests.ts"
"hapi-auth-jwt2-tests.ts"
]
}
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "../tslint.json" }
+2 -1
View File
@@ -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;
+2
View File
@@ -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
@@ -1,34 +1,24 @@
import HtmlWebpackPlugin = require("html-webpack-plugin");
import { Configuration } from "webpack";
import * as HtmlWebpackPlugin from 'html-webpack-plugin';
const a: Configuration = {
plugins: [
new HtmlWebpackPlugin()
]
};
new HtmlWebpackPlugin();
const b: Configuration = {
plugins: [
new HtmlWebpackPlugin({
title: "test"
})
]
};
const optionsArray: HtmlWebpackPlugin.Options[] = [
{
title: 'test',
},
{
minify: {
caseSensitive: true,
},
},
{
chunksSortMode: function compare(a, b) {
return 1;
},
},
{
arbitrary: 'data',
},
];
const minify: HtmlWebpackPlugin.MinifyConfig = {
caseSensitive: true
};
new HtmlWebpackPlugin({
minify
});
new HtmlWebpackPlugin({
chunksSortMode: function compare(a, b) {
return 1;
}
});
new HtmlWebpackPlugin({
arbitrary: "data"
});
const plugins: HtmlWebpackPlugin[] = optionsArray.map(options => new HtmlWebpackPlugin(options));
+72 -92
View File
@@ -3,106 +3,86 @@
// Definitions by: Simon Hartcher <https://github.com/deevus>, Benjamin Lim <https://github.com/bumbleblym>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
import { Plugin, Webpack } from "webpack";
import { Options } from "html-minifier";
import { Plugin } from 'webpack';
import { Options as HtmlMinifierOptions } from 'html-minifier';
export = HtmlWebpackPlugin;
declare class HtmlWebpackPlugin implements Plugin {
constructor(options?: HtmlWebpackPlugin.Config);
apply(thisArg: Webpack, ...args: any[]): void;
declare class HtmlWebpackPlugin extends Plugin {
constructor(options?: HtmlWebpackPlugin.Options);
}
declare namespace HtmlWebpackPlugin {
export type MinifyConfig = Options;
type MinifyOptions = HtmlMinifierOptions;
/**
* It is assumed that each [chunk] contains at least the properties "id"
* (containing the chunk id) and "parents" (array containing the ids of the
* parent chunks).
*/
export interface Chunk { // TODO: Import from webpack?
id: string;
parents: string[];
[propName: string]: any; // TODO: Narrow type
}
/**
* It is assumed that each [chunk] contains at least the properties "id"
* (containing the chunk id) and "parents" (array containing the ids of the
* parent chunks).
*
* @todo define in webpack
*/
interface Chunk {
id: string;
parents: string[];
[propName: string]: any;
}
export type ChunkComparator = (a: Chunk, b: Chunk) => number;
type ChunkComparator = (a: Chunk, b: Chunk) => number;
export interface Config {
/**
* The title to use for the generated HTML document.
*/
title?: string;
interface Options {
/** `true | false` if `true` (default) try to emit the file only if it was changed. */
cache?: boolean;
/**
* Allows to control how chunks should be sorted before they are included to the html.
* Allowed values: `'none' | 'auto' | 'dependency' | {function}` - default: `'auto'`
*/
chunksSortMode?: 'none' | 'auto' | 'dependency' | ChunkComparator;
/** Allows you to add only some chunks (e.g. only the unit-test chunk) */
chunks?: string[];
/** Allows you to skip some chunks (e.g. don't add the unit-test chunk) */
excludeChunks?: string[];
/** Adds the given favicon path to the output html. */
favicon?: string;
/**
* The file to write the HTML to.
* Defaults to index.html. You can specify a subdirectory here too (eg: `assets/admin.html`).
*/
filename?: string;
/**
* `true | false` if `true` then append a unique webpack compilation hash to all included scripts and css files.
* This is useful for cache busting.
*/
hash?: boolean;
/**
* `true | 'head' | 'body' | false`
* Inject all assets into the given template or templateContent.
* When passing true or 'body' all javascript resources will be placed at the bottom of the body element.
* 'head' will place the scripts in the head element.
*/
inject?: 'body' | 'head' | boolean;
/**
* `{...} | false` Pass a html-minifier options object to minify the output.
* https://github.com/kangax/html-minifier#options-quick-reference
*/
minify?: false | MinifyOptions;
/** `true | false` if `true` (default) errors details will be written into the html page. */
showErrors?: boolean;
/** Webpack require path to the template. Please see the docs for details. */
template?: string;
/** The title to use for the generated HTML document. */
title?: string;
/** `true | false` If `true` render the link tags as self-closing, XHTML compliant. Default is `false` */
xhtml?: boolean;
/**
* In addition to the options actually used by this plugin, you can use this hash to pass arbitrary data through
* to your template.
*/
[option: string]: any;
}
/**
* The file to write the HTML to. Defaults to index.html. You can specify a subdirectory here too (eg: `assets/admin.html`).
*/
filename?: string;
/**
* Webpack require path to the template. Please see the docs for details.
*/
template?: string;
/**
* `true | 'head' | 'body' | false`
*
* Inject all assets into the given template or templateContent - When passing true or 'body' all javascript resources will be placed at the bottom of the body element. 'head' will place the scripts in the head element.
*/
inject?: boolean | "head" | "body";
/**
* Adds the given favicon path to the output html.
*/
favicon?: string;
/**
* `{...} | false` Pass a html-minifier options object to minify the output.
*
* https://github.com/kangax/html-minifier#options-quick-reference
*/
minify?: MinifyConfig | false;
/**
* `true | false` if `true` then append a unique webpack compilation hash to all included scripts and css files. This is useful for cache busting.
*/
hash?: boolean;
/**
* `true | false` if `true` (default) try to emit the file only if it was changed.
*/
cache?: boolean;
/**
* `true | false` if `true` (default) errors details will be written into the html page.
*/
showErrors?: boolean;
/**
* Allows you to add only some chunks (e.g. only the unit-test chunk)
*/
chunks?: string[];
/**
* Allows to control how chunks should be sorted before they are included to the html. Allowed values: `'none' | 'auto' | 'dependency' | {function}` - default: `'auto'`
*/
chunksSortMode?: "none" | "auto" | "dependency" | ChunkComparator;
/**
* Allows you to skip some chunks (e.g. don't add the unit-test chunk)
*/
excludeChunks?: string[];
/**
* `true | false` If `true` render the link tags as self-closing, XHTML compliant. Default is `false`
*/
xhtml?: boolean;
/**
* In addition to the options actually used by this plugin, you can use
* this hash to pass arbitrary data through to your template.
*/
[option: string]: any;
}
/** @deprecated use MinifyOptions */
type MinifyConfig = MinifyOptions;
/** @deprecated use Options */
type Config = Options;
}
@@ -1,65 +1,65 @@
import HtmlWebpackPlugin = require('html-webpack-plugin');
import template = require('html-webpack-template');
import * as HtmlWebpackPlugin from 'html-webpack-plugin';
import * as template from 'html-webpack-template';
const configs: Array<template.Config> = [
{
// Required
inject: false,
template,
// template: 'node_modules/html-webpack-template/index.ejs',
const optionsArray: template.Options[] = [
{
/** Required */
inject: false,
template,
// template: 'node_modules/html-webpack-template/index.ejs',
// Optional
appMountId: 'app',
appMountIds: [
'root0',
'root1',
],
baseHref: 'http://example.com/awesome',
devServer: 'http://localhost:3001',
googleAnalytics: {
trackingId: 'UA-XXXX-XX',
pageViewOnLoad: true,
},
links: [
'https://fonts.googleapis.com/css?family=Roboto',
{
href: '/apple-touch-icon.png',
rel: 'apple-touch-icon',
sizes: '180x180',
},
{
href: '/favicon-32x32.png',
rel: 'icon',
sizes: '32x32',
type: 'image/png',
},
],
meta: [
{
description: 'A better default template for html-webpack-plugin.',
},
],
mobile: true,
inlineManifestWebpackName: 'webpackManifest',
scripts: [
'http://example.com/somescript.js',
{
src: '/myModule.js',
type: 'module',
},
],
window: {
env: {
apiHost: 'http://myapi.com/api/v1',
},
},
/** Optional */
appMountId: 'app',
appMountIds: [
'root0',
'root1',
],
baseHref: 'http://example.com/awesome',
devServer: 'http://localhost:3001',
googleAnalytics: {
trackingId: 'UA-XXXX-XX',
pageViewOnLoad: true,
},
links: [
'https://fonts.googleapis.com/css?family=Roboto',
{
href: '/apple-touch-icon.png',
rel: 'apple-touch-icon',
sizes: '180x180',
},
{
href: '/favicon-32x32.png',
rel: 'icon',
sizes: '32x32',
type: 'image/png',
},
],
meta: [
{
description: 'A better default template for html-webpack-plugin.',
},
],
mobile: true,
inlineManifestWebpackName: 'webpackManifest',
scripts: [
'http://example.com/somescript.js',
{
src: '/myModule.js',
type: 'module',
},
],
window: {
env: {
apiHost: 'http://myapi.com/api/v1',
},
},
// And any other config options from html-webpack-plugin:
// https://github.com/ampedandwired/html-webpack-plugin#configuration
title: 'My App',
},
/**
* And any other config options from html-webpack-plugin:
* https://github.com/ampedandwired/html-webpack-plugin#configuration
*/
title: 'My App',
},
];
const plugins: Array<HtmlWebpackPlugin> = configs.map(config =>
new HtmlWebpackPlugin(config)
);
const plugins: HtmlWebpackPlugin[] = optionsArray.map(options => new HtmlWebpackPlugin(options));
+58 -78
View File
@@ -3,94 +3,74 @@
// Definitions by: Benjamin Lim <https://github.com/bumbleblym>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
import { Config as HtmlWebpackPluginConfig } from 'html-webpack-plugin';
import { Options as HtmlWebpackPluginOptions } from 'html-webpack-plugin';
export = HtmlWebpackTemplate;
declare const HtmlWebpackTemplate: string;
declare namespace HtmlWebpackTemplate {
export interface GoogleAnalyticsConfig {
trackingId: string;
// Log a pageview event after the analytics code loads.
pageViewOnLoad?: boolean;
}
interface GoogleAnalyticsOptions {
/** Log a pageview event after the analytics code loads. */
pageViewOnLoad?: boolean;
trackingId: string;
}
export interface Attributes {
[name: string]: any;
}
interface Attributes {
[name: string]: any;
}
type Resource = string | Attributes;
type Resource = string | Attributes;
/**
* string: value is assigned to the href attribute and the rel attribute is
* set to "stylesheet"
*
* object: properties and values are used as the attribute names and values,
* respectively:
*/
export type Link = Resource;
/**
* string: value is assigned to the href attribute and the rel attribute is set to "stylesheet"
* object: properties and values are used as the attribute names and values, respectively.
*/
type Link = Resource;
/**
* string: value is assigned to the src attribute and the type attribute is
* set to "text/javascript";
*
* object: properties and values are used as the attribute names and values,
* respectively.
*/
export type Script = Resource;
/**
* string: value is assigned to the src attribute and the type attribute is set to "text/javascript".
* object: properties and values are used as the attribute names and values, respectively.
*/
type Script = Resource;
export interface Config extends HtmlWebpackPluginConfig {
/**
* Set to false. Controls asset addition to the template. This template
* takes care of that.
*/
inject: false;
interface Options extends HtmlWebpackPluginOptions {
/** The <div> element id on which you plan to mount a JavaScript app. */
appMountId?: string;
/** An array of application element ids. */
appMountIds?: string[];
/**
* Adjust the URL for relative URLs in the document (MDN).
* https://developer.mozilla.org/en/docs/Web/HTML/Element/base
*/
baseHref?: string;
/** Insert the webpack-dev-server hot reload script at this host:port/path; e.g., http://localhost:3000. */
devServer?: string;
/** Track usage of your site via Google Analytics. */
googleAnalytics?: GoogleAnalyticsOptions;
/** Set to false. Controls asset addition to the template. This template takes care of that. */
inject: false;
/**
* For use with inline-manifest-webpack-plugin.
* https://github.com/szrenwei/inline-manifest-webpack-plugin
*/
inlineManifestWebpackName?: string;
/** Array of <link> elements. */
links?: Link[];
/** Array of objects containing key value pairs to be included as meta tags. */
meta?: Attributes[];
/** Sets appropriate meta tag for page scaling. */
mobile?: boolean;
/** Array of external script imports to include on page. */
scripts?: Script[];
/** Specify this module's index.ejs file. */
template: string;
/** Object that defines data you need to bootstrap a JavaScript app. */
window?: {};
}
// Specify this module's index.ejs file.
template: string;
// The <div> element id on which you plan to mount a JavaScript app.
appMountId?: string;
// An array of application element ids.
appMountIds?: string[];
/**
* Adjust the URL for relative URLs in the document (MDN).
* https://developer.mozilla.org/en/docs/Web/HTML/Element/base
*/
baseHref?: string;
/**
* Insert the webpack-dev-server hot reload script at this
* host:port/path; e.g., http://localhost:3000.
*/
devServer?: string;
// Track usage of your site via Google Analytics.
googleAnalytics?: GoogleAnalyticsConfig;
// Array of <link> elements.
links?: Link[];
// Array of objects containing key value pairs to be included as meta tags.
meta?: Attributes[];
// Sets appropriate meta tag for page scaling.
mobile?: boolean;
/**
* For use with inline-manifest-webpack-plugin.
*
* https://github.com/szrenwei/inline-manifest-webpack-plugin
*/
inlineManifestWebpackName?: string;
// Array of external script imports to include on page.
scripts?: Script[];
// Object that defines data you need to bootstrap a JavaScript app.
window?: {};
}
/** @deprecated use GoogleAnalyticsOptions */
type GoogleAnalyticsConfig = GoogleAnalyticsOptions;
/** @deprecated use Options */
type Config = Options;
}
+41 -32
View File
@@ -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 <https://github.com/kingdango/>
// Definitions by: Aaron King <https://github.com/kingdango/>, Tim Helfensdörfer <https://github.com/thelfensdrfer>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// Project by: Nedim Carter <http://needim.github.io>
@@ -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 '<div class="noty_message"><span class="noty_text"></span><div class="noty_close"></div></div>' */
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 */
/** The note`s optional template like '<div class="noty_message"><span class="noty_text"></span><div class="noty_close"></div></div>' */
template?: string;
/** Delay for closing event. Set false for sticky notifications */
timeout?: any;
/** displays a progress bar */
progressBar?: boolean;
animation?: NotyAnimationOptions;
/** backdrop click will close all notifications */
closeWith?: ('click' | 'button' | 'hover' | 'backdrop')[];
/** if true adds an overlay */
modal?: boolean;
/** if true closes all notifications and shows itself */
killer?: boolean;
closeWith?: any[];
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 {
+265 -204
View File
@@ -1,4 +1,4 @@
// 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 <https://github.com/alejo90>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
@@ -8,6 +8,19 @@
type NativeMouseEvent = MouseEvent;
type NativeKeyboardEvent = KeyboardEvent;
// 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 ? */;
@@ -25,43 +38,37 @@ declare namespace L {
}
export namespace LineUtil {
export function simplify(points: Array<Point>, tolerance: number): Array<Point>;
export function simplify(points: PointExpression[], tolerance: number): Point[];
export function simplify(points: Array<PointTuple>, tolerance: number): Array<Point>;
export function pointToSegmentDistance(p: PointExpression, p1: PointExpression, p2: PointExpression): number;
export function pointToSegmentDistance(p: Point, p1: Point, p2: Point): number;
export function pointToSegmentDistance(p: PointTuple, p1: PointTuple, p2: PointTuple): number;
export function closestPointOnSegment(p: Point, p1: Point, p2: Point): Point;
export function closestPointOnSegment(p: PointTuple, p1: PointTuple, p2: PointTuple): Point;
export function closestPointOnSegment(p: PointExpression, p1: PointExpression, p2: PointExpression): Point;
}
export namespace PolyUtil {
export function clipPolygon(points: Array<Point>, bounds: Bounds, round?: boolean): Array<Point>;
export function clipPolygon(points: Array<PointTuple>, bounds: BoundsLiteral, round?: boolean): Array<Point>;
export function clipPolygon(points: PointExpression[], bounds: BoundsExpression, round?: boolean): Point[];
}
export class DomUtil {
static get(id: string): HTMLElement;
static get(id: HTMLElement): HTMLElement;
/**
* 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 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;
@@ -71,7 +78,7 @@ declare namespace L {
static restoreOutline(): void;
}
export interface CRS {
export abstract class CRS {
latLngToPoint(latlng: LatLngExpression, zoom: number): Point;
pointToLatLng(point: PointExpression, zoom: number): LatLng;
project(latlng: LatLngExpression): Point;
@@ -109,7 +116,9 @@ declare namespace L {
export const SphericalMercator: Projection;
}
export interface 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;
@@ -132,17 +141,12 @@ declare namespace L {
export function latLng(latitude: number, longitude: number, altitude?: number): LatLng;
export function latLng(coords: LatLngTuple): LatLng;
export function latLng(coords: LatLngTuple | [number, number, number] | LatLngLiteral | {lat: number, lng: number, alt?: number}): LatLng;
export function latLng(coords: [number, number, number]): LatLng;
export function latLng(coords: LatLngLiteral): LatLng;
export function latLng(coords: {lat: number, lng: number, alt: number}): LatLng;
export interface LatLngBounds {
extend(latlng: LatLngExpression): this;
extend(otherBounds: LatLngBoundsExpression): this;
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;
@@ -153,8 +157,7 @@ declare namespace L {
getSouth(): number;
getEast(): number;
getNorth(): number;
contains(otherBounds: LatLngBoundsExpression): boolean;
contains(latlng: LatLngExpression): boolean;
contains(otherBoundsOrLatLng: LatLngBoundsExpression | LatLngExpression): boolean;
intersects(otherBounds: LatLngBoundsExpression): boolean;
overlaps(otherBounds: BoundsExpression): boolean; // investigate if this is really bounds and not latlngbounds
toBBoxString(): string;
@@ -162,7 +165,7 @@ declare namespace L {
isValid(): boolean;
}
export type LatLngBoundsLiteral = Array<LatLngTuple>;
export type LatLngBoundsLiteral = LatLngTuple[]; // Must be [LatLngTuple, LatLngTuple], cant't change because Map.setMaxBounds
type LatLngBoundsExpression = LatLngBounds | LatLngBoundsLiteral;
@@ -172,7 +175,9 @@ declare namespace L {
export type PointTuple = [number, number];
export interface Point {
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;
@@ -195,20 +200,19 @@ declare namespace L {
export function point(x: number, y: number, round?: boolean): Point;
export function point(coords: PointTuple): Point;
export function point(coords: PointTuple | {x: number, y: number}): Point;
export function point(coords: {x: number, y: number}): Point;
export type BoundsLiteral = [PointTuple, PointTuple];
export type BoundsLiteral = Array<PointTuple>;
export interface Bounds {
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(otherBounds: BoundsExpression): boolean;
contains(point: PointExpression): boolean;
contains(pointOrBounds: BoundsExpression | PointExpression): boolean;
intersects(otherBounds: BoundsExpression): boolean;
overlaps(otherBounds: BoundsExpression): boolean;
@@ -220,13 +224,13 @@ declare namespace L {
export function bounds(topLeft: PointExpression, bottomRight: PointExpression): Bounds;
export function bounds(points: Array<Point>): Bounds;
export function bounds(points: BoundsLiteral): Bounds;
export function bounds(points: Point[] | BoundsLiteral): Bounds;
export type EventHandlerFn = (event: Event) => void;
export type EventHandlerFnMap = {[type: string]: EventHandlerFn};
export interface EventHandlerFnMap {
[type: string]: EventHandlerFn;
}
/**
* A set of methods shared between event-powered classes (like Map and Marker).
@@ -248,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.
@@ -260,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.
*/
@@ -401,35 +406,23 @@ declare namespace L {
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;
bindPopup(content: (layer: Layer) => Content | Content | Popup, options?: PopupOptions): this;
unbindPopup(): this;
openPopup(): this;
openPopup(latlng: LatLngExpression): this;
openPopup(latlng?: LatLngExpression): this;
closePopup(): this;
togglePopup(): this;
isPopupOpen(): boolean;
setPopupContent(content: string): this;
setPopupContent(content: HTMLElement): this;
setPopupContent(content: Popup): this;
setPopupContent(content: 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;
bindTooltip(content: (layer: Layer) => Content | Tooltip | Content, options?: TooltipOptions): this;
unbindTooltip(): this;
openTooltip(): this;
openTooltip(latlng: LatLngExpression): this;
openTooltip(latlng?: LatLngExpression): this;
closeTooltip(): this;
toggleTooltip(): this;
isTooltipOpen(): boolean;
setTooltipContent(content: string): this;
setTooltipContent(content: HTMLElement): this;
setTooltipContent(content: Tooltip): this;
setTooltipContent(content: Content | Tooltip): this;
getTooltip(): Tooltip;
// Extension methods
@@ -457,7 +450,8 @@ declare namespace L {
keepBuffer?: number;
}
export interface GridLayer extends Layer {
export class GridLayer extends Layer {
constructor(options?: GridLayerOptions);
bringToFront(): this;
bringToBack(): this;
getAttribution(): string;
@@ -475,7 +469,8 @@ declare namespace L {
minZoom?: number;
maxZoom?: number;
maxNativeZoom?: number;
subdomains?: string | Array<string>;
minNativeZoom?: number;
subdomains?: string | string[];
errorTileUrl?: string;
zoomOffset?: number;
tms?: boolean;
@@ -485,12 +480,25 @@ declare namespace L {
[name: string]: any;
}
export interface TileLayer extends GridLayer {
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;
@@ -501,12 +509,20 @@ declare namespace L {
uppercase?: boolean;
}
export interface WMS extends TileLayer {
setParams(params: any, noRedraw?: boolean): this;
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): WMS;
export function wms(baseUrl: string, options?: WMSOptions): TileLayer.WMS;
}
export interface ImageOverlayOptions extends LayerOptions {
@@ -517,7 +533,8 @@ declare namespace L {
crossOrigin?: boolean;
}
export interface ImageOverlay extends Layer {
export class ImageOverlay extends Layer {
constructor(imageUrl: string, bounds: LatLngBoundsExpression, options?: ImageOverlayOptions);
setOpacity(opacity: number): this;
bringToFront(): this;
bringToBack(): this;
@@ -531,6 +548,8 @@ declare namespace L {
/** 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;
@@ -558,11 +577,14 @@ declare namespace L {
className?: string;
}
export interface Path extends Layer {
export abstract class Path extends Layer {
redraw(): this;
setStyle(style: PathOptions): this;
bringToFront(): this;
bringToBack(): this;
getElement(): HTMLElement;
options: PathOptions;
}
export interface PolylineOptions extends PathOptions {
@@ -570,32 +592,37 @@ declare namespace L {
noClip?: boolean;
}
interface InternalPolyline extends Path {
getLatLngs(): Array<LatLng>;
setLatLngs(latlngs: Array<LatLngExpression>): this;
class InternalPolyline extends Path {
getLatLngs(): LatLng[];
setLatLngs(latlngs: LatLngExpression[]): this;
isEmpty(): boolean;
getCenter(): LatLng;
getBounds(): LatLngBounds;
addLatLng(latlng: LatLngExpression): this;
addLatLng(latlng: Array<LatLngExpression>): this; // these three overloads aren't explicitly noted in the docs
addLatLng(latlng: LatLngExpression | LatLngExpression[]): this;
options: PolylineOptions;
}
export interface Polyline extends InternalPolyline {
toGeoJSON(): GeoJSON.LineString | GeoJSON.MultiLineString;
export class Polyline extends InternalPolyline {
constructor(latlngs: LatLngExpression[], options?: PolylineOptions);
toGeoJSON(): GeoJSONFeature<GeoJSONLineString | GeoJSONMultiLineString>;
feature: GeoJSONFeature<GeoJSONLineString | GeoJSONMultiLineString>;
}
export function polyline(latlngs: Array<LatLngExpression>, options?: PolylineOptions): Polyline;
export function polyline(latlngs: Array<Array<LatLngExpression>>, options?: PolylineOptions): Polyline;
export function polyline(latlngs: LatLngExpression[], options?: PolylineOptions): Polyline;
export interface Polygon extends InternalPolyline {
toGeoJSON(): GeoJSON.Polygon | GeoJSON.MultiPolygon;
export class Polygon extends InternalPolyline {
constructor(latlngs: LatLngExpression[], options?: PolylineOptions);
toGeoJSON(): GeoJSONFeature<GeoJSONPolygon | GeoJSONMultiPolygon>;
feature: GeoJSONFeature<GeoJSONPolygon | GeoJSONMultiPolygon>;
}
export function polygon(latlngs: Array<LatLngExpression>, options?: PolylineOptions): Polygon;
export function polygon(latlngs: LatLngExpression[], options?: PolylineOptions): Polygon;
export function polygon(latlngs: Array<Array<LatLngExpression>>, options?: PolylineOptions): Polygon;
export interface Rectangle extends Polygon {
export class Rectangle extends Polygon {
constructor(latLngBounds: LatLngBoundsExpression, options?: PolylineOptions);
setBounds(latLngBounds: LatLngBoundsExpression): this;
}
@@ -605,48 +632,50 @@ declare namespace L {
radius?: number;
}
export interface CircleMarker extends Path {
toGeoJSON(): GeoJSON.Point;
export class CircleMarker extends Path {
constructor(latlng: LatLngExpression, options?: CircleMarkerOptions);
toGeoJSON(): GeoJSONFeature<GeoJSONPoint>;
setLatLng(latLng: LatLngExpression): this;
getLatLng(): LatLng;
setRadius(radius: number): this;
getRadius(): number;
options: CircleMarkerOptions;
feature: GeoJSONFeature<GeoJSONPoint>;
}
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;
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?: CircleOptions): Circle;
export function circle(latlng: LatLngExpression, radius: number, options?: CircleOptions): Circle;
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 interface Renderer extends Layer {}
export class Renderer extends Layer {
constructor(options?: RendererOptions);
export interface SVG extends Renderer {}
options: RendererOptions;
}
export class SVG extends Renderer {}
export namespace SVG {
export function create(name: string): SVGElement;
export function pointsToPath(rings: Array<Point>, close: boolean): string;
export function pointsToPath(rings: Array<PointTuple>, close: boolean): string;
export function pointsToPath(rings: PointExpression[], close: boolean): string;
}
export function svg(options?: RendererOptions): SVG;
export interface Canvas extends Renderer {}
export class Canvas extends Renderer {}
export function canvas(options?: RendererOptions): Canvas;
@@ -655,11 +684,12 @@ declare namespace L {
* 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 interface LayerGroup extends Layer {
export class LayerGroup extends Layer {
constructor(layers: Layer[]);
/**
* Returns a GeoJSON representation of the layer group (as a GeoJSON GeometryCollection).
* Returns a GeoJSON representation of the layer group (as a GeoJSON GeometryCollection, GeoJSONFeatureCollection or Multipoint).
*/
toGeoJSON(): GeoJSON.GeometryCollection;
toGeoJSON(): GeoJSONFeatureCollection<GeoJSONGeometryObject> | GeoJSONFeature<GeoJSONGeometryCollection | GeoJSONMultiPoint>;
/**
* Adds the given layer to the group.
@@ -667,14 +697,9 @@ declare namespace L {
addLayer(layer: Layer): this;
/**
* Removes the given layer from the group.
* Removes the layer with the given internal ID or the given layer from the group.
*/
removeLayer(layer: Layer): this;
/**
* Removes the layer with the given internal ID from the group.
*/
removeLayer(id: number): this;
removeLayer(layer: number | Layer): this;
/**
* Returns true if the given layer is currently added to the group.
@@ -690,7 +715,7 @@ declare namespace L {
* 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<any>): this;
invoke(methodName: string, ...params: any[]): this;
/**
* Iterates over the layers of the group,
@@ -706,7 +731,7 @@ declare namespace L {
/**
* Returns an array of all the layers added to the group.
*/
getLayers(): Array<Layer>;
getLayers(): Layer[];
/**
* Calls setZIndex on every layer contained in this group, passing the z-index.
@@ -717,18 +742,20 @@ declare namespace L {
* Returns the internal ID for a layer
*/
getLayerId(layer: Layer): number;
feature: GeoJSONFeatureCollection<GeoJSONGeometryObject> | GeoJSONFeature<GeoJSONGeometryCollection | GeoJSONMultiPoint>;
}
/**
* Create a layer group, optionally given an initial set of layers.
*/
export function layerGroup(layers: Array<Layer>): LayerGroup;
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 interface FeatureGroup extends LayerGroup {
export class FeatureGroup extends LayerGroup {
/**
* Sets the given path options to each layer of the group that has a setStyle method.
*/
@@ -754,9 +781,9 @@ declare namespace L {
/**
* Create a feature group, optionally given an initial set of layers.
*/
export function featureGroup(layers?: Array<Layer>): FeatureGroup;
export function featureGroup(layers?: Layer[]): FeatureGroup;
type StyleFunction = (feature: GeoJSON.Feature<GeoJSON.GeometryObject>) => PathOptions;
type StyleFunction = (feature: GeoJSONFeature<GeoJSONGeometryObject>) => PathOptions;
export interface GeoJSONOptions extends LayerOptions {
/**
@@ -772,7 +799,7 @@ declare namespace L {
* }
* ```
*/
pointToLayer?: (geoJsonPoint: GeoJSON.Feature<GeoJSON.Point>, latlng: LatLng) => Layer; // should import GeoJSON typings
pointToLayer?: (geoJsonPoint: GeoJSONFeature<GeoJSONPoint>, latlng: LatLng) => Layer; // should import GeoJSON typings
/**
* A Function defining the Path options for styling GeoJSON lines and polygons,
@@ -798,7 +825,7 @@ declare namespace L {
* function (feature, layer) {}
* ```
*/
onEachFeature?: (feature: GeoJSON.Feature<GeoJSON.GeometryObject>, layer: Layer) => void;
onEachFeature?: (feature: GeoJSONFeature<GeoJSONGeometryObject>, layer: Layer) => void;
/**
* A Function that will be used to decide whether to show a feature or not.
@@ -811,7 +838,7 @@ declare namespace L {
* }
* ```
*/
filter?: (geoJsonFeature: GeoJSON.Feature<GeoJSON.GeometryObject>) => boolean;
filter?: (geoJsonFeature: GeoJSONFeature<GeoJSONGeometryObject>) => boolean;
/**
* A Function that will be used for converting GeoJSON coordinates to LatLngs.
@@ -820,12 +847,16 @@ declare namespace L {
coordsToLatLng?: (coords: [number, number] | [number, number, number]) => LatLng; // check if LatLng has an altitude property
}
export class GeoJSON {
/**
* 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 extends FeatureGroup {
/**
* 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<GeoJSON.GeometryObject>, options?: GeoJSONOptions): Layer;
static geometryToLayer(featureData: GeoJSONFeature<GeoJSONGeometryObject>, options?: GeoJSONOptions): Layer;
/**
* Creates a LatLng object from an array of 2 numbers (longitude, latitude) or
@@ -849,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.
@@ -860,21 +890,13 @@ declare namespace L {
/**
* Normalize GeoJSON geometries/features into GeoJSON features.
*/
static asFeature(geojson: GeoJSON.GeometryObject): GeoJSON.Feature<GeoJSON.GeometryObject>;
static asFeature(geojson: GeoJSONFeature<GeoJSONGeometryObject> | GeoJSONGeometryObject): GeoJSONFeature<GeoJSONGeometryObject>;
static asFeature(geojson: GeoJSON.Feature<GeoJSON.GeometryObject>): GeoJSON.Feature<GeoJSON.GeometryObject>;
}
/**
* 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 interface GeoJSON extends FeatureGroup {
constructor(geojson?: GeoJSONGeoJsonObject, options?: GeoJSONOptions)
/**
* Adds a GeoJSON object to the layer.
*/
addData(data: GeoJSON.GeoJsonObject): Layer;
addData(data: GeoJSONGeoJsonObject): Layer;
/**
* Resets the given vector layer's style to the original GeoJSON style,
@@ -887,6 +909,8 @@ declare namespace L {
*/
setStyle(style: StyleFunction): this;
options: GeoJSONOptions;
}
/**
@@ -896,7 +920,7 @@ declare namespace L {
* map (you can alternatively add it later with addData method) and
* an options object.
*/
export function geoJSON(geojson?: GeoJSON.GeoJsonObject, options?: GeoJSONOptions): GeoJSON;
export function geoJSON(geojson?: GeoJSONGeoJsonObject, options?: GeoJSONOptions): GeoJSON;
type Zoom = boolean | 'center';
@@ -922,7 +946,7 @@ declare namespace L {
zoom?: number;
minZoom?: number;
maxZoom?: number;
layers?: Array<Layer>;
layers?: Layer[];
maxBounds?: LatLngBoundsExpression;
renderer?: Renderer;
@@ -964,7 +988,7 @@ declare namespace L {
}
export class Control extends Class {
constructor (options?: ControlOptions);
constructor(options?: ControlOptions);
getPosition(): ControlPosition;
setPosition(position: ControlPosition): this;
getContainer(): HTMLElement;
@@ -974,6 +998,8 @@ declare namespace L {
// Extension methods
onAdd(map: Map): HTMLElement;
onRemove(map: Map): void;
options: ControlOptions;
}
export namespace Control {
@@ -984,16 +1010,21 @@ declare namespace L {
zoomOutTitle?: string;
}
export interface Zoom extends Control {}
export class Zoom extends Control {
constructor(options?: ZoomOptions);
options: ZoomOptions;
}
export interface AttributionOptions extends ControlOptions {
prefix?: string | boolean;
}
export interface Attribution 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 interface LayersOptions extends ControlOptions {
@@ -1002,12 +1033,18 @@ declare namespace L {
hideSingleBase?: boolean;
}
export interface Layers extends Control {
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 {
@@ -1017,17 +1054,18 @@ declare namespace L {
updateWhenIdle?: boolean;
}
export interface Scale extends Control {}
export class Scale extends Control {
constructor(options?: Control.ScaleOptions);
options: ScaleOptions;
}
}
export namespace control {
export function zoom(options: Control.ZoomOptions): Control.Zoom;
export function zoom(options?: Control.ZoomOptions): Control.Zoom;
export function attribution(options: Control.AttributionOptions): Control.Attribution;
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 layers(baseLayers?: Control.LayersObject, overlays?: Control.LayersObject, options?: Control.LayersOptions): Control.Layers;
export function scale(options?: Control.ScaleOptions): Control.Scale;
}
@@ -1055,19 +1093,20 @@ declare namespace L {
type Content = string | HTMLElement;
export interface Popup extends Layer {
export class Popup extends Layer {
constructor(options?: PopupOptions, source?: 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;
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;
@@ -1084,7 +1123,21 @@ declare namespace L {
opacity?: number;
}
export interface Tooltip extends Layer {}
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;
@@ -1099,7 +1152,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;
@@ -1117,7 +1172,8 @@ declare namespace L {
enableHighAccuracy?: boolean;
}
export interface Handler {
export class Handler extends Class {
constructor(map: Map);
enable(): this;
disable(): this;
enabled(): boolean;
@@ -1207,13 +1263,13 @@ declare namespace L {
}
export namespace DomEvent {
export function on(el: HTMLElement, types: string, fn: (ev: Event) => any, context?: any): typeof DomEvent;
export function on(el: HTMLElement, types: string, fn: EventHandlerFn, context?: any): typeof DomEvent;
export function on(el: HTMLElement, eventMap: {[eventName: string]: Function}, 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: (ev: Event) => any, 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]: Function}, context?: any): typeof DomEvent;
export function off(el: HTMLElement, eventMap: {[eventName: string]: EventHandlerFn}, context?: any): typeof DomEvent;
export function stopPropagation(ev: Event): typeof DomEvent;
@@ -1229,13 +1285,13 @@ declare namespace L {
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, types: string, fn: EventHandlerFn, context?: any): typeof DomEvent;
export function addListener(el: HTMLElement, eventMap: {[eventName: string]: Function}, 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: (ev: Event) => any, 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]: Function}, context?: any): typeof DomEvent;
export function removeListener(el: HTMLElement, eventMap: {[eventName: string]: EventHandlerFn}, context?: any): typeof DomEvent;
}
interface DefaultMapPanes {
@@ -1248,7 +1304,8 @@ declare namespace L {
popupPane: HTMLElement;
}
export interface Map extends Evented {
export class Map extends Evented {
constructor(element: string | HTMLElement, options?: MapOptions);
getRenderer(layer: Path): Renderer;
// Methods for layers and controls
@@ -1259,12 +1316,10 @@ declare namespace L {
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;
openPopup(content: Content, 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;
openTooltip(content: Content, latlng: LatLngExpression, options?: TooltipOptions): this;
closeTooltip(tooltip?: Tooltip): this;
// Methods for modifying map state
@@ -1272,8 +1327,7 @@ declare namespace L {
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;
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;
@@ -1282,8 +1336,10 @@ declare namespace L {
setMinZoom(zoom: number): this;
setMaxZoom(zoom: number): this;
panInsideBounds(bounds: LatLngBoundsExpression, options?: PanOptions): this;
invalidateSize(options: ZoomPanOptions): this;
invalidateSize(animate: boolean): 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;
@@ -1292,8 +1348,10 @@ declare namespace L {
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;
/**
* 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;
@@ -1321,7 +1379,6 @@ declare namespace L {
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;
@@ -1339,11 +1396,14 @@ declare namespace L {
scrollWheelZoom: Handler;
tap: Handler;
touchZoom: Handler;
options: MapOptions;
}
export function map(id: string, options?: MapOptions): Map;
export function map(el: HTMLElement, options?: MapOptions): Map;
/**
* 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;
@@ -1358,22 +1418,18 @@ declare namespace L {
className?: string;
}
export interface Icon extends Layer {
createIcon(oldIcon?: HTMLElement): HTMLElement;
createShadow(oldIcon?: HTMLElement): HTMLElement;
}
export interface IconDefault extends Icon {
imagePath: string;
}
export class Icon {
class InternalIcon extends Layer {
constructor(options: IconOptions);
createIcon(oldIcon?: HTMLElement): HTMLElement;
}
export class Icon extends InternalIcon {
createShadow(oldIcon?: HTMLElement): HTMLElement;
options: IconOptions;
}
export namespace Icon {
export class Default extends Icon {
constructor(options?: IconOptions);
export class Default extends InternalIcon {
imagePath: string;
}
}
@@ -1389,8 +1445,9 @@ declare namespace L {
className?: string;
}
export class DivIcon extends Icon {
export class DivIcon extends InternalIcon {
constructor(options?: DivIconOptions);
options: DivIconOptions;
}
export function divIcon(options?: DivIconOptions): DivIcon;
@@ -1406,6 +1463,8 @@ declare namespace L {
opacity?: number;
riseOnHover?: boolean;
riseOffset?: number;
options: DivIconOptions;
}
export class Marker extends Layer {
@@ -1415,9 +1474,10 @@ declare namespace L {
setZIndexOffset(offset: number): this;
setIcon(icon: Icon): this;
setOpacity(opacity: number): this;
getElement(): Element;
getElement(): HTMLElement;
// Properties
options: MarkerOptions;
dragging: Handler;
}
@@ -1452,6 +1512,7 @@ declare namespace L {
export const vml: boolean;
export const svg: boolean;
}
}
declare module 'leaflet' {
+29
View File
@@ -11,6 +11,13 @@ 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 +25,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 +37,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 +60,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<L.Point>;
points = L.LineUtil.simplify([point, point], 1);
points = L.LineUtil.simplify([pointTuple, pointTuple], 2);
@@ -143,6 +164,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 +255,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
+6
View File
@@ -0,0 +1,6 @@
{
"extends": "../tslint.json",
"rules": {
"no-single-declare-module": false
}
}
+285 -1
View File
@@ -2,4 +2,288 @@
// Project: http://lodash.com/
// Definitions by: Stephen Lautier <https://github.com/stephenlautier>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.1
// TypeScript Version: 2.1
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';
+3 -4
View File
@@ -3,17 +3,16 @@
// Definitions by: Benjamin Lim <https://github.com/bumbleblym>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
import { Plugin, Webpack } from 'webpack';
import { Plugin } from 'webpack';
export = LodashModuleReplacementPlugin;
declare class LodashModuleReplacementPlugin implements Plugin {
declare class LodashModuleReplacementPlugin extends Plugin {
constructor(options?: LodashModuleReplacementPlugin.Options);
apply(thisArg: Webpack, ...args: any[]): void;
}
declare namespace LodashModuleReplacementPlugin {
export interface Options {
interface Options {
caching?: boolean;
chaining?: boolean;
cloning?: boolean;
@@ -1,27 +1,31 @@
import * as LodashModuleReplacementPlugin from 'lodash-webpack-plugin'
import * as LodashModuleReplacementPlugin from 'lodash-webpack-plugin';
new LodashModuleReplacementPlugin()
new LodashModuleReplacementPlugin();
new LodashModuleReplacementPlugin({
collections: true,
paths: true,
})
const optionsArray: LodashModuleReplacementPlugin.Options[] = [
{
collections: true,
paths: true,
},
{
caching: true,
chaining: true,
cloning: true,
coercions: true,
collections: true,
currying: true,
deburring: true,
exotics: true,
flattening: true,
guards: true,
memoizing: true,
metadata: true,
paths: true,
placeholders: true,
shorthands: true,
unicode: true,
},
];
new LodashModuleReplacementPlugin({
caching: true,
chaining: true,
cloning: true,
coercions: true,
collections: true,
currying: true,
deburring: true,
exotics: true,
flattening: true,
guards: true,
memoizing: true,
metadata: true,
paths: true,
placeholders: true,
shorthands: true,
unicode: true,
})
const plugins: LodashModuleReplacementPlugin[] = optionsArray
.map(options => new LodashModuleReplacementPlugin(options));
+4
View File
@@ -986,3 +986,7 @@ declare namespace mapboxgl {
declare module 'mapbox-gl' {
export = mapboxgl;
}
declare module 'mapbox-gl/dist/mapbox-gl' {
export = mapboxgl;
}
+4 -1
View File
@@ -1,7 +1,8 @@
// Type definitions for Mongoose 4.7.0
// Project: http://mongoosejs.com/
// Definitions by: simonxca <https://github.com/simonxca/>, horiuchi <https://github.com/horiuchi/>
// Definitions by: simonxca <https://github.com/simonxca/>, horiuchi <https://github.com/horiuchi/>, sindrenm <https://github.com/sindrenm>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.1
/// <reference types="mongodb" />
/// <reference types="node" />
@@ -994,10 +995,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. */
+141 -59
View File
@@ -1,71 +1,153 @@
// Type definitions for msgpack-lite 0.1.20
// Type definitions for msgpack-lite 0.1
// Project: https://github.com/kawanet/msgpack-lite
// Definitions by: Endel Dreyer <https://github.com/endel/>
// Definitions by: Endel Dreyer <https://github.com/endel/>, Edmund Fokschaner <https://github.com/efokschaner>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference types="node" />
declare module "msgpack-lite" {
import { Transform } from "stream";
import * as stream from 'stream';
namespace MsgpackLite {
interface BufferOptions { codec: any; }
/**
* encode from JS Object to MessagePack
*/
export function encode(input: any, options?: EncoderOptions): Buffer;
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;
}
/**
* decode from MessagePack to JS Object
*/
export function decode(input: Buffer | Uint8Array | number[], options?: DecoderOptions): any;
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;
}
/**
* create a stream that encodes from JS Object to MessagePack
*/
export function createEncodeStream(options?: EncoderOptions & stream.TransformOptions ): EncodeStream;
interface EncodeStream extends Transform {
encoder: Encoder;
}
interface DecodeStream extends Transform {
decoder: Decoder;
}
/**
* create a stream that decodes from MessagePack (Buffer) to JS Object
*/
export function createDecodeStream(options?: DecoderOptions & stream.TransformOptions): DecodeStream;
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;
}
/**
* 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;
export function encode(input: any, options?: BufferOptions): any;
export function decode(input: Buffer | Uint8Array | Array<number>, options?: BufferOptions): any;
export function createEncodeStream (): EncodeStream;
export function createDecodeStream (): DecodeStream;
export function createCodec (options?: any): Codec;
export function codec (): { preset: Codec };
}
/**
* The default built-in codec
*/
export var codec: {
/**
* The default built-in codec
*/
preset: Codec;
};
export = MsgpackLite;
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<T>(
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<T>(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;
}
+72 -3
View File
@@ -1,5 +1,74 @@
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 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
}
}
+1 -1
View File
@@ -6,7 +6,7 @@
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": false,
"strictNullChecks": true,
"baseUrl": "../",
"typeRoots": [
"../"
+1
View File
@@ -0,0 +1 @@
{ "extends": "../tslint.json" }
+15 -19
View File
@@ -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 <https://github.com/kubiq>
// 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<T>(key: string): T;
}
export interface IStorageService {
$default(items: {}): IStorageService;
$reset(items?: {}): IStorageService;
$apply(): void;
$sync(): void;
get<T>(key: string): T;
}
interface IStorageProvider extends angular.IServiceProvider {
export interface IStorageProvider extends angular.IServiceProvider {
get<T>(key: string): T;
set<T>(key: string, value: T): T;
get<T>(key: string): T;
set<T>(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;
}
}
+34 -34
View File
@@ -1,9 +1,9 @@
/// <reference types="angular" />
/// <reference types="angular"/>
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);
}
]);
+1 -1
View File
@@ -20,4 +20,4 @@
"index.d.ts",
"ngstorage-tests.ts"
]
}
}
+2
View File
@@ -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
+6
View File
@@ -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"
}
]
}
+18 -30
View File
@@ -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 <http://pspeter3.com>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference types="node" />
/// <reference types="pg-types" />
import events = require("events");
import stream = require("stream");
@@ -63,45 +61,38 @@ 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<Client>;
connect(callback: (err: Error, client: Client, done: () => void) => void): void;
end(): Promise<void>;
query(queryText: string): Promise<QueryResult>;
query(queryText: string, values: any[]): Promise<QueryResult>;
query(queryText: string, values?: any[]): Promise<QueryResult>;
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<QueryResult>;
query(queryTextOrConfig: string | QueryConfig): Promise<QueryResult>;
query(queryText: string, values: any[]): Promise<QueryResult>;
query(queryText: string, callback?: (err: Error, result: QueryResult) => void): Query;
query(config: QueryConfig, callback?: (err: Error, result: QueryResult) => void): Query;
query(queryText: string, values: any[], 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;
copyTo(queryText: string): stream.Readable;
@@ -109,25 +100,22 @@ 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;
on(event: "end", listener: () => 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;
export const defaults: Defaults & ClientConfig;
+8 -6
View File
@@ -4,9 +4,10 @@ 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;
pg.connect(conString, (err, client, done) => {
if (err) {
return console.error("Error fetching client from pool", err);
@@ -27,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);
}
@@ -42,6 +43,7 @@ client.connect((err) => {
});
return null;
});
client.on('end', () => console.log("Client was disconnected."));
// client pooling
@@ -55,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) {
@@ -69,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)
})
})
+3 -2
View File
@@ -5,12 +5,13 @@
// TypeScript Version: 2.1
/// <reference types="react" />
/// <reference types="bootstrap-datepicker" />
/// <reference types="daterangepicker" />
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;
+1 -1
View File
@@ -75,7 +75,7 @@ declare namespace ReactDayPicker {
toMonth?: Date;
localeUtils?: LocaleUtils;
locale?: string;
captionElement?: React.ReactElement<CaptionElementProps> | null;
captionElement?: React.ReactElement<CaptionElementProps>;
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;
+2 -2
View File
@@ -28,7 +28,7 @@ declare namespace ReactDOM {
container: Element | null,
callback?: (component: T) => any): T;
function render<P>(
element: ReactElement<P> | null,
element: ReactElement<P>,
container: Element | null,
callback?: (component?: Component<P, ComponentState> | Element) => any): Component<P, ComponentState> | Element | void;
@@ -57,7 +57,7 @@ declare namespace ReactDOM {
callback?: () => any): void;
function unstable_renderSubtreeIntoContainer<P>(
parentComponent: Component<any, any>,
element: ReactElement<P> | null,
element: ReactElement<P>,
container: Element,
callback?: (component?: Component<P, ComponentState> | Element) => any): Component<P, ComponentState> | Element | void;
}
+50 -20
View File
@@ -1,32 +1,62 @@
// Type definitions for react-modal v1.6.1
// Type definitions for react-modal 1.6
// Project: https://github.com/reactjs/react-modal
// Definitions by: Rajab Shakirov <https://github.com/radziksh>
// Definitions by: Rajab Shakirov <https://github.com/radziksh>, Drew Noakes <https://github.com/drewnoakes>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.1
/// <reference types="react"/>
import * as React from "react";
declare module "react-modal" {
interface ReactModal {
isOpen: boolean;
export as namespace ReactModal;
export = ReactModal;
declare namespace ReactModal {
export interface Styles {
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
};
};
}
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;
}
let ReactModal: React.ClassicComponentClass<ReactModal>;
export = ReactModal;
}
declare class ReactModal extends React.Component<ReactModal.Props, {}> {
/* 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;
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "../tslint.json" }
+34
View File
@@ -0,0 +1,34 @@
// Type definitions for react-native-datepicker 1.4
// Project: https://github.com/xgfe/react-native-datepicker
// Definitions by: Jacob Baskin <https://github.com/jacobbaskin>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.1
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<DatePickerProps, {}> {
constructor(props: DatePickerProps);
}
export default DatePicker;
@@ -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 (
<DatePicker
style={{width: 200}}
date={this.state.date}
mode="date"
placeholder="select date"
format="YYYY-MM-DD"
minDate="2016-05-01"
maxDate="2016-06-01"
confirmBtnText="Confirm"
cancelBtnText="Cancel"
customStyles={{
dateIcon: {
position: 'absolute',
left: 0,
top: 4,
marginLeft: 0
},
dateInput: {
marginLeft: 36
}
}}
onDateChange={(date: string) => {this.setState({date});}}
/>
);
}
}
+24
View File
@@ -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"
]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "../tslint.json" }
@@ -18,7 +18,7 @@ class SwiperTest extends React.Component<IProperties, IState> {
super(props);
}
public render(): React.ReactElement<any> | null {
public render(): React.ReactElement<any> {
return (
<Swiper
style={styles.wrapper}>
+5 -5
View File
@@ -86,11 +86,11 @@ export interface InjectedRouter {
}
export interface RouteComponentProps<P, R> {
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<any> {
+9 -1
View File
@@ -1,6 +1,6 @@
// Type definitions for react-select v1.0.0
// Project: https://github.com/JedWatson/react-select
// Definitions by: ESQUIBET Hugo <https://github.com/Hesquibet/>, Gilad Gray <https://github.com/giladgray/>, Izaak Baker <https://github.com/iebaker/>, Tadas Dailyda <https://github.com/skirsdeda/>, Mark Vujevits <https://github.com/vujevits/>
// Definitions by: ESQUIBET Hugo <https://github.com/Hesquibet/>, Gilad Gray <https://github.com/giladgray/>, Izaak Baker <https://github.com/iebaker/>, Tadas Dailyda <https://github.com/skirsdeda/>, Mark Vujevits <https://github.com/vujevits/>, Mike Deverell <https://github.com/devrelm/>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.1
@@ -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
*/
@@ -268,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
*/
+1
View File
@@ -99,6 +99,7 @@ class SelectTest extends React.Component<React.Props<{}>, {}> {
className: "test-select",
key: "1",
options: options,
optionClassName: 'test-select-option',
optionRenderer: optionRenderer,
autofocus: true,
autosize: true,
+4
View File
@@ -7,6 +7,10 @@
/// <reference types="react"/>
interface __config {
accessibility?: boolean
nextArrow?: HTMLElement | any
prevArrow?: HTMLElement | any
pauseOnHover?: boolean
className?: string
adaptiveHeight?: boolean
arrows?: boolean
+2 -1
View File
@@ -10,7 +10,8 @@ class SliderTest extends React.Component<React.Props<{}>, {}> {
slidesToShow: 8,
slidesToScroll: 1,
draggable: false,
infinite: false
infinite: false,
prevArrow: <a href="#">link</a>
};
return (
+4 -6
View File
@@ -171,7 +171,7 @@ declare namespace React {
setState<K extends keyof S>(f: (prevState: S, props: P) => Pick<S, K>, callback?: () => any): void;
setState<K extends keyof S>(state: Pick<S, K>, callback?: () => any): void;
forceUpdate(callBack?: () => any): void;
render(): JSX.Element;
render(): JSX.Element | null;
// React.Props<T> is now deprecated, which means that the `children`
// property is not available on `P` by default, even though you can
@@ -204,7 +204,7 @@ declare namespace React {
type SFC<P> = StatelessComponent<P>;
interface StatelessComponent<P> {
(props: P & { children?: ReactNode }, context?: any): ReactElement<any> | null;
(props: P & { children?: ReactNode }, context?: any): ReactElement<any>;
propTypes?: ValidationMap<P>;
contextTypes?: ValidationMap<any>;
defaultProps?: P;
@@ -2628,11 +2628,9 @@ declare namespace React {
declare global {
namespace JSX {
interface JSXElement extends React.ReactElement<any> { }
type Element = JSXElement | null;
interface Element extends React.ReactElement<any> { }
interface ElementClass extends React.Component<any, any> {
render(): JSX.Element;
render(): JSX.Element | null;
}
interface ElementAttributesProperty { props: {}; }
-3
View File
@@ -32,6 +32,3 @@ StatelessComponent2.defaultProps = {
</text>
</g>
</svg>;
const CustomComponent = (props: { flag: boolean }) => props.flag ? React.createElement('div') : null;
const UseComponent2 = (f: boolean) => <CustomComponent flag={f} />;
+2 -2
View File
@@ -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 <https://github.com/iskandersierra>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
@@ -103,7 +103,7 @@ declare module 'recompose' {
export function branch<TOutter>(
test: predicate<TOutter>,
trueEnhancer: InferableComponentEnhancer,
falseEnhancer: InferableComponentEnhancer
falseEnhancer?: InferableComponentEnhancer
): ComponentEnhancer<any, TOutter>;
// renderComponent: https://github.com/acdlite/recompose/blob/master/docs/API.md#renderComponent
+6
View File
@@ -148,13 +148,19 @@ function testBranch() {
const innerComponent: React.StatelessComponent<InnerProps> = (props: InnerProps) =>
<div onClick={() => props.update()}>{props.count}</div>;
const innerComponent2 = () => <div>Hello</div>;
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<OutterProps> = enhancer(innerComponent);
const enhanced2: React.ComponentClass<OutterProps> = enhancer2(innerComponent);
}
function testRenderComponent() {
+12 -12
View File
@@ -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 <https://github.com/codefoster>
// 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;
}
+14 -4
View File
@@ -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 <https://github.com/ludohenin/>, Nathan Walker <https://github.com/NathanWalker/>, Giedrius Grabauskas <https://github.com/GiedriusGrabauskas>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
@@ -29,7 +29,7 @@ declare namespace SystemJSLoader {
*/
type Transpiler = "plugin-traceur" | "plugin-babel" | "plugin-typescript" | "traceur" | "babel" | "typescript" | boolean;
type ConfigMap = PackageList<string>;
type ConfigMap = PackageList<string | PackageList<string>>;
type ConfigMeta = PackageList<MetaConfig>;
@@ -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<TModule>(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<any>;
import<TModule>(moduleName: string, normalizedParentName?: string): Promise<TModule>;
/**
* 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<any>;
}
}
declare var SystemJS: SystemJSLoader.System;
+20 -11
View File
@@ -1,14 +1,12 @@
import SystemJS = require('systemjs');
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();
+4
View File
@@ -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;
+43 -31
View File
@@ -3,9 +3,8 @@
// Definitions by: Konstantin Burkalev <https://github.com/KSDaemon>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
interface WampyOptions {
interface WampyOptions
{
autoReconnect?: boolean;
reconnectInterval?: number;
maxRetries?: number;
@@ -23,82 +22,95 @@ 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;
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;
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;
payload?: any,
callbacks?: SuccessErrorCallbacksHash,
advancedOptions?: PublishAdvancedOptions): Wampy;
call(topicURI: string,
payload?: any,
callbacks?: (((data: any) => void) | CallSuccessErrorCallbacksHash),
advancedOptions?: CallAdvancedOptions): Wampy;
payload?: any,
callbacks?: (((args: any[], kwargs: any) => void) | CallSuccessErrorCallbacksHash),
advancedOptions?: CallAdvancedOptions): Wampy;
cancel(reqId: number,
callbacks?: ((() => void) | SuccessErrorCallbacksHash),
advancedOptions?: CancelAdvancedOptions): Wampy;
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;
declare var wampy: Wampy;
declare module 'wampy'
{
export = wampy;
}
declare var wampy: WampyInstance;
export default wampy;
+34 -50
View File
@@ -1,47 +1,50 @@
/// <reference types="node" />
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)
});
+13 -11
View File
@@ -3,21 +3,23 @@
// Definitions by: Benjamin Lim <https://github.com/bumbleblym>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
import { Plugin, Webpack } from 'webpack';
import { Plugin } from 'webpack';
export = WebpackNotifierPlugin;
declare class WebpackNotifierPlugin implements Plugin {
constructor(options?: WebpackNotifierPlugin.Config);
apply(thisArg: Webpack, ...args: any[]): void;
declare class WebpackNotifierPlugin extends Plugin {
constructor(options?: WebpackNotifierPlugin.Options);
}
declare namespace WebpackNotifierPlugin {
export interface Config {
title?: string;
contentImage?: string;
excludeWarnings?: boolean;
alwaysNotify?: boolean;
skipFirstNotification?: boolean;
}
interface Options {
alwaysNotify?: boolean;
contentImage?: string;
excludeWarnings?: boolean;
skipFirstNotification?: boolean;
title?: string;
}
/** @deprecated use Options */
type Config = Options;
}
+10 -10
View File
@@ -1,14 +1,14 @@
import WebpackNotifierPlugin = require('webpack-notifier');
import { Plugin } from 'webpack';
import * as WebpackNotifierPlugin from 'webpack-notifier';
const configs: Array<WebpackNotifierPlugin.Config> = [
{
title: 'Webpack',
contentImage: 'logo.png',
excludeWarnings: true,
alwaysNotify: true,
skipFirstNotification: true,
},
const optionsArray: WebpackNotifierPlugin.Options[] = [
{
title: 'Webpack',
contentImage: 'logo.png',
excludeWarnings: true,
alwaysNotify: true,
skipFirstNotification: true,
},
];
const plugins: Array<Plugin> = configs.map(config => new WebpackNotifierPlugin(config));
const plugins: Plugin[] = optionsArray.map(options => new WebpackNotifierPlugin(options));
+17 -39
View File
@@ -1,48 +1,26 @@
// Type definitions for webpack-stream v3.2.0
// Type definitions for webpack-stream 3.2
// Project: https://github.com/shama/webpack-stream
// Definitions by: Ian Clanton-Thuon <https://github.com/iclanton>
// Definitions by: Ian Clanton-Thuon <https://github.com/iclanton>, Benjamin Lim <https://github.com/bumbleblym>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
///<reference types="webpack" />
///<reference types="node" />
declare module "webpack-stream" {
import webpack = require("webpack");
import * as webpack from 'webpack';
interface WebpackStreamStatic {
/**
* Run webpack with the default configuration.
*/
(): NodeJS.ReadWriteStream;
export = webpackStream;
/**
* Run webpack with the specified configuration.
*
* @param {config} Webpack configuration
*/
(config: webpack.Configuration): NodeJS.ReadWriteStream;
/**
* Run webpack with the specified configuration and webpack instance
*
* @param {webpack.Configuration} config - Webpack configuration
* @param {webpack} wp - A webpack object
* @param {webpack.Compiler.Handler} callback - A callback with the webpack stats and error objects.
*/
declare function webpackStream(
config?: webpack.Configuration,
wp?: typeof webpack,
callback?: webpack.Compiler.Handler,
): NodeJS.ReadWriteStream;
/**
* Run webpack with the specified configuration and webpack instance
*
* @param {config} Webpack configuration
* @param {webpack} A webpack object
*/
(config: webpack.Configuration, webpack: webpack.Webpack): NodeJS.ReadWriteStream;
/**
* Run webpack with the specified configuration and webpack instance
*
* @param {config} Webpack configuration
* @param {webpack} A webpack object
* @param {callback} A callback with the webpack stats and error objects.
*/
(config: webpack.Configuration,
webpack: webpack.Webpack,
callback?: (err: Error, stats: webpack.compiler.Stats) => void): NodeJS.ReadWriteStream;
}
var webpackStream: WebpackStreamStatic;
export = webpackStream;
declare namespace webpackStream {
}
+2 -2
View File
@@ -6,7 +6,7 @@
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": false,
"strictNullChecks": true,
"baseUrl": "../",
"typeRoots": [
"../"
@@ -19,4 +19,4 @@
"index.d.ts",
"webpack-stream-tests.ts"
]
}
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "../tslint.json" }
+2 -2
View File
@@ -1,5 +1,5 @@
import webpackStream = require("webpack-stream");
import webpack = require("webpack");
import * as webpack from 'webpack';
import * as webpackStream from 'webpack-stream';
let output: NodeJS.ReadWriteStream;
+357 -408
View File
@@ -5,8 +5,22 @@
/// <reference types="node" />
import * as Tapable from 'tapable';
import * as UglifyJS from 'uglify-js';
import * as tapable from 'tapable';
export = webpack;
declare function webpack(
options: webpack.Configuration,
handler: webpack.Compiler.Handler
): webpack.Compiler.Watching | webpack.Compiler;
declare function webpack(options?: webpack.Configuration): webpack.Compiler;
declare function webpack(
options: webpack.Configuration[],
handler: webpack.MultiCompiler.Handler
): webpack.MultiWatching | webpack.MultiCompiler;
declare function webpack(options: webpack.Configuration[]): webpack.MultiCompiler;
declare namespace webpack {
interface Configuration {
@@ -46,7 +60,7 @@ declare namespace webpack {
cache?: boolean | any;
/** Enter watch mode, which rebuilds on file change. */
watch?: boolean;
watchOptions?: WatchOptions;
watchOptions?: Options.WatchOptions;
/** Switch loaders to debug mode. */
debug?: boolean;
/** Can be used to configure the behaviour of webpack-dev-server when the webpack config is passed to webpack-dev-server CLI. */
@@ -64,9 +78,9 @@ declare namespace webpack {
/** Add additional plugins to the compiler. */
plugins?: Plugin[];
/** Stats options for logging */
stats?: compiler.StatsToStringOptions;
stats?: Options.Stats;
/** Performance options */
performance?: PerformanceOptions;
performance?: Options.Performance;
}
interface Entry {
@@ -324,15 +338,6 @@ declare namespace webpack {
type ExternalsFunctionElement = (context: any, request: any, callback: (error: any, result: any) => void) => any;
interface WatchOptions {
/** Delay the rebuilt after the first change. Value is a time in ms. */
aggregateTimeout?: number;
/** For some systems, watching many file systems can result in a lot of CPU or memory usage. It is possible to exclude a huge folder like node_modules. It is also possible to use anymatch patterns. */
ignored?: RegExp | string;
/** true: use polling, number: use polling with specified interval */
poll?: boolean | number;
}
interface Node {
console?: boolean;
global?: boolean;
@@ -468,283 +473,335 @@ declare namespace webpack {
}
type Rule = LoaderRule | UseRule | RulesRule | OneOfRule;
interface Plugin extends tapable.Plugin {
apply(thisArg: Webpack, ...args: any[]): void;
namespace Options {
interface Performance {
/** This property allows webpack to control what files are used to calculate performance hints. */
assetFilter?(assetFilename: string): boolean;
/**
* Turns hints on/off. In addition, tells webpack to throw either an error or a warning when hints are
* found. This property is set to "warning" by default.
*/
hints?: 'warning' | 'error' | boolean;
/**
* An asset is any emitted file from webpack. This option controls when webpack emits a performance hint
* based on individual asset size. The default value is 250000 (bytes).
*/
maxAssetSize?: number;
/**
* An entrypoint represents all assets that would be utilized during initial load time for a specific entry.
* This option controls when webpack should emit performance hints based on the maximum entrypoint size.
* The default value is 250000 (bytes).
*/
maxEntrypointSize?: number;
}
type Stats = webpack.Stats.ToStringOptions;
type WatchOptions = ICompiler.WatchOptions;
}
type UglifyCommentFunction = (astNode: any, comment: any) => boolean
interface UglifyPluginOptions extends UglifyJS.MinifyOptions {
beautify?: boolean;
comments?: boolean | RegExp | UglifyCommentFunction;
sourceMap?: boolean;
test?: Condition | Condition[];
include?: Condition | Condition[];
exclude?: Condition | Condition[];
// tslint:disable-next-line:interface-name
interface ICompiler {
run(handler: ICompiler.Handler): void;
watch(watchOptions: ICompiler.WatchOptions, handler: ICompiler.Handler): Watching;
}
interface Webpack {
(config: Configuration, callback?: compiler.CompilerCallback): compiler.Compiler;
/**
* optimize namespace
*/
optimize: Optimize;
/**
* dependencies namespace
*/
dependencies: Dependencies;
/**
* Replace resources that matches resourceRegExp with newResource.
* If newResource is relative, it is resolve relative to the previous resource.
* If newResource is a function, it is expected to overwrite the request attribute of the supplied object.
*/
NormalModuleReplacementPlugin: NormalModuleReplacementPluginStatic;
/**
* Replaces the default resource, recursive flag or regExp generated by parsing with newContentResource,
* newContentRecursive resp. newContextRegExp if the resource (directory) matches resourceRegExp.
* If newContentResource is relative, it is resolve relative to the previous resource.
* If newContentResource is a function, it is expected to overwrite the request attribute of the supplied object.
*/
ContextReplacementPlugin: ContextReplacementPluginStatic;
/**
* Dont generate modules for requests matching the provided RegExp.
*/
IgnorePlugin: IgnorePluginStatic;
/**
* A request for a normal module, which is resolved and built even before a require to it occurs.
* 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.
*/
BannerPlugin: BannerPluginStatic;
/**
* Define free variables. Useful for having development builds with debug logging or adding global constants.
*/
DefinePlugin: DefinePluginStatic;
/**
* Automatically loaded modules.
* Module (value) is loaded when the identifier (key) is used as free variable in a module.
* The identifier is filled with the exports of the loaded module.
*/
ProvidePlugin: ProvidePluginStatic;
/**
* Adds SourceMaps for assets.
*/
SourceMapDevToolPlugin: SourceMapDevToolPluginStatic;
/**
* Adds SourceMaps for assets, but wrapped inside eval statements.
* Much faster incremental build speed, but harder to debug.
*/
EvalSourceMapDevToolPlugin: EvalSourceMapDevToolPluginStatic;
/**
* Enables Hot Module Replacement. (This requires records data if not in dev-server mode, recordsPath)
* Generates Hot Update Chunks of each chunk in the records.
* It also enables the API and makes __webpack_hash__ available in the bundle.
*/
HotModuleReplacementPlugin: HotModuleReplacementPluginStatic;
/**
* Adds useful free vars to the bundle.
*/
ExtendedAPIPlugin: ExtendedAPIPluginStatic;
/**
* When there are errors while compiling this plugin skips the emitting phase (and recording phase),
* so there are no assets emitted that include errors. The emitted flag in the stats is false for all assets.
*/
NoEmitOnErrorsPlugin: NoEmitOnErrorsPluginStatic;
/**
* Alias for NoEmitOnErrorsPlugin
* @deprecated
*/
NoErrorsPlugin: NoEmitOnErrorsPluginStatic;
/**
* Does not watch specified files matching provided paths or RegExps.
*/
WatchIgnorePlugin: WatchIgnorePluginStatic;
/**
* Uses the module name as the module id inside the bundle, instead of a number.
* Helps with debugging, but increases bundle size.
*/
NamedModulesPlugin: NamedModulesPluginStatic;
/**
* Some loaders need context information and read them from the configuration.
* This need to be passed via loader options in the long-term. See loader documentation for relevant options.
* To keep compatibility with old loaders, these options can be passed via this plugin.
*/
LoaderOptionsPlugin: LoaderOptionsPluginStatic;
namespace ICompiler {
type Handler = (err: Error, stats: Stats) => void;
interface WatchOptions {
/**
* Add a delay before rebuilding once the first file changed. This allows webpack to aggregate any other
* changes made during this time period into one rebuild.
* Pass a value in milliseconds. Default: 300.
*/
aggregateTimeout?: number;
/**
* For some systems, watching many file systems can result in a lot of CPU or memory usage.
* It is possible to exclude a huge folder like node_modules.
* It is also possible to use anymatch patterns.
*/
ignored?: string | RegExp;
/** Turn on polling by passing true, or specifying a poll interval in milliseconds. */
poll?: boolean | number;
}
}
interface Optimize {
/**
* Search for equal or similar files and deduplicate them in the output.
* This comes with some overhead for the entry chunk, but can reduce file size effectively.
* This is experimental and may crash, because of some missing implementations. (Report an issue)
*/
DedupePlugin: optimize.DedupePluginStatic;
/**
* Limit the chunk count to a defined value. Chunks are merged until it fits.
*/
LimitChunkCountPlugin: optimize.LimitChunkCountPluginStatic;
/**
* Merge small chunks that are lower than this min size (in chars). Size is approximated.
*/
MinChunkSizePlugin: optimize.MinChunkSizePluginStatic;
/**
* 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;
/**
* Minimize all JavaScript output of chunks. Loaders are switched into minimizing mode.
* You can pass an object containing UglifyJs options.
*/
UglifyJsPlugin: optimize.UglifyJsPluginStatic;
CommonsChunkPlugin: optimize.CommonsChunkPluginStatic;
/**
* A plugin for a more aggressive chunk merging strategy.
* Even similar chunks are merged if the total size is reduced enough.
* As an option modules that are not common in these chunks can be moved up the chunk tree to the parents.
*/
AggressiveMergingPlugin: optimize.AggressiveMergingPluginStatic;
interface Watching {
close(callback: () => void): void;
invalidate(): void;
}
interface Dependencies {
/**
* Support Labeled Modules.
*/
LabeledModulesPlugin: dependencies.LabeledModulesPluginStatic;
class Compiler extends Tapable implements ICompiler {
constructor();
name: string;
options: Configuration;
outputFileSystem: any;
run(handler: Compiler.Handler): void;
watch(watchOptions: Compiler.WatchOptions, handler: Compiler.Handler): Compiler.Watching;
}
interface DirectoryDescriptionFilePluginStatic {
new (file: string, files: string[]): Plugin;
namespace Compiler {
type Handler = ICompiler.Handler;
type WatchOptions = ICompiler.WatchOptions;
class Watching implements webpack.Watching {
constructor(compiler: Compiler, watchOptions: Watching.WatchOptions, handler: Watching.Handler);
close(callback: () => void): void;
invalidate(): void;
}
namespace Watching {
type WatchOptions = ICompiler.WatchOptions;
type Handler = ICompiler.Handler;
}
}
interface NormalModuleReplacementPluginStatic {
new (resourceRegExp: any, newResource: any): Plugin;
abstract class MultiCompiler implements ICompiler {
run(handler: MultiCompiler.Handler): void;
watch(watchOptions: MultiCompiler.WatchOptions, handler: MultiCompiler.Handler): MultiWatching;
}
interface ContextReplacementPluginStatic {
new (resourceRegExp: any, newContentResource?: any, newContentRecursive?: any, newContentRegExp?: any): Plugin;
namespace MultiCompiler {
type Handler = ICompiler.Handler;
type WatchOptions = ICompiler.WatchOptions;
}
interface IgnorePluginStatic {
new (requestRegExp: any, contextRegExp?: any): Plugin;
abstract class MultiWatching implements Watching {
close(callback: () => void): void;
invalidate(): void;
}
interface PrefetchPluginStatic {
abstract class Plugin implements Tapable.Plugin {
apply(compiler: Compiler): void;
}
abstract class Stats {
/** Returns true if there were errors while compiling. */
hasErrors(): boolean;
/** Returns true if there were warnings while compiling. */
hasWarnings(): boolean;
/** Returns compilation information as a JSON object. */
toJson(options?: Stats.ToJsonOptions): any;
/** Returns a formatted string of the compilation information (similar to CLI output). */
toString(options?: Stats.ToStringOptions): string;
}
namespace Stats {
type Preset
= boolean
| 'errors-only'
| 'minimal'
| 'none'
| 'normal'
| 'verbose';
interface ToJsonOptionsObject {
/** Add asset Information */
assets?: boolean;
/** Sort assets by a field */
assetsSort?: string;
/** Add information about cached (not built) modules */
cached?: boolean;
/** Add children information */
children?: boolean;
/** Add built modules information to chunk information */
chunkModules?: boolean;
/** Add the origins of chunks and chunk merging info */
chunkOrigins?: boolean;
/** Add chunk information (setting this to `false` allows for a less verbose output) */
chunks?: boolean;
/** Sort the chunks by a field */
chunksSort?: string;
/** Context directory for request shortening */
context?: string;
/** Add details to errors (like resolving log) */
errorDetails?: boolean;
/** Add errors */
errors?: boolean;
/** Add the hash of the compilation */
hash?: boolean;
/** Add built modules information */
modules?: boolean;
/** Sort the modules by a field */
modulesSort?: string;
/** Add public path information */
publicPath?: boolean;
/** Add information about the reasons why modules are included */
reasons?: boolean;
/** Add the source code of modules */
source?: boolean;
/** Add timing information */
timings?: boolean;
/** Add webpack version information */
version?: boolean;
/** Add warnings */
warnings?: boolean;
}
type ToJsonOptions = Preset | ToJsonOptionsObject;
interface ToStringOptionsObject extends ToJsonOptionsObject {
/** `webpack --colors` equivalent */
colors?: boolean;
}
type ToStringOptions = Preset | ToStringOptionsObject;
}
/**
* Plugins
*/
class BannerPlugin extends Plugin {
constructor(banner: any, options: any);
}
class ContextReplacementPlugin extends Plugin {
constructor(resourceRegExp: any, newContentResource?: any, newContentRecursive?: any, newContentRegExp?: any);
}
class DefinePlugin extends Plugin {
constructor(definitions: {[key: string]: any});
}
class EvalSourceMapDevToolPlugin extends Plugin {
constructor(options?: false | string | EvalSourceMapDevToolPlugin.Options);
}
namespace EvalSourceMapDevToolPlugin {
interface Options {
append?: false | string;
columns?: boolean;
lineToLine?: boolean | {
exclude?: Condition | Condition[];
include?: Condition | Condition[];
test?: Condition | Condition[];
};
module?: boolean;
moduleFilenameTemplate?: string;
sourceRoot?: string;
}
}
class ExtendedAPIPlugin extends Plugin {
constructor();
}
class HotModuleReplacementPlugin extends Plugin {
constructor(options?: any);
}
class IgnorePlugin extends Plugin {
constructor(requestRegExp: any, contextRegExp?: any);
}
class LoaderOptionsPlugin extends Plugin {
constructor(options: any);
}
class NamedModulesPlugin extends Plugin {
constructor();
}
class NoEmitOnErrorsPlugin extends Plugin {
constructor();
}
/** @deprecated use webpack.NoEmitOnErrorsPlugin */
class NoErrorsPlugin extends Plugin {
constructor();
}
class NormalModuleReplacementPlugin extends Plugin {
constructor(resourceRegExp: any, newResource: any);
}
class PrefetchPlugin extends Plugin {
// tslint:disable-next-line:unified-signatures
new (context: any, request: any): Plugin;
new (request: any): Plugin;
constructor(context: any, request: any);
constructor(request: any);
}
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;
class ProvidePlugin extends Plugin {
constructor(definitions: {[key: string]: any});
}
interface FileAppendPluginStatic {
new (files: string[]): Plugin;
class SourceMapDevToolPlugin extends Plugin {
constructor(options?: null | false | string | SourceMapDevToolPlugin.Options);
}
interface BannerPluginStatic {
new (banner: any, options: any): Plugin;
}
interface DefinePluginStatic {
new (definitions: {[key: string]: any}): Plugin;
}
interface ProvidePluginStatic {
new (definitions: {[key: string]: any}): Plugin;
}
interface SourceMapDevToolPluginStatic {
// if string | false | null, maps to the filename option
new (options?: string | false | null | SourceMapDevToolPluginOptions): Plugin;
}
interface SourceMapDevToolPluginOptions {
// output filename pattern (false/null to append)
filename?: string | false | null;
// source map comment pattern (false to not append)
append?: false | string;
// template for the module filename inside the source map
moduleFilenameTemplate?: string;
// fallback used when the moduleFilenameTemplate produces a collision
fallbackModuleFilenameTemplate?: string;
// test/include/exclude files
test?: Condition | Condition[];
include?: Condition | Condition[];
exclude?: Condition | Condition[];
// whether to include the footer comment with source information
noSources?: boolean;
// the source map sourceRoot ("The URL root from which all sources are relative.")
sourceRoot?: string | null;
// whether to generate per-module source map
module?: boolean;
// whether to include column information in the source map
columns?: boolean;
// whether to preserve line numbers between source and source map
lineToLine?: boolean | {
test?: Condition | Condition[];
include?: Condition | Condition[];
namespace SourceMapDevToolPlugin {
/** @todo extend EvalSourceMapDevToolPlugin.Options */
interface Options {
append?: false | string;
columns?: boolean;
exclude?: Condition | Condition[];
};
}
interface EvalSourceMapDevToolPluginStatic {
// if string | false, maps to the append option
new (options?: string | false | EvalSourceMapDevToolPluginOptions): Plugin;
}
interface EvalSourceMapDevToolPluginOptions {
append?: false | string;
moduleFilenameTemplate?: string;
sourceRoot?: string;
module?: boolean;
columns?: boolean;
lineToLine?: boolean | {
test?: Condition | Condition[];
fallbackModuleFilenameTemplate?: string;
filename?: null | false | string;
include?: Condition | Condition[];
exclude?: Condition | Condition[];
};
lineToLine?: boolean | {
exclude?: Condition | Condition[];
include?: Condition | Condition[];
test?: Condition | Condition[];
};
module?: boolean;
moduleFilenameTemplate?: string;
noSources?: boolean;
sourceRoot?: null | string;
test?: Condition | Condition[];
}
}
interface HotModuleReplacementPluginStatic {
new (options?: any): Plugin;
class WatchIgnorePlugin extends Plugin {
constructor(paths: RegExp[]);
}
interface ExtendedAPIPluginStatic {
new (): Plugin;
namespace optimize {
class AggressiveMergingPlugin extends Plugin {
constructor(options: any);
}
class CommonsChunkPlugin extends Plugin {
constructor(options?: any);
}
/** @deprecated */
class DedupePlugin extends Plugin {
constructor();
}
class LimitChunkCountPlugin extends Plugin {
constructor(options: any);
}
class MinChunkSizePlugin extends Plugin {
constructor(options: any);
}
class OccurrenceOrderPlugin extends Plugin {
constructor(preferEntry: boolean);
}
class UglifyJsPlugin extends Plugin {
constructor(options?: UglifyJsPlugin.Options);
}
namespace UglifyJsPlugin {
type CommentFilter = (astNode: any, comment: any) => boolean;
interface Options extends UglifyJS.MinifyOptions {
beautify?: boolean;
comments?: boolean | RegExp | CommentFilter;
exclude?: Condition | Condition[];
include?: Condition | Condition[];
sourceMap?: boolean;
test?: Condition | Condition[];
}
}
}
interface NoEmitOnErrorsPluginStatic {
new (): Plugin;
}
interface WatchIgnorePluginStatic {
new (paths: RegExp[]): Plugin;
}
interface NamedModulesPluginStatic {
new (): Plugin;
}
interface LoaderOptionsPluginStatic {
new (options: any): Plugin;
namespace dependencies {
}
namespace loader {
@@ -810,7 +867,7 @@ declare namespace webpack {
data?: any;
callback: loaderCallback | void;
callback: loaderCallback;
/**
@@ -832,16 +889,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[];
@@ -861,7 +918,7 @@ declare namespace webpack {
* The resource file.
* In the example: "/abc/resource.js"
*/
resourcePath: string
resourcePath: string;
/**
* The query of the resource.
@@ -898,14 +955,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 +985,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 +1048,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;
/**
@@ -1007,7 +1064,7 @@ declare namespace webpack {
/**
* Hacky access to the Compiler object of webpack.
*/
_compiler: compiler.Compiler;
_compiler: Compiler;
/**
@@ -1017,148 +1074,40 @@ declare namespace webpack {
}
}
namespace optimize {
interface DedupePluginStatic {
new (): Plugin;
}
interface LimitChunkCountPluginStatic {
new (options: any): Plugin;
}
interface MinChunkSizePluginStatic {
new (options: any): Plugin;
}
interface OccurenceOrderPluginStatic {
new (preferEntry: boolean): Plugin;
}
interface UglifyJsPluginStatic {
new (options?: UglifyPluginOptions): Plugin;
}
interface CommonsChunkPluginStatic {
new (chunkName: string, filenames?: string | string[]): Plugin;
new (options?: any): Plugin;
}
interface AggressiveMergingPluginStatic {
new (options: any): Plugin;
}
}
namespace dependencies {
interface LabeledModulesPluginStatic {
new (): Plugin;
}
}
/** @deprecated */
namespace compiler {
interface Compiler {
/** Builds the bundle(s). */
run(callback: CompilerCallback): void;
/**
* Builds the bundle(s) then starts the watcher, which rebuilds bundles whenever their source files change.
* Returns a Watching instance. Note: since this will automatically run an initial build, so you only need to run watch (and not run).
*/
watch(watchOptions: WatchOptions, handler: CompilerCallback): Watching;
//TODO: below are some of the undocumented properties. needs typings
outputFileSystem: any;
name: string;
options: Configuration;
}
/** @deprecated use webpack.Compiler */
type Compiler = webpack.Compiler;
interface Watching {
close(callback: () => void): void;
}
/** @deprecated use webpack.Compiler.Watching */
type Watching = webpack.Compiler.Watching;
interface WatchOptions {
/** After a change the watcher waits that time (in milliseconds) for more changes. Default: 300. */
aggregateTimeout?: number;
/** For some systems, watching many file systems can result in a lot of CPU or memory usage. It is possible to exclude a huge folder like node_modules. It is also possible to use anymatch patterns. */
ignored?: RegExp | string;
/** The watcher uses polling instead of native watchers. true uses the default interval, a number specifies a interval in milliseconds. Default: undefined (automatic). */
poll?: number | boolean;
}
/** @deprecated use webpack.Compiler.WatchOptions */
type WatchOptions = webpack.Compiler.WatchOptions;
interface Stats {
/** Returns true if there were errors while compiling */
hasErrors(): boolean;
/** Returns true if there were warnings while compiling. */
hasWarnings(): boolean;
/** Return information as json object */
toJson(options?: StatsOptions): any; //TODO: type this
/** Returns a formatted string of the result. */
toString(options?: StatsToStringOptions): string;
}
/** @deprecated use webpack.Stats */
type Stats = webpack.Stats;
interface StatsOptions {
/** Add asset Information */
assets?: boolean;
/** Sort assets by a field */
assetsSort?: string;
/** Add information about cached (not built) modules */
cached?: boolean;
/** Add children information */
children?: boolean;
/** Add chunk information (setting this to `false` allows for a less verbose output) */
chunks?: boolean;
/** Add built modules information to chunk information */
chunkModules?: boolean;
/** Add the origins of chunks and chunk merging info */
chunkOrigins?: boolean;
/** Sort the chunks by a field */
chunksSort?: string;
/** Context directory for request shortening */
context?: string;
/** Add errors */
errors?: boolean;
/** Add details to errors (like resolving log) */
errorDetails?: boolean;
/** Add the hash of the compilation */
hash?: boolean;
/** Add built modules information */
modules?: boolean;
/** Sort the modules by a field */
modulesSort?: string;
/** Add public path information */
publicPath?: boolean;
/** Add information about the reasons why modules are included */
reasons?: boolean;
/** Add the source code of modules */
source?: boolean;
/** Add timing information */
timings?: boolean;
/** Add webpack version information */
version?: boolean;
/** Add warnings */
warnings?: boolean;
}
/** @deprecated use webpack.Stats.ToJsonOptions */
type StatsOptions = webpack.Stats.ToJsonOptions;
interface StatsToStringOptions extends StatsOptions {
/** With console colors */
colors?: boolean;
}
/** @deprecated use webpack.Stats.ToStringOptions */
type StatsToStringOptions = webpack.Stats.ToStringOptions;
type CompilerCallback = (err: Error, stats: Stats) => void;
/** @deprecated use webpack.Compiler.Handler */
type CompilerCallback = webpack.Compiler.Handler;
}
interface PerformanceOptions {
/**
* Turns hints on/off. In addition, tells webpack to throw either an error or a warning when hints are found. This property is set to "warning" by default.
*/
hints?: boolean | 'error' | 'warning';
/**
* An entrypoint represents all assets that would be utilized during initial load time for a specific entry. This option controls when webpack should emit performance hints based on the maximum entrypoint size. The default value is 250000 (bytes).
*/
maxEntrypointSize?: number;
/**
* An asset is any emitted file from webpack. This option controls when webpack emits a performance hint based on individual asset size. The default value is 250000 (bytes).
*/
maxAssetSize?: number;
/**
* This property allows webpack to control what files are used to calculate performance hints.
*/
assetFilter?: (assetFilename: string) => boolean;
}
/** @deprecated use webpack.Options.Performance */
type PerformanceOptions = webpack.Options.Performance;
/** @deprecated use webpack.Options.WatchOptions */
type WatchOptions = webpack.Options.WatchOptions;
/** @deprecated use webpack.EvalSourceMapDevToolPlugin.Options */
type EvalSourceMapDevToolPluginOptions = webpack.EvalSourceMapDevToolPlugin.Options;
/** @deprecated use webpack.SourceMapDevToolPlugin.Options */
type SourceMapDevToolPluginOptions = webpack.SourceMapDevToolPlugin.Options;
/** @deprecated use webpack.optimize.UglifyJsPlugin.CommentFilter */
type UglifyCommentFunction = webpack.optimize.UglifyJsPlugin.CommentFilter;
/** @deprecated use webpack.optimize.UglifyJsPlugin.Options */
type UglifyPluginOptions = webpack.optimize.UglifyJsPlugin.Options;
}
declare var webpack: webpack.Webpack;
//export default webpack;
export = webpack;
+2 -2
View File
@@ -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"
]
}
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "../tslint.json" }
+107 -126
View File
@@ -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/
//
@@ -74,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",
}),
]
};
@@ -138,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"])
]
};
// <script>s required:
// page1.html: commons.js, p1.js
@@ -157,7 +144,10 @@ configuration = {
commons: "./entry-for-the-commons-chunk"
},
plugins: [
new CommonsChunkPlugin("commons", "commons.js")
new CommonsChunkPlugin({
name: "commons",
filename: "commons.js",
}),
]
};
@@ -196,9 +186,9 @@ configuration = {
};
configuration = {
resolve: {
root: __dirname
}
resolve: {
root: __dirname
}
};
rule = {
@@ -217,7 +207,7 @@ declare var require: any;
declare var path: any;
configuration = {
plugins: [
function() {
function(this: webpack.Compiler) {
this.plugin("done", function(stats: any) {
require("fs").writeFileSync(
path.join(__dirname, "...", "stats.json"),
@@ -267,19 +257,11 @@ 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);
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();
@@ -289,12 +271,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 +284,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({
@@ -344,7 +326,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"),
@@ -383,7 +364,7 @@ plugin = new webpack.NoErrorsPlugin();
plugin = new webpack.NoEmitOnErrorsPlugin();
plugin = new webpack.WatchIgnorePlugin(paths);
plugin = new webpack.LoaderOptionsPlugin({
debug: true
debug: true
});
//
@@ -412,19 +393,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 +419,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,87 +472,87 @@ 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 = {
cachePredicate: 'boo' // why does this test _not_ fail!?
}
const performance: webpack.PerformanceOptions = {
hints: 'error',
maxEntrypointSize: 400000,
maxAssetSize: 100000,
assetFilter: function(assetFilename) {
return assetFilename.endsWith('.js');
},
const performance: webpack.Options.Performance = {
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);
+5
View File
@@ -0,0 +1,5 @@
[*.ts]
indent_style = space
indent_size = 4
end_of_line = lf
charset = utf-8
+23 -3
View File
@@ -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 <https://github.com/poelstra>, Mizunashi Mana <https://github.com/mizunashi-mana>, Jeffery Grajkowski <https://github.com/pushplay>
// Definitions by: Martin Poelstra <https://github.com/poelstra>, Mizunashi Mana <https://github.com/mizunashi-mana>, Jeffery Grajkowski <https://github.com/pushplay>, Jeff Kenney <https://github.com/jeffkenney>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
declare namespace yargs {
@@ -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;
@@ -36,6 +39,15 @@ 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;
/**
* @deprecated since version 6.6.0
*/
require(key: string, msg: string): Argv;
require(key: string, required: boolean): Argv;
require(keys: number[], msg: string): Argv;
@@ -43,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;
@@ -103,6 +118,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;
@@ -147,7 +165,7 @@ declare namespace yargs {
fail(func: (msg: string, err: Error) => any): Argv;
coerce<T, U>(key: string|string[], func: (arg: T) => U): Argv;
coerce<T, U>(key: string | string[], func: (arg: T) => U): Argv;
coerce<T, U>(opts: { [key: string]: (arg: T) => U; }): Argv;
getCompletion(args: string[], done: (completions: string[]) => void): Argv;
@@ -186,7 +204,9 @@ declare namespace yargs {
count?: boolean;
default?: any;
defaultDescription?: string;
/** @deprecated since version 6.6.0 */
demand?: boolean | string;
demandOption?: boolean | string;
desc?: string;
describe?: string;
description?: string;

Some files were not shown because too many files have changed in this diff Show More