Merge branch 'master' into update_fixed-data-table

This commit is contained in:
Kanchalai Tanglertsampan
2017-04-24 14:41:58 -07:00
240 changed files with 17591 additions and 11114 deletions
+16
View File
@@ -470,6 +470,22 @@ namespace TestInjector {
$injector.annotate(() => {});
$injector.annotate(() => {}, true);
// $injector.instantiate
{
class Foobar {
constructor($q) {}
}
let result: Foobar = $injector.instantiate(Foobar);
}
// $injector.invoke
{
function foobar(v: boolean): number {
return 7;
}
let result: number = $injector.invoke(foobar);
}
}
// Promise signature tests
+2 -2
View File
@@ -1978,9 +1978,9 @@ declare namespace angular {
get(name: '$window'): IWindowService;
get<T>(name: '$xhrFactory'): IXhrFactory<T>;
has(name: string): boolean;
instantiate<T>(typeConstructor: Function, locals?: any): T;
instantiate<T>(typeConstructor: {new(...args: any[]): T}, locals?: any): T;
invoke(inlineAnnotatedFunction: any[]): any;
invoke(func: Function, context?: any, locals?: any): any;
invoke<T>(func: (...args: any[]) => T, context?: any, locals?: any): T;
strictDi: boolean;
}
+1
View File
@@ -13,6 +13,7 @@
"jsdoc-format": false,
"max-line-length": false,
"no-empty-interface": false,
"no-namespace": false,
"unified-signatures": false,
"void-return": false
}
+1 -1
View File
@@ -1,4 +1,4 @@
// Type definitions for Apple Pay JS 1.0.1
// Type definitions for Apple Pay JS 1.0
// Project: https://developer.apple.com/reference/applepayjs
// Definitions by: Martin Costello <https://martincostello.com/>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
+1 -3
View File
@@ -2,8 +2,6 @@ import Map = require("esri/Map");
import MapView = require("esri/views/MapView");
import Point = require("esri/geometry/Point");
export = MapController;
class MapController {
map: Map;
@@ -19,7 +17,7 @@ class MapController {
this.map = new Map({
basemap: "topo"
});
let view = new MapView({
center: point,
container: this.mapDiv,
@@ -2,8 +2,6 @@ import esri = require("esri");
import Map = require("esri/map");
import Point = require("esri/geometry/Point");
export = MapController;
class MapController {
map: Map;
@@ -0,0 +1,16 @@
import * as React from 'react';
import assertEqualJSX = require('assert-equal-jsx');
function sanitizeId(str: string): string {
return str.replace(/my-component-id-(\d+)/ig, 'my-component-id-0');
}
assertEqualJSX(
<div id='my-component-id-314159265' />,
// should equal:
<div id='my-component-id-0' />,
// with sanitization:
{
sanitize: sanitizeId
}
);
+17
View File
@@ -0,0 +1,17 @@
// Type definitions for assert-equal-jsx 1.0
// Project: https://github.com/thejameskyle/assert-equal-jsx
// Definitions by: Josh Toft <https://github.com/seryl>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.2
import * as React from 'react';
declare namespace assertEqualJSX {
interface AsssertOptions {
sanitize?(str: string): string;
}
}
declare function assertEqualJSX(actual: JSX.Element, expected: JSX.Element, opts?: assertEqualJSX.AsssertOptions): void;
export = assertEqualJSX;
+24
View File
@@ -0,0 +1,24 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6",
"dom"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"baseUrl": "../",
"jsx": "react",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"assert-equal-jsx-tests.tsx"
]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }
+100
View File
@@ -0,0 +1,100 @@
import * as Bagpipes from 'bagpipes';
// test `create`
Bagpipes.create({});
Bagpipes.create({ CustomPipe: [] });
Bagpipes.create({ CustomPipe: [] }, undefined);
Bagpipes.create({ CustomPipe: [] }, {});
// test `PipeDefs` Pipe Definitions Object
const perDefsMixed: Bagpipes.PipeDefMap = {
HelloWorld: [
{ emit: 'Hello, World!' },
'StringTypeDef'
],
xxx: 'ddd'
};
const pipesDefsEmpty: Bagpipes.PipeDefMap = {};
const pipesDefs: Bagpipes.PipeDefMap = {
_router: {
name: 'swagger_router',
mockMode: false,
mockControllersDirs: [ 'api/mocks' ],
controllersDirs: [ 'api/controllers' ]
},
_swagger_validate: {
name: 'swagger_validator',
validateReponse: true
},
swagger_controllers: [
'cors',
'swagger_params_parser',
'swagger_security',
'_swagger_validate',
'express_compatibility',
'_router'
]
};
// test `Config` object
const pipesConfigA: Bagpipes.Config = {
connectMiddlewareDirs: ['some_dir', 'ssssss']
};
const pipesConfigempty: Bagpipes.Config = { };
const pipesConfigFull: Bagpipes.Config = {
connectMiddlewareDirs: ['test'],
userFittingsDirs: ['test'],
userViewsDirs: ['test']
};
const pipesConfigFullEmpty: Bagpipes.Config = {
connectMiddlewareDirs: [],
userFittingsDirs: [],
userViewsDirs: []
};
let pipesA = Bagpipes.create(perDefsMixed, {
connectMiddlewareDirs: ['some_dir', 'ssssss'],
swaggerNodeRunner: {}
});
let pipeA = pipesA.getPipe('HelloWorld');
// log the output to standard out
pipeA.fit((context, cb) => {
cb(null, context);
});
pipesA.play(pipeA, {});
// test cb with err
const pipesEnty = Bagpipes.create({
HelloWorld: []
}, {});
// test fit a registered pipe and return error
const pipeErrTest = pipesEnty.pipes['any'].fit((context, cb) => {
cb(new Error("test err"));
});
pipesEnty.play(pipeErrTest, {});
const fittingsC = ["xxxx", "aaa"].map((name) => {
let fittingDef = {} as Bagpipes.PipeDefMap;
fittingDef[name] = 'nothing';
return fittingDef;
});
const bagpipesC = Bagpipes.create({ fittings: fittingsC });
// test create with array of object literals
const pipeWithObj = [{ emit: 'something' }];
const bagpipesD = Bagpipes.create({ objPipe: pipeWithObj });
bagpipesD.play(bagpipesD.getPipe('objPipe'), {});
// Test full create
const userFittingsDirs = ['./fixtures/fittings'];
const pipeWithString = ['emit'];
let contextPlain = {};
const bagpipesWithPipeAndFittings = Bagpipes.create({ myCustomPipe: pipeWithString }, { userFittingsDirs });
bagpipesWithPipeAndFittings.play(bagpipesWithPipeAndFittings.getPipe('myCustomPipe'), contextPlain);
Vendored Executable
+177
View File
@@ -0,0 +1,177 @@
// Type definitions for bagpipes 0.1
// Project: https://github.com/apigee-127/bagpipes
// Definitions by: Michael Mrowetz <https://github.com/micmro>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
interface FittingContext {
/** The input defined in the fitting definition
* (string, number, object, array)
*/
input: any;
/** Output to be delivered to the next fitting or client */
output: any;
[prop: string]: any;
}
/**
* Fitting types has pre-defined fittings `system` and `user`
* but can be any any string for custom types like `swagger` or `node-machine`
*/
type FittingType = "system" | "user" | string;
interface FittingDef {
/**
* If type is omitted (as it must be for in-line usage), Bagpipes will
* first check the user fittings then the system fittings for the name and
* use the first fitting found.
*
* Thus be aware that if you define a fitting with the same name as a
* system one, your fitting will override it.
*/
type?: FittingType;
/** The name of the fitting of the type specified */
name?: string;
/** Static values passed to the fitting during construction */
config?: any;
/** Dynamic values passed to the fitting during execution */
input?: any;
/** The name of the context key to which the output value is assigned */
output?: any;
// allow other config settings
[prop: string]: any;
}
/**
* Fitting Execution Function
*
* Will be called called when the `Pipe` it is contained it gets 'played'
*/
type Fitting = (
context: FittingContext,
next: {(err: Error | null | undefined, res?: any): void}) => void;
/**
* Fitting creation Function
*
* Executed during parsing
* @see {@link https://github.com/apigee-127/bagpipes#fittings|Docs}
*
* @param {Object} fittingDef Fitting Definition
*/
type FittingFactory = (fittingDef: FittingDef, bagpipes: any) => Fitting;
/**
* Hashmap of `fittingType`s (the name of a fitting) and the
* `FittingFactory` functions used to create them
*/
interface FittingTypesMap {
[fittingType: string]: FittingFactory;
}
/** The Pipe Definition */
type PipeDef = any[] | string | FittingDef;
/** Hashmap of Pipe Definitons */
export interface PipeDefMap {
[name: string]: PipeDef;
}
/**
* Bagpipes Instance (a collection of pipes)
* @see {@link https://github.com/apigee-127/bagpipes#pipes|Docs}
*/
export class Bagpipes {
/**
* Hashmap of `fittingType`s (the name of a fitting) and the
* `FittingFactory` functions used to create them
*/
fittingTypes: FittingTypesMap;
/** The pipes */
pipes: {
[name: string]: Pipe;
};
/** The `Bagpipes`' configuration */
config: Config;
/**
* Creates a `Fitting`
* @throws {Error} Throws error if an invalid (not defined) fitting typ is used
* (can't find argument `fittingType` in `Bagpipes.fittingTypes`)
*/
createFitting(fittingDef: FittingDef): Fitting;
/** returns `pipeworks` Pipe instance */
createPipe(pipeDef: PipeDef): Pipe;
createPipeFromFitting(fitting: Fitting, fittingDef: FittingDef): Pipe;
/**
* Finds and returns a `Pipe` by name and lazily creates if it is not defined
* @throws {Error} Throws error if `pipeDef` pipe is not yet defined and `pipeDef` is
* not supplied
*/
getPipe(pipeName: string, pipeDef?: PipeDef): Pipe;
/** Handler for errors that occure when a `Fitting` gets 'played' */
handleError(context: FittingContext, err: Error): void;
/** Loads `FittingFactory`s from file-system and adds them to `Bagpipes.fittingTypes` */
loadFittingTypes(): FittingTypesMap;
/**
* Builds a new (wrappend) `Fitting`
* @throws {Error} Throws error if an invalid (not defined) fitting typ is used
* (can't find argument `fittingType` in `Bagpipes.fittingTypes`)
*/
newFitting(fittingType: string, fittingDef: FittingDef): Fitting;
/** Run the pipeline */
play(pipe: Pipe, context: any): void;
/**
* Wraps `Fitting` with debugging, `preflight`, `postflight`
* and error handling functionality and returns as new Fitting
*/
wrapFitting(fitting: Fitting, fittingDef: FittingDef): Fitting | null;
}
/** Configuration object for `Bagpipes` */
export interface Config {
connectMiddlewareDirs?: string[];
userFittingsDirs?: string[];
userViewsDirs?: string[];
// allow to store custom values e.g. for swagger-node-runner
// see https://github.com/theganyo/swagger-node-runner/blob/v0.7.1/index.js#L304
[name: string]: any;
}
/**
* Creates `Bagpipes`
*/
export function create(pipesDefs: PipeDefMap, conf?: Config): Bagpipes;
// Types for imports from `pipeworks` module
type Affinity = "hoist" | "sink";
/** PipeDef used in `pipeworks` module */
interface PipeworksOptions {
/**
* Adds to the pre and post queues, respectively.
* Ensures a pipe gets fitted before or after the main execution pipeline.
*/
affinity: Affinity;
}
/**
* Instance of a `Pipeworks` pipeline (in `pipeworks` module) -
* called 'pipe' in `Bagpipes`
*
* _(simplified version)_
*/
export class Pipe {
/** add a new `Fitting` (piece) to the pipe (aka. pipeline) */
fit(pipe: Fitting): Pipe;
/** add a new `Fitting` (piece) to the pipe (aka. pipeline) */
fit(options: PipeworksOptions, pipe: Fitting): Pipe;
/** Redirect the flow to another pipe (aka. pipeline). */
siphon(pipe: Fitting): Pipe;
/** Redirect the flow to another pipe (aka. pipeline). */
siphon(options: PipeworksOptions, pipe: Fitting): Pipe;
/**
* Send something down the pipe (aka. pipeline)! Any number of arguments
* can be sent, but often there's just a single `context` object.
*/
flow(...args: any[]): Pipe;
}
+22
View File
@@ -0,0 +1,22 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"bagpipes-tests.ts"
]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }
+10
View File
@@ -251,6 +251,16 @@ declare namespace BlissNS {
(expr: Node, context?: Element): [Node];
}
interface AriaRequestEvent extends Event {
readonly attributeName: string;
attributeValue: string | null;
}
interface CommandEvent extends Event {
readonly commandName: string;
readonly detail: string | null;
}
// Native methods added into "_" property, but methods that return "void" now return thi stype in order to be chainables
// Methods are All HTMLElement a ELement methods
interface BlissNativeExtentions<T> {
+30 -30
View File
@@ -16,19 +16,19 @@
// TODO verify support to have no return statement in handlers to get a Promise<void> (more overloads?)
declare class Promise<R> implements Promise.Thenable<R> {
declare class Promise<T> implements Promise.Thenable<T> {
/**
* Create a new promise. The passed in function will receive functions `resolve` and `reject` as its arguments which can be called to seal the fate of the created promise.
*/
constructor(callback: (resolve: (thenableOrResult: R | Promise.Thenable<R>) => void, reject: (error: any) => void) => void);
constructor(callback: (resolve: (thenableOrResult: T | Promise.Thenable<T>) => void, reject: (error: any) => void) => void);
/**
* Promises/A+ `.then()` with progress handler. Returns a new promise chained from this promise. The new promise will be rejected or resolved dedefer on the passed `fulfilledHandler`, `rejectedHandler` and the state of this promise.
*/
then<U>(onFulfill: (value: R) => Promise.Thenable<U>, onReject: (error: any) => Promise.Thenable<U>, onProgress?: (note: any) => any): Promise<U>;
then<U>(onFulfill: (value: R) => Promise.Thenable<U>, onReject?: (error: any) => U, onProgress?: (note: any) => any): Promise<U>;
then<U>(onFulfill: (value: R) => U, onReject: (error: any) => Promise.Thenable<U>, onProgress?: (note: any) => any): Promise<U>;
then<U>(onFulfill?: (value: R) => U, onReject?: (error: any) => U, onProgress?: (note: any) => any): Promise<U>;
then<U>(onFulfill: (value: T) => Promise.Thenable<U>, onReject: (error: any) => Promise.Thenable<U>, onProgress?: (note: any) => any): Promise<U>;
then<U>(onFulfill: (value: T) => Promise.Thenable<U>, onReject?: (error: any) => U, onProgress?: (note: any) => any): Promise<U>;
then<U>(onFulfill: (value: T) => U, onReject: (error: any) => Promise.Thenable<U>, onProgress?: (note: any) => any): Promise<U>;
then<U>(onFulfill?: (value: T) => U, onReject?: (error: any) => U, onProgress?: (note: any) => any): Promise<U>;
/**
* This is a catch-all exception handler, shortcut for calling `.then(null, handler)` on this promise. Any exception happening in a `.then`-chain will propagate to nearest `.catch` handler.
@@ -71,55 +71,55 @@ declare class Promise<R> implements Promise.Thenable<R> {
*
* Alias `.lastly();` for compatibility with earlier ECMAScript version.
*/
finally(handler: (value: R) => Promise.Thenable<R>): Promise<R>;
finally(handler: (value: R) => R): Promise<R>;
finally(handler: (value: R) => void): Promise<R>;
finally(handler: (value: T) => Promise.Thenable<T>): Promise<T>;
finally(handler: (value: T) => T): Promise<T>;
finally(handler: (value: T) => void): Promise<T>;
lastly(handler: (value: R) => Promise.Thenable<R>): Promise<R>;
lastly(handler: (value: R) => R): Promise<R>;
lastly(handler: (value: R) => void): Promise<R>;
lastly(handler: (value: T) => Promise.Thenable<T>): Promise<T>;
lastly(handler: (value: T) => T): Promise<T>;
lastly(handler: (value: T) => void): Promise<T>;
/**
* Create a promise that follows this promise, but is bound to the given `thisArg` value. A bound promise will call its handlers with the bound value set to `this`. Additionally promises derived from a bound promise will also be bound promises with the same `thisArg` binding as the original promise.
*/
bind(thisArg: any): Promise<R>;
bind(thisArg: any): Promise<T>;
/**
* Like `.then()`, but any unhandled rejection that ends up here will be thrown as an error.
*/
done<U>(onFulfilled: (value: R) => Promise.Thenable<U>, onRejected: (error: any) => Promise.Thenable<U>, onProgress?: (note: any) => any): Promise<U>;
done<U>(onFulfilled: (value: R) => Promise.Thenable<U>, onRejected?: (error: any) => U, onProgress?: (note: any) => any): Promise<U>;
done<U>(onFulfilled: (value: R) => U, onRejected: (error: any) => Promise.Thenable<U>, onProgress?: (note: any) => any): Promise<U>;
done<U>(onFulfilled?: (value: R) => U, onRejected?: (error: any) => U, onProgress?: (note: any) => any): Promise<U>;
done<U>(onFulfilled: (value: T) => Promise.Thenable<U>, onRejected: (error: any) => Promise.Thenable<U>, onProgress?: (note: any) => any): Promise<U>;
done<U>(onFulfilled: (value: T) => Promise.Thenable<U>, onRejected?: (error: any) => U, onProgress?: (note: any) => any): Promise<U>;
done<U>(onFulfilled: (value: T) => U, onRejected: (error: any) => Promise.Thenable<U>, onProgress?: (note: any) => any): Promise<U>;
done<U>(onFulfilled?: (value: T) => U, onRejected?: (error: any) => U, onProgress?: (note: any) => any): Promise<U>;
/**
* Shorthand for `.then(null, null, handler);`. Attach a progress handler that will be called if this promise is progressed. Returns a new promise chained from this promise.
*/
progressed(handler: (note: any) => any): Promise<R>;
progressed(handler: (note: any) => any): Promise<T>;
/**
* Same as calling `Promise.delay(this, ms)`. With the exception that if this promise is bound to a value, the returned promise is bound to that value too.
*/
delay(ms: number): Promise<R>;
delay(ms: number): Promise<T>;
/**
* Returns a promise that will be fulfilled with this promise's fulfillment value or rejection reason. However, if this promise is not fulfilled or rejected within `ms` milliseconds, the returned promise is rejected with a `Promise.TimeoutError` instance.
*
* You may specify a custom error message with the `message` parameter.
*/
timeout(ms: number, message?: string): Promise<R>;
timeout(ms: number, message?: string): Promise<T>;
/**
* Register a node-style callback on this promise. When this promise is is either fulfilled or rejected, the node callback will be called back with the node.js convention where error reason is the first argument and success value is the second argument. The error argument will be `null` in case of success.
* Returns back this promise instead of creating a new one. If the `callback` argument is not a function, this method does not do anything.
*/
nodeify(callback: (err: any, value?: R) => void): Promise<R>;
nodeify(callback: (err: any, value?: T) => void): Promise<T>;
nodeify(...sink: any[]): void;
/**
* Marks this promise as cancellable. Promises by default are not cancellable after v0.11 and must be marked as such for `.cancel()` to have any effect. Marking a promise as cancellable is infectious and you don't need to remark any descendant promise.
*/
cancellable(): Promise<R>;
cancellable(): Promise<T>;
/**
* Cancel this promise. The cancellation will propagate to farthest cancellable ancestor promise which is still pending.
@@ -136,15 +136,15 @@ declare class Promise<R> implements Promise.Thenable<R> {
/**
* Like `.then()`, but cancellation of the the returned promise or any of its descendant will not propagate cancellation to this promise or this promise's ancestors.
*/
fork<U>(onFulfilled: (value: R) => Promise.Thenable<U>, onRejected: (error: any) => Promise.Thenable<U>, onProgress?: (note: any) => any): Promise<U>;
fork<U>(onFulfilled: (value: R) => Promise.Thenable<U>, onRejected?: (error: any) => U, onProgress?: (note: any) => any): Promise<U>;
fork<U>(onFulfilled: (value: R) => U, onRejected: (error: any) => Promise.Thenable<U>, onProgress?: (note: any) => any): Promise<U>;
fork<U>(onFulfilled?: (value: R) => U, onRejected?: (error: any) => U, onProgress?: (note: any) => any): Promise<U>;
fork<U>(onFulfilled: (value: T) => Promise.Thenable<U>, onRejected: (error: any) => Promise.Thenable<U>, onProgress?: (note: any) => any): Promise<U>;
fork<U>(onFulfilled: (value: T) => Promise.Thenable<U>, onRejected?: (error: any) => U, onProgress?: (note: any) => any): Promise<U>;
fork<U>(onFulfilled: (value: T) => U, onRejected: (error: any) => Promise.Thenable<U>, onProgress?: (note: any) => any): Promise<U>;
fork<U>(onFulfilled?: (value: T) => U, onRejected?: (error: any) => U, onProgress?: (note: any) => any): Promise<U>;
/**
* Create an uncancellable promise based on this promise.
*/
uncancellable(): Promise<R>;
uncancellable(): Promise<T>;
/**
* See if this promise can be cancelled.
@@ -174,7 +174,7 @@ declare class Promise<R> implements Promise.Thenable<R> {
/**
* Synchronously inspect the state of this `promise`. The `PromiseInspection` will represent the state of the promise as snapshotted at the time of calling `.inspect()`.
*/
inspect(): Promise.Inspection<R>;
inspect(): Promise.Inspection<T>;
/**
* This is a convenience method for doing:
@@ -229,8 +229,8 @@ declare class Promise<R> implements Promise.Thenable<R> {
*
* Alias `.thenThrow();` for compatibility with earlier ECMAScript version.
*/
throw(reason: Error): Promise<R>;
thenThrow(reason: Error): Promise<R>;
throw(reason: Error): Promise<T>;
thenThrow(reason: Error): Promise<T>;
/**
* Convert to String.
+5 -5
View File
@@ -257,11 +257,6 @@ class Library extends bookshelf.Model<Library> {
/* new Model(), see http://bookshelfjs.org/#Model */
{
new Book({
title: "One Thousand and One Nights",
author: "Scheherazade"
});
class Book extends bookshelf.Model<Book> {
get tableName() { return 'documents'; }
@@ -273,6 +268,11 @@ class Library extends bookshelf.Model<Library> {
});
}
}
new Book({
title: "One Thousand and One Nights",
author: "Scheherazade"
});
}
/* model.initialize(), see http://bookshelfjs.org/#Model-instance-initialize */
+14
View File
@@ -39,3 +39,17 @@ Boom.serverUnavailable('message', {some: 'data'});
Boom.gatewayTimeout('message', {some: 'data'});
Boom.unauthorized() as Error;
const error = Boom.badRequest('Cannot feed after midnight');
error.output.statusCode = 499; // Assign a custom error code
error.reformat();
/**
* Add a custom key to the payload
*/
interface CustomPayload extends Boom.Payload {
custom: string;
}
(error.output.payload as CustomPayload).custom = 'abc_123';
+13 -8
View File
@@ -24,6 +24,8 @@ declare namespace Boom {
output: Output;
/** reformat() - rebuilds error.output using the other object properties. */
reformat: () => string;
/** "If message is unset, the 'error' segment of the header will not be present and isMissing will be true on the error object." mentioned in @see {@link https://github.com/hapijs/boom#boomunauthorizedmessage-scheme-attributes} */
isMissing?: boolean;
}
export interface Output {
@@ -32,14 +34,17 @@ declare namespace Boom {
/** headers - an object containing any HTTP headers where each key is a header name and value is the header content. (Limited value type to string https://github.com/hapijs/boom/issues/151 ) */
headers: {[index: string]: string};
/** payload - the formatted object used as the response payload (stringified). Can be directly manipulated but any changes will be lost if reformat() is called. Any content allowed and by default includes the following content: */
payload: {
/** statusCode - the HTTP status code, derived from error.output.statusCode. */
statusCode: number;
/** error - the HTTP status message (e.g. 'Bad Request', 'Internal Server Error') derived from statusCode. */
error: string;
/** message - the error message derived from error.message. */
message: string;
}
payload: Payload;
}
export interface Payload {
/** statusCode - the HTTP status code, derived from error.output.statusCode. */
statusCode: number;
/** error - the HTTP status message (e.g. 'Bad Request', 'Internal Server Error') derived from statusCode. */
error: string;
/** message - the error message derived from error.message. */
message: string;
// Excluded this to aid typing of the other values. See tests for example casting to a custom interface to manipulate the payload
// [anyContent: string]: any;
}
/**
+21
View File
@@ -0,0 +1,21 @@
import * as ccap from 'ccap';
const captcha1 = ccap();
const width = 0;
const height = 0;
const offset = 0;
const captcha2 = ccap(width, height, offset);
const captcha3 = ccap({
width: 256, // set width,default is 256
height: 60, // set height,default is 60
offset: 40, // set text spacing,default is 40
quality: 100, // set pic quality,default is 50
fontsize: 57, // set font size,default is 57
// Custom the function to generate captcha text
generate() {
// generate captcha text here
return 'text'; // return the captcha text
}
});
+26
View File
@@ -0,0 +1,26 @@
// Type definitions for ccap 0.6
// Project: https://github.com/DoubleSpout/ccap
// Definitions by: taoqf <https://github.com/taoqf>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference types="node" />
interface Captcha {
get(): [string, Buffer];
}
interface Options {
width?: number; // set width,default is 256
height?: number; // set height,default is 60
offset?: number; // set text spacing,default is 40
quality?: number; // set pic quality,default is 50
fontsize?: number; // set font size,default is 57
// Custom the function to generate captcha text
generate?(): string;
}
declare function ccap(width: number, height: number, offset: number): Captcha;
declare function ccap(options?: Options): Captcha;
declare namespace ccap { }
export = ccap;
+22
View File
@@ -0,0 +1,22 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"ccap-tests.ts"
]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }
+90 -95
View File
@@ -2,23 +2,23 @@
$(function() {
alert('Ready to do stuff!');
});
var docRoot = $();
var divTag = $('div');
var divClass = $('.div');
var divID = $('#div');
var divAttr = $('[name=div]');
var documentElement = $();
var divTag2 = $(divTag);
var nodeName = divTag2[0].nodeName;
const docRoot = $();
const divTag = $('div');
const divClass = $('.div');
const divID = $('#div');
const divAttr = $('[name=div]');
const documentElement = $();
const divTag2 = $(divTag);
const nodeName = divTag2[0].nodeName;
// Assorted properties and functions on ChocolateChipStatic:
var version = $.version;
var libraryName = $.libraryName;
var els = $('li');
var madeEls = $.make('<p>Stuff</p>');
var moreEls = $.html('<p>Stuff</p>');
var oldTag = $('#oldTag');
var newTag = $('#newTag');
const version = $.version;
const libraryName = $.libraryName;
const els = $('li');
const madeEls = $.make('<p>Stuff</p>');
const moreEls = $.html('<p>Stuff</p>');
const oldTag = $('#oldTag');
const newTag = $('#newTag');
$.replace(oldTag, newTag);
$.require('./scripts/myscript.js', function() {
$.noop;
@@ -26,9 +26,8 @@ $.require('./scripts/myscript.js', function() {
$.defer(function() {
console.log("This comes after Squawk!");
});
var concatenation = $.concat('This', ' ', 'is', ' ', 'a', ' ', 'string', '.');
var arrayOfStringWords = $.w('This is a string');
const concatenation = $.concat('This', ' ', 'is', ' ', 'a', ' ', 'string', '.');
const arrayOfStringWords = $.w('This is a string');
// Boolean tests:
$.isString('This is a string');
@@ -41,7 +40,7 @@ $.isNumber(123);
$.isInteger(123);
$.isInteger(123.123); // should return false
$.isFloat(123.123); // should return true
var newUuid = $.makeUuid();
const newUuid = $.makeUuid();
$.each(['a', 'b', 'c'], function(ctx: string, idx: number) {
console.log(ctx);
console.log(idx);
@@ -50,7 +49,7 @@ $.each(['a', 'b', 'c'], function(ctx: string, idx: number) {
// Plugin interface for ChocolateChipElementArray:
$.fn.extend({
whateverProperty: "whatever",
whateverMethod: function() {
whateverMethod() {
alert("Whatever!");
}
});
@@ -59,11 +58,11 @@ $.fn.extend({
$('li').each(function(ctx, idx) {
console.log(ctx.nodeName);
});
var uniqueElements = $('li').unique();
var secondElement = $('li').eq(1);
var lastElement = $('li').eq(-1);
var whichIndex = $('li').index($('.selected'));
var whichListItemIndex = $('li').eq(3).index();
const uniqueElements = $('li').unique();
const secondElement = $('li').eq(1);
const lastElement = $('li').eq(-1);
const whichIndex = $('li').index($('.selected'));
const whichListItemIndex = $('li').eq(3).index();
$('.elems').is('div').each(function(ctx) {
console.log('This element is a div.');
});
@@ -71,20 +70,20 @@ $('.elems').isnt('p').each(function() {
console.log('This element is not a paragraph tag.');
});
$('li').has('p').each(function(ctx) {
console.log('This list item has a paragraph tag.')
console.log('This list item has a paragraph tag.');
});
$('li').hasnt('p').each(function(ctx) {
console.log('This list item does not have a paragraph tag.')
console.log('This list item does not have a paragraph tag.');
});
$('ul').find('li').each(function(ctx) {
console.log(ctx);
});
$('li').css('color');
$('li').css('color', 'red');
$('li').css({ "color": "red", "background-color": "yellow" });
var elemWidth = $('#header').width();
var elemHeight = $('#header').height();
var offset = $('h1').offset();
$('li').css({ color: "red", "background-color": "yellow" });
const elemWidth = $('#header').width();
const elemHeight = $('#header').height();
const offset = $('h1').offset();
console.log(offset.top);
console.log(offset.left);
console.log(offset.bottom);
@@ -93,7 +92,7 @@ $('li.selected').prependTo('#selectedItems');
$('li.selected').appendTo('#selectedItems');
$('ul').before("<h2>Subtitle</h2>");
$('ul').after("<p>Footer stuff here.</p>");
var h1Text = $('h1').text();
const h1Text = $('h1').text();
$('h1').text('The New Title');
$('ul').insert("<li>1</li><li>2</li><li>3</li>", "first");
$('ul').insert("<li>1</li><li>2</li><li>3</li>", "last");
@@ -101,12 +100,12 @@ $('ul').insert("<li>1</li><li>2</li><li>3</li>", 3);
$('ul').insert("<li>1</li><li>2</li><li>3</li>");
$('ul').html('<li>1</li><li><2/li><li>3</li>');
$('ul').html('');
var listContent = $('ul').html();
const listContent = $('ul').html();
$('ul').prepend('<li class="title">The title</li>');
$('ul').append('<li>The Last Item</li>');
var inputName = $('input').attr('name');
const inputName = $('input').attr('name');
$('input').attr('name', 'wobba');
var inputProperty = $('input').prop('disabled');
const inputProperty = $('input').prop('disabled');
$('input[type=checked]').prop('checked', true);
$('input').removeProp('disabled');
$('input').hasAttr('disabled').css('border', 'solid 1px red');
@@ -116,8 +115,8 @@ $('article').addClass('current');
$('article').removeClass('current');
$('article').toggleClass("current");
$('h1').dataset('status', 'ready');
var theStatus = $('h1').dataset('status');
var theText = $('textarea').val();
const theStatus = $('h1').dataset('status');
const theText = $('textarea').val();
$('textarea').val('This is the new text.');
$('input').disable();
$('input').enable();
@@ -146,21 +145,21 @@ $('#list').ancestor(5).css('margin', "20px");
$('#list').closest('article').css('margin', "20px");
$('button').siblings().css('padding', "20px");
$('button').siblings("p").css('padding', "20px");
var cloned = $('#list').clone();
const cloned = $('#list').clone();
$('#list').wrap('<div class="very-special"></div>');
$('#list').unwrap();
$('#list').remove();
$('#list').empty();
var thePrice = $('#list').data('price');
const thePrice = $('#list').data('price');
$('#list').data('price', '$1000');
$('#list').removeData('price');
// Animate:
$('#list').animate({
"transform": "rotate3d(30, 150, 200, 180deg) scale(3) translate3d(-50%, -30%, 140%)",
"opacity": .25,
transform: "rotate3d(30, 150, 200, 180deg) scale(3) translate3d(-50%, -30%, 140%)",
opacity: .25,
"transform-style": "preserve-3d",
"perspective": 500
perspective: 500
},
'2s',
"ease-in-out"
@@ -169,37 +168,34 @@ $('#list').animate({
// Form to JSON:
$.form2JSON($('form')[0], '.');
// Strings:
$.camelize("this-is-a-string"); // should return "thisIsAString"
$.deCamelize("thisIsAString"); // Should return "this-is-a-string"
$.capitalize("a string"); // Should return "A string"
$.capitalize("a string", true); // Should return "A STRING"
// Booleans:
var isiPhone = $.isiPhone;
var isiPad = $.isiPad;
var isiPod = $.isiPod;
var isiOS = $.isiOS;
var isAndroid = $.isAndroid;
var isWebOS = $.isWebOS;
var isBlackberry = $.isBlackberry;
var isTouchEnabled = $.isTouchEnabled;
var isOnline = $.isOnline;
var isStandalone = $.isStandalone;
var isiOS6 = $.isiOS6;
var isiOS7 = $.isiOS7;
var isWin = $.isWin;
var isWinPhone = $.isWinPhone;
var isIE10 = $.isIE10;
var isIE11 = $.isIE11;
var isWebkit = $.isWebkit;
var isMobile = $.isMobile;
var isDesktop = $.isDesktop;
var isSafari = $.isSafari;
var isNativeAndroid = $.isNativeAndroid;
const isiPhone = $.isiPhone;
const isiPad = $.isiPad;
const isiPod = $.isiPod;
const isiOS = $.isiOS;
const isAndroid = $.isAndroid;
const isWebOS = $.isWebOS;
const isBlackberry = $.isBlackberry;
const isTouchEnabled = $.isTouchEnabled;
const isOnline = $.isOnline;
const isStandalone = $.isStandalone;
const isiOS6 = $.isiOS6;
const isiOS7 = $.isiOS7;
const isWin = $.isWin;
const isWinPhone = $.isWinPhone;
const isIE10 = $.isIE10;
const isIE11 = $.isIE11;
const isWebkit = $.isWebkit;
const isMobile = $.isMobile;
const isDesktop = $.isDesktop;
const isSafari = $.isSafari;
const isNativeAndroid = $.isNativeAndroid;
// Events:
$('li').bind('click', function() {
@@ -216,9 +212,9 @@ $('ul').undelegate('click', 'li', function() {
}, false);
$('li').on('click', function() {
$.noop;
})
});
$('ul').on('click', 'li', function() {
console.log($(this).text())
console.log($(this).text());
});
$('li').off('click');
$('li').off('click', 'li');
@@ -228,11 +224,11 @@ $('.selected').data('selection', 'This is awesome!'); // set the value of data v
$('.selected').data('selection'); // return the data value of "selection" on ".selected"
// Promises:
var myPromise = new Promise(function(resolve, reject) {
let myPromise = new Promise(function(resolve, reject) {
$.noop;
});
var myPromise = new Promise(function(resolve, reject) {
myPromise = new Promise(function(resolve, reject) {
// Resolve the promise:
resolve('Success!');
// or reject it:
@@ -248,23 +244,23 @@ myPromise.then(function(value) {
});
// Fetch API
//===========
// ===========
// GET:
interface WineObject {
data: Array<WineInterface>;
data: WineInterface[];
}
interface WineInterface {
wine: {
name: string;
}
};
}
fetch('../data/wines.json')
.then($.json)
.then(function<WineObject>(obj: any):any {
.then(function<WineObject>(obj: any): any {
$('#message_ajax').empty();
obj.data.forEach(function(wine: any) {
$('#message_ajax').append('<li>' + wine.name + '</li>');
})
});
});
// POST:
@@ -273,7 +269,7 @@ interface postData {
name: string;
msg: string;
}
var formData = $.serialize($('form')[0]);
const formData = $.serialize($('form')[0]);
fetch('../controllers/php-post.php', {
method: 'post',
headers: {
@@ -283,7 +279,7 @@ fetch('../controllers/php-post.php', {
})
.then($.json)
.then(function<postData>(data: any): any {
if(data.email_check == "valid"){
if (data.email_check === "valid") {
$("#message_ajax").html("<div class='successMessage'>" + data.email + " is a valid e-mail address. Thank you, " + data.name + ".</div>");
$("#message_ajax").append('<p>' + data.msg + '</p>');
} else {
@@ -296,7 +292,7 @@ interface putData {
result: string;
fileName: string;
}
var putData = $('#fileText').val();
const putData = $('#fileText').val();
fetch('../controllers/php-put.php', {
method: 'put',
headers: {
@@ -305,22 +301,21 @@ fetch('../controllers/php-put.php', {
body: putData
})
.then($.json)
.then(function<putData>(data:any): any {
.then(function<putData>(data: any): any {
console.dir(data.base);
$("#message_ajax").append('<p>' + data.result + '</p>');
$("#message_ajax").append('<p>The file name is: ' + data.fileName + '</p>');
})
.catch(function(error:Error) {
.catch(function(error: Error) {
console.log(error);
$("#message_ajax").html("<div class='errorMessage'>Sorry, put was not successful.</div>");
});
// DELETE:
interface deleteData {
result: string;
}
var file = $('#fileName').val();
const file = $('#fileName').val();
fetch('../controllers/php-delete.php', {
method: 'delete',
headers: {
@@ -334,7 +329,7 @@ fetch('../controllers/php-delete.php', {
$("#message_ajax").append('<p>' + data.result + '</p>');
},
function(data: any) {
console.log('PROBLEM')
console.log('PROBLEM');
console.log(data);
})
.catch(function(error: any) {
@@ -343,7 +338,7 @@ function(data: any) {
});
// Timeout:
var formData2 = $.serialize($('form')[0]);
const formData2 = $.serialize($('form')[0]);
fetch('../controllers/php-post.php', {
method: 'post',
headers: {
@@ -355,7 +350,7 @@ fetch('../controllers/php-post.php', {
})
.then($.json)
.then(function <postData>(data: any): any {
if (data.email_check == "valid") {
if (data.email_check === "valid") {
$("#message_ajax").html("<div class='successMessage'>" + data.email + " is a valid e-mail address. Thank you, " + data.name + ".</div>");
$("#message_ajax").append('<p>' + data.msg + '</p>');
} else {
@@ -377,27 +372,27 @@ $.jsonp('https://api.github.com/users/rbiggs/repos?name=chipper', {timeout: 1000
});
})
.catch(function(error: any): any {
$('#message_ajax').append("<li>" + error.message + "</li>")
$('#message_ajax').append("<li>" + error.message + "</li>");
});
// Templates:
var myTemplate = '<li>Name: [[= data.name]]</li>';
var userInfo = {
const myTemplate = '<li>Name: [[= data.name]]</li>';
const userInfo = {
name: 'Wobba',
age: 100,
job: 'Rocket Scientist',
salary: '$1,000,000,000'
};
var parsedTempl8 = $.template(myTemplate);
const parsedTempl8 = $.template(myTemplate);
$('#user').html(parsedTempl8(userInfo));
// Output a simple array of data:
var simpleArray = ['One', 'Two', 'Three', 'Four', 'Five'];
var repeaterTmplate1 = '<li>[[= data ]]</li>';
const simpleArray = ['One', 'Two', 'Three', 'Four', 'Five'];
const repeaterTmplate1 = '<li>[[= data ]]</li>';
$.template.repeater($('#arrayList'), repeaterTmplate1, simpleArray);
// Output an array of objects:
var luminaries = {
const luminaries = {
persons:
[
{ firstName: "Albert", lastName: "Einstein" },
@@ -407,7 +402,7 @@ var luminaries = {
{ firstName: "Nicholas", lastName: "Copernicus" }
]
};
var repeaterTmplate2 = '<li>[[= data.firstName ]], [[= data.lastName]]</li>';
const repeaterTmplate2 = '<li>[[= data.firstName ]], [[= data.lastName]]</li>';
// Pass in the array of persons:
$.template.repeater($('#objectArrayList'), repeaterTmplate2, luminaries.persons);
@@ -416,10 +411,10 @@ $.template.data['myRepeater'] = [{ name: "Joe" }, { name: "Sally" }, {name: "Tom
$.template.repeater();
// Pub/Sub:
var arraySubscriber = function(topic: string, data: any): any {
const arraySubscriber = function(topic: string, data: any): any {
$('.list').append('<li><h3>' + topic + '</h3><h4>' + data + '</h4></li>');
};
var newsSubscription = $.subscribe('news/update', arraySubscriber);
const newsSubscription = $.subscribe('news/update', arraySubscriber);
$.publish('news/update', 'The New York Stock Exchange rose an unprecedented 1000 points in just three minutes. Analysts and investors are confused and uncertain how to respond.');
$.unsubscribe('news/update');
// Due to being unsubscribed above, this does nothing:
+57 -244
View File
@@ -1,9 +1,10 @@
// Type definitions for chocolatechip v4.0.4
// Type definitions for chocolatechip 4.0
// Project: https://github.com/chocolatechipui/ChocolateChipJS
// Definitions by: Robert Biggs <http://chocolatechip-ui.com>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
interface ChocolateChipStatic {
// TypeScript Version: 2.2
interface ChocolateChipStatic {
/**
* Accepts a string containing a CSS selector which is then used to match a set of elements.
*
@@ -21,7 +22,6 @@ interface ChocolateChipStatic {
*/
(callback: () => any): void;
/**
* Accepts a string containing a CSS selector which is then used to match a set of elements.
*
@@ -45,7 +45,7 @@ interface ChocolateChipStatic {
* @return document[]
*/
(document: Document): Document[];
/**
* If no argument is provided, return the document as a ChocolateChipElementArray.
* @return Document[]
@@ -118,7 +118,6 @@ interface ChocolateChipStatic {
*/
makeUuid(): string;
/**
* Create a ChocolateChip collection object by creating elements from an HTML string.
*
@@ -196,7 +195,9 @@ interface ChocolateChipStatic {
defer(callback: Function): Function;
/**
* This method makes sure a method always returns an array. If no values are available to return, it returns and empty array. This is to make sure that methods that expect a chainable array will not throw and exception.
* This method makes sure a method always returns an array.
* If no values are available to return, it returns and empty array.
* This is to make sure that methods that expect a chainable array will not throw and exception.
*
* @param result The result of a method to test if it can be returned in an array.
* @return An array holding the results of a method, otherwise an empty array.
@@ -489,7 +490,6 @@ interface ChocolateChipStatic {
*
*/
template: {
/**
* This method parses a string and an optoinal variable name and returns a parsed template in the form of a function. You can then pass this function data to get rendered nodes.
*
@@ -503,20 +503,19 @@ interface ChocolateChipStatic {
* The repeater method used to rendering iterable template data.
*/
repeater: {
/**
* Use this method to render declarative temlate repeaters. This expects a "data-repeater" attribute whose value points to data stored on $.template.data.
*/
(): void;
/**
* A method to repeated output a template.
*
* @param element The target container into which the content will be inserted.
* @param template A string of markup.
* @param data The iterable data the template will consume.
* @return void.
*/
* A method to repeated output a template.
*
* @param element The target container into which the content will be inserted.
* @param template A string of markup.
* @param data The iterable data the template will consume.
* @return void.
*/
(element: ChocolateChipElementArray, template: string, data: any): void;
}
@@ -535,8 +534,11 @@ interface ChocolateChipStatic {
};
/**
* ATENTION: DO NOT TOUCH! This is the ChocolateChipJS cache. This is used to store details about registered events and data. You should not touch any of these values, even though they are exposed, as this can seriously impair the behavior of your app.
*
* ATENTION: DO NOT TOUCH!
* This is the ChocolateChipJS cache.
* This is used to store details about registered events and data.
* You should not touch any of these values, even though they are exposed, as this can seriously impair the behavior of your app.
*
* data: this is used by $(element).data() to store data.
* events: this is used by the event system.
*/
@@ -545,7 +547,7 @@ interface ChocolateChipStatic {
* DO NOT TOUCH! This hold data stored by $(element).data().
*/
data: {};
/**
* DO NOT TOUCH! This stores information about registered events.
*/
@@ -556,17 +558,13 @@ interface ChocolateChipStatic {
hasKey: Function;
_delete: Function;
}
}
};
}
/**
* Interface for ChocolateChipJS Element Collections.
*/
interface ChocolateChipElementArray extends Array<HTMLElement> {
/**
* Iterate over an Array object, executing a function for each matched element.
*
@@ -652,7 +650,7 @@ interface ChocolateChipElementArray extends Array<HTMLElement> {
* @ return HTMLElement[]
*/
has(selector: string): ChocolateChipElementArray;
/**
* Reduce the set of matched elements to those that have a descendant that matches the selector or DOM element.
*
@@ -668,7 +666,7 @@ interface ChocolateChipElementArray extends Array<HTMLElement> {
* @ return HTMLElement[]
*/
hasnt(selector: string): ChocolateChipElementArray;
/**
* Reduce the set of matched elements to those that have a descendant that does not match the selector or DOM element.
*
@@ -857,10 +855,10 @@ interface ChocolateChipElementArray extends Array<HTMLElement> {
* @return HTMLElement[]
*/
prop(propertyName: string, value: any | boolean): ChocolateChipElementArray;
/**
* Remove an element property.
*
*
* @param property The property to remove.
* @return HTMLElement[]
*/
@@ -934,11 +932,11 @@ interface ChocolateChipElementArray extends Array<HTMLElement> {
dataset(key: string, value: any): ChocolateChipElementArray;
/**
* Retrieve a dataset key's value for the first element in the element collection.
*
* @param key A string naming the piece of data to set.
* @return HTMLElement[]
*/
* Retrieve a dataset key's value for the first element in the element collection.
*
* @param key A string naming the piece of data to set.
* @return HTMLElement[]
*/
dataset(key: string): ChocolateChipElementArray;
/**
@@ -1137,7 +1135,10 @@ interface ChocolateChipElementArray extends Array<HTMLElement> {
/**
* Set the content of each element in the set of matched elements to the specified text.
*
* @param text The text to set as the content of each matched element. When Number is supplied, it will be converted to a String representation. To delete text, use ChocolateChipElementArray.empty() or ChocolateChipElementArray.remove().
* @param text
* The text to set as the content of each matched element.
* When Number is supplied, it will be converted to a String representation.
* To delete text, use ChocolateChipElementArray.empty() or ChocolateChipElementArray.remove().
* @return HTMLElement
*/
text(text: string | number): HTMLElement;
@@ -1219,145 +1220,16 @@ interface ChocolateChipElementArray extends Array<HTMLElement> {
off(eventType?: string, selector?: any, handler?: (eventObject: Event) => any, capturePhase?: boolean): ChocolateChipStatic;
/**
* Trigger an event on an element.
*
* @param eventType The event to trigger.
* @return void
*/
* Trigger an event on an element.
*
* @param eventType The event to trigger.
* @return void
*/
trigger(eventType: string): void;
}
/**
* Represents the completion of an asynchronous operation
*/
interface Promise<T> {
/**
* Attaches callbacks for the resolution and/or rejection of the Promise.
*
* @param onfulfilled The callback to execute when the Promise is resolved.
* @param onrejected The callback to execute when the Promise is rejected.
* @return Promise A Promise for the completion of which ever callback is executed.
* @return Promise A new Promise
*/
then<TResult>(onfulfilled?: (value: T) => TResult | Promise<TResult>, onrejected?: (reason: any) => TResult | Promise<TResult>): Promise<TResult>;
/**
* Attaches a callback for only the rejection of the Promise.
*
* @param onrejected The callback to execute when the Promise is rejected.
* @return Promise A Promise for the completion of the callback.
* @return Promise A new Promise
*/
catch(onrejected?: (reason: any) => T | Promise<T>): Promise<T>;
}
interface PromiseConstructor {
/**
* Creates a new Promise.
*
* @param init A callback used to initialize the promise. This callback is passed two arguments: a resolve callback used resolve the promise with a value or the result of another promise, and a reject callback used to reject the promise with a provided reason or error.
* @return Promise A new Proimise
*/
new <T>(init: (resolve: (value?: T | Promise<T>) => void, reject: (reason?: any) => void) => void): Promise<T>;
<T>(init: (resolve: (value?: T | Promise<T>) => void, reject: (reason?: any) => void) => void): Promise<T>;
/**
* Creates a Promise that is resolved with an array of results when all of the provided Promises resolve, or rejected when any Promise is rejected.
*
* @param values An array of Promises.
* @return Promise A new Promise.
*/
all<T>(values: (T | Promise<T>)[]): Promise<T[]>;
/**
* Creates a Promise that is resolved with an array of results when all of the provided Promises resolve, or rejected when any Promise is rejected.
*
* @param values An array of values.
* @returns A new Promise.
*/
all(values: Promise<void>[]): Promise<void>;
/**
* Creates a Promise that is resolved or rejected when any of the provided Promises are resolved or rejected.
*
* @param values An array of Promises.
* @return Promise A new Promise.
*/
race<T>(values: (T | Promise<T>)[]): Promise<T>;
/**
* Creates a new rejected promise for the provided reason.
*
* @param reason The reason the promise was rejected.
* @return Promise A new rejected Promise.
*/
reject(reason: any): Promise<void>;
/**
* Creates a new rejected promise for the provided reason.
*
* @param reason The reason the promise was rejected.
* @return void A Promise is rejected.
*/
reject<T>(reason: any): Promise<T>;
/**
* Creates a new resolved promise for the provided value.
*
* @param value A promise.
* @return Promise A promise whose internal state matches the provided promise.
*/
resolve<T>(value: T | Promise<T>): Promise<T>;
/**
* Creates a new resolved promise.
*
* @return Promise A resolved promise.
*/
resolve(): Promise<void>;
}
declare var Promise: PromiseConstructor;
declare type ByteString = string;
declare type USVString = string;
declare type DOMString = string;
declare type OpenEndedDictionary = Object;
/**
* Interface for fetch API.
*
* @param input A string representing a valid url.
* @param init An object literal of key value pairs to set method, headers, body, credentials or cache.
* @return Promise.
*/
interface fetch {
(input: string,
init?: {
method?: string;
headers?: {};
body?: any;
mode?: {
cors: string;
"no-cors": string;
"same-origin": string;
};
credentials?: {
omit: string;
"same-origin": string;
include: string;
};
cache?: {
default: string;
"no-store": string;
reload: string;
"no-cache": string;
"force-cache": string;
"only-if-cached": string;
};
timeout?: number;
}): Promise<any>;
}
type DOMString = string;
type OpenEndedDictionary = Object;
/**
* Headers Interface. This defines the methods exposed by the Headers object.
@@ -1373,81 +1245,20 @@ interface Headers {
forEach(callback: Function, thisArg: any): any;
}
interface decode {
(body: any): FormData;
}
/**
* Request Interface. This defines the properties and methods exposed by the Request object.
*/
interface Request {
(input: {
url: string;
request: Request;
}, init: Object): Request;
clone(): Request;
arrayBuffer(): ArrayBuffer;
blob(): Blob;
formData(): FormData;
json(): JSON;
text(): string;
method: string;
url: string;
heaers: Headers;
context: any;
referrer: any;
mode: string;
credentials: any;
cache: string;
bodyUsed: boolean;
}
interface URLSearchParams {
():URLSearchParams;
}
/**
* Resonse Interface. This defines the properties and methods exposed by the Response object.
*/
interface Response {
(body?: {
blob: Blob;
bormData: FormData;
urlParams: URLSearchParams;
url: string;
},
init?: {
status?: string | number;
statusText?: string;
headers: Headers;
}): Response;
clone(): Response;
redirect(): Response;
arrayBuffer(): ArrayBuffer;
blob(): Blob;
formData(): FormData;
json(): JSON;
text(): string;
type: string;
url: string;
useFinalURL: boolean;
ok: boolean;
statusText: string;
headers: Headers;
bodyUsed: boolean;
interface RequestInit {
timeout?: number;
}
interface ChocolateChipStatic {
/**
* A cache to hold callbacks execute by the response from a JSONP request. This is an array of strings. By default these values get purged when the callback execute and exposes the data returned by the request.
* A cache to hold callbacks execute by the response from a JSONP request.
* This is an array of strings.
* By default these values get purged when the callback execute and exposes the data returned by the request.
*/
JSONPCallbacks: string[];
/**
* Method to perform JSONP request.
*
* Method to perform JSONP request.
*
* @param url A string defining the url to target.
* @param options And object literal of properties: {timeout? number, callbackName?: string, clear?: boolean}
*/
@@ -1456,17 +1267,20 @@ interface ChocolateChipStatic {
* A number representing milliseconds to express when to refect a JSONP request.
*/
timeout?: number;
/**
* The optional name for the callback when the server response will execute. The default value is "callback". However some sites may use a different name for their JSONP function. Consult the documentation on the site to ascertain the correct value for this callback.
* The optional name for the callback when the server response will execute.
* The default value is "callback".
* However some sites may use a different name for their JSONP function.
* Consult the documentation on the site to ascertain the correct value for this callback.
*/
callbackName?: string;
/**
* This value determines whether the callbacks and script associate with JSONP persist or are purged after the request returns. By default this is set to true, meaning that they will be purged.
*/
clear?: boolean;
}): any
}): any;
}
interface Window {
@@ -1475,6 +1289,5 @@ interface Window {
jsonp: any;
}
declare var $: ChocolateChipStatic;
declare var fetch: fetch;
declare var chocolatechipjs: ChocolateChipStatic;
declare var chocolatechipjs: ChocolateChipStatic;
+10
View File
@@ -0,0 +1,10 @@
{
"extends": "dtslint/dt.json",
"rules": {
// TODOs
"adjacent-overload-signatures": false,
"ban-types": false,
"only-arrow-functions": false,
"unified-signatures": false
}
}
+74 -8
View File
@@ -10,30 +10,41 @@ declare namespace cropperjs {
CanvasShouldNotBeWithInTheContainer = 2,
ContainerSshouldBeWithInTheCanvas = 3
}
export interface CropperCustomEvent extends CustomEvent {
export interface CropperReadyEvent extends CustomEvent { }
export interface CropperCropEvent extends CustomEvent {
detail: Data;
}
export interface CropperCropStepEvent extends CustomEvent {
detail: CropStepData;
}
export interface CropperZoomEvent extends CustomEvent {
detail: ZoomData;
}
export interface CropperOptions {
/**
* Function called when crop box is ready
*/
ready?: (event: CropperCustomEvent) => void;
ready?: (event: CropperReadyEvent) => void;
/**
* Function called when crop box is moved or resized
*/
crop?: (event: CropperCustomEvent) => void;
crop?: (event: CropperCropEvent) => void;
/**
* Function called at start of crop box being moved or resized
*/
cropstart?: (event: CropperCustomEvent) => void;
cropstart?: (event: CropperCropStepEvent) => void;
/**
* Function called when crop box is moved
*/
cropmove?: (event: CropperCustomEvent) => void;
cropmove?: (event: CropperCropStepEvent) => void;
/**
* Function called when crop box is finished being moved or resized
*/
cropend?: (event: CropperCustomEvent) => void;
cropend?: (event: CropperCropStepEvent) => void;
/**
* Function called when a cropper instance starts to zoom in or zoom out its canvas (image wrapper).
*/
zoom?: (event: CropperZoomEvent) => void;
/**
* Define the view mode of the cropper.
* @default 0
@@ -231,6 +242,47 @@ declare namespace cropperjs {
*/
scaleY: number;
}
interface CropStepData {
/**
* The original event that was triggered
* Options:
* `cropstart`: mousedown, touchstart and pointerdown
* `cropmove`: mousemove, touchmove and pointermove
* `cropend`: mouseup, touchend, touchcancel, pointerup and pointercancel
*/
originalEvent: Event;
/**
* Options:
* 'crop': create a new crop box
* 'move': move the canvas (image wrapper)
* 'zoom': zoom in / out the canvas (image wrapper) by touch
* 'e': resize the east side of the crop box
* 'w': resize the west side of the crop box
* 's': resize the south side of the crop box
* 'n': resize the north side of the crop box
* 'se': resize the southeast side of the crop box
* 'sw': resize the southwest side of the crop box
* 'ne': resize the northeast side of the crop box
* 'nw': resize the northwest side of the crop box
* 'all': move the crop box (all directions)
*/
action: string;
}
interface ZoomData {
/**
* The original event that was triggered
* Options: wheel, touchmove
*/
originalEvent: Event;
/**
* The old (current) ratio of the canvas
*/
oldRatio: number;
/**
* The new (next) ratio of the canvas (canvasData.width / canvasData.naturalWidth)
*/
ratio: number;
}
interface ContainerData {
/**
* The current width of the container
@@ -338,8 +390,8 @@ declare namespace cropperjs {
declare class cropperjs {
constructor(element: HTMLImageElement, options: cropperjs.CropperOptions);
/**
* Show the crop box manually.
*/
* Show the crop box manually.
*/
crop(): void;
/**
@@ -391,6 +443,13 @@ declare class cropperjs {
*/
zoom(ratio: number): void;
/**
* Zoom the canvas (image wrapper) to an absolute ratio.
* Zoom in: requires a positive number (ratio > 0)
* Zoom out: requires a negative number (ratio < 0)
*/
zoomTo(ratio: number): void;
/**
* Rotate the canvas (image wrapper) with a relative degree.
* Rotate right: requires a positive number (degree > 0)
@@ -398,6 +457,13 @@ declare class cropperjs {
*/
rotate(degree: number): void;
/**
* Rotate the canvas (image wrapper) to an absolute degree.
* Rotate right: requires a positive number (degree > 0)
* Rotate left: requires a negative number (degree < 0)
*/
rotateTo(degree: number): void;
/**
* Clear the crop box.
*/
+3 -2
View File
@@ -1,4 +1,5 @@
import cuid = require('cuid')
import cuid = require('cuid');
var result: string = cuid();
var cuidResult: string = cuid();
var slugResult: string = cuid.slug();
+8 -5
View File
@@ -1,9 +1,12 @@
// Type definitions for cuid
// Type definitions for cuid v1.3.8
// Project: https://github.com/ericelliott/cuid
// Definitions by: Dave Keen <http://www.keendevelopment.ch>
// Definitions by: Dave Keen <http://www.keendevelopment.ch>, João Forja <http://discipliningcode.com>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
interface CUID {
(): string;
slug: () => string;
}
declare var cuid: CUID;
declare function cuid(): string;
export = cuid
export = cuid;
+3 -3
View File
@@ -27,7 +27,7 @@ function testPieChart() {
.append("g")
.attr("transform", "translate(" + width / 2 + "," + height / 2 + ")");
d3.csv("data.csv", d => ({ population: +d['population'], age: d['age'] }), function (error, data) {
d3.csv("data.csv", d => ({ population: +d['population'], age: d['age'] }), function (error: any, data: any) {
var g = svg.selectAll(".arc")
.data(pie(data))
.enter().append("g")
@@ -301,7 +301,7 @@ function normalizedBarChart() {
.append("g")
.attr("transform", "translate(" + margin.left + "," + margin.top + ")");
d3.csv("data.csv", function (error, data) {
d3.csv("data.csv", function (error: any, data: any) {
color.domain(d3.keys(data[0]).filter(function (key) { return key !== "State"; }));
data.forEach(function (d: any) {
@@ -494,7 +494,7 @@ function callenderView() {
.attr("class", "month")
.attr("d", monthPath);
d3.csv("dji.csv", function (error, csv) {
d3.csv("dji.csv", function (error: any, csv: any) {
var data = d3.nest()
.key(function (d: any) { return d.Date; })
.rollup(function (d: any) { return (d[0].Close - d[0].Open) / d[0].Open; })
+16 -18
View File
@@ -1,21 +1,19 @@
namespace DagreD3Tests {
const gDagre = new dagreD3.graphlib.Graph();
const graph = gDagre.graph();
const gDagre = new dagreD3.graphlib.Graph();
const graph = gDagre.graph();
// has graph methods from dagre.d.ts
graph.setNode("a", {});
const num: number = 251 + graph.height + graph.width;
const predecessors: { [vertex: string]: string[] } = {};
const successors: { [vertex: string]: string[] } = {};
// has graph methods from dagre.d.ts
graph.setNode("a", {});
const num: number = 251 + graph.height + graph.width;
const predecessors: { [vertex: string]: string[] } = {};
const successors: { [vertex: string]: string[] } = {};
predecessors["a"] = graph.predecessors("a");
successors["a"] = graph.successors("a");
graph.transition = (selection: d3.Selection<any>) => {
return d3.transition();
};
predecessors["a"] = graph.predecessors("a");
successors["a"] = graph.successors("a");
graph.transition = (selection: d3.Selection<any>) => {
return d3.transition();
};
const render = new dagreD3.render();
const svg = d3.select("svg");
render.arrows()["arrowType"] = (parent: d3.Selection<any>, id: string, edge: dagre.Edge, type: string) => {};
render(svg, graph);
}
const render = new dagreD3.render();
const svg = d3.select("svg");
render.arrows()["arrowType"] = (parent: d3.Selection<any>, id: string, edge: dagre.Edge, type: string) => {};
render(svg, graph);
+7 -9
View File
@@ -1,10 +1,8 @@
namespace DagreTests {
const gDagre = new dagre.graphlib.Graph();
gDagre.setGraph({})
.setDefaultEdgeLabel(() => {})
.setNode("a", {})
.setEdge("b", "c")
.setEdge("c", "d", {class: "class"});
const gDagre = new dagre.graphlib.Graph();
gDagre.setGraph({})
.setDefaultEdgeLabel(() => {})
.setNode("a", {})
.setEdge("b", "c")
.setEdge("c", "d", {class: "class"});
dagre.layout(gDagre);
}
dagre.layout(gDagre);
+7 -5
View File
@@ -1,13 +1,15 @@
import debounce from "debounce";
import debounce = require("debounce");
const doThings = () => 1;
debounce(function(){ doThings(); })();
debounce(doThings)();
debounce(function(){ doThings(); }, 1000)();
debounce(doThings, 1000)();
debounce(function(a: string){ doThings(); }, 1000)("foo");
debounce((a: string) => doThings, 1000)("foo");
// Immediate true should return the value
const imm1: number = (debounce((x: number) => x * 2, 100, true))(2);
const clearable = debounce(doThings);
clearable.clear();
+3 -6
View File
@@ -1,10 +1,7 @@
// Type definitions for compose-function
// Type definitions for debounce 1.0
// Project: https://github.com/component/debounce
// Definitions by: Denis Sokolov <https://github.com/denis-sokolov>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// Overload on boolean constants would allow us to narrow further,
// but it is not implemented for TypeScript yet
declare function f<A extends Function>(f: A, interval?: number, immediate?: boolean): A
export default f;
declare function debounce<A extends Function>(f: A, interval?: number, immediate?: boolean): A & { clear(): void; };
export = debounce;
+6
View File
@@ -0,0 +1,6 @@
{
"extends": "dtslint/dt.json",
"rules": {
"ban-types": false
}
}
+3
View File
@@ -0,0 +1,3 @@
import detectHover from 'detect-hover';
detectHover.update();
+16
View File
@@ -0,0 +1,16 @@
// Type definitions for detect-hover 1.0
// Project: https://github.com/rafrex/detect-hover#readme
// Definitions by: Thomas Tilkema <https://github.com/thomastilkema>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
interface detectHover {
anyHover: boolean;
anyNone: boolean;
hover: boolean;
none: boolean;
update(): void;
}
declare const detectHover: detectHover;
export default detectHover;
+22
View File
@@ -0,0 +1,22 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"detect-hover-tests.ts"
]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }
+3
View File
@@ -0,0 +1,3 @@
import detectIt from 'detect-it';
detectIt.update();
+33
View File
@@ -0,0 +1,33 @@
// Type definitions for detect-it 2.1
// Project: https://github.com/rafrex/detect-it#readme
// Definitions by: Thomas Tilkema <https://github.com/thomastilkema>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
import detectHover from 'detect-hover';
import detectPassiveEvents from 'detect-passive-events';
import detectPointer from 'detect-pointer';
import detectTouchEvents from 'detect-touch-events';
interface detectIt {
deviceType: 'hybrid' | 'mouseOnly' | 'touchOnly';
hasMouse: boolean;
hasTouch: boolean;
maxTouchPoints: number;
passiveEvents: boolean;
primaryHover: 'hover' | 'none';
primaryPointer: 'coarse' | 'fine' | 'none';
state: state;
update(): void;
}
interface state {
detectHover: detectHover;
detectPassiveEvents: detectPassiveEvents;
detectPointer: detectPointer;
detectTouchEvents: detectTouchEvents;
}
declare const detectIt: detectIt;
export default detectIt;
+22
View File
@@ -0,0 +1,22 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"detect-it-tests.ts"
]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }
@@ -0,0 +1,3 @@
import detectPassiveEvents from 'detect-passive-events';
detectPassiveEvents.update();
+13
View File
@@ -0,0 +1,13 @@
// Type definitions for detect-passive-events 1.0
// Project: https://github.com/rafrex/detect-passive-events#readme
// Definitions by: Thomas Tilkema <https://github.com/thomastilkema>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
interface detectPassiveEvents {
hasSupport: boolean;
update(): void;
}
declare const detectPassiveEvents: detectPassiveEvents;
export default detectPassiveEvents;
+22
View File
@@ -0,0 +1,22 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"detect-passive-events-tests.ts"
]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }
@@ -0,0 +1,3 @@
import detectPointer from 'detect-pointer';
detectPointer.update();
+19
View File
@@ -0,0 +1,19 @@
// Type definitions for detect-pointer 1.0
// Project: https://github.com/rafrex/detect-pointer#readme
// Definitions by: Thomas Tilkema <https://github.com/thomastilkema>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
interface detectPointer {
anyCoarse: boolean;
anyFine: boolean;
anyNone: boolean;
coarse: boolean;
fine: boolean;
none: boolean;
update(): void;
}
declare const detectPointer: detectPointer;
export default detectPointer;
+22
View File
@@ -0,0 +1,22 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"detect-pointer-tests.ts"
]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }
@@ -0,0 +1,3 @@
import detectTouchEvents from 'detect-touch-events';
detectTouchEvents.update();
+14
View File
@@ -0,0 +1,14 @@
// Type definitions for detect-touch-events 1.0
// Project: https://github.com/rafrex/detect-touch-events#readme
// Definitions by: Thomas Tilkema <https://github.com/thomastilkema>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
interface detectTouchEvents {
hasApi: boolean;
maxTouchPoints: number;
update(): void;
}
declare const detectTouchEvents: detectTouchEvents;
export default detectTouchEvents;
+22
View File
@@ -0,0 +1,22 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"detect-touch-events-tests.ts"
]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }
+12
View File
@@ -0,0 +1,12 @@
import * as download from 'downloadjs';
download('hello world', 'dlText.txt', 'text/plain');
download('data:text/plain,hello%20world', 'dlDataUrlText.txt', 'text/plain');
download(new Blob(['hello world']), 'dlTextBlob.txt', 'text/plain');
download('/robots.txt');
download(document.documentElement.outerHTML, 'dlHTML.html', 'text/html');
download(new Blob(['hello world'.bold()]), 'dlHtmlBlob.html', 'text/html');
download('/diff6.png');
+10
View File
@@ -0,0 +1,10 @@
// Type definitions for downloadjs 1.4
// Project: http://danml.com/download.html
// Definitions by: cwmoo740 <https://github.com/cwmoo740>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.2
declare namespace download {
}
declare function download(data: string | File | Blob, filename?: string, mimeType?: string): void;
export = download;
+23
View File
@@ -0,0 +1,23 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6",
"dom"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"downloadjs-tests.ts"
]
}
+3
View File
@@ -0,0 +1,3 @@
{
"extends": "dtslint/dt.json"
}
+1 -1
View File
@@ -9,7 +9,7 @@ import * as Immutable from 'immutable';
type SyntheticKeyboardEvent = React.KeyboardEvent<{}>;
type SyntheticEvent = React.SyntheticEvent<{}>;
export as namespace Draft;
declare namespace Draft {
namespace Component {
namespace Base {
+6
View File
@@ -0,0 +1,6 @@
import * as mm from 'egg-mock';
const app = mm.app();
app.ready();
app.mockService('foo', 'bar', ['123']);
const ctx = app.mockContext();
+107
View File
@@ -0,0 +1,107 @@
// Type definitions for Egg-mock 3.x
// Project: https://github.com/eggjs/egg-mock
// Definitions by: Eward Song <https://github.com/sheperdwind/>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
import { Application, Context } from 'egg';
interface MockApplication extends Application { // tslint:disble-line
ready(): Promise<void>;
close(): Promise<void>;
callback(): any;
/**
* mock Context
*/
mockContext(data?: any): Context;
/**
* mock cookie session
*/
mockSession(data: any): MockApplication;
mockCookies(cookies: any): MockApplication;
mockHeaders(headers: any): MockApplication;
/**
* Mock service
*/
mockService(service: string, methodName: string, fn: any): MockApplication;
/**
* mock service that return error
*/
mockServiceError(service: string, methodName: string, err?: Error): MockApplication;
mockHttpclient(mockUrl: string, mockMethod: string | string[], mockResult: {
data: Buffer | string | JSON;
status: number;
headers: any;
}): MockApplication;
}
interface MockOption {
/**
* The directory of the application
*/
baseDir?: string;
/**
* Custom you plugins
*/
plugins?: any;
/**
* The directory of the egg framework
*/
framework?: string;
/**
* Cache application based on baseDir
*/
cache?: boolean;
/**
* Swtich on process coverage, but it'll be slower
*/
coverage?: boolean;
/**
* Remove $baseDir/logs
*/
clean?: boolean;
}
type EnvType = 'default' | 'test' | 'prod' | 'local' | 'unittest';
interface EggMock {
/**
* Create a egg mocked application
*/
app(option?: MockOption): MockApplication;
/**
* mock the serverEnv of Egg
*/
env(env: EnvType): void;
/**
* mock console level
*/
consoleLevel(level: string): void;
/**
* set EGG_HOME path
*/
home(homePath: string): void;
/**
* restore mock
*/
restore(): void;
}
declare var mm: EggMock;
export = mm;
+22
View File
@@ -0,0 +1,22 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": false,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"egg-mock-tests.ts"
]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }
+33
View File
@@ -0,0 +1,33 @@
import { Controller, Service, Application } from 'egg';
// controller
class FooController extends Controller {
async getData() {
this.ctx.body = await this.service.foo.bar();
}
}
// add user controller and service
declare module 'egg' {
interface Controllers {
foo: FooController;
}
interface Services {
foo: FooService;
}
}
class FooService extends Service {
async bar() {
//
return this.config.env;
}
}
// router
function router(app: Application) {
const controller = app.controller;
app.get('/foo', controller.foo.getData);
app.post('/', controller.foo.getData);
}
+785
View File
@@ -0,0 +1,785 @@
// Type definitions for Egg 1.x
// Project: https://github.com/eggjs/egg
// Definitions by: Eward Song <https://github.com/sheperdwind/>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.2
import * as accepts from 'accepts';
import * as KoaApplication from 'koa';
import * as KoaRouter from 'koa-router';
import { Readable } from 'stream';
/**
* BaseContextClass is a base class that can be extended,
* it's instantiated in context level,
* {@link Helper}, {@link Service} is extending it.
*/
declare class BaseContextClass { // tslint:disable-line
/**
* request context
*/
ctx: Context;
/**
* Application
*/
app: Application;
/**
* Application config object
*/
config: EggAppConfig;
/**
* service
*/
service: Services;
constructor(ctx: Context);
}
export interface Logger {
info(info: string, ...args: string[]): void;
warn(info: string, ...args: string[]): void;
debug(info: string, ...args: string[]): void;
error(info: string, ...args: string[]): void;
}
interface Request extends KoaApplication.Request { // tslint:disable-line
/**
* detect if response should be json
* 1. url path ends with `.json`
* 2. response type is set to json
* 3. detect by request accept header
*
* @member {Boolean} Request#acceptJSON
* @since 1.0.0
*/
acceptJSON: boolean;
/**
* Request remote IPv4 address
* @member {String} Request#ip
* @example
* ```js
* this.request.ip
* => '127.0.0.1'
* => '111.10.2.1'
* ```
*/
ip: string;
/**
* Get all pass through ip addresses from the request.
* Enable only on `app.config.proxy = true`
*
* @member {Array} Request#ips
* @example
* ```js
* this.request.ips
* => ['100.23.1.2', '201.10.10.2']
* ```
*/
ips: string[];
protocol: string;
/**
* get params pass by querystring, all value are Array type. {@link Request#query}
* @member {Array} Request#queries
* @example
* ```js
* GET http://127.0.0.1:7001?a=b&a=c&o[foo]=bar&b[]=1&b[]=2&e=val
* this.queries
* =>
* {
* "a": ["b", "c"],
* "o[foo]": ["bar"],
* "b[]": ["1", "2"],
* "e": ["val"]
* }
* ```
*/
queries: { [key: string]: string[] };
/**
* get params pass by querystring, all value are String type.
* @member {Object} Request#query
* @example
* ```js
* GET http://127.0.0.1:7001?name=Foo&age=20&age=21
* this.query
* => { 'name': 'Foo', 'age': 20 }
*
* GET http://127.0.0.1:7001?a=b&a=c&o[foo]=bar&b[]=1&b[]=2&e=val
* this.query
* =>
* {
* "a": "b",
* "o[foo]": "bar",
* "b[]": "1",
* "e": "val"
* }
* ```
*/
query: { [key: string]: string };
}
interface Response extends KoaApplication.Response { // tslint:disable-line
/**
* read response real status code.
*
* e.g.: Using 302 status redirect to the global error page
* instead of show current 500 status page.
* And access log should save 500 not 302,
* then the `realStatus` can help us find out the real status code.
* @member {Number} Context#realStatus
*/
realStatus: number;
}
interface ContextView { // tslint:disable-line
/**
* Render a file by view engine
* @param {String} name - the file path based on root
* @param {Object} [locals] - data used by template
* @param {Object} [options] - view options, you can use `options.viewEngine` to specify view engine
* @return {Promise<String>} result - return a promise with a render result
*/
render(name: string, locals: any, options?: any): Promise<string>;
/**
* Render a template string by view engine
* @param {String} tpl - template string
* @param {Object} [locals] - data used by template
* @param {Object} [options] - view options, you can use `options.viewEngine` to specify view engine
* @return {Promise<String>} result - return a promise with a render result
*/
renderString(name: string, locals: any, options?: any): Promise<string>;
}
export type LoggerLevel = 'DEBUG' | 'INFO' | 'WARN' | 'ERROR' | 'NONE';
export interface EggAppConfig {
workerStartTimeout: number;
baseDir: string;
/**
* The option of `bodyParser` middleware
*
* @member Config#bodyParser
* @property {Boolean} enable - enable bodyParser or not, default to true
* @property {String | RegExp | Function | Array} ignore - won't parse request body when url path hit ignore pattern, can not set `ignore` when `match` presented
* @property {String | RegExp | Function | Array} match - will parse request body only when url path hit match pattern
* @property {String} encoding - body encoding config, default utf8
* @property {String} formLimit - form body size limit, default 100kb
* @property {String} jsonLimit - json body size limit, default 100kb
* @property {Boolean} strict - json body strict mode, if set strict value true, then only receive object and array json body
* @property {Number} queryString.arrayLimit - from item array length limit, default 100
* @property {Number} queryString.depth - json value deep lenght, default 5
* @property {Number} queryString.parameterLimit - paramter number limit ,default 1000
*/
bodyParser: {
enable: boolean;
encoding: string;
formLimit: string;
jsonLimit: string;
strict: true;
queryString: {
arrayLimit: number;
depth: number;
parameterLimit: number;
};
};
/**
* logger options
* @member Config#logger
* @property {String} dir - directory of log files
* @property {String} encoding - log file encloding, defaults to utf8
* @property {String} level - default log level, could be: DEBUG, INFO, WARN, ERROR or NONE, defaults to INFO in production
* @property {String} consoleLevel - log level of stdout, defaults to INFO in local serverEnv, defaults to WARN in unittest, defaults to NONE elsewise
* @property {Boolean} outputJSON - log as JSON or not, defaults to false
* @property {Boolean} buffer - if enabled, flush logs to disk at a certain frequency to improve performance, defaults to true
* @property {String} errorLogName - file name of errorLogger
* @property {String} coreLogName - file name of coreLogger
* @property {String} agentLogName - file name of agent worker log
* @property {Object} coreLogger - custom config of coreLogger
*/
logger: {
dir: string;
encoding: string;
env: string;
level: LoggerLevel;
consoleLevel: LoggerLevel;
outputJSON: boolean;
buffer: boolean;
appLogName: string;
coreLogName: string;
agentLogName: string;
errorLogName: string;
coreLogger: any;
};
httpclient: {
keepAlive: boolean;
freeSocketKeepAliveTimeout: number;
timeout: number;
maxSockets: number;
maxFreeSockets: number;
enableDNSCache: boolean;
};
development: {
/**
* dirs needed watch, when files under these change, application will reload, use relative path
*/
watchDirs: string[];
/**
* dirs don't need watch, including subdirectories, use relative path
*/
ignoreDirs: string[];
/**
* don't wait all plugins ready, default is true.
*/
fastReady: boolean;
};
/**
* It will ignore special keys when dumpConfig
*/
dump: {
ignore: Set<string>;
};
/**
* The environment of egg
*/
env: string;
/**
* The current HOME directory
*/
HOME: string;
hostHeaders: string;
/**
* I18n options
*/
i18n: {
/**
* default value EN_US
*/
defaultLocale: string;
/**
* i18n resource file dir, not recommend to change default value
*/
dir: string;
/**
* custom the locale value field, default `query.locale`, you can modify this config, such as `query.lang`
*/
queryField: string;
/**
* The locale value key in the cookie, default is locale.
*/
cookieField: string;
/**
* Locale cookie expire time, default `1y`, If pass number value, the unit will be ms
*/
cookieMaxAge: string | number;
};
/**
* Detect request' ip from specified headers, not case-sensitive. Only worked when config.proxy set to true.
*/
ipHeaders: string;
/**
* jsonp options
* @member Config#jsonp
* @property {String} callback - jsonp callback method key, default to `_callback`
* @property {Number} limit - callback method name's max length, default to `50`
* @property {Boolean} csrf - enable csrf check or not. default to false
* @property {String|RegExp|Array} whiteList - referrer white list
*/
jsonp: {
limit: number;
callback: string;
csrf: boolean;
whiteList: string | RegExp | Array<string | RegExp>;
};
/**
* The key that signing cookies. It can contain multiple keys seperated by .
*/
keys: string;
/**
* The name of the application
*/
name: string;
/**
* package.json
*/
pkg: any;
rundir: string;
security: {
domainWhiteList: string[];
protocolWhiteList: string[];
defaultMiddleware: string;
csrf: any;
xframe: {
enable: boolean;
value: 'SAMEORIGIN' | 'DENY' | 'ALLOW-FROM';
};
hsts: any;
methodnoallow: { enable: boolean };
noopen: { enable: boolean; }
xssProtection: any;
csp: any;
};
siteFile: any;
static: any;
view: any;
watcher: any;
}
export interface Router extends KoaRouter {
/**
* restful router api
*/
resources(name: string, prefix: string, middleware: any): Router;
/**
* @param {String} name - Router name
* @param {Object} params - more parameters
* @example
* ```js
* router.url('edit_post', { id: 1, name: 'foo', page: 2 })
* => /posts/1/edit?name=foo&page=2
* router.url('posts', { name: 'foo&1', page: 2 })
* => /posts?name=foo%261&page=2
* ```
* @return {String} url by path name and query params.
* @since 1.0.0
*/
url(name: string, params: any): any;
}
declare interface EggApplication extends KoaApplication { // tslint:disable-line
/**
* The current directory of application
*/
baseDir: string;
/**
* The configuration of application
*/
config: EggAppConfig;
/**
* app.env delegate app.config.env
*/
env: string;
/**
* core logger for framework and plugins, log file is $HOME/logs/{appname}/egg-web
*/
coreLogger: Logger;
/**
* Alias to https://npmjs.com/package/depd
*/
deprecate: any;
/**
* HttpClient instance
*/
httpclient: any;
/**
* The loader instance, the default class is EggLoader. If you want define
*/
loader: any;
/**
* Logger for Application, wrapping app.coreLogger with context infomation
*
* @member {ContextLogger} Context#logger
* @since 1.0.0
* @example
* ```js
* this.logger.info('some request data: %j', this.request.body);
* this.logger.warn('WARNING!!!!');
* ```
*/
logger: Logger;
/**
* All loggers contain logger, coreLogger and customLogger
*/
loggers: { [loggerName: string]: Logger };
/**
* messenger instance
*/
messenger: any;
plugins: any;
/**
* get router
*/
router: Router;
Service: Service;
/**
* Whether `application` or `agent`
*/
type: string;
/**
* create a singleton instance
*/
addSingleton(name: string, create: any): void;
/**
* Excute scope after loaded and before app start
*/
beforeStart(scrope: () => void): void;
/**
* Close all, it wil close
* - callbacks registered by beforeClose
* - emit `close` event
* - remove add listeners
*
* If error is thrown when it's closing, the promise will reject.
* It will also reject after following call.
* @return {Promise} promise
* @since 1.0.0
*/
close(): Promise<any>;
/**
* http request helper base on httpclient, it will auto save httpclient log.
* Keep the same api with httpclient.request(url, args).
* See https://github.com/node-modules/urllib#api-doc for more details.
*/
curl(url: string, opt: any): Promise<any>;
/**
* Get logger by name, it's equal to app.loggers['name'], but you can extend it with your own logical
*/
getLogger(name: string): Logger;
/**
* print the infomation when console.log(app)
*/
inspect(): any;
/**
* Alias to Router#url
*/
url(name: string, params: any): any;
}
export interface Application extends EggApplication {
/**
* global locals for view
* @see Context#locals
*/
locals: any;
/**
* HTTP get method
*/
get(path: string, fn: string): void;
get(path: string, ...middleware: any[]): void;
/**
* HTTP post method
*/
post(path: string, fn: string): void;
post(path: string, ...middleware: any[]): void;
/**
* HTTP put method
*/
put(path: string, fn: string): void;
put(path: string, ...middleware: any[]): void;
/**
* HTTP delete method
*/
delete(path: string, fn: string): void;
delete(path: string, ...middleware: any[]): void;
/**
* restful router api
*/
resources(name: string, prefix: string, fn: string): Router;
redirect(path: string, redirectPath: string): void;
controller: Controllers;
Controller: Controller;
}
interface FileStream extends Readable { // tslint:disable-line
fields: any;
}
export interface Context extends KoaApplication.Context {
app: Application;
service: Services;
request: Request;
response: Response;
/**
* Resource Parameters
* @example
* ##### ctx.params.id {string}
*
* `GET /api/users/1` => `'1'`
*
* ##### ctx.params.ids {Array<String>}
*
* `GET /api/users/1,2,3` => `['1', '2', '3']`
*
* ##### ctx.params.fields {Array<String>}
*
* Expect request return data fields, for example
* `GET /api/users/1?fields=name,title` => `['name', 'title']`.
*
* ##### ctx.params.data {Object}
*
* Tht request data object
*
* ##### ctx.params.page {Number}
*
* Page number, `GET /api/users?page=10` => `10`
*
* ##### ctx.params.per_page {Number}
*
* The number of every page, `GET /api/users?per_page=20` => `20`
*/
params: any;
/**
* @see Request#accept
*/
queries: { [key: string]: string[] };
/**
* @see Request#accept
*/
accept: accepts.Accepts;
/**
* @see Request#acceptJSON
*/
acceptJSON: boolean;
/**
* @see Request#ip
*/
ip: string;
/**
* @see Response#realStatus
*/
realStatus: number;
/**
*
* set the ctx.body.data value
*
* @member {Object} Context#data=
* @example
* ```js
* ctx.data = {
* id: 1,
* name: 'fengmk2'
* };
* ```
*
* will get responce
*
* ```js
* HTTP/1.1 200 OK
*
* {
* "data": {
* "id": 1,
* "name": "fengmk2"
* }
* }
* ```
*/
data: any;
/**
* set ctx.body.meta value
*
* @example
* ```js
* ctx.meta = {
* count: 100
* };
* ```
* will get responce
*
* ```js
* HTTP/1.1 200 OK
*
* {
* "meta": {
* "count": 100
* }
* }
* ```
*/
meta: any;
/**
* locals is an object for view, you can use `app.locals` and `ctx.locals` to set variables,
* which will be used as data when view is rendering.
* The difference between `app.locals` and `ctx.locals` is the context level, `app.locals` is global level, and `ctx.locals` is request level. when you get `ctx.locals`, it will merge `app.locals`.
*
* when you set locals, only object is available
*
* ```js
* this.locals = {
* a: 1
* };
* this.locals = {
* b: 1
* };
* this.locals.c = 1;
* console.log(this.locals);
* {
* a: 1,
* b: 1,
* c: 1,
* };
* ```
*
* `ctx.locals` has cache, it only merges `app.locals` once in one request.
*
* @member {Object} Context#locals
*/
locals: any;
/**
* alias to {@link locals}, compatible with koa that use this variable
*/
state: any;
/**
* Logger for Application, wrapping app.coreLogger with context infomation
*
* @member {ContextLogger} Context#logger
* @since 1.0.0
* @example
* ```js
* this.logger.info('some request data: %j', this.request.body);
* this.logger.warn('WARNING!!!!');
* ```
*/
logger: Logger;
/**
* Request start time
*/
starttime: number;
/**
* View instance that is created every request
*/
view: ContextView;
/**
* http request helper base on httpclient, it will auto save httpclient log.
* Keep the same api with httpclient.request(url, args).
* See https://github.com/node-modules/urllib#api-doc for more details.
*/
curl(url: string, opt: any): Promise<any>;
/**
* Render a file by view engine
* @param {String} name - the file path based on root
* @param {Object} [locals] - data used by template
* @param {Object} [options] - view options, you can use `options.viewEngine` to specify view engine
* @return {Promise<String>} result - return a promise with a render result
*/
render(name: string, locals: any, options?: any): Promise<string>;
/**
* Render a template string by view engine
* @param {String} tpl - template string
* @param {Object} [locals] - data used by template
* @param {Object} [options] - view options, you can use `options.viewEngine` to specify view engine
* @return {Promise<String>} result - return a promise with a render result
*/
renderString(name: string, locals: any, options?: any): Promise<string>;
__(key: string, ...values: string[]): string;
gettext(key: string, ...values: string[]): string;
/**
* get upload file stream
* @example
* ```js
* const stream = yield this.getFileStream();
* // get other fields
* console.log(stream.fields);
* ```
* @method Context#getFileStream
* @return {ReadStream} stream
* @since 1.0.0
*/
getFileStream(): Promise<FileStream>;
/**
* @see Responce.redirect
*/
redirect(url: string, alt?: string): void;
}
export class Controller extends BaseContextClass { }
export class Service extends BaseContextClass { }
/**
* The empty interface `Services` is an placehoder, for egg
* to auto injection service to ctx.service
*
* @example
*
* import { Service } from 'egg';
* class FooService extends Service {
* async bar() {}
* }
*
* declare module 'egg' {
* export interface service {
* foo: FooService;
* }
* }
*
* Now I can get ctx.service.foo at controller and other service file.
*/
export interface Services { }// tslint:disable-line
export interface Controllers { } // tslint:disable-line
+23
View File
@@ -0,0 +1,23 @@
{
"compilerOptions": {
"module": "commonjs",
"target": "es2017",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"egg-tests.ts"
]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }
@@ -0,0 +1,26 @@
import settings = require("electron-settings");
settings.has('foo.bar'); // $ExpectType boolean
settings.set('foo.bar', 'test'); // $ExpectType Settings
settings.set('foo.bar', 'test', {prettify: true}); // $ExpectType Settings
settings.set('foo.bar', {test: 'test'}); // $ExpectType Settings
settings.set('foo.bar', {test: 'test'}, {prettify: true}); // $ExpectType Settings
settings.setAll({foo: {bar: 'test'}}); // $ExpectType Settings
settings.setAll({foo: {bar: 'test'}}, {prettify: true}); // $ExpectType Settings
settings.get('foo.bar'); // $ExpectType JsonValue
settings.get('foo.bar', 'test'); // $ExpectType JsonValue
settings.getAll(); // $ExpectType JsonValue
settings.delete('foo.bar'); // $ExpectType Settings
settings.delete('foo.bar', {prettify: true}); // $ExpectType Settings
settings.deleteAll(); // $ExpectType Settings
settings.deleteAll({prettify: true}); // $ExpectType Settings
settings.watch('foo.bar', () => {}); // $ExpectType SettingsObserver
settings.file(); // $ExpectType string
+122
View File
@@ -0,0 +1,122 @@
// Type definitions for electron-settings 3.0
// Project: https://github.com/nathanbuchar/electron-settings#readme
// Definitions by: Ian Copp <https://github.com/icopp>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference types="node"/>
import * as fs from "fs";
type SettingsHandler = (newValue: any, oldValue: any) => any;
interface JsonObject {
[x: string]: JsonValue;
}
interface JsonArray extends Array<JsonValue> {} // tslint:disable-line no-empty-interface
type JsonValue = string | number | boolean | null | JsonArray | JsonObject;
interface SettingsOptions {
/**
* Prettify the JSON output. Defaults to `false`.
*/
prettify?: boolean;
}
interface Settings extends NodeJS.EventEmitter {
/**
* Returns a boolean indicating whether the settings object contains the
* given key path.
*/
has(keyPath: string): boolean;
/**
* Sets the value at the given key path and returns the Settings instance.
* Chainable.
* @param keyPath The path to the key whose value we wish to set. This key
* need not already exist.
* @param value The value to set the key at the chosen key path to. This
* must be a data type supported by JSON.
* @see #setAll
*/
set(keyPath: string, value: JsonValue, options?: SettingsOptions): Settings;
/**
* Sets all settings and returns the Settings instance. Chainable.
* @param obj The new settings object.
* @see #set
*/
setAll(obj: JsonValue, options?: SettingsOptions): Settings;
/**
* Returns the value at the given key path, or sets the value at that key
* path to the default value, if provided, if the key does not exist.
* @param defaultValue The value to apply if the setting does not already
* exist.
* @see #getAll
*/
get(keyPath: string, defaultValue?: any): JsonValue;
/**
* Returns all settings.
* @see #get
*/
getAll(): JsonValue;
/**
* Deletes the key and value at the given key path and returns the Settings
* instance. Chainable.
* @see #deleteAll
*/
delete(keyPath: string, options?: SettingsOptions): Settings;
/**
* Deletes all settings and returns the Settings instance. Chainable.
* @see #delete
*/
deleteAll(options?: SettingsOptions): Settings;
/**
* Returns an Observer instance which watches the given key path for changes
* and calls the given handler if the value changes. To unsubscribe from
* changes, call observer.dispose().
* @param keyPath The path to the key that we wish to watch for changes.
* @param handler The callback that will be invoked if the value at the
* chosen key path changes. The context of this callback is
* that of the observer instance.
*/
watch(keyPath: string, handler: SettingsHandler): SettingsObserver;
/**
* Returns the absolute path to where the settings file is or will be
* stored.
*
* In general, the settings file is stored in your app's user data directory
* in a file called Settings. The default user data directory for your
* system can be found below.
*
* * MacOS: If you're running macOS, your app's default user data directory
* is `~/Library/Application\ Support/<Your App>`.
* * Windows: If you're running Windows, your app's default user data
* directory is `%APPDATA%/<Your App>`.
* * Linux: If you're running Linux, your app's default user data directory
* is either `$XDG_CONFIG_HOME/<Your App>` or `~/.config/<Your App>`.
*
* If you wish, you may change your app's default user data directory by
* calling Electron's `app.setPath()` method before the ready event of the
* app module is emitted, but this is not recommended, as it will likely
* cause unintended consequences.
*/
file(): string;
}
interface SettingsObserver {
/**
* Disposes of this Observer instance.
*/
dispose(): void;
}
declare var settings: Settings;
export = settings;
+22
View File
@@ -0,0 +1,22 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"electron-settings-tests.ts"
]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }
+9
View File
@@ -0,0 +1,9 @@
import * as entities from 'entities';
// encoding
entities.encodeXML(`&#38;`); // `&amp;#38;`
entities.encodeHTML(`&#38;`); // `&amp;&num;38&semi;`
// decoding
entities.decodeXML(`asdf &amp; &#xFF; &#xFC; &apos;`); // `asdf & ÿ ü '`
entities.decodeHTML(`asdf &amp; &yuml; &uuml; &apos;`); // `asdf & ÿ ü '`
+26
View File
@@ -0,0 +1,26 @@
// Type definitions for entities 1.1
// Project: https://github.com/fb55/node-entities
// Definitions by: Alice Klipper <https://github.com/aliceklipper>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
export function decode(data: string, level?: number): string;
export function decodeStrict(data: string, level?: number): string;
export function encode(data: string, level?: number): string;
export function decodeXML(str: string): string;
export function decodeXMLStrict(str: string): string;
export function encodeXML(data: string): string;
export function decodeHTML(str: string): string;
export function decodeHTMLStrict(str: string): string;
export function encodeHTML(data: string): string;
export function decodeHTML4(str: string): string;
export function decodeHTML4Strict(str: string): string;
export function encodeHTML4(data: string): string;
export function decodeHTML5(str: string): string;
export function decodeHTML5Strict(str: string): string;
export function encodeHTML5(data: string): string;
export function escape(data: string): string;
+22
View File
@@ -0,0 +1,22 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"entities-tests.ts"
]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }
+3 -3
View File
@@ -25,7 +25,7 @@ class MyComponent extends Component<MyComponentProps, MyComponentState> {
const MyStatelessComponent = (props: StatelessProps) => <span />;
// ShallowWrapper
namespace ShallowWrapperTest {
function ShallowWrapperTest() {
let shallowWrapper: ShallowWrapper<MyComponentProps, MyComponentState> =
shallow<MyComponentProps, MyComponentState>(<MyComponent stringProp="value"/>);
@@ -331,7 +331,7 @@ namespace ShallowWrapperTest {
}
// ReactWrapper
namespace ReactWrapperTest {
function ReactWrapperTest() {
let reactWrapper: ReactWrapper<MyComponentProps, MyComponentState> =
mount<MyComponentProps, MyComponentState>(<MyComponent stringProp="value"/>);
@@ -631,7 +631,7 @@ namespace ReactWrapperTest {
}
// CheerioWrapper
namespace CheerioWrapperTest {
function CheerioWrapperTest() {
const wrapper: Cheerio =
shallow(<div />).render() ||
mount(<div />).render();
+1 -1
View File
@@ -3,7 +3,7 @@
// Definitions by: Zachary Collins <https://github.com/corps/>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
import { Thrift } from "thrift";
import * as Thrift from 'thrift';
declare namespace Evernote {
interface Callback<T> {
+1 -6
View File
@@ -1,6 +1 @@
{
"extends": "dtslint/dt.json",
"rules": {
"only-arrow-functions-2": false
}
}
{ "extends": "dtslint/dt.json" }
File diff suppressed because it is too large Load Diff
+10
View File
@@ -0,0 +1,10 @@
import FuzzySet = require('fuzzyset');
const fuzzyset: FuzzySet = FuzzySet(['coucou', 'foo', 'bar', 'toto']);
const results = fuzzyset.get('foo');
fuzzyset.length();
fuzzyset.isEmpty();
fuzzyset.values();
+17
View File
@@ -0,0 +1,17 @@
// Type definitions for fuzzset 1.0
// Project: https://github.com/washt/fuzzyset
// Definitions by: Louis Grignon <https://github.com/lgrignon>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
interface FuzzySet {
get(candidate: string): Array<[number, string]>;
add(value: string): boolean;
length(): number;
isEmpty(): boolean;
values(): string[];
}
declare function FuzzySet(source: string[], useLevenshtein?: boolean, gramSizeLower?: number, gramSizeUpper?: number): FuzzySet;
export = FuzzySet;
export as namespace FuzzySet;
+22
View File
@@ -0,0 +1,22 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"fuzzyset-tests.ts"
]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }
+11
View File
@@ -0,0 +1,11 @@
import * as Hls from 'hls.js';
if (Hls.isSupported) {
const video = <HTMLVideoElement> document.getElementById('video');
const hls = new Hls();
hls.loadSource('http://www.streambox.fr/playlists/test_001/stream.m3u8');
hls.attachMedia(video);
hls.on(Hls.Events.MANIFEST_PARSED, () => {
video.play();
});
}
+1253
View File
File diff suppressed because it is too large Load Diff
+23
View File
@@ -0,0 +1,23 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6",
"dom"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"hls.js-tests.ts"
]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }
+5 -1
View File
@@ -662,7 +662,11 @@ declare module IORedis {
*/
enableReadyCheck?: boolean;
keyPrefix?: string;
retryStrategy?: (times: number) => number;
/**
* When the return value isn't a number, ioredis will stop trying to reconnect.
* Fixed in: https://github.com/DefinitelyTyped/DefinitelyTyped/pull/15858
*/
retryStrategy?: (times: number) => number | false;
reconnectOnError?: (error: Error) => boolean;
/**
* By default, if there is no active connection to the Redis server, commands are added to a queue
+2 -1
View File
@@ -29,7 +29,8 @@ new Redis({
host: '127.0.0.1', // Redis host
family: 4, // 4 (IPv4) or 6 (IPv6)
password: 'auth',
db: 0
db: 0,
retryStrategy: function() { return false; }
})
var pub = new Redis();
+8 -4
View File
@@ -1,6 +1,6 @@
// Type definitions for joi v10.0.0
// Type definitions for joi v10.3.0
// Project: https://github.com/hapijs/joi
// Definitions by: Bart van der Schoor <https://github.com/Bartvds>, Laurence Dougal Myers <https://github.com/laurence-myers>, Christopher Glantschnig <https://github.com/cglantschnig>, David Broder-Rodgers <https://github.com/DavidBR-SW>, Gael Magnan de Bornier <hhttps://github.com/GaelMagnan>, Rytis Alekna <hhttps://github.com/ralekna>
// Definitions by: Bart van der Schoor <https://github.com/Bartvds>, Laurence Dougal Myers <https://github.com/laurence-myers>, Christopher Glantschnig <https://github.com/cglantschnig>, David Broder-Rodgers <https://github.com/DavidBR-SW>, Gael Magnan de Bornier <https://github.com/GaelMagnan>, Rytis Alekna <https://github.com/ralekna>, Pavel Ivanov <https://github.com/schfkt>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TODO express type of Schema in a type-parameter (.default, .valid, .example etc)
@@ -25,9 +25,13 @@ export interface ValidationOptions {
*/
skipFunctions?: boolean;
/**
* when true, unknown keys are deleted (only when value is an object). Defaults to false.
* remove unknown elements from objects and arrays. Defaults to false
* - when true, all unknown elements will be removed
* - when an object:
* - arrays - set to true to remove unknown items from arrays.
* - objects - set to true to remove unknown keys from objects
*/
stripUnknown?: boolean;
stripUnknown?: boolean | {arrays: boolean} | {objects: boolean} | {arrays: boolean; objects: boolean};
/**
* overrides individual error messages. Defaults to no override ({}).
*/
+3
View File
@@ -55,6 +55,9 @@ validOpts = {convert: bool};
validOpts = {allowUnknown: bool};
validOpts = {skipFunctions: bool};
validOpts = {stripUnknown: bool};
validOpts = {stripUnknown: {arrays: bool}};
validOpts = {stripUnknown: {objects: bool}};
validOpts = {stripUnknown: {arrays: bool, objects: bool}};
validOpts = {language: bool};
validOpts = {presence: str};
validOpts = {context: obj};
+543
View File
@@ -0,0 +1,543 @@
// Type definitions for jweixin 1.0
// Project: https://mp.weixin.qq.com/wiki/11/74ad127cc054f6b80759c40f77ec03db.html
// Definitions by: taoqf <https://github.com/taoqf>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/* =================== USAGE ===================
import * as wx from 'jweixin';
wx.config(...);
or
import { config } from 'jweixin';
config();
=============================================== */
declare namespace wx {
type ImageSizeType = 'original' | 'compressed';
type ImageSourceType = 'album' | 'camera';
type VideoSourceType = 'album' | 'camera';
type ApiMethod = 'onMenuShareTimeline' |
'onMenuShareAppMessage' |
'onMenuShareQQ' |
'onMenuShareWeibo' |
'onMenuShareQZone' |
'startRecord' |
'stopRecord' |
'onVoiceRecordEnd' |
'playVoice' |
'pauseVoice' |
'stopVoice' |
'onVoicePlayEnd' |
'uploadVoice' |
'downloadVoice' |
'chooseImage' |
'previewImage' |
'uploadImage' |
'downloadImage' |
'translateVoice' |
'getNetworkType' |
'openLocation' |
'getLocation' |
'hideOptionMenu' |
'showOptionMenu' |
'hideMenuItems' |
'showMenuItems' |
'hideAllNonBaseMenuItem' |
'showAllNonBaseMenuItem' |
'closeWindow' |
'scanQRCode' |
'chooseWXPay' |
'openProductSpecificView' |
'addCard' |
'chooseCard' |
'openCard';
// 所有JS接口列表
type jsApiList = ApiMethod[];
// 所有菜单项列表
// 基本类
type menuBase = "menuItem:exposeArticle" | // 举报
"menuItem:setFont" | // 调整字体
"menuItem:dayMode" | // 日间模式
"menuItem:nightMode" | // 夜间模式
"menuItem:refresh" | // 刷新
"menuItem:profile" | // 查看公众号(已添加)
"menuItem:addContact"; // 查看公众号(未添加)
// 传播类
type menuShare = "menuItem:share:appMessage" | // 发送给朋友
"menuItem:share:timeline" | // 分享到朋友圈
"menuItem:share:qq" | // 分享到QQ
"menuItem:share:weiboApp" | // 分享到Weibo
"menuItem:favorite" | // 收藏
"menuItem:share:facebook" | // 分享到FB
"menuItem:share:QZone"; // 分享到 QQ 空间
// 保护类
type menuProtected = "menuItem:editTag" | // 编辑标签
"menuItem:delete" | // 删除
"menuItem:copyUrl" | // 复制链接
"menuItem:originPage" | // 原网页
"menuItem:readMode" | // 阅读模式
"menuItem:openWithQQBrowser" | // 在QQ浏览器中打开
"menuItem:openWithSafari" | // 在Safari中打开
"menuItem:share:email" | // 邮件
"menuItem:share:brand"; // 一些特殊公众号
type menuList = Array<menuBase | menuProtected | menuShare>;
function config(conf: {
debug?: boolean; // 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印。
appId: string; // 必填,公众号的唯一标识
timestamp: number; // 必填,生成签名的时间戳
nonceStr: string; // 必填,生成签名的随机串
signature: string; // 必填,签名,见附录1
jsApiList: jsApiList; // 必填,需要使用的JS接口列表,所有JS接口列表见附录2
}): void;
interface Resouce {
localId: string;
}
interface BaseParams {
success?(...args: any[]): void;
/** 接口调用失败的回调函数 */
fail?(...args: any[]): void;
/** 接口调用结束的回调函数(调用成功、失败都会执行) */
complete?(...args: any[]): void;
}
function ready(fn: () => void): void;
function error(fn: (err: { errMsg: string; }) => void): void;
interface IcheckJsApi extends BaseParams {
jsApiList: jsApiList; // 需要检测的JS接口列表,所有JS接口列表见附录2,
// 以键值对的形式返回,可用的api值true,不可用为false
// 如:{"checkResult":{"chooseImage":true},"errMsg":"checkJsApi:ok"}
success(res: { checkResult: { [api: string]: boolean }, errMsg: string; }): void;
}
/**
* JS接口
* checkJsApi接口是客户端6.0.2使checkJsApi来检测
*/
function checkJsApi(params: IcheckJsApi): void;
interface IonMenuShareTimeline extends BaseParams {
title: string; // 分享标题
link: string; // 分享链接
imgUrl: string; // 分享图标
// 用户确认分享后执行的回调函数
success(): void;
// 用户取消分享后执行的回调函数
cancel(): void;
}
/*=============================基础接口================================*/
/**
*
*/
function onMenuShareTimeline(params: IonMenuShareTimeline): void;
interface IonMenuShareAppMessage extends BaseParams {
title: string; // 分享标题
desc: string; // 分享描述
link: string; // 分享链接
imgUrl: string; // 分享图标
type?: 'music' | 'video或link' | 'link'; // 分享类型,music、video或link,不填默认为link
dataUrl?: string; // 如果type是music或video,则要提供数据链接,默认为空
// 用户确认分享后执行的回调函数
success(): void;
// 用户取消分享后执行的回调函数
cancel(): void;
}
/**
*
*/
function onMenuShareAppMessage(params: IonMenuShareAppMessage): void;
interface IonMenuShareQQ extends BaseParams {
title: string; // 分享标题
desc: string; // 分享描述
link: string; // 分享链接
imgUrl: string; // 分享图标
// 用户确认分享后执行的回调函数
success(): void;
// 用户取消分享后执行的回调函数
cancel(): void;
}
/**
* QQ
*/
function onMenuShareQQ(params: IonMenuShareQQ): void;
interface IonMenuShareWeibo extends BaseParams {
title: string; // 分享标题
desc: string; // 分享描述
link: string; // 分享链接
imgUrl: string; // 分享图标
// 用户确认分享后执行的回调函数
success(): void;
// 用户取消分享后执行的回调函数
cancel(): void;
}
/**
*
*/
function onMenuShareWeibo(params: IonMenuShareWeibo): void;
interface IonMenuShareQZone extends BaseParams {
title: string; // 分享标题
desc: string; // 分享描述
link: string; // 分享链接
imgUrl: string; // 分享图标
// 用户确认分享后执行的回调函数
success(): void;
// 用户取消分享后执行的回调函数
cancel(): void;
}
/**
* QQ空间
*/
function onMenuShareQZone(params: IonMenuShareQZone): void;
/*=============================基础接口================================*/
/*=============================图像接口================================*/
interface IchooseImage extends BaseParams {
/** 最多可以选择的图片张数,默认9 */
count?: number;
/** original 原图,compressed 压缩图,默认二者都有 */
sizeType?: ImageSizeType[];
/** album 从相册选图,camera 使用相机,默认二者都有 */
sourceType?: ImageSourceType[];
/** 成功则返回图片的本地文件路径列表 tempFilePaths */
success(res: {
sourceType: string; // weixin album camera
localIds: string[];
errMsg: string;
}): void;
}
/**
* 使
*/
function chooseImage(params: IchooseImage): void;
interface IpreviewImage extends BaseParams {
current: string; // 当前显示图片的http链接
urls: string[]; // 需要预览的图片http链接列表
}
/**
*
*/
function previewImage(params: IpreviewImage): void;
interface IuploadImage extends BaseParams {
localId: string; // 需要上传的图片的本地ID,由chooseImage接口获得
isShowProgressTips: number; // 默认为1,显示进度提示
// 返回图片的服务器端ID
success(res: { serverId: string }): void;
}
/**
*
*/
function uploadImage(params: IuploadImage): void;
interface IdownloadImage extends BaseParams {
serverId: string; // 需要下载的图片的服务器端ID,由uploadImage接口获得
isShowProgressTips: number; // 默认为1,显示进度提示
// 返回图片下载后的本地ID
success(res: Resouce): void;
}
/**
*
*/
function downloadImage(params: IdownloadImage): void;
/*=============================图像接口================================*/
/*=============================音频接口================================*/
/**
*
*/
function startRecord(): void;
interface IstopRecord extends BaseParams {
success(res: Resouce): void;
}
/**
*
*/
function stopRecord(params: IstopRecord): void;
interface IonVoiceRecordEnd extends BaseParams {
// 录音时间超过一分钟没有停止的时候会执行 complete 回调
complete(res: Resouce): void;
}
/**
*
*/
function onVoiceRecordEnd(params: IonVoiceRecordEnd): void;
interface IplaypausestopVoice extends BaseParams {
localId: string; // 需要播放的音频的本地ID,由stopRecord接口获得
}
/**
*
*/
function playVoice(params: IplaypausestopVoice): void;
/**
*
*/
function pauseVoice(params: IplaypausestopVoice): void;
/**
*
*/
function stopVoice(params: IplaypausestopVoice): void;
interface IonVoicePlayEnd extends BaseParams {
success(res: Resouce): void;
}
/**
*
*/
function onVoicePlayEnd(params: IonVoicePlayEnd): void;
interface IupdownloadVoice extends BaseParams {
localId: string; // 需要上传的音频的本地ID,由stopRecord接口获得
isShowProgressTips: number; // 默认为1,显示进度提示
success(res: Resouce): void;
}
/**
*
* 3
* serverId media_id
* ../12 / 58bfcfabbd501c7cd77c19bd9cfa8354.html
* 10000/
* weixin - open@qq.com,
*
* 使
*/
function uploadVoice(params: IupdownloadVoice): void;
/**
*
*/
function downloadVoice(params: IupdownloadVoice): void;
/*=============================音频接口================================*/
/*=============================智能接口================================*/
interface ItranslateVoice extends BaseParams {
localId: string; // 需要识别的音频的本地Id,由录音相关接口获得
isShowProgressTips: number; // 默认为1,显示进度提示
success(res: {
translateResult: string;
}): void;
}
/**
*
*/
function translateVoice(params: ItranslateVoice): void;
/*=============================智能接口================================*/
/*=============================设备信息================================*/
type networkType = '2g' | '3g' | '4g' | 'wifi';
interface IgetNetworkType extends BaseParams {
success(res: { networkType: networkType }): void;
}
/**
*
*/
function getNetworkType(params: IgetNetworkType): void;
/*=============================设备信息================================*/
/*=============================地理位置================================*/
interface IopenLocation extends BaseParams {
latitude: number; // 纬度,浮点数,范围为90 ~ -90
longitude: number; // 经度,浮点数,范围为180 ~ -180。
name: string; // 位置名
address: string; // 地址详情说明
scale: number; // 地图缩放级别,整形值,范围从1~28。默认为最大
infoUrl: string; // 在查看位置界面底部显示的超链接,可点击跳转
}
/**
* 使
*/
function openLocation(params: IopenLocation): void;
interface IgetLocation extends BaseParams {
type: 'wgs84' | 'gcj02'; // 默认为wgs84的gps坐标,如果要返回直接给openLocation用的火星坐标,可传入'gcj02'
success(res: {
latitude: number; // 纬度,浮点数,范围为90 ~ -90
longitude: number; // 经度,浮点数,范围为180 ~ -180。
speed: number; // 速度,以米/每秒计
accuracy: number; // 位置精度
}): void;
}
/**
*
*/
function getLocation(params: IgetLocation): void;
/*=============================地理位置================================*/
/*=============================摇一摇周边================================*/
interface IstartSearchBeacons extends BaseParams {
ticket: string; // 摇周边的业务ticket, 系统自动添加在摇出来的页面链接后面
// 开启查找完成后的回调函数
complete(argv: any): void;
}
/**
* ibeacon设备接口
*
*/
function startSearchBeacons(params: IstartSearchBeacons): void;
interface IstopSearchBeacons extends BaseParams {
// 关闭查找完成后的回调函数
complete(res: any): void;
}
/**
* ibeacon设备接口
*/
function stopSearchBeacons(params: IstopSearchBeacons): void;
interface IonSearchBeacons extends BaseParams {
// 回调函数,可以数组形式取得该商家注册的在周边的相关设备列表
complete(argv: any): void;
}
/**
* ibeacon设备接口
*/
function onSearchBeacons(params: IonSearchBeacons): void;
/*=============================摇一摇周边================================*/
/*=============================界面操作================================*/
/**
*
*/
function hideOptionMenu(): void;
/**
*
*/
function showOptionMenu(): void;
/**
*
*/
function closeWindow(): void;
interface IhideMenuItems extends BaseParams {
menuList: Array<menuProtected | menuShare>; // 要隐藏的菜单项,只能隐藏“传播类”和“保护类”按钮,所有menu项见附录3
}
/**
*
*/
function hideMenuItems(): void;
interface IshowMenuItems extends BaseParams {
menuList: menuList; // 要显示的菜单项,所有menu项见附录3
}
/**
*
*/
function showMenuItems(params: IshowMenuItems): void;
/**
*
* 3
*/
function hideAllNonBaseMenuItem(): void;
/**
*
*/
function showAllNonBaseMenuItem(): void;
/*=============================界面操作================================*/
/*=============================微信扫一扫================================*/
type scanType = "qrCode" | "barCode";
interface IscanQRCode extends BaseParams {
needResult: 0 | 1; // 默认为0,扫描结果由微信处理,1则直接返回扫描结果,
scanType: scanType[]; // 可以指定扫二维码还是一维码,默认二者都有
// 当needResult 为 1 时,扫码返回的结果
success(res: { resultStr: string; }): void;
}
/**
*
*/
function scanQRCode(params: IscanQRCode): void;
/*=============================微信扫一扫================================*/
/*=============================微信小店================================*/
interface IopenProductSpecificView extends BaseParams {
productId: string; // 商品id
viewType: '0' | '1' | '2'; // 0.默认值,普通商品详情页1.扫一扫商品详情页2.小店商品详情页
}
/**
*
*/
function openProductSpecificView(params: IopenProductSpecificView): void;
/*=============================微信卡券================================*/
interface IchooseCard extends BaseParams {
shopId: string; // 门店Id
cardType: string; // 卡券类型
cardId: string; // 卡券Id
timestamp: number; // 卡券签名时间戳
nonceStr: string; // 卡券签名随机串
signType: string; // 签名方式,默认'SHA1'
cardSign: string; // 卡券签名
success(res: {
cardList: string[];
}): void;
}
/**
*
*/
function chooseCard(params: IchooseCard): void;
interface IaddCard extends BaseParams {
cardList: Array<{
cardId: string;
cardExt: string;
}>; // 需要添加的卡券列表
success(res: { cardList: string[]; }): void;
}
/**
*
*/
function addCard(): void;
interface IopenCard extends BaseParams {
cardList: Array<{
cardId: string;
code: string;
}>; // 需要打开的卡券列表
}
/**
*
*/
function openCard(params: IopenCard): void;
interface IconsumeAndShareCard extends BaseParams {
cardId: string;
code: string;
}
/**
*
*/
function consumeAndShareCard(params: IconsumeAndShareCard): void;
/*=============================微信卡券================================*/
/*=============================微信支付================================*/
interface IchooseWXPay extends BaseParams {
timestamp: number; // 支付签名时间戳,注意微信jssdk中的所有使用timestamp字段均为小写。但最新版的支付后台生成签名使用的timeStamp字段名需大写其中的S字符
nonceStr: string; // 支付签名随机串,不长于 32 位
package: string; // 统一支付接口返回的prepay_id参数值,提交格式如:prepay_id=***
signType: string; // 签名方式,默认为'SHA1',使用新版支付需传入'MD5'
paySign: string; // 支付签名
// 支付成功后的回调函数
success(res: any): void;
}
/**
*
*/
function chooseWXPay(params: IchooseWXPay): void;
/*=============================微信支付================================*/
}
declare function wx(): void;
export = wx;
+9
View File
@@ -0,0 +1,9 @@
import { scanQRCode } from 'jweixin';
scanQRCode({
needResult: 0,
scanType: ['qrCode'],
success(res) {
console.log(res);
}
});
+23
View File
@@ -0,0 +1,23 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6",
"dom"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"jweixin-tests.ts"
]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }
+12
View File
@@ -0,0 +1,12 @@
// Type definitions for karma-chai 0.1
// Project: http://xdissent.github.io/karma-chai
// Definitions by: Jay Sherby <https://github.com/JayAndCatchFire>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
import chai = require('chai');
declare global {
var assert: Chai.AssertStatic;
var expect: Chai.ExpectStatic;
var should: Chai.Should;
}
+3
View File
@@ -0,0 +1,3 @@
true.should.be.ok;
expect(true).to.be.ok;
assert.isTrue(true);
+22
View File
@@ -0,0 +1,22 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"karma-chai-tests.ts"
]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }

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