Merge branch 'master' of github.com:nishantkyal/DefinitelyTyped

This commit is contained in:
Nishant Kyal
2017-09-21 14:23:11 +05:30
1263 changed files with 188126 additions and 25654 deletions

View File

@@ -88,6 +88,7 @@ First, [fork](https://guides.github.com/activities/forking/) this repository, in
* `cd types/my-package-to-edit`
* Make changes. Remember to edit tests.
* You may also want to add yourself to "Definitions by" section of the package header.
- This will cause you to be notified (via your GitHub username) whenever someone makes a pull request or issue about the package.
- Do this by adding your name to the end of the line, as in `// Definitions by: Alice <https://github.com/alice>, Bob <https://github.com/bob>`.
- Or if there are more people, it can be multiline
```typescript
@@ -144,6 +145,10 @@ For a good example package, see [base64-js](https://github.com/DefinitelyTyped/D
Example where a type parameter is acceptable: `function id<T>(value: T): T;`.
Example where it is not acceptable: `function parseJson<T>(json: string): T;`.
Exception: `new Map<string, number>()` is OK.
* Using the types `Function` and `Object` is almost never a good idea. In 99% of cases it's possible to specify a more specific type. Examples are `(x: number) => number` for [functions](http://www.typescriptlang.org/docs/handbook/functions.html#function-types) and `{ x: number, y: number }` for objects. If there is no certainty at all about the type, [`any`](http://www.typescriptlang.org/docs/handbook/basic-types.html#any) is the right choice, not `Object`. If the only known fact about the type is that it's some object, use the type [`object`](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-2.html#object-type), not `Object` or `{ [key: string]: any }`.
* `var foo: string | any`:
When `any` is used in a union type, the resulting type is still `any`. So while the `string` portion of this type annotation may _look_ useful, it in fact offers no additional typechecking over simply using `any`.
Depending on the intention, acceptable alternatives could be `any`, `string`, or `string | object`.
#### Removing a package
@@ -199,7 +204,14 @@ This script uses [dtslint](https://github.com/Microsoft/dtslint).
#### What exactly is the relationship between this repository and the `@types` packages on NPM?
The `master` branch is automatically published to the `@types` scope on NPM thanks to [types-publisher](https://github.com/Microsoft/types-publisher).
This usually happens within an hour of changes being merged.
#### I've submitted a pull request. How long until it is merged?
It depends, but most pull requests will be merged within a week. PRs that have been approved by an author listed in the definition's header are usually merged more quickly; PRs for new definitions will take more time as they require more review from maintainers. Each PR is reviewed by a TypeScript or DefinitelyTyped team member before being merged, so please be patient as human factors may cause delays. Check the [PR Burndown Board](https://github.com/DefinitelyTyped/DefinitelyTyped/projects/3?card_filter_query=is%3Aopen) to see progress as maintainers work through the open PRs.
#### My PR is merged; when will the `@types` NPM package be updated?
NPM packages should update within a few hours. If it's been more than 24 hours, ping @RyanCavanaugh and @andy-ms on the PR to investigate.
#### I'm writing a definition that depends on another definition. Should I use `<reference types="" />` or an import?
@@ -286,7 +298,7 @@ When `dts-gen` is used to scaffold a scoped package, the `paths` property has to
"@foo/bar": ["foo__bar"]
}
}
```
```
#### The file history in GitHub looks incomplete.

View File

@@ -558,6 +558,12 @@
"sourceRepoURL": "https://github.com/tildeio/route-recognizer",
"asOfVersion": "0.3.0"
},
{
"libraryName": "router5",
"typingsPackageName": "router5",
"sourceRepoURL": "https://github.com/router5/router5",
"asOfVersion": "5.0.0"
},
{
"libraryName": "samchon",
"typingsPackageName": "samchon",

View File

@@ -23,8 +23,5 @@
"devDependencies": {
"dtslint": "github:Microsoft/dtslint#production",
"types-publisher": "Microsoft/types-publisher#production"
},
"dependencies": {
"@egjs/axes": "^2.0.0"
}
}

View File

@@ -39,7 +39,16 @@ function fix(config: any): any {
const out: any = {};
for (const key in config) {
let value = config[key];
out[key] = value;
out[key] = key === "rules" ? fixRules(value) : value;
}
return out;
}
function fixRules(rules: any): any {
const out: any = {};
for (const key in rules) {
out[key] = rules[key];
}
return out;
}

View File

@@ -1,147 +0,0 @@
const {get} = require('https')
const {readdir, readFile, writeFile} = require('fs')
const {join, extname, basename, dirname, relative} = require('path')
const token = process.env.GITHUB_ACCESS_TOKEN || ''
const toMixedCase = (name) => {
let dist = name[0].toUpperCase()
for (let i = 1; i < name.length; i++) {
const c = name[i]
if (c !== '-') {
dist += c
continue
}
i++
dist += name[i].toUpperCase()
}
return dist
}
const github = (path) => new Promise((resolve, reject) => {
get({
headers: {'user-agent': 'DefinitelyTyped/material-ui/generate'},
host: 'api.github.com',
path,
}, (res) => {
if ((res.statusCode / 100 >> 0) != 2) {
reject(`GitHub response: ${res.statusCode} ${res.statusMessage}`)
return
}
let data = '';
res
.on('data', (chunk) => data += chunk)
.on('end', () => resolve(JSON.parse(data)))
}).on('error', reject)
})
const categories = () => github(`/repos/callemall/material-ui/contents/src/svg-icons?ref=master&access_token=${token}`)
const contents = (path) => github(`/repos/callemall/material-ui/contents/${path}?ref=master&access_token=${token}`)
const collator = new Intl.Collator()
const resolvePath = (filename) => join(__dirname, '../../types/material-ui', filename)
const readText = (filename) => new Promise((resolve, reject) => {
readFile(resolvePath(filename), 'utf8', (err, data) => {
if (err != null) {
reject(err)
return
}
resolve(data)
})
})
const writeText = (filename, text) => new Promise((resolve, reject) => {
writeFile(resolvePath(filename), text, 'utf8', (err) => {
if (err != null) {
reject(err)
return
}
resolve()
})
})
const inject = (content) => {
content.category = this.name
return content
}
const rMark = /(\/{2} \{{3})[\s\S]*?(\/{2} \}{3})/g
categories()
.then((cats) => Promise.all(Array.prototype.map.call(cats, (cat) => contents(cat.path)
.then((cons) => Array.prototype.map.call(cons, (con) => {
con.category = cat.name
return con
}))
)))
.then((contentsList) => Array.prototype.concat.apply([], contentsList)
.map((content) => {
const {path} = content
const name = basename(path, extname(path))
content.id = join(relative('src', dirname(path)), name)
content.className = toMixedCase(content.category) + toMixedCase(name)
return content
})
.sort((a, b) => collator.compare(a.id, b.id))
.reduce((prev, content) => {
const {dts, test} = prev
dts.individuals.push(`declare module 'material-ui/${content.id}' {
export import ${content.className} = __MaterialUI.SvgIcon;
export default ${content.className};
}`)
dts.summarizeds.push(` export import ${content.className} = __MaterialUI.SvgIcon; // require('material-ui/${content.id}');`)
test.individuals.push(`import _${content.className} from 'material-ui/${content.id}';`)
test.summarizeds.push(` ${content.className},`)
return prev
}, {
dts: {individuals: [], summarizeds: []},
test: {individuals: [], summarizeds: []},
})
)
.then(({dts, test}) => {
return Promise.all([
(() => {
const {individuals, summarizeds} = dts
const file = 'index.d.ts'
let index = 0
return readText(file)
.then((script) => writeText(file, script.replace(rMark, (_, p1, p2) => {
let text = ''
switch (index) {
case 0:
text = individuals.join('\n\n')
break
case 1:
text = summarizeds.join('\n')
break
}
index++
return p1 + '\n' + text + '\n' + p2
})))
})(),
(() => {
const {individuals, summarizeds} = test
const file = join('material-ui-tests.tsx')
let index = 0
return readText(file)
.then((script) => writeText(file, script.replace(rMark, (_, p1, p2) => {
let text = ''
switch (index) {
case 0:
text = individuals.join('\n')
break
case 1:
text = summarizeds.join('\n')
break
}
index++
return p1 + '\n' + text + '\n' + p2
})))
})(),
])
})
.catch((err) => console.error(err))

View File

@@ -1 +1,6 @@
{ "extends": "dtslint/dt.json" }
{
"extends": "dtslint/dt.json",
"rules": {
"no-any-union": false
}
}

View File

@@ -44,16 +44,14 @@ declare namespace accepts {
/**
* Return the first accepted type (and it is returned as the same text as what appears in the `types` array). If nothing in `types` is accepted, then `false` is returned.
* If no types are supplied, return the entire set of acceptable types.
*
* The `types` array can contain full MIME types or file extensions. Any value that is not a full MIME types is passed to `require('mime-types').lookup`.
*/
type(types: string[]): string | false;
type(...types: string[]): string | false;
/**
* Return the types that the request accepts, in the order of the client's preference (most preferred first).
*/
types(): string[];
type(types: string[]): string[] | string | false;
type(...types: string[]): string[] | string | false;
types(types: string[]): string[] | string | false;
types(...types: string[]): string[] | string | false;
}
}

View File

@@ -50,7 +50,10 @@ interface Acl {
allowedPermissions: (userId: Value, resources: strings, cb?: AnyCallback) => Promise<void>;
isAllowed: (userId: Value, resources: strings, permissions: strings, cb?: AllowedCallback) => Promise<boolean>;
areAnyRolesAllowed: (roles: strings, resource: strings, permissions: strings, cb?: AllowedCallback) => Promise<any>;
whatResources: (roles: strings, permissions: strings, cb?: AnyCallback) => Promise<any>;
whatResources: {
(roles: strings, cb?: AnyCallback): Promise<any>;
(roles: strings, permissions: strings, cb?: AnyCallback): Promise<any>;
}
permittedResources: (roles: strings, permissions: strings, cb?: Function) => Promise<void>;
middleware: (numPathComponents?: number, userId?: Value | GetUserId, actions?: strings) => express.RequestHandler;
}

View File

@@ -66,6 +66,18 @@ acl.isAllowed('joed', 'blogs', 'view', (err, res) => {
}
});
acl.whatResources('foo', (err, res) => {
if (res) {
console.log(res);
}
});
acl.whatResources('foo', 'view', (err, res) => {
if (res) {
console.log(res);
}
});
acl.isAllowed('jsmith', 'blogs', ['edit','view','delete'])
.then((result) => {
console.dir('jsmith is allowed blogs ' + result);

View File

@@ -1 +1,6 @@
{ "dependencies": { "activex-helpers": "*"}}
{
"private": true,
"dependencies": {
"activex-helpers": "*"
}
}

View File

@@ -6,7 +6,6 @@
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strict": true,
"baseUrl": "../",
"typeRoots": [
"../"

View File

@@ -0,0 +1,171 @@
(() => {
// https://wiki.openoffice.org/wiki/Documentation/DevGuide/ProUNO/Bridge/Automation_Bridge
// This is a JScript example
// The service manager is always the starting point
// If there is no office running then an office is started up
const serviceManager = new ActiveXObject('com.sun.star.ServiceManager');
// Create the CoreReflection service that is later used to create structs
const coreReflection = serviceManager.createInstance("com.sun.star.reflection.CoreReflection");
// Create the Desktop
const desktop = serviceManager.defaultContext.getByName('/singleton/com.sun.star.frame.theDesktop');
// Open a new empty writer document
const args: any[] = [];
const document = desktop.loadComponentFromURL("private:factory/swriter", "_blank", 0, args); // as com.sun.star.text.TextDocument;
// Create a text object
const text = document.Text;
// Create a cursor object
const cursor = (text.createTextCursor() as any) as com.sun.star.text.TextCursor;
// Inserting some Text
text.insertString(cursor, "The first line in the newly created text document.\n", false);
// Inserting a second line
text.insertString(cursor, "Now we're in the second line", false);
// Create instance of a text table with 4 columns and 4 rows
const table = document.createInstance("com.sun.star.text.TextTable");
table.initialize(4, 4);
// Insert the table
text.insertTextContent(cursor, table, false);
// Get first row
const rows = table.Rows;
const row = rows.getByIndex(0) as com.sun.star.table.TableRow;
// Set the table background color
((table as any) as com.sun.star.beans.XPropertySet).setPropertyValue("BackTransparent", false);
((table as any) as com.sun.star.beans.XPropertySet).setPropertyValue("BackColor", 13421823);
// Set a different background color for the first row
row.setPropertyValue("BackTransparent", false);
row.setPropertyValue("BackColor", 6710932);
// Fill the first table row
insertIntoCell("A1", "FirstColumn", table); // insertIntoCell is a helper function, see below
insertIntoCell("B1", "SecondColumn", table);
insertIntoCell("C1", "ThirdColumn", table);
insertIntoCell("D1", "SUM", table);
table.getCellByName("A2").setValue(22.5);
table.getCellByName("B2").setValue(5615.3);
table.getCellByName("C2").setValue(-2315.7);
table.getCellByName("D2").setFormula("sum ");
table.getCellByName("A3").setValue(21.5);
table.getCellByName("B3").setValue(615.3);
table.getCellByName("C3").setValue(- 315.7);
table.getCellByName("D3").setFormula("sum ");
table.getCellByName("A4").setValue(121.5);
table.getCellByName("B4").setValue(-615.3);
table.getCellByName("C4").setValue(415.7);
table.getCellByName("D4").setFormula("sum ");
// Change the CharColor and add a Shadow
cursor.setPropertyValue("CharColor", 255);
cursor.setPropertyValue("CharShadowed", true);
// Create a paragraph break
// The second argument is a com::sun::star::text::ControlCharacter::PARAGRAPH_BREAK constant
text.insertControlCharacter(cursor, 0, false);
// Inserting colored Text.
text.insertString(cursor, " This is a colored Text - blue with shadow\n", false);
// Create a paragraph break ( ControlCharacter::PARAGRAPH_BREAK).
text.insertControlCharacter(cursor, 0, false);
// Create a TextFrame.
const textFrame = document.createInstance("com.sun.star.text.TextFrame");
// Create a Size struct.
const size = createStruct("com.sun.star.awt.Size"); // helper function, see below
size.Width = 15000;
size.Height = 400;
textFrame.setSize(size);
// TextContentAnchorType.AS_CHARACTER = 1
textFrame.setPropertyValue("AnchorType", com.sun.star.text.TextContentAnchorType.AS_CHARACTER);
// insert the frame
text.insertTextContent(cursor, textFrame, false);
// Get the text object of the frame
const objFrameText = textFrame.Text;
// Create a cursor object
const objFrameTextCursor = objFrameText.createTextCursor();
// Inserting some Text
objFrameText.insertString(objFrameTextCursor, "The first line in the newly created text frame.", false);
objFrameText.insertString(objFrameTextCursor, "\nWith this second line the height of the frame raises.", false);
// Create a paragraph break
// The second argument is a com::sun::star::text::ControlCharacter::PARAGRAPH_BREAK constant
objFrameText.insertControlCharacter(cursor, 0, false);
// Change the CharColor and add a Shadow
cursor.setPropertyValue("CharColor", 65536);
cursor.setPropertyValue("CharShadowed", false);
// Insert another string
text.insertString(cursor, " That's all for now !!", false);
function insertIntoCell(strCellName: string, strText: string, objTable: com.sun.star.text.TextTable) {
const objCellText = objTable.getCellByName(strCellName) as com.sun.star.table.Cell;
const objCellCursor = (objCellText.createTextCursor() as any) as com.sun.star.text.TextCursor;
objCellCursor.setPropertyValue("CharColor", 16777215);
objCellText.insertString(objCellCursor, strText, false);
}
function createStruct<K extends keyof LibreOffice.StructNameMap>(strTypeName: K): LibreOffice.StructNameMap[K] {
const classSize = coreReflection.forName(strTypeName);
const aStruct: [LibreOffice.StructNameMap[K]] = [] as any;
classSize.createObject(aStruct);
return aStruct[0];
}
})();
(() => {
// This shows some specific features of the Automation bridge
const serviceManager = new ActiveXObject('com.sun.star.ServiceManager');
// singleton access
const desktop = serviceManager.defaultContext.getByName('/singleton/com.sun.star.frame.theDesktop');
// defaultContext property implements XNameAccess
// sequence is returned as a safearray
const elementNames = new VBArray(serviceManager.defaultContext.getElementNames()).toArray().join('\n');
WScript.Echo(elementNames);
// get/set methods exposed as properties -- getText => Text, getViewData/setViewData => ViewData
const document = desktop.loadComponentFromURL("private:factory/swriter", "_blank", 0, []);
const viewData = document.ViewData;
WScript.Echo(viewData.Count);
const text = document.Text;
WScript.Echo(text);
})();
(() => {
// Forces use of tuple type for out parameters
// Instantiating via reflection
const serviceManager = new ActiveXObject('com.sun.star.ServiceManager');
const coreReflection = serviceManager.defaultContext.getByName('/singleton/com.sun.star.reflection.theCoreReflection');
const classInfo = coreReflection.forName('com.sun.star.accessibility.Accessible');
const accessible: [com.sun.star.accessibility.XAccessible] = [] as any;
classInfo.createObject(accessible);
accessible[0].acquire();
// Get a struct via Bridge_GetStruct
const size = serviceManager.Bridge_GetStruct('com.sun.star.awt.Size');
size.Height = 110;
size.Width = 120;
})();

105882
types/activex-libreoffice/index.d.ts vendored Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,21 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": ["es5", "scripthost"],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"activex-libreoffice-tests.ts"
]
}

View File

@@ -0,0 +1,8 @@
{
"extends": "dtslint/dt.json",
"rules": {
"interface-name": [false],
"ban-types": false,
"no-unnecessary-qualifier": false
}
}

View File

@@ -1 +1,6 @@
{ "dependencies": { "activex-helpers": "*"}}
{
"private": true,
"dependencies": {
"activex-helpers": "*"
}
}

View File

@@ -6,7 +6,6 @@
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strict": true,
"baseUrl": "../",
"typeRoots": [
"../"

View File

@@ -1 +1,6 @@
{ "dependencies": { "activex-helpers": "*"}}
{
"private": true,
"dependencies": {
"activex-helpers": "*"
}
}

View File

@@ -6,7 +6,6 @@
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strict": true,
"baseUrl": "../",
"typeRoots": [
"../"

13
types/adal/index.d.ts vendored
View File

@@ -8,7 +8,8 @@ declare var AuthenticationContext: adal.AuthenticationContextStatic;
declare var Logging: adal.Logging;
declare module 'adal' {
export = { AuthenticationContext, Logging };
export const AuthenticationContext: adal.AuthenticationContextStatic;
export const Logging: adal.Logging;
}
declare namespace adal {
@@ -47,15 +48,15 @@ declare namespace adal {
stateResponse: string;
requestType: string;
}
interface Logging {
log: (message: string) => void;
level: LoggingLevel;
}
enum LoggingLevel {
ERROR = 0,
WARNING = 1,
WARNING = 1,
INFO = 2,
VERBOSE = 3
}
@@ -67,7 +68,7 @@ declare namespace adal {
interface AuthenticationContext {
instance: string;
config: Config;
config: Config;
/**
* Gets initial Idtoken for the app backend
@@ -162,7 +163,7 @@ declare namespace adal {
getResourceForEndpoint(endpoint: string): string;
/**
* Handles redirection after login operation.
* Handles redirection after login operation.
* Gets access token from url and saves token to the (local/session) storage
* or saves error in case unsuccessful login.
*/

View File

@@ -20,11 +20,11 @@ namespace AdoneRootTests {
{ const a: object = adone.o({}); }
{ const a: typeof Date = adone.Date; }
{ const a: typeof process.hrtime = adone.hrtime; }
{ const a: typeof setTimeout = adone.setTimeout; }
{ const a: typeof global.setTimeout = adone.setTimeout; }
{ const a: typeof clearTimeout = adone.clearTimeout; }
{ const a: typeof setInterval = adone.setInterval; }
{ const a: typeof clearInterval = adone.clearInterval; }
{ const a: typeof setImmediate = adone.setImmediate; }
{ const a: typeof global.setImmediate = adone.setImmediate; }
{ const a: typeof clearImmediate = adone.clearImmediate; }
adone.lazify({});
adone.lazify({}, {});

View File

@@ -5,9 +5,11 @@
"align": false,
"no-namespace": false,
"strict-export-declare-modifiers": false,
"no-any-union": false,
"no-boolean-literal-compare": false,
"no-mergeable-namespace": false,
"no-single-declare-module": false,
"no-unnecessary-generics": false,
"no-unnecessary-qualifier": false,
"unified-signatures": false,
"space-before-function-paren": false

View File

@@ -1,25 +1,25 @@
{
"compilerOptions": {
"baseUrl": "..",
"lib": [
"es5",
"dom",
"es2015.iterable",
"es2015.promise"
],
"module": "commonjs",
"noImplicitAny": true,
"noImplicitThis": true,
"removeComments": false,
"sourceMap": true,
"strictNullChecks": true,
"noEmit": true,
"forceConsistentCasingInFileNames": true,
"typeRoots": [ "../" ],
"types": [ ]
"module": "commonjs",
"lib": [
"es5",
"dom",
"es2015.iterable",
"es2015.promise"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"aframe-tests.ts"
"index.d.ts",
"aframe-tests.ts"
]
}
}

View File

@@ -1,3 +1,6 @@
{
"extends": "dtslint/dt.json"
"extends": "dtslint/dt.json",
"rules": {
"no-unnecessary-generics": false
}
}

View File

@@ -3,16 +3,16 @@ import * as Agenda from "agenda";
var mongoConnectionString = "mongodb://127.0.0.1/agenda";
var agenda = new Agenda({ db: { address: mongoConnectionString } });
agenda.define('delete old users', (job, done) => {
});
agenda.on('ready', () => {
agenda.every('3 minutes', 'delete old users');
// Alternatively, you could also do:
// Alternatively, you could also do:
agenda.every('*/3 * * * *', 'delete old users');
agenda.start();
@@ -81,6 +81,8 @@ agenda.stop(function() {
process.exit(0);
});
job.agenda.now('do the hokey pokey');
job.repeatEvery('10 minutes');
job.repeatAt('3:30pm');

View File

@@ -1,4 +1,4 @@
// Type definitions for Agenda v0.8.9
// Type definitions for Agenda v1.0.0
// Project: https://github.com/rschmukler/agenda
// Definitions by: Meir Gottlieb <https://github.com/meirgottlieb>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
@@ -337,6 +337,11 @@ declare namespace Agenda {
*/
attrs: JobAttributes;
/**
* The agenda that created the job.
*/
agenda: Agenda;
/**
* Specifies an interval on which the job should repeat.
* @param interval A human-readable format String, a cron format String, or a Number.

View File

@@ -98,10 +98,34 @@ export interface Request {
locale?: string;
}
export interface ResolutionStatus {
code: string;
}
export interface ResolutionValue {
name: string;
id: string;
}
export interface ResolutionValueContainer {
value: ResolutionValue;
}
export interface Resolution {
authority: string;
status: ResolutionStatus;
values: ResolutionValueContainer[];
}
export interface Resolutions {
resolutionsPerAuthority: Resolution[];
}
export interface SlotValue {
confirmationStatus?: ConfirmationStatuses;
name: string;
value?: any;
resolutions?: Resolutions;
}
export interface Intent {

View File

@@ -1,4 +1,5 @@
{
"private": true,
"dependencies": {
"moment": ">=2.14.0"
}

View File

@@ -6,7 +6,8 @@
import * as angular from "angular";
export default "gridster";
declare const exportedString: "gridster";
export default exportedString;
declare module "angular" {
namespace gridster {

View File

@@ -1,5 +1,4 @@
var app = angular.module('testModule', ['angular-loading-bar']);
class TestController {
@@ -19,5 +18,8 @@ barConfig.push({
includeSpinner: true,
includeBar: true,
spinnerTemplate: 'template',
latencyThreshold: 100
latencyThreshold: 100,
startSize: 0.02,
loadingBarTemplate: '',
autoIncrement: true
});

View File

@@ -1,6 +1,7 @@
// Type definitions for angular-loading-bar
// Project: https://github.com/chieffancypants/angular-loading-bar
// Definitions by: Stephen Lautier <https://github.com/stephenlautier>
// Definitions by: Stephen Lautier <https://github.com/stephenlautier>
// Tyrone Dougherty <https://github.com/tyronedougherty>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.3
@@ -9,40 +10,55 @@
import * as angular from 'angular';
declare module 'angular' {
export namespace loadingBar {
export namespace loadingBar {
interface ILoadingBarProvider {
/**
* Turn the spinner on or off
*/
includeSpinner?: boolean;
interface ILoadingBarProvider {
/**
* Turn the spinner on or off
*/
includeSpinner?: boolean;
/**
* Turn the loading bar on or off
*/
includeBar?: boolean;
/**
* Turn the loading bar on or off
*/
includeBar?: boolean;
/**
* HTML template
*/
spinnerTemplate?: string;
/**
* HTML template
*/
spinnerTemplate?: string;
/**
* Latency Threshold
*/
latencyThreshold?: number;
/**
* HTML element selector of parent
*/
parentSelector?: string;
}
}
/**
* Loading bar template
*/
loadingBarTemplate?: string;
interface IRequestShortcutConfig {
/**
* Indicates that the loading bar should be hidden.
*/
ignoreLoadingBar?: boolean;
}
/**
* Latency Threshold
*/
latencyThreshold?: number;
/**
* HTML element selector of parent
*/
parentSelector?: string;
/**
* Starting size
*/
startSize?: number;
/**
* Give illusion that there's always progress
*/
autoIncrement?: boolean;
}
}
interface IRequestShortcutConfig {
/**
* Indicates that the loading bar should be hidden.
*/
ignoreLoadingBar?: boolean;
}
}

View File

@@ -1,4 +1,5 @@
{
"private": true,
"dependencies": {
"localforage": "^1.5.0"
}

View File

@@ -8,6 +8,7 @@
"no-object-literal-type-assertion": false,
"ban-types": false,
"space-before-function-paren": false,
"unified-signatures": false
"unified-signatures": false,
"no-unnecessary-generics": false
}
}

View File

@@ -1,5 +1,4 @@
namespace angularStrapTests {
import ngStrap = mgcrea.ngStrap;
///////////////////////////////////////////////////////////////////////////
@@ -7,9 +6,8 @@ namespace angularStrapTests {
///////////////////////////////////////////////////////////////////////////
namespace modalTests {
interface IDemoCtrlScope extends ngStrap.modal.IModalScope {
showModal: () => void;
showModal(): void;
}
angular.module('demoApp')
@@ -17,23 +15,22 @@ namespace angularStrapTests {
.controller('demoCtrl', demoCtrl);
function demoCtrl($scope: IDemoCtrlScope,
$modal: ngStrap.modal.IModalService): void {
var myModalOptions: ngStrap.modal.IModalOptions = {};
$modal: ngStrap.modal.IModalService): void {
const myModalOptions: ngStrap.modal.IModalOptions = {};
myModalOptions.title = 'My Title';
myModalOptions.content = 'Hello Modal<br />This is a multiline message!';
myModalOptions.show = true;
var myModal = $modal(myModalOptions);
const myModal = $modal(myModalOptions);
var myOtherModalOptions: ngStrap.modal.IModalOptions = {};
const myOtherModalOptions: ngStrap.modal.IModalOptions = {};
myOtherModalOptions.scope = $scope;
myOtherModalOptions.template = 'modal/docs/modal.demo.tpl.html';
myOtherModalOptions.show = false;
myOtherModalOptions.controller = demoCtrl;
myOtherModalOptions.controller = demoCtrl;
myOtherModalOptions.controllerAs = "ctrl";
var myOtherModal = $modal(myOtherModalOptions);
const myOtherModal = $modal(myOtherModalOptions);
$scope.showModal = (): void => {
myOtherModal.$promise.then(myOtherModal.show);
@@ -41,39 +38,36 @@ namespace angularStrapTests {
}
function $modalConfig($modalProvider: ngStrap.modal.IModalProvider): void {
var defaults: ngStrap.modal.IModalOptions = {
const defaults: ngStrap.modal.IModalOptions = {
animation: 'am-flip-x'
}
};
angular.extend($modalProvider.defaults, defaults);
}
}
///////////////////////////////////////////////////////////////////////////
// Aside
///////////////////////////////////////////////////////////////////////////
namespace asideTests {
angular.module('demoApp')
.config($asideConfig)
.controller('demoCtrl', demoCtrl);
function demoCtrl($scope: ngStrap.aside.IAsideScope,
$aside: ngStrap.aside.IAsideService): void {
var myAsideOptions: ngStrap.aside.IAsideOptions = {};
$aside: ngStrap.aside.IAsideService): void {
const myAsideOptions: ngStrap.aside.IAsideOptions = {};
myAsideOptions.title = 'My Title';
myAsideOptions.content = 'My content';
myAsideOptions.show = true;
var myAside = $aside(myAsideOptions);
const myAside = $aside(myAsideOptions);
var myOtherAsideOptions: ngStrap.aside.IAsideOptions = {};
const myOtherAsideOptions: ngStrap.aside.IAsideOptions = {};
myOtherAsideOptions.scope = $scope;
myOtherAsideOptions.template = 'aside/docs/aside.demo.tpl.html';
var myOtherAside = $aside();
const myOtherAside = $aside();
myOtherAside.$promise.then(() => {
myOtherAside.show();
@@ -81,7 +75,7 @@ namespace angularStrapTests {
}
function $asideConfig($asideProvider: ngStrap.aside.IAsideProvider): void {
var defaults: ngStrap.aside.IAsideOptions = {};
const defaults: ngStrap.aside.IAsideOptions = {};
defaults.animation = 'am-fadeAndSlideLeft';
defaults.placement = 'left';
@@ -89,91 +83,84 @@ namespace angularStrapTests {
}
}
///////////////////////////////////////////////////////////////////////////
// Alert
///////////////////////////////////////////////////////////////////////////
namespace alertTests {
angular.module('demoApp')
.config($alertConfig)
.controller('demoCtrl', demoCtrl);
function demoCtrl($scope: ngStrap.alert.IAlertScope,
$alert: ngStrap.alert.IAlertService): void {
var options: ngStrap.alert.IAlertOptions = {};
$alert: ngStrap.alert.IAlertService): void {
const options: ngStrap.alert.IAlertOptions = {};
options.title = 'Holy guacamole!';
options.content = 'Best check yo self, you\'re not looking too good.';
options.placement = 'top';
options.type = 'info';
options.show = true;
var myAlert = $alert();
const myAlert = $alert();
}
function $alertConfig($alertProvider: ngStrap.alert.IAlertProvider): void {
var defaults: ngStrap.alert.IAlertOptions = {};
const defaults: ngStrap.alert.IAlertOptions = {};
defaults.animation = 'am-fade-and-slide-top';
defaults.placement = 'top';
angular.extend($alertProvider.defaults, defaults);
};
}
}
///////////////////////////////////////////////////////////////////////////
// Tooltip
///////////////////////////////////////////////////////////////////////////
namespace tooltipTests {
angular.module('demoApp')
.config($tooltipConfig)
.controller('demoDrct', demoDrct);
function demoDrct($tooltip: ngStrap.tooltip.ITooltipService): ng.IDirective {
var drct: ng.IDirective = {};
const drct: ng.IDirective = {};
drct.restrict = 'EA';
drct.link = link;
return drct;
function link(scope: ng.IScope, elem: ng.IAugmentedJQuery, attrs: ng.IAttributes): void {
var options: ngStrap.tooltip.ITooltipOptions = {};
const options: ngStrap.tooltip.ITooltipOptions = {};
options.title = 'My Title';
$tooltip(elem, options);
}
}
function $tooltipConfig($tooltipProvider: ngStrap.tooltip.ITooltipProvider): void {
var defaults: ngStrap.tooltip.ITooltipOptions = {};
const defaults: ngStrap.tooltip.ITooltipOptions = {};
defaults.animation = 'am-flip-x';
defaults.trigger = 'hover';
angular.extend($tooltipProvider.defaults, defaults);
};
}
}
///////////////////////////////////////////////////////////////////////////
// Popover
///////////////////////////////////////////////////////////////////////////
namespace popoverTests {
angular.module('demoApp')
.config($popoverConfig)
.controller('demoDrct', demoDrct);
function demoDrct($popover: ngStrap.popover.IPopoverService): ng.IDirective {
var drct: ng.IDirective = {};
const drct: ng.IDirective = {};
drct.restrict = 'EA';
drct.link = link;
return drct;
function link(scope: ng.IScope, elem: ng.IAugmentedJQuery, attrs: ng.IAttributes): void {
var options: ngStrap.tooltip.ITooltipOptions = {};
const options: ngStrap.tooltip.ITooltipOptions = {};
options.title = 'My Title';
$popover(elem, options);
@@ -181,84 +168,76 @@ namespace angularStrapTests {
}
function $popoverConfig($popoverProvider: ngStrap.popover.IPopoverProvider): void {
var defaults: ngStrap.tooltip.ITooltipOptions = {}
const defaults: ngStrap.tooltip.ITooltipOptions = {};
defaults.animation = 'am-flip-x';
defaults.trigger = 'hover';
angular.extend($popoverProvider.defaults, defaults);
};
}
}
///////////////////////////////////////////////////////////////////////////
// Typeahead
///////////////////////////////////////////////////////////////////////////
namespace typeaheadTests {
angular.module('myApp')
.config($typeaheadConfig);
function $typeaheadConfig($typeaheadProvider: ngStrap.typeahead.ITypeaheadProvider) {
var defaults: ngStrap.typeahead.ITypeaheadOptions = {}
defaults.animation = 'am-flip-x';
defaults.minLength = 2;
defaults.limit = 8;
const defaults: ngStrap.typeahead.ITypeaheadOptions = {};
defaults.animation = 'am-flip-x';
defaults.minLength = 2;
defaults.limit = 8;
angular.extend($typeaheadProvider.defaults, defaults);
angular.extend($typeaheadProvider.defaults, defaults);
}
}
///////////////////////////////////////////////////////////////////////////
// Datepicker
///////////////////////////////////////////////////////////////////////////
namespace datepickerTests {
angular.module('myApp')
.config($datepickerConfig);
function $datepickerConfig($datepickerProvider: ngStrap.datepicker.IDatepickerProvider): void {
var defaults: ngStrap.datepicker.IDatepickerOptions = {};
const defaults: ngStrap.datepicker.IDatepickerOptions = {};
defaults.dateFormat = 'dd/MM/yyyy';
defaults.startWeek = 1;
angular.extend($datepickerProvider.defaults, defaults);
};
}
}
///////////////////////////////////////////////////////////////////////////
// Timepicker
///////////////////////////////////////////////////////////////////////////
namespace timepickerTests {
angular.module('myApp')
.config($timepickerConfig);
function $timepickerConfig($timepickerProvider: ngStrap.timepicker.ITimepickerProvider): void {
var defaults: ngStrap.timepicker.ITimepickerOptions = {};
const defaults: ngStrap.timepicker.ITimepickerOptions = {};
defaults.timeFormat = 'HH:mm';
defaults.length = 7;
angular.extend($timepickerProvider.defaults, defaults);
};
}
}
///////////////////////////////////////////////////////////////////////////
// Select
///////////////////////////////////////////////////////////////////////////
namespace selectTests {
angular.module('myApp')
.config($selectConfig);
function $selectConfig($selectProvider: ngStrap.select.ISelectProvider): void {
var defaults: ngStrap.select.ISelectOptions = {};
const defaults: ngStrap.select.ISelectOptions = {};
defaults.animation = 'am-flip-x';
defaults.sort = false;
@@ -266,21 +245,19 @@ namespace angularStrapTests {
}
}
///////////////////////////////////////////////////////////////////////////
// Tabs
///////////////////////////////////////////////////////////////////////////
namespace tabTests {
angular.module('myApp')
.config($tabConfig);
function $tabConfig($tabProvider: ngStrap.tab.ITabProvider) {
var defaults: ngStrap.tab.ITabOptions = {};
defaults.animation = 'am-flip-x';
const defaults: ngStrap.tab.ITabOptions = {};
defaults.animation = 'am-flip-x';
angular.extend($tabProvider.defaults, defaults);
angular.extend($tabProvider.defaults, defaults);
}
}
@@ -289,89 +266,80 @@ namespace angularStrapTests {
///////////////////////////////////////////////////////////////////////////
namespace collapseTests {
angular.module('myApp')
.config($collapseConfig);
function $collapseConfig($collapseProvider: ngStrap.collapse.ICollapseProvider):void {
var defaults: ngStrap.collapse.ICollapseOptions = {};
defaults.animation = 'am-flip-x';
function $collapseConfig($collapseProvider: ngStrap.collapse.ICollapseProvider): void {
const defaults: ngStrap.collapse.ICollapseOptions = {};
defaults.animation = 'am-flip-x';
angular.extend($collapseProvider.defaults, defaults);
}
angular.extend($collapseProvider.defaults, defaults);
}
}
///////////////////////////////////////////////////////////////////////////
// Dropdown
///////////////////////////////////////////////////////////////////////////
namespace dropdownTests {
angular.module('myApp')
.config($dropdownConfig);
function $dropdownConfig($dropdownProvider: ngStrap.dropdown.IDropdownProvider):void {
var defaults: ngStrap.dropdown.IDropdownOptions = {};
defaults.animation = 'am-flip-x';
defaults.trigger = 'hover';
function $dropdownConfig($dropdownProvider: ngStrap.dropdown.IDropdownProvider): void {
const defaults: ngStrap.dropdown.IDropdownOptions = {};
defaults.animation = 'am-flip-x';
defaults.trigger = 'hover';
angular.extend($dropdownProvider.defaults, defaults);
angular.extend($dropdownProvider.defaults, defaults);
}
}
///////////////////////////////////////////////////////////////////////////
// Navbar
///////////////////////////////////////////////////////////////////////////
namespace navbarTests {
angular.module('myApp')
.config($navbarConfig);
function $navbarConfig($navbarProvider: ngStrap.navbar.INavbarProvider):void {
var defaults: ngStrap.navbar.INavbarOptions = {};
defaults.activeClass = 'in';
function $navbarConfig($navbarProvider: ngStrap.navbar.INavbarProvider): void {
const defaults: ngStrap.navbar.INavbarOptions = {};
defaults.activeClass = 'in';
angular.extend($navbarProvider.defaults, defaults);
angular.extend($navbarProvider.defaults, defaults);
}
}
///////////////////////////////////////////////////////////////////////////
// Scrollspy
///////////////////////////////////////////////////////////////////////////
namespace scrollspyTests {
angular.module('myApp')
.config($scrollspyConfig);
function $scrollspyConfig($scrollspyProvider: ngStrap.scrollspy.IScrollspyProvider):void {
var defaults: ngStrap.scrollspy.IScrollspyOptions = {};
defaults.offset = 0;
defaults.target = 'my-selector';
function $scrollspyConfig($scrollspyProvider: ngStrap.scrollspy.IScrollspyProvider): void {
const defaults: ngStrap.scrollspy.IScrollspyOptions = {};
defaults.offset = 0;
defaults.target = 'my-selector';
angular.extend($scrollspyProvider.defaults, defaults);
angular.extend($scrollspyProvider.defaults, defaults);
}
}
///////////////////////////////////////////////////////////////////////////
// Affix
///////////////////////////////////////////////////////////////////////////
namespace affixTests {
angular.module('myApp')
.config($affixConfig);
function $affixConfig($affixProvider: ngStrap.affix.IAffixProvider):void {
var defaults: ngStrap.affix.IAffixOptions = {};
defaults.offsetTop = 100;
function $affixConfig($affixProvider: ngStrap.affix.IAffixProvider): void {
const defaults: ngStrap.affix.IAffixOptions = {};
defaults.offsetTop = 100;
angular.extend($affixProvider.defaults, defaults);
angular.extend($affixProvider.defaults, defaults);
}
}
}

View File

@@ -1,24 +1,20 @@
// Type definitions for angular-strap v2.3.x
// Type definitions for angular-strap 2.3
// Project: http://mgcrea.github.io/angular-strap/
// Definitions by: Sam Herrmann <https://github.com/samherrmann>
// Matthias Kannwischer <https://github.com/mkannwischer>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.3
/// <reference types="angular" />
declare namespace mgcrea.ngStrap {
///////////////////////////////////////////////////////////////////////////
// Modal
// see http://mgcrea.github.io/angular-strap/#/modals
///////////////////////////////////////////////////////////////////////////
namespace modal {
interface IModalService {
(config?: IModalOptions): IModal;
}
type IModalService = (config?: IModalOptions) => IModal;
interface IModalProvider {
defaults: IModalOptions;
@@ -26,9 +22,9 @@ declare namespace mgcrea.ngStrap {
interface IModal {
$promise: ng.IPromise<void>;
show: () => void;
hide: () => void;
toggle: () => void;
show(): void;
hide(): void;
toggle(): void;
}
interface IModalOptions {
@@ -44,37 +40,34 @@ declare namespace mgcrea.ngStrap {
container?: string | boolean;
controller?: any;
controllerAs?: string;
resolve?: any;
locals?: any;
template?: string;
templateUrl?: string;
contentTemplate?: string;
prefixClass?: string;
prefixEvent?: string;
id?: string;
scope?: ng.IScope;
onBeforeHide?: (modal: IModal) => void;
onHide?: (modal: IModal) => void;
onBeforeShow?: (modal: IModal) => void;
onShow?: (modal: IModal) => void;
onShow?(modal: IModal): void;
onBeforeShow?(modal: IModal): void;
onHide?(modal: IModal): void;
onBeforeHide?(modal: IModal): void;
}
interface IModalScope extends ng.IScope {
$show: () => void;
$hide: () => void;
$toggle: () => void;
$show(): void;
$hide(): void;
$toggle(): void;
}
}
///////////////////////////////////////////////////////////////////////////
// Aside
// see http://mgcrea.github.io/angular-strap/#/asides
///////////////////////////////////////////////////////////////////////////
namespace aside {
interface IAsideService {
(config?: IAsideOptions): IAside;
}
type IAsideService = (config?: IAsideOptions) => IAside;
interface IAsideProvider {
defaults: IAsideOptions;
@@ -82,9 +75,9 @@ declare namespace mgcrea.ngStrap {
interface IAside {
$promise: ng.IPromise<void>;
show: () => void;
hide: () => void;
toggle: () => void;
show(): void;
hide(): void;
toggle(): void;
}
interface IAsideOptions {
@@ -97,30 +90,32 @@ declare namespace mgcrea.ngStrap {
keyboard?: boolean;
show?: boolean;
container?: string | boolean;
controller?: any;
controllerAs?: string;
template?: string;
templateUrl?: string;
contentTemplate?: string;
scope?: ng.IScope;
onShow?(aside: IAside): void;
onBeforeShow?(aside: IAside): void;
onHide?(aside: IAside): void;
onBeforeHide?(aside: IAside): void;
}
interface IAsideScope extends ng.IScope {
$show: () => void;
$hide: () => void;
$toggle: () => void;
$show(): void;
$hide(): void;
$toggle(): void;
}
}
///////////////////////////////////////////////////////////////////////////
// Alert
// see http://mgcrea.github.io/angular-strap/#/alerts
///////////////////////////////////////////////////////////////////////////
namespace alert {
interface IAlertService {
(config?: IAlertOptions): IAlert;
}
type IAlertService = (config?: IAlertOptions) => IAlert;
interface IAlertProvider {
defaults: IAlertOptions;
@@ -128,9 +123,9 @@ declare namespace mgcrea.ngStrap {
interface IAlert {
$promise: ng.IPromise<void>;
show: () => void;
hide: () => void;
toggle: () => void;
show(): void;
hide(): void;
toggle(): void;
}
interface IAlertOptions {
@@ -139,32 +134,34 @@ declare namespace mgcrea.ngStrap {
title?: string;
content?: string;
type?: string;
keyboard?: boolean;
show?: boolean;
container?: string | boolean;
controller?: any;
controllerAs?: string;
template?: string;
templateUrl?: string;
duration?: number | boolean;
dismissable?: boolean;
onShow?(alert: IAlert): void;
onBeforeShow?(alert: IAlert): void;
onHide?(alert: IAlert): void;
onBeforeHide?(alert: IAlert): void;
}
interface IAlertScope extends ng.IScope {
$show: () => void;
$hide: () => void;
$toggle: () => void;
$show(): void;
$hide(): void;
$toggle(): void;
}
}
///////////////////////////////////////////////////////////////////////////
// Tooltip
// see http://mgcrea.github.io/angular-strap/#/tooltips
///////////////////////////////////////////////////////////////////////////
namespace tooltip {
interface ITooltipService {
(element: ng.IAugmentedJQuery, config?: ITooltipOptions): ITooltip;
}
type ITooltipService = (element: ng.IAugmentedJQuery, config?: ITooltipOptions) => ITooltip;
interface ITooltipProvider {
defaults: ITooltipOptions;
@@ -172,9 +169,9 @@ declare namespace mgcrea.ngStrap {
interface ITooltip {
$promise: ng.IPromise<void>;
show: () => void;
hide: () => void;
toggle: () => void;
show(): void;
hide(): void;
toggle(): void;
}
interface ITooltipOptions {
@@ -187,31 +184,32 @@ declare namespace mgcrea.ngStrap {
container?: string | boolean;
target?: string | ng.IAugmentedJQuery | boolean;
template?: string;
contentTemplate?: string;
templateUrl?: string;
titleTemplate?: string;
prefixEvent?: string;
id?: string;
onShow?(tooltip: ITooltip): void;
onBeforeShow?(tooltip: ITooltip): void;
onHide?(tooltip: ITooltip): void;
onBeforeHide?(tooltip: ITooltip): void;
viewport?: string | { selector: string; padding: string | number };
}
interface ITooltipScope extends ng.IScope {
$show: () => void;
$hide: () => void;
$toggle: () => void;
$setEnabled: (isEnabled: boolean) => void;
$show(): void;
$hide(): void;
$toggle(): void;
$setEnabled(isEnabled: boolean): void;
}
}
///////////////////////////////////////////////////////////////////////////
// Popover
// see http://mgcrea.github.io/angular-strap/#/popovers
///////////////////////////////////////////////////////////////////////////
namespace popover {
interface IPopoverService {
(element: ng.IAugmentedJQuery, config?: IPopoverOptions): IPopover;
}
type IPopoverService = (element: ng.IAugmentedJQuery, config?: IPopoverOptions) => IPopover;
interface IPopoverProvider {
defaults: IPopoverOptions;
@@ -219,9 +217,9 @@ declare namespace mgcrea.ngStrap {
interface IPopover {
$promise: ng.IPromise<void>;
show: () => void;
hide: () => void;
toggle: () => void;
show(): void;
hide(): void;
toggle(): void;
}
interface IPopoverOptions {
@@ -235,31 +233,31 @@ declare namespace mgcrea.ngStrap {
container?: string | boolean;
target?: string | ng.IAugmentedJQuery | boolean;
template?: string;
templateUrl?: string;
contentTemplate?: string;
autoClose?: boolean;
id?: string;
onShow?(popover: IPopover): void;
onBeforeShow?(popover: IPopover): void;
onHide?(popover: IPopover): void;
onBeforeHide?(popover: IPopover): void;
viewport?: string | { selector: string; padding: string | number };
}
interface IPopoverScope extends ng.IScope {
$show: () => void;
$hide: () => void;
$toggle: () => void;
$show(): void;
$hide(): void;
$toggle(): void;
}
}
///////////////////////////////////////////////////////////////////////////
// Typeahead
// see http://mgcrea.github.io/angular-strap/#/typeaheads
///////////////////////////////////////////////////////////////////////////
namespace typeahead {
interface ITypeaheadService {
(element: ng.IAugmentedJQuery, controller: any, config?: ITypeaheadOptions): ITypeahead;
}
type ITypeaheadService = (element: ng.IAugmentedJQuery, controller: any, config?: ITypeaheadOptions) => ITypeahead;
interface ITypeaheadProvider {
defaults: ITypeaheadOptions;
@@ -267,9 +265,9 @@ declare namespace mgcrea.ngStrap {
interface ITypeahead {
$promise: ng.IPromise<void>;
show: () => void;
hide: () => void;
toggle: () => void;
show(): void;
hide(): void;
toggle(): void;
}
interface ITypeaheadOptions {
@@ -286,34 +284,36 @@ declare namespace mgcrea.ngStrap {
comparator?: string;
id?: string;
watchOptions?: boolean;
trimValue?: boolean;
onShow?(typeahead: ITypeahead): void;
onBeforeShow?(typeahead: ITypeahead): void;
onHide?(typeahead: ITypeahead): void;
onBeforeHide?(typeahead: ITypeahead): void;
onSelect?(typeahead: ITypeahead): void;
}
}
///////////////////////////////////////////////////////////////////////////
// Datepicker
// see http://mgcrea.github.io/angular-strap/#/datepickers
///////////////////////////////////////////////////////////////////////////
namespace datepicker {
interface IDatepickerService {
(element: ng.IAugmentedJQuery, controller: any, config?: IDatepickerOptions): IDatepicker;
}
type IDatepickerService = (element: ng.IAugmentedJQuery, controller: any, config?: IDatepickerOptions) => IDatepicker;
interface IDatepickerProvider {
defaults: IDatepickerOptions;
}
interface IDatepicker {
update: (date: Date) => void;
updateDisabledDates: (dateRanges: IDatepickerDateRange[]) => void;
select: (dateConstructorArg: string | number | number[], keep: boolean) => void;
setMode: (mode: any) => void;
int: () => void;
destroy: () => void;
show: () => void;
hide: () => void;
update(date: Date): void;
updateDisabledDates(dateRanges: IDatepickerDateRange[]): void;
select(dateConstructorArg: string | number | number[], keep: boolean): void;
setMode(mode: any): void;
int(): void;
destroy(): void;
show(): void;
hide(): void;
}
interface IDatepickerDateRange {
@@ -329,6 +329,10 @@ declare namespace mgcrea.ngStrap {
delay?: number | { show: number; hide: number };
container?: string | boolean;
template?: string;
onShow?(datepicker: IDatepicker): void;
onBeforeShow?(datepicker: IDatepicker): void;
onHide?(datepicker: IDatepicker): void;
onBeforeHide?(datepicker: IDatepicker): void;
dateFormat?: string;
modelDateFormat?: string;
dateType?: string;
@@ -348,24 +352,19 @@ declare namespace mgcrea.ngStrap {
}
}
///////////////////////////////////////////////////////////////////////////
// Timepicker
// see http://mgcrea.github.io/angular-strap/#/timepickers
///////////////////////////////////////////////////////////////////////////
namespace timepicker {
interface ITimepickerService {
(element: ng.IAugmentedJQuery, controller: any, config?: ITimepickerOptions): ITimepicker;
}
type ITimepickerService = (element: ng.IAugmentedJQuery, controller: any, config?: ITimepickerOptions) => ITimepicker;
interface ITimepickerProvider {
defaults: ITimepickerOptions;
}
interface ITimepicker {
}
interface ITimepickerOptions {
@@ -376,6 +375,10 @@ declare namespace mgcrea.ngStrap {
delay?: number | { show: number; hide: number; };
container?: string | boolean;
template?: string;
onShow?(timepicker: ITimepicker): void;
onBeforeShow?(timepicker: ITimepicker): void;
onHide?(timepicker: ITimepicker): void;
onBeforeHide?(timepicker: ITimepicker): void;
timeFormat?: string;
modelTimeFormat?: string;
timeType?: string;
@@ -394,7 +397,6 @@ declare namespace mgcrea.ngStrap {
}
}
///////////////////////////////////////////////////////////////////////////
// Button
// see http://mgcrea.github.io/angular-strap/#/buttons
@@ -402,28 +404,24 @@ declare namespace mgcrea.ngStrap {
// No definitions for this module
///////////////////////////////////////////////////////////////////////////
// Select
// see http://mgcrea.github.io/angular-strap/#/selects
///////////////////////////////////////////////////////////////////////////
namespace select {
interface ISelectService {
(element: ng.IAugmentedJQuery, controller: any, config: ISelectOptions): ISelect;
}
type ISelectService = (element: ng.IAugmentedJQuery, controller: any, config: ISelectOptions) => ISelect;
interface ISelectProvider {
defaults: ISelectOptions;
}
interface ISelect {
update: (matches: any) => void;
active: (index: number) => number;
select: (index: number) => void;
show: () => void;
hide: () => void;
update(matches: any): void;
active(index: number): number;
select(index: number): void;
show(): void;
hide(): void;
}
interface ISelectOptions {
@@ -434,6 +432,11 @@ declare namespace mgcrea.ngStrap {
delay?: number | { show: number; hide: number; };
container?: string | boolean;
template?: string;
toggle?: boolean;
onShow?(select: ISelect): void;
onBeforeShow?(select: ISelect): void;
onHide?(select: ISelect): void;
onBeforeHide?(select: ISelect): void;
multiple?: boolean;
allNoneButtons?: boolean;
allText?: string;
@@ -453,7 +456,6 @@ declare namespace mgcrea.ngStrap {
///////////////////////////////////////////////////////////////////////////
namespace tab {
interface ITabProvider {
defaults: ITabOptions;
}
@@ -471,14 +473,12 @@ declare namespace mgcrea.ngStrap {
}
}
///////////////////////////////////////////////////////////////////////////
// Collapses
// see http://mgcrea.github.io/angular-strap/#/collapses
///////////////////////////////////////////////////////////////////////////
namespace collapse {
interface ICollapseProvider {
defaults: ICollapseOptions;
}
@@ -492,26 +492,22 @@ declare namespace mgcrea.ngStrap {
}
}
///////////////////////////////////////////////////////////////////////////
// Dropdowsn
// see http://mgcrea.github.io/angular-strap/#/dropdowns
///////////////////////////////////////////////////////////////////////////
namespace dropdown {
interface IDropdownProvider {
defaults: IDropdownOptions;
}
interface IDropdownService {
(element: ng.IAugmentedJQuery, config: IDropdownOptions): IDropdown;
}
type IDropdownService = (element: ng.IAugmentedJQuery, config: IDropdownOptions) => IDropdown;
interface IDropdown {
show: () => void;
hide: () => void;
destroy: () => void;
show(): void;
hide(): void;
destroy(): void;
}
interface IDropdownOptions {
@@ -522,17 +518,20 @@ declare namespace mgcrea.ngStrap {
delay?: number | { show: number; hide: number; };
container?: string | boolean;
template?: string;
templateUrl?: string;
onShow?(dropdown: IDropdown): void;
onBeforeShow?(dropdown: IDropdown): void;
onHide?(dropdown: IDropdown): void;
onBeforeHide?(dropdown: IDropdown): void;
}
}
///////////////////////////////////////////////////////////////////////////
// Navbar
// see http://mgcrea.github.io/angular-strap/#/navbars
///////////////////////////////////////////////////////////////////////////
namespace navbar {
interface INavbarProvider {
defaults: INavbarOptions;
}
@@ -547,27 +546,23 @@ declare namespace mgcrea.ngStrap {
}
}
///////////////////////////////////////////////////////////////////////////
// Scrollspy
// see http://mgcrea.github.io/angular-strap/#/scrollspy
///////////////////////////////////////////////////////////////////////////
namespace scrollspy {
interface IScrollspyProvider {
defaults: IScrollspyOptions;
}
interface IScrollspyService {
(element: ng.IAugmentedJQuery, options: IScrollspyOptions): IScrollspy;
}
type IScrollspyService = (element: ng.IAugmentedJQuery, options: IScrollspyOptions) => IScrollspy;
interface IScrollspy {
checkOffsets: () => void;
trackElement: (target: any, source: any) => void;
untrackElement: (target: any, source: any) => void;
activate: (index: number) => void;
checkOffsets(): void;
trackElement(target: any, source: any): void;
untrackElement(target: any, source: any): void;
activate(index: number): void;
}
interface IScrollspyOptions {
@@ -576,27 +571,23 @@ declare namespace mgcrea.ngStrap {
}
}
///////////////////////////////////////////////////////////////////////////
// Affix
// see http://mgcrea.github.io/angular-strap/#/affix
///////////////////////////////////////////////////////////////////////////
namespace affix {
interface IAffixProvider {
defaults: IAffixOptions;
}
interface IAffixService {
(element: ng.IAugmentedJQuery, options: IAffixOptions): IAffix;
}
type IAffixService = (element: ng.IAugmentedJQuery, options: IAffixOptions) => IAffix;
interface IAffix {
init: () => void;
destroy: () => void;
checkPositionWithEventLoop: () => void;
checkPosition: () => void;
init(): void;
destroy(): void;
checkPositionWithEventLoop(): void;
checkPosition(): void;
}
interface IAffixOptions {

View File

@@ -0,0 +1,8 @@
{
"extends": "dtslint/dt.json" ,
"rules": { //TODO
"interface-name": [true, "always-prefix"],
"no-empty-interface" : false,
"no-namespace" : false
}
}

View File

@@ -1,6 +1,4 @@
var testApp = angular.module('testApp');
const testApp = angular.module('testApp');
testApp.config((
$accordionConfig: ng.ui.bootstrap.IAccordionConfig,
@@ -176,7 +174,7 @@ testApp.controller('TestCtrl', (
/**
* test the $modal service
*/
var modalInstance = $modal.open({
const modalInstance = $modal.open({
ariaLabelledBy: "label",
ariaDescribedBy: "description",
animation: false,
@@ -220,10 +218,20 @@ testApp.controller('TestCtrl', (
backdrop: 'static'
});
$modal.open({
template: () => "<div>i'm a template!</div>"
});
$modal.open({
templateUrl: () => '/templates/modal.html'
});
$modal.getPromiseChain().then(() => {});
$modal.getPromiseChain().then((value) => value * 2);
$modal.getPromiseChain().then((value: string) => value);
/**
* test the $modalStack service
*/
@@ -240,13 +248,13 @@ testApp.controller('TestCtrl', (
/**
* test the $position service
*/
var elementLogger = (coordinates: ng.ui.bootstrap.IPositionCoordinates): void=> {
const elementLogger = (coordinates: ng.ui.bootstrap.IPositionCoordinates): void=> {
$log.log('height', coordinates.height);
$log.log('left', coordinates.left);
$log.log('top', coordinates.top);
$log.log('width', coordinates.width);
};
var element = angular.element('<div/>');
const element = angular.element('<div/>');
elementLogger($position.position(element));
elementLogger($position.offset(element));
@@ -257,7 +265,7 @@ testApp.controller('TestCtrl', (
$log.log('animationEndEventName', $transition.animationEndEventName);
$log.log('transitionEndEventName', $transition.transitionEndEventName);
var transitionElement = angular.element('<div/>');
const transitionElement = angular.element('<div/>');
$transition(transitionElement, 'transition-class', { animation: true });
$transition(transitionElement, { height: '100px', width: '50px' }, { animation: true });
$transition(transitionElement, ()=> {}, { animation: true });

View File

@@ -320,6 +320,11 @@ declare module 'angular' {
}
interface IModalService {
/**
* @returns {IPromise}
*/
getPromiseChain(): IPromise<any>;
/**
* @param {IModalSettings} options
* @returns {IModalInstanceService}
@@ -389,7 +394,7 @@ declare module 'angular' {
/**
* inline template representing the modal's content
*/
template?: string;
template?: string | (() => string);
/**
* a scope instance to be used for the modal's content (actually the $modal service is going to create a child scope of a provided scope).

View File

@@ -197,6 +197,11 @@ class UrlLocatorTestService implements IUrlLocatorTestService {
this.$state.get(this.$state.current);
this.$state.get(this.$state.current, "yourState");
this.$state.get(this.$state.current, this.$state.current);
// make sure get() accepts a discriminated union type as well
let myState: string | ng.ui.IState;
this.$state.get(myState);
this.$state.reload();
// http://angular-ui.github.io/ui-router/site/#/api/ui.router.state.$state#properties

View File

@@ -1,12 +1,15 @@
// Type definitions for Angular JS (ui.router module) 1.1.5
// Type definitions for Angular JS (ui.router module) 1.1.38
// Project: https://github.com/angular-ui/ui-router
// Definitions by: Michel Salib <https://github.com/michelsalib>, Ivan Matiishyn <https://github.com/matiishyn>
// Definitions by: Michel Salib <https://github.com/michelsalib>
// Ivan Matiishyn <https://github.com/matiishyn>
// Mike Haas <https://github.com/mikehaas763>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.3
import * as angular from 'angular';
export default "ui.router";
declare const exportedString: "ui.router";
export default exportedString;
export type IState = angular.ui.IState;
export type IStateProvider = angular.ui.IStateProvider;
@@ -272,10 +275,7 @@ declare module 'angular' {
is(state: IState, params?: {}): boolean;
href(state: IState, params?: {}, options?: IHrefOptions): string;
href(state: string, params?: {}, options?: IHrefOptions): string;
get(state: string, context?: string): IState;
get(state: IState, context?: string): IState;
get(state: string, context?: IState): IState;
get(state: IState, context?: IState): IState;
get(state: string | IState, context?: string | IState): IState;
get(): IState[];
/** A reference to the state's config object. However you passed it in. Useful for accessing custom data. */
current: IState;

View File

@@ -661,8 +661,21 @@ interface JQuery {
controller(name?: string): any;
injector(): ng.auto.IInjectorService;
/** It's declared generic for custom scope interfaces */
/**
* Returns the `$scope` of the element.
*
* **IMPORTANT**: Requires `debugInfoEnabled` to be true.
*
* See https://docs.angularjs.org/guide/production#disabling-debug-data for more information.
*/
scope<T extends ng.IScope>(): T;
/**
* Returns the `$scope` of the element.
*
* **IMPORTANT**: Requires `debugInfoEnabled` to be true.
*
* See https://docs.angularjs.org/guide/production#disabling-debug-data for more information.
*/
isolateScope<T extends ng.IScope>(): T;
inheritedData(key: string, value: any): this;

View File

@@ -20,7 +20,7 @@ export interface MigrationTask {
down: MigFn;
name: string;
}
export declare function create(db: AnydbSql, tasks: any): {
export declare function create(db: AnydbSql, tasks: string | MigrationTask[]): {
run: () => Promise<any>;
migrateTo: (target?: string) => Promise<any>;
check: (f: (m: {

View File

@@ -1,5 +1,6 @@
{
"dependencies": {
"anydb-sql": "^0.6.53"
}
}
"private": true,
"dependencies": {
"anydb-sql": "^0.6.53"
}
}

View File

@@ -1 +1,6 @@
{ "extends": "dtslint/dt.json" }
{
"extends": "dtslint/dt.json",
"rules": {
"no-unnecessary-generics": false
}
}

View File

@@ -1,25 +1,24 @@
// near copy of each of the tests from https://github.com/nodeca/argparse/tree/master/examples
import { ArgumentParser, RawDescriptionHelpFormatter } from 'argparse';
var args: any;
let args: any;
var simpleExample = new ArgumentParser({
version: '0.0.1',
addHelp: true,
description: 'Argparse example',
const simpleExample = new ArgumentParser({
version: '0.0.1',
addHelp: true,
description: 'Argparse example',
});
simpleExample.addArgument(
['-f', '--foo'],
{
help: 'foo bar',
}
['-f', '--foo'],
{
help: 'foo bar',
}
);
simpleExample.addArgument(
['-b', '--bar'],
{
help: 'bar foo',
}
['-b', '--bar'],
{
help: 'bar foo',
}
);
simpleExample.printHelp();
@@ -35,13 +34,10 @@ args = simpleExample.parseArgs('--foo 5 --bar 6'.split(' '));
console.dir(args);
console.log('-----------');
var choicesExample = new ArgumentParser({
version: '0.0.1',
addHelp: true,
description: 'Argparse examples: choice'
const choicesExample = new ArgumentParser({
version: '0.0.1',
addHelp: true,
description: 'Argparse examples: choice'
});
choicesExample.addArgument(['foo'], { choices: 'abc' });
@@ -55,56 +51,53 @@ console.log('-----------');
// choicesExample.parseArgs(['X']);
// console.dir(args);
var constantExample = new ArgumentParser({
version: '0.0.1',
addHelp: true,
description: 'Argparse examples: constant'
const constantExample = new ArgumentParser({
version: '0.0.1',
addHelp: true,
description: 'Argparse examples: constant'
});
constantExample.addArgument(
['-a'],
{
action: 'storeConst',
dest: 'answer',
help: 'store constant',
constant: 42
}
['-a'],
{
action: 'storeConst',
dest: 'answer',
help: 'store constant',
constant: 42
}
);
constantExample.addArgument(
['--str'],
{
action: 'appendConst',
dest: 'types',
help: 'append constant "str" to types',
constant: 'str'
}
['--str'],
{
action: 'appendConst',
dest: 'types',
help: 'append constant "str" to types',
constant: 'str'
}
);
constantExample.addArgument(
['--int'],
{
action: 'appendConst',
dest: 'types',
help: 'append constant "int" to types',
constant: 'int'
}
['--int'],
{
action: 'appendConst',
dest: 'types',
help: 'append constant "int" to types',
constant: 'int'
}
);
constantExample.addArgument(
['--true'],
{
action: 'storeTrue',
help: 'store true constant'
}
['--true'],
{
action: 'storeTrue',
help: 'store true constant'
}
);
constantExample.addArgument(
['--false'],
{
action: 'storeFalse',
help: 'store false constant'
}
['--false'],
{
action: 'storeFalse',
help: 'store false constant'
}
);
constantExample.printHelp();
@@ -113,27 +106,24 @@ console.log('-----------');
args = constantExample.parseArgs('-a --str --int --true'.split(' '));
console.dir(args);
var nargsExample = new ArgumentParser({
version: '0.0.1',
addHelp: true,
description: 'Argparse examples: nargs'
const nargsExample = new ArgumentParser({
version: '0.0.1',
addHelp: true,
description: 'Argparse examples: nargs'
});
nargsExample.addArgument(
['-f', '--foo'],
{
help: 'foo bar',
nargs: 1
}
['-f', '--foo'],
{
help: 'foo bar',
nargs: 1
}
);
nargsExample.addArgument(
['-b', '--bar'],
{
help: 'bar foo',
nargs: '*'
}
['-b', '--bar'],
{
help: 'bar foo',
nargs: '*'
}
);
nargsExample.printHelp();
@@ -145,40 +135,34 @@ console.log('-----------');
args = nargsExample.parseArgs('--bar b c f --foo a'.split(' '));
console.dir(args);
var parent_parser = new ArgumentParser({ addHelp: false });
const parent_parser = new ArgumentParser({ addHelp: false });
// note addHelp:false to prevent duplication of the -h option
parent_parser.addArgument(
['--parent'],
{ type: 'int', help: 'parent' }
['--parent'],
{ type: 'int', help: 'parent' }
);
var foo_parser = new ArgumentParser({
parents: [parent_parser],
description: 'child1'
const foo_parser = new ArgumentParser({
parents: [parent_parser],
description: 'child1'
});
foo_parser.addArgument(['foo']);
args = foo_parser.parseArgs(['--parent', '2', 'XXX']);
console.log(args);
var bar_parser = new ArgumentParser({
parents: [parent_parser],
description: 'child2'
const bar_parser = new ArgumentParser({
parents: [parent_parser],
description: 'child2'
});
bar_parser.addArgument(['--bar']);
args = bar_parser.parseArgs(['--bar', 'YYY']);
console.log(args);
var prefixCharsExample = new ArgumentParser({
version: '0.0.1',
addHelp: true,
description: 'Argparse examples: prefix_chars',
prefixChars: '-+'
const prefixCharsExample = new ArgumentParser({
version: '0.0.1',
addHelp: true,
description: 'Argparse examples: prefix_chars',
prefixChars: '-+'
});
prefixCharsExample.addArgument(['+f', '++foo']);
prefixCharsExample.addArgument(['++bar'], { action: 'storeTrue' });
@@ -193,39 +177,36 @@ console.dir(args);
args = prefixCharsExample.parseArgs(['++foo', '2', '++bar']);
console.dir(args);
var subparserExample = new ArgumentParser({
version: '0.0.1',
addHelp: true,
description: 'Argparse examples: sub-commands'
const subparserExample = new ArgumentParser({
version: '0.0.1',
addHelp: true,
description: 'Argparse examples: sub-commands'
});
var subparsers = subparserExample.addSubparsers({
title: 'subcommands',
dest: "subcommand_name"
const subparsers = subparserExample.addSubparsers({
title: 'subcommands',
dest: "subcommand_name"
});
var bar = subparsers.addParser('c1', { addHelp: true, help: 'c1 help' });
let bar = subparsers.addParser('c1', { addHelp: true, help: 'c1 help' });
bar.addArgument(
['-f', '--foo'],
{
action: 'store',
help: 'foo3 bar3'
}
['-f', '--foo'],
{
action: 'store',
help: 'foo3 bar3'
}
);
var bar = subparsers.addParser(
'c2',
{ aliases: ['co'], addHelp: true, help: 'c2 help' }
bar = subparsers.addParser(
'c2',
{ aliases: ['co'], addHelp: true, help: 'c2 help' }
);
bar.addArgument(
['-b', '--bar'],
{
action: 'store',
type: 'int',
help: 'foo3 bar3'
}
['-b', '--bar'],
{
action: 'store',
type: 'int',
help: 'foo3 bar3'
}
);
subparserExample.printHelp();
console.log('-----------');
@@ -241,66 +222,51 @@ console.dir(args);
console.log('-----------');
subparserExample.parseArgs(['c1', '-h']);
var functionExample = new ArgumentParser({ description: 'Process some integers.' });
const functionExample = new ArgumentParser({ description: 'Process some integers.' });
function sum(arr: number[]) {
return arr.reduce(function(a, b) {
return a + b;
}, 0);
return arr.reduce((a, b) => a + b, 0);
}
function max(arr: number[]) {
return Math.max.apply(Math, arr);
return Math.max.apply(Math, arr);
}
functionExample.addArgument(['integers'], {
metavar: 'N',
type: 'int',
nargs: '+',
help: 'an integer for the accumulator'
metavar: 'N',
type: 'int',
nargs: '+',
help: 'an integer for the accumulator'
});
functionExample.addArgument(['--sum'], {
dest: 'accumulate',
action: 'storeConst',
constant: sum,
defaultValue: max,
help: 'sum the integers (default: find the max)'
dest: 'accumulate',
action: 'storeConst',
constant: sum,
defaultValue: max,
help: 'sum the integers (default: find the max)'
});
args = functionExample.parseArgs('--sum 1 2 -1'.split(' '));
console.log(args.accumulate(args.integers));
var formatterExample = new ArgumentParser({
prog: 'PROG',
formatterClass: RawDescriptionHelpFormatter,
description: 'Keep the formatting\n' +
' exactly as it is written\n' +
'\n' +
'here\n'
const formatterExample = new ArgumentParser({
prog: 'PROG',
formatterClass: RawDescriptionHelpFormatter,
description: `Keep the formatting\nexactly as it is written\n\nhere\n`,
});
formatterExample.addArgument(['--foo'], {
help: ' foo help should not\n' +
' retain this odd formatting'
help: `foo help should not\nretain this odd formatting`,
});
formatterExample.addArgument(['spam'], {
'help': 'spam help'
help: 'spam help',
});
var group = formatterExample.addArgumentGroup({
title: 'title',
description: ' This text\n' +
' should be indented\n' +
' exactly like it is here\n'
const group = formatterExample.addArgumentGroup({
title: 'title',
description: `This text\nshould be indented\nexactly like it is here\n`,
});
group.addArgument(['--bar'], {
help: 'bar help'
help: 'bar help'
});
formatterExample.printHelp();

View File

@@ -1,31 +1,39 @@
// Type definitions for argparse v1.0.3
// Type definitions for argparse 1.0
// Project: https://github.com/nodeca/argparse
// Definitions by: Andrew Schurman <https://github.com/arcticwaters>
// Tomasz Łaziuk <https://github.com/tlaziuk>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.2
export declare class ArgumentParser extends ArgumentGroup {
export class ArgumentParser extends ArgumentGroup {
constructor(options?: ArgumentParserOptions);
addSubparsers(options?: SubparserOptions): SubParser;
parseArgs(args?: string[], ns?: Namespace | Object): any;
parseArgs(args?: string[], ns?: Namespace | object): any;
printUsage(): void;
printHelp(): void;
formatUsage(): string;
formatHelp(): string;
parseKnownArgs(args?: string[], ns?: Namespace | Object): any[];
parseKnownArgs(args?: string[], ns?: Namespace | object): any[];
convertArgLineToArg(argLine: string): string[];
exit(status: number, message: string): void;
error(err: string | Error): void;
}
interface Namespace { }
export class Namespace {
constructor(options: object);
get<K extends keyof this, D extends any>(key: K, defaultValue?: D): this[K] | D;
isset(key: keyof this): boolean;
set<K extends keyof this>(key: K, value: this[K]): this;
set<K extends string, V extends any>(key: K, value: V): this & Record<K, V>;
set<K extends object>(obj: K): this & K;
unset<K extends keyof this, D extends any>(key: K, defaultValue?: D): this[K] | D;
}
declare class SubParser {
export class SubParser {
addParser(name: string, options?: SubArgumentParserOptions): ArgumentParser;
}
declare class ArgumentGroup {
export class ArgumentGroup {
addArgument(args: string[], options?: ArgumentOptions): void;
addArgumentGroup(options?: ArgumentGroupOptions): ArgumentGroup;
addMutuallyExclusiveGroup(options?: { required: boolean }): ArgumentGroup;
@@ -33,7 +41,7 @@ declare class ArgumentGroup {
getDefault(dest: string): any;
}
interface SubparserOptions {
export interface SubparserOptions {
title?: string;
description?: string;
prog?: string;
@@ -44,12 +52,12 @@ interface SubparserOptions {
metavar?: string;
}
interface SubArgumentParserOptions extends ArgumentParserOptions {
export interface SubArgumentParserOptions extends ArgumentParserOptions {
aliases?: string[];
help?: string;
}
interface ArgumentParserOptions {
export interface ArgumentParserOptions {
description?: string;
epilog?: string;
addHelp?: boolean;
@@ -62,26 +70,27 @@ interface ArgumentParserOptions {
version?: string;
}
interface ArgumentGroupOptions {
export interface ArgumentGroupOptions {
prefixChars?: string;
argumentDefault?: any;
title?: string;
description?: string;
}
export declare class HelpFormatter { }
export declare class ArgumentDefaultsHelpFormatter { }
export declare class RawDescriptionHelpFormatter { }
export declare class RawTextHelpFormatter { }
export class HelpFormatter { }
export class ArgumentDefaultsHelpFormatter { }
export class RawDescriptionHelpFormatter { }
export class RawTextHelpFormatter { }
interface ArgumentOptions {
export interface ArgumentOptions {
action?: string;
optionStrings?: string[];
dest?: string;
nargs?: string | number;
constant?: any;
defaultValue?: any;
type?: string | Function;
// type may be a string (primitive) or a Function (constructor)
type?: string | Function; // tslint:disable-line:ban-types
choices?: string | string[];
required?: boolean;
help?: string;

View File

@@ -0,0 +1,3 @@
{
"extends": "dtslint/dt.json"
}

View File

@@ -205,7 +205,7 @@ declare namespace autobahn {
type DeferFactory = () => When.Promise<any>;
type OnChallengeHandler = (session: Session, method: string, extra: any) => When.Promise<string>;
type OnChallengeHandler = (session: Session, method: string, extra: any) => string;
interface IConnectionOptions {
use_es6_promises?: boolean;

View File

@@ -1,5 +1,6 @@
{
"dependencies": {
"postcss": "^5.2.15"
}
"private": true,
"dependencies": {
"postcss": "^5.2.15"
}
}

View File

@@ -1 +1,6 @@
{ "extends": "dtslint/dt.json" }
{
"extends": "dtslint/dt.json",
"rules": {
"no-any-union": false
}
}

View File

@@ -10,8 +10,12 @@ export { t as types };
export type Node = t.Node;
export import template = require('babel-template');
export const version: string;
import traverse, { Visitor } from "babel-traverse";
import traverse, { Visitor, NodePath } from "babel-traverse";
export { traverse, Visitor };
import { BabylonOptions } from "babylon";
export { BabylonOptions };
import { GeneratorOptions } from "babel-generator";
export { GeneratorOptions };
// A babel plugin is a simple function which must return an object matching
// the following interface. Babel will throw if it finds unknown properties.
@@ -38,14 +42,29 @@ export function transformFileSync(filename: string, opts?: TransformOptions): Ba
export function transformFromAst(ast: Node, code?: string, opts?: TransformOptions): BabelFileResult;
export interface TransformOptions {
/** Filename to use when reading from stdin - this will be used in source-maps, errors etc. Default: "unknown". */
filename?: string;
/** Include the AST in the returned object. Default: `true`. */
ast?: boolean;
/** Filename relative to `sourceRoot`. */
filenameRelative?: string;
/** Attach a comment after all non-user injected code. */
auxiliaryCommentAfter?: string;
/** A source map object that the output source map will be based on. */
inputSourceMap?: object;
/** Attach a comment before all non-user injected code. */
auxiliaryCommentBefore?: string;
/** Specify whether or not to use `.babelrc` and `.babelignore` files. Default: `true`. */
babelrc?: boolean;
/** Enable code generation. Default: `true`. */
code?: boolean;
/** write comments to generated output. Default: `true`. */
comments?: boolean;
/**
* Do not include superfluous whitespace characters and line terminators. When set to `"auto"`, `compact` is set to
* `true` on input sizes of >100KB.
*/
compact?: boolean | "auto";
/**
* This is an object of keys that represent different environments. For example, you may have:
@@ -55,38 +74,68 @@ export interface TransformOptions {
*/
env?: object;
/** Retain line numbers - will result in really ugly code. Default: `false` */
retainLines?: boolean;
/** A path to an .babelrc file to extend. */
extends?: string;
/** Filename to use when reading from stdin - this will be used in source-maps, errors etc. Default: "unknown". */
filename?: string;
/** Filename relative to `sourceRoot`. */
filenameRelative?: string;
/** An object containing the options to be passed down to the babel code generator, babel-generator. Default: `{}` */
generatorOpts?: GeneratorOptions;
/**
* Specify a custom callback to generate a module id with. Called as `getModuleId(moduleName)`.
* If falsy value is returned then the generated module id is used.
*/
getModuleId?(moduleName: string): string;
/** Enable/disable ANSI syntax highlighting of code frames. Default: `true`. */
highlightCode?: boolean;
/** List of presets (a set of plugins) to load and use. */
presets?: any[];
/** List of plugins to load and use. */
plugins?: any[];
/** list of glob paths to **not** compile. Opposite to the `only` option. */
ignore?: string[];
/** A source map object that the output source map will be based on. */
inputSourceMap?: object;
/** Should the output be minified. Default: `false` */
minified?: boolean;
/** Specify a custom name for module ids. */
moduleId?: string;
/**
* If truthy, insert an explicit id for modules. By default, all modules are anonymous.
* (Not available for `common` modules).
*/
moduleIds?: boolean;
/** Optional prefix for the AMD module formatter that will be prepend to the filename on module definitions. */
moduleRoot?: string;
/**
* A glob, regex, or mixed array of both, matching paths to only compile. Can also be an array of arrays containing
* paths to explicitly match. When attempting to compile a non-matching file it's returned verbatim.
*/
only?: string | RegExp | Array<string | RegExp>;
/** Enable code generation. Default: `true`. */
code?: boolean;
/** Babylon parser options. */
parserOpts?: BabylonOptions;
/** Include the AST in the returned object. Default: `true`. */
ast?: boolean;
/** List of plugins to load and use. */
plugins?: any[];
/** A path to an .babelrc file to extend. */
extends?: string;
/** List of presets (a set of plugins) to load and use. */
presets?: any[];
/** write comments to generated output. Default: `true`. */
comments?: boolean;
/** Retain line numbers - will result in really ugly code. Default: `false` */
retainLines?: boolean;
/** Resolve a module source ie. import "SOURCE"; to a custom value. */
resolveModuleSource?(source: string, filename: string): string;
/**
* An optional callback that controls whether a comment should be output or not. Called as
@@ -94,11 +143,8 @@ export interface TransformOptions {
*/
shouldPrintComment?(comment: string): boolean;
/**
* Do not include superfluous whitespace characters and line terminators. When set to `"auto"`, `compact` is set to
* `true` on input sizes of >100KB.
*/
compact?: boolean | "auto";
/** Set `sources[0]` on returned source map. */
sourceFileName?: string;
/**
* If truthy, adds a `map` property to returned output. If set to `"inline"`, a comment with a `sourceMappingURL`
@@ -110,38 +156,16 @@ export interface TransformOptions {
/** Set `file` on returned source map. */
sourceMapTarget?: string;
/** Set `sources[0]` on returned source map. */
sourceFileName?: string;
/** The root from which all sources are relative. */
sourceRoot?: string;
/** Specify whether or not to use `.babelrc` and `.babelignore` files. Default: `true`. */
babelrc?: boolean;
/** Indicate the mode the code should be parsed in. Can be either “script” or “module. Default: "module" */
sourceType?: "script" | "module";
/** Attach a comment before all non-user injected code. */
auxiliaryCommentBefore?: string;
/** Attach a comment after all non-user injected code. */
auxiliaryCommentAfter?: string;
/**
* Specify a custom callback to generate a module id with. Called as `getModuleId(moduleName)`.
* If falsy value is returned then the generated module id is used.
/** An optional callback that can be used to wrap visitor methods.
* NOTE: This is useful for things like introspection, and not really needed for implementing anything.
*/
getModuleId?(moduleName: string): string;
/** Optional prefix for the AMD module formatter that will be prepend to the filename on module definitions. */
moduleRoot?: string;
/**
* If truthy, insert an explicit id for modules. By default, all modules are anonymous.
* (Not available for `common` modules).
*/
moduleIds?: boolean;
/** Specify a custom name for module ids. */
moduleId?: string;
wrapPluginVisitorMethod?(pluginAlias: string, visitorType: 'enter' | 'exit', callback: (path: NodePath, state: any) => void): (path: NodePath, state: any) => void ;
}
export interface BabelFileResult {

View File

@@ -0,0 +1,4 @@
// $ExpectType any
pug`
p Hello pug!
`;

View File

@@ -0,0 +1,6 @@
// Type definitions for babel-plugin-react-pug 0.5
// Project: https://github.com/ljbc1994/babel-plugin-react-pug
// Definitions by: John Papandriopoulos <https://github.com/jpap>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
declare var pug: any;

View File

@@ -0,0 +1,23 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true,
"jsx": "react"
},
"files": [
"index.d.ts",
"babel-plugin-react-pug-tests.tsx"
]
}

View File

@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }

View File

@@ -6,12 +6,12 @@ class DestroyWarn extends Marionette.Behavior {
// just like you can in your Backbone Models
// they will be overriden if you pass in an option with the same key
defaults = {
"message": "you are destroying!"
message: 'you are destroying!'
};
// behaviors have events that are bound to the views DOM
events = {
"click @ui.destroy": "warnBeforeDestroy"
'click @ui.destroy': 'warnBeforeDestroy'
};
warnBeforeDestroy() {
@@ -22,34 +22,32 @@ class DestroyWarn extends Marionette.Behavior {
}
}
Marionette.Behaviors.getBehaviorClass = (options, key) => {
if (key === "DestroyWarn")
if (key === 'DestroyWarn')
return DestroyWarn;
return undefined;
};
class MyRouter extends Marionette.AppRouter {
// "someMethod" must exist at controller.someMethod
// 'someMethod' must exist at controller.someMethod
appRoutes = {
"some/route": "someMethod"
'some/route': 'someMethod'
};
/* standard routes can be mixed with appRoutes/Controllers above */
routes = {
"some/otherRoute": "someOtherMethod"
'some/otherRoute': 'someOtherMethod'
};
someOtherMethod() {
// do something here.
}
}
class MyApplication extends Marionette.Application {
initialize(options?: any) {
console.log("initializing application");
console.log('initializing application');
this.layoutView = new AppLayoutView();
}
@@ -60,12 +58,16 @@ class MyApplication extends Marionette.Application {
this.mainRegion = new Marionette.Region({ el: '#main' });
this.layoutView.addRegion('main', this.mainRegion);
this.layoutView.render();
this.layoutView.showChildView('main', new MyView(new MyModel));
this.layoutView.showChildView('main', new MyView(new MyModel()));
let view: Backbone.View<Backbone.Model> = this.layoutView.getChildView('main');
let regions: {[key: string]: Marionette.Region} = this.layoutView.getRegions();
let prefix: string = this.layoutView.childViewEventPrefix;
let region: Marionette.Region = this.layoutView.removeRegion('main');
let layout: Marionette.View<Backbone.Model> = this.layoutView.destroy();
let prefix: string;
if (typeof this.layoutView.childViewEventPrefix === 'string') {
this.layoutView.childViewEventPrefix;
}
}
}
@@ -75,16 +77,15 @@ class AppLayoutView extends Marionette.View<Backbone.Model> {
}
template() {
return "<div id='main'></div>";
return '<div id="main"></div>';
}
initialize(options?: any) {
console.log("initializing layoutview");
console.log('initializing layoutview');
}
}
class MyModel extends Backbone.Model {
constructor(options?: any) {
super(options);
}
@@ -99,22 +100,20 @@ class MyModel extends Backbone.Model {
}
class MyBaseView extends Marionette.View<MyModel> {
constructor() {
super();
this.getOption<string>('foo');
this.triggers = {
'click .foo': 'bar'
};
super();
this.getOption('foo');
this.triggers = {
'click .foo': 'bar'
};
}
}
class MyView extends Marionette.View<MyModel> {
behaviors: any;
constructor(model: MyModel) {
super({ model: model });
super({ model });
this.ui = {
destroy: '.destroy'
@@ -130,8 +129,7 @@ class MyView extends Marionette.View<MyModel> {
template() {
return '<h1>' + this.model.getName() + '</h1> <button class="destroy">Destroy Me</button>';
}
};
}
class MainRegion extends Marionette.Region {
constructor() {
@@ -140,7 +138,6 @@ class MainRegion extends Marionette.Region {
}
}
class MyObject extends Marionette.Object {
name: string;
options: any;
@@ -153,13 +150,13 @@ class MyObject extends Marionette.Object {
name: 'Foo'
};
this.on("before:destroy", () => {
console.log("before:destroy");
this.on('before:destroy', () => {
console.log('before:destroy');
});
}
onBeforeDestroy(arg: any) {
console.log("in onBeforeDestroy with arg " + arg);
console.log('in onBeforeDestroy with arg ' + arg);
}
}
@@ -180,7 +177,7 @@ class MyJQueryRegion extends Marionette.Region {
class MyHtmlElRegion extends Marionette.Region {
constructor() {
super();
this.el = document.querySelector("body");
this.el = document.querySelector('body');
}
}
@@ -189,77 +186,48 @@ class MyCollectionView extends Marionette.CollectionView<MyModel, MyView> {
super();
this.childView = MyView;
this.childViewEvents = {
render: function () {
console.log("a childView has been rendered");
render() {
console.log('a childView has been rendered');
}
};
this.childViewOptions = function (model: any, index: any): any {
this.childViewOptions = (model: any, index: any): any => {
// do some calculations based on the model
return {
foo: "bar",
childIndex: index
}
id: 'bar'
};
};
this.childViewOptions = {
foo: "bar"
id: 'bar'
};
this.childViewEventPrefix = "some:prefix";
this.on('some:prefix:render', function () {
this.childViewEventPrefix = 'some:prefix';
this.on('some:prefix:render', () => {
});
}
}
var app: MyApplication;
let app: MyApplication;
function ApplicationTests() {
app = new MyApplication();
app.start();
var view = new MyView(new MyModel());
let view = new MyView(new MyModel());
app.mainRegion.show(view);
}
function ObjectTests() {
var obj = new MyObject();
let obj = new MyObject();
console.log(obj.getOption('name'));
obj.destroy("goodbye");
}
function RegionManagerTests() {
var rm = new Marionette.RegionManager();
rm.addRegions({
contentRegion: {
el: '#content',
regionClass: MainRegion
},
navigationRegion: {
el: '#navigation',
regionClass: MainRegion,
// Options passed to instance of `MyOtherRegion` for
// the `navigationRegion` on `App`
navigationOption: 42,
anotherNavigationOption: 'foo'
},
footerRegion: {
regionClass: MainRegion,
someOption: 42,
someValue: 'value'
}
});
obj.destroy('goodbye');
}
function RegionTests() {
var myView: Marionette.View<MyModel> = new MyView(new MyModel());
let myView: Marionette.View<MyModel> = new MyView(new MyModel());
// render and display the view
app.mainRegion.show(myView);
@@ -268,28 +236,27 @@ function RegionTests() {
app.mainRegion.empty();
myView = new MyView(new MyModel());
app.mainRegion.show(myView, { preventDestroy: true, forceShow: true, triggerAttach: true, triggerBeforeAttach: false });
app.mainRegion.show(myView, { preventDestroy: true });
var hasView: boolean = app.mainRegion.hasView();
let hasView: boolean = app.mainRegion.hasView();
app.mainRegion.reset();
Marionette.Region.prototype.attachHtml = function (view: any): void {
Marionette.Region.prototype.attachHtml = (view: any): void => {
this.$el.empty().append(view.el);
}
};
myView = new Marionette.View<MyModel>({
el: $("#existing-view-stuff")
el: $('#existing-view-stuff')
});
app.mainRegion.attachView(myView);
app.mainRegion.show(myView);
app.mainRegion.on("empty", function (view: any, region: any, options: any) {
app.mainRegion.on('empty', (view: any, region: any, options: any) => {
// manipulate the `view` or do something extra
// with the `region`
// you also have access to the `options` that were passed to the Region.show call
});
}
function ViewTests() {
@@ -301,29 +268,27 @@ function ViewTests() {
}
function CollectionViewTests() {
var cv = new MyCollectionView();
let cv = new MyCollectionView();
cv.collection.add(new MyModel());
app.mainRegion.attachView(cv);
cv.addEmptyView(new MyModel, MyView);
cv.proxyChildEvents(new MyView(new MyModel));
let children: Backbone.ChildViewContainer<Marionette.View<Backbone.Model>> = cv.destroyChildren();
let view: Marionette.CollectionView<Backbone.Model, Marionette.View<Backbone.Model>> = cv.destroy();
app.mainRegion.show(cv);
cv.emptyView = MyView;
let view: Marionette.CollectionView<MyModel, MyView> = cv.destroy();
}
class MyController extends Marionette.Controller {
class MyController {
doFoo() { }
doBar() { }
}
function AppRouterTests() {
var myController = new MyController();
var router = new MyRouter();
let myController = new MyController();
let router = new MyRouter();
router.appRoute("/foo", "fooThat");
router.appRoute('/foo', 'fooThat');
router.processAppRoutes(myController, {
"foo": "doFoo",
"bar/:id": "doBar"
foo: 'doFoo',
'bar/:id': 'doBar'
});
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,3 @@
{
"extends": "dtslint/dt.json"
}

View File

@@ -0,0 +1,351 @@
import * as backoff from 'backoff';
const fibonacciBackoff = backoff.fibonacci();
fibonacciBackoff; // $ExpectType Backoff
backoff.fibonacci({
randomisationFactor: 0,
initialDelay: 10,
maxDelay: 300
});
backoff.fibonacci({randomisationFactor: 0});
backoff.fibonacci({initialDelay: 10});
backoff.fibonacci({maxDelay: 300});
backoff.exponential(); // $ExpectType Backoff
backoff.exponential({
factor: 1,
randomisationFactor: 0,
initialDelay: 10,
maxDelay: 300
});
backoff.exponential({factor: 1});
backoff.exponential({randomisationFactor: 0});
backoff.exponential({initialDelay: 10});
backoff.exponential({maxDelay: 300});
const fibonacciStrategy = new backoff.FibonacciStrategy();
new backoff.FibonacciStrategy({
randomisationFactor: 0,
initialDelay: 10,
maxDelay: 300
});
new backoff.FibonacciStrategy({randomisationFactor: 0});
new backoff.FibonacciStrategy({initialDelay: 10});
new backoff.FibonacciStrategy({maxDelay: 300});
fibonacciStrategy.next(); // $ExpectType number
fibonacciStrategy.reset();
const exponentialStrategy = new backoff.ExponentialStrategy();
new backoff.ExponentialStrategy({
factor: 1,
randomisationFactor: 0,
initialDelay: 10,
maxDelay: 300
});
new backoff.ExponentialStrategy({factor: 1});
new backoff.ExponentialStrategy({randomisationFactor: 0});
new backoff.ExponentialStrategy({initialDelay: 10});
new backoff.ExponentialStrategy({maxDelay: 300});
exponentialStrategy.next(); // $ExpectType number
exponentialStrategy.reset();
class MyStrategy extends backoff.BackoffStrategy {
constructor() {
super({
randomisationFactor: 0,
initialDelay: 10,
maxDelay: 300
});
}
protected next_() {
return 1;
}
protected reset_() {
}
}
const myStrategy = new MyStrategy();
exponentialStrategy.next(); // $ExpectType number
exponentialStrategy.reset();
// $ExpectType TypedFunctionCall<undefined[], Error, undefined, undefined, undefined>
backoff.call((cb: (err: Error) => void) => {}, (err) => {
err; // $ExpectType Error
});
// $ExpectType TypedFunctionCall<undefined[], Error, string, undefined, undefined>
backoff.call((cb: (err: Error, r1: string) => void) => {}, (err, r1) => {
r1; // $ExpectType string
err; // $ExpectType Error
});
// TypedFunctionCall<undefined[], Error, string, number, undefined>
backoff.call((cb: (err: Error, r1: string, r2: number) => void) => {}, (err, r1, r2) => {
r1; // $ExpectType string
r2; // $ExpectType number
err; // $ExpectType Error
});
// TypedFunctionCall<undefined[], Error, string, number, boolean>
backoff.call((cb: (err: Error, r1: string, r2: number, r3: boolean) => void) => {}, (err, r1, r2, r3) => {
r1; // $ExpectType string
r2; // $ExpectType number
r3; // $ExpectType boolean
err; // $ExpectType Error
});
// TypedFunctionCall<[number], Error, string, undefined, undefined>
backoff.call(
(t1: number, cb: (err: Error, r1: string) => void) => {
},
1,
(err, r1) => {
r1; // $ExpectType string
err; // $ExpectType Error
});
// TypedFunctionCall<[number], Error, string, number, undefined>
backoff.call(
(t1: number, cb: (err: Error, r1: string, r2: number) => void) => {
},
1,
(err, r1, r2) => {
r1; // $ExpectType string
r2; // $ExpectType number
err; // $ExpectType Error
});
// TypedFunctionCall<[number], Error, string, number, boolean>
backoff.call(
(t1: number, cb: (err: Error, r1: string, r2: number, r3: boolean) => void) => {
},
1,
(err, r1, r2, r3) => {
r1; // $ExpectType string
r2; // $ExpectType number
r3; // $ExpectType boolean
err; // $ExpectType Error
});
// TypedFunctionCall<[number, string], Error, string, undefined, undefined>
backoff.call(
(t1: number, t2: string, cb: (err: Error, r1: string) => void) => {
},
1, 'foo',
(err, r1) => {
r1; // $ExpectType string
err; // $ExpectType Error
});
// TypedFunctionCall<[number, string], Error, string, number, undefined>
backoff.call(
(t1: number, t2: string, cb: (err: Error, r1: string, r2: number) => void) => {
},
1, 'foo',
(err, r1, r2) => {
r1; // $ExpectType string
r2; // $ExpectType number
err; // $ExpectType Error
});
// TypedFunctionCall<[number, string], Error, string, number, boolean>
backoff.call(
(t1: number, t2: string, cb: (err: Error, r1: string, r2: number, r3: boolean) => void) => {
},
1, 'foo',
(err, r1, r2, r3) => {
r1; // $ExpectType string
r2; // $ExpectType number
r3; // $ExpectType boolean
err; // $ExpectType Error
});
// TypedFunctionCall<[number, string, boolean], Error, string, undefined, undefined>
backoff.call(
(t1: number, t2: string, t3: boolean, cb: (err: Error, r1: string) => void) => {
},
1, 'foo', true,
(err, r1) => {
r1; // $ExpectType string
err; // $ExpectType Error
});
// TypedFunctionCall<[number, string, boolean], Error, string, number, undefined>
backoff.call(
(t1: number, t2: string, t3: boolean, cb: (err: Error, r1: string, r2: number) => void) => {
},
1, 'foo', true,
(err, r1, r2) => {
r1; // $ExpectType string
r2; // $ExpectType number
err; // $ExpectType Error
});
// TypedFunctionCall<[number, string, boolean], Error, string, number, boolean>
backoff.call(
(t1: number, t2: string, t3: boolean, cb: (err: Error, r1: string, r2: number, r3: boolean) => void) => {
},
1, 'foo', true,
(err, r1, r2, r3) => {
r1; // $ExpectType string
r2; // $ExpectType number
r3; // $ExpectType boolean
err; // $ExpectType Error
});
// $ExpectType FunctionCallAny
backoff.call(
(t1: number, t2: string, t3: boolean, t4: string, cb: (err: Error, r1: string, r2: number, r3: boolean) => void) => {
},
1, 'foo', true, 'bar',
(err: Error, r1: string, r2: number, r3: boolean) => {});
fibonacciBackoff.failAfter(10);
fibonacciBackoff.backoff(new Error('foo'));
fibonacciBackoff.reset();
fibonacciBackoff.on('backoff', (number, delay) => {
number; // $ExpectType number
delay; // $ExpectType number
});
fibonacciBackoff.on('ready', (number, delay) => {
number; // $ExpectType number
delay; // $ExpectType number
});
fibonacciBackoff.on('fail', (err) => {
err; // $ExpectType any
});
// TypedFunctionCall<undefined[], Error, undefined, undefined, undefined>
new backoff.FunctionCall((cb: (err: Error) => void) => {}, [], (err) => {
err; // $ExpectType Error
});
// TypedFunctionCall<undefined[], Error, string, undefined, undefined>
new backoff.FunctionCall((cb: (err: Error, r1: string) => void) => {}, [], (err, r1) => {
r1; // $ExpectType string
err; // $ExpectType Error
});
// TypedFunctionCall<undefined[], Error, string, number, undefined>
new backoff.FunctionCall((cb: (err: Error, r1: string, r2: number) => void) => {}, [], (err, r1, r2) => {
r1; // $ExpectType string
r2; // $ExpectType number
err; // $ExpectType Error
});
// TypedFunctionCall<undefined[], Error, string, number, boolean>
new backoff.FunctionCall((cb: (err: Error, r1: string, r2: number, r3: boolean) => void) => {}, [], (err, r1, r2, r3) => {
r1; // $ExpectType string
r2; // $ExpectType number
r3; // $ExpectType boolean
err; // $ExpectType Error
});
// TypedFunctionCall<[number], Error, string, undefined, undefined>
new backoff.FunctionCall(
(t1: number, cb: (err: Error, r1: string) => void) => {
},
[1],
(err, r1) => {
r1; // $ExpectType string
err; // $ExpectType Error
});
// TypedFunctionCall<[number], Error, string, number, undefined>
new backoff.FunctionCall(
(t1: number, cb: (err: Error, r1: string, r2: number) => void) => {
},
[1],
(err, r1, r2) => {
r1; // $ExpectType string
r2; // $ExpectType number
err; // $ExpectType Error
});
// TypedFunctionCall<[number], Error, string, number, boolean>
new backoff.FunctionCall(
(t1: number, cb: (err: Error, r1: string, r2: number, r3: boolean) => void) => {
},
[1],
(err, r1, r2, r3) => {
r1; // $ExpectType string
r2; // $ExpectType number
r3; // $ExpectType boolean
err; // $ExpectType Error
});
// TypedFunctionCall<[number, string], Error, string, undefined, undefined>
new backoff.FunctionCall(
(t1: number, t2: string, cb: (err: Error, r1: string) => void) => {
},
[1, 'foo'],
(err, r1) => {
r1; // $ExpectType string
err; // $ExpectType Error
});
// TypedFunctionCall<[number, string], Error, string, number, undefined>
new backoff.FunctionCall(
(t1: number, t2: string, cb: (err: Error, r1: string, r2: number) => void) => {
},
[1, 'foo'],
(err, r1, r2) => {
r1; // $ExpectType string
r2; // $ExpectType number
err; // $ExpectType Error
});
// TypedFunctionCall<[number, string], Error, string, number, boolean>
new backoff.FunctionCall(
(t1: number, t2: string, cb: (err: Error, r1: string, r2: number, r3: boolean) => void) => {
},
[1, 'foo'],
(err, r1, r2, r3) => {
r1; // $ExpectType string
r2; // $ExpectType number
r3; // $ExpectType boolean
err; // $ExpectType Error
});
// TypedFunctionCall<[number, string, boolean], Error, string, undefined, undefined>
new backoff.FunctionCall(
(t1: number, t2: string, t3: boolean, cb: (err: Error, r1: string) => void) => {
},
[1, 'foo', true],
(err, r1) => {
r1; // $ExpectType string
err; // $ExpectType Error
});
// TypedFunctionCall<[number, string, boolean], Error, string, number, undefined>
new backoff.FunctionCall(
(t1: number, t2: string, t3: boolean, cb: (err: Error, r1: string, r2: number) => void) => {
},
[1, 'foo', true],
(err, r1, r2) => {
r1; // $ExpectType string
r2; // $ExpectType number
err; // $ExpectType Error
});
const functionCall = new backoff.FunctionCall(
(t1: number, t2: string, t3: boolean, cb: (err: Error, r1: string, r2: number, r3: boolean) => void) => {
},
[1, 'foo', true],
(err, r1, r2, r3) => {
r1; // $ExpectType string
r2; // $ExpectType number
r3; // $ExpectType boolean
err; // $ExpectType Error
});
functionCall; // TypedFunctionCall<[number, string, boolean], Error, string, number, boolean>
// $ExpectType FunctionCallAny
new backoff.FunctionCall(
(t1: number, t2: string, t3: boolean, t4: string, cb: (err: Error, r1: string, r2: number, r3: boolean) => void) => {
},
[1, 'foo', true, 'bar'],
(err: Error, r1: string, r2: number, r3: boolean) => {});
functionCall.isPending(); // $ExpectType boolean
functionCall.isRunning(); // $ExpectType boolean
functionCall.isCompleted(); // $ExpectType boolean
functionCall.isAborted(); // $ExpectType boolean
functionCall.setStrategy(myStrategy); // $ExpectType TypedFunctionCall<[number, string, boolean], Error, string, number, boolean>
functionCall.retryIf(err => err.status === 503); // $ExpectType TypedFunctionCall<[number, string, boolean], Error, string, number, boolean>
functionCall.failAfter(10); // $ExpectType TypedFunctionCall<[number, string, boolean], Error, string, number, boolean>
functionCall.getLastResult(); // $ExpectType [Error, string, number, boolean]
functionCall.getNumRetries(); // $ExpectType number
functionCall.start();
functionCall.abort();
functionCall.on('call', args => {
args; // $ExpectType [number, string, boolean]
});
functionCall.on('callback', args => {
args; // $ExpectType [Error, string, number, boolean]
});
functionCall.on('backoff', (number, delay, err) => {
number; // $ExpectType number
delay; // $ExpectType number
err; // $ExpectType any
});
functionCall.on('abort', () => {});

525
types/backoff/index.d.ts vendored Normal file
View File

@@ -0,0 +1,525 @@
// Type definitions for backoff 2.5
// Project: https://github.com/MathieuTurcotte/node-backoff#readme
// Definitions by: BendingBender <https://github.com/BendingBender>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.4
/// <reference types="node" />
import { EventEmitter } from 'events';
/**
* Constructs a Fibonacci backoff (10, 10, 20, 30, 50, etc.).
*
* @param options.randomisationFactor: defaults to 0, must be between 0 and 1
* @param options.initialDelay: defaults to 100 ms
* @param options.maxDelay: defaults to 10000 ms
*
* With these values, the backoff delay will increase from 100 ms to 10000 ms. The
* randomisation factor controls the range of randomness and must be between 0
* and 1. By default, no randomisation is applied on the backoff delay.
*/
export function fibonacci(options?: Options): Backoff;
/**
* Constructs an exponential backoff (10, 20, 40, 80, etc.).
*
* @param options.randomisationFactor: defaults to 0, must be between 0 and 1
* @param options.initialDelay: defaults to 100 ms
* @param options.maxDelay: defaults to 10000 ms
* @param options.factor: defaults to 2, must be greater than 1
*
* With these values, the backoff delay will increase from 100 ms to 10000 ms. The
* randomisation factor controls the range of randomness and must be between 0
* and 1. By default, no randomisation is applied on the backoff delay.
*/
export function exponential(options?: ExponentialOptions): Backoff;
export interface Options {
randomisationFactor?: number;
initialDelay?: number;
maxDelay?: number;
}
export interface ExponentialOptions extends Options {
factor?: number;
}
/**
* Constructs a `FunctionCall` instance for the given function. The wrapped
* function will get retried until it succeds or reaches the maximum number
* of backoffs. In both cases, the callback function will be invoked with the
* last result returned by the wrapped function.
*
* It is the caller's responsability to initiate the call by invoking the
* `start` method on the returned `FunctionCall` instance.
*
* @param wrappedFunction: function to call in a backoff handler, i.e. the wrapped function
* @param args: function's arguments
* @param callback: function's callback accepting an error as its first argument
*
*/
export function call<R1, R2, R3, E>(wrappedFunction: (cb: (err: E, r1: R1, r2: R2, r3: R3) => void) => void,
callback: (error: E, r1: R1, r2: R2, r3: R3) => void): TypedFunctionCall<undefined[], E, R1, R2, R3>;
export function call<R1, R2, E>(wrappedFunction: (cb: (err: E, r1: R1, r2: R2) => void) => void,
callback: (error: E, r1: R1, r2: R2) => void): TypedFunctionCall<undefined[], E, R1, R2>;
export function call<R1, E>(wrappedFunction: (cb: (err: E, r1: R1) => void) => void,
callback: (error: E, r1: R1) => void): TypedFunctionCall<undefined[], E, R1>;
export function call<E>(wrappedFunction: (cb: (err: E) => void) => void,
callback: (err: E) => void): TypedFunctionCall<undefined[], E>;
export function call<T1, R1, R2, R3, E>(wrappedFunction: (t1: T1, cb: (err: E, r1: R1, r2: R2, r3: R3) => void) => void,
t1: T1,
callback: (error: E, r1: R1, r2: R2, r3: R3) => void): TypedFunctionCall<[T1], E, R1, R2, R3>;
export function call<T1, R1, R2, E>(wrappedFunction: (t1: T1, cb: (err: E, r1: R1, r2: R2) => void) => void,
t1: T1,
callback: (error: E, r1: R1, r2: R2) => void): TypedFunctionCall<[T1], E, R1, R2>;
export function call<T1, R1, E>(wrappedFunction: (t1: T1, cb: (err: E, r1: R1) => void) => void,
t1: T1,
callback: (error: E, r1: R1) => void): TypedFunctionCall<[T1], E, R1>;
export function call<T1, E>(wrappedFunction: (t1: T1, cb: (err: E) => void) => void,
t1: T1,
callback: (err: E) => void): TypedFunctionCall<[T1], E>;
export function call<T1, T2, R1, R2, R3, E>(wrappedFunction: (t1: T1, t2: T2, cb: (err: E, r1: R1, r2: R2, r3: R3) => void) => void,
t1: T1, t2: T2,
callback: (error: E, r1: R1, r2: R2, r3: R3) => void): TypedFunctionCall<[T1, T2], E, R1, R2, R3>;
export function call<T1, T2, R1, R2, E>(wrappedFunction: (t1: T1, t2: T2, cb: (err: E, r1: R1, r2: R2) => void) => void,
t1: T1, t2: T2,
callback: (error: E, r1: R1, r2: R2) => void): TypedFunctionCall<[T1, T2], E, R1, R2>;
export function call<T1, T2, R1, E>(wrappedFunction: (t1: T1, t2: T2, cb: (err: E, r1: R1) => void) => void,
t1: T1, t2: T2,
callback: (error: E, r1: R1) => void): TypedFunctionCall<[T1, T2], E, R1>;
export function call<T1, T2, E>(wrappedFunction: (t1: T1, t2: T2, cb: (err: E) => void) => void,
t1: T1, t2: T2,
callback: (err: E) => void): TypedFunctionCall<[T1, T2], E>;
export function call<T1, T2, T3, R1, R2, R3, E>(wrappedFunction: (t1: T1, t2: T2, t3: T3, cb: (err: E, r1: R1, r2: R2, r3: R3) => void) => void,
t1: T1, t2: T2, t3: T3,
callback: (error: E, r1: R1, r2: R2, r3: R3) => void): TypedFunctionCall<[T1, T2, T3], E, R1, R2, R3>;
export function call<T1, T2, T3, R1, R2, E>(wrappedFunction: (t1: T1, t2: T2, t3: T3, cb: (err: E, r1: R1, r2: R2) => void) => void,
t1: T1, t2: T2, t3: T3,
callback: (error: E, r1: R1, r2: R2) => void): TypedFunctionCall<[T1, T2, T3], E, R1, R2>;
export function call<T1, T2, T3, R1, E>(wrappedFunction: (t1: T1, t2: T2, t3: T3, cb: (err: E, r1: R1) => void) => void,
t1: T1, t2: T2, t3: T3,
callback: (error: E, r1: R1) => void): TypedFunctionCall<[T1, T2, T3], E, R1>;
export function call<T1, T2, T3, E>(wrappedFunction: (t1: T1, t2: T2, t3: T3, cb: (err: E) => void) => void,
t1: T1, t2: T2, t3: T3,
callback: (err: E) => void): TypedFunctionCall<[T1, T2, T3], E>;
export function call<R>(wrappedFunction: (...args: any[]) => void, ...args: any[]): FunctionCallAny;
export class Backoff extends EventEmitter {
/**
* Constructs a new backoff object from a specific backoff strategy. The backoff
* strategy must implement the `BackoffStrategy`interface defined bellow.
*
* @param strategy: the backoff strategy to use
*/
constructor(strategy: BackoffStrategy);
/**
* Sets a limit on the maximum number of backoffs that can be performed before
* a fail event gets emitted and the backoff instance is reset. By default, there
* is no limit on the number of backoffs that can be performed.
*
* @param numberOfBackoffs: maximum number of backoffs before the fail event gets
* emitted, must be greater than 0
*/
failAfter(numberOfBackoffs: number): void;
/**
* Starts a backoff operation. If provided, the error parameter will be emitted
* as the last argument of the `backoff` and `fail` events to let the listeners
* know why the backoff operation was attempted.
*
* An error will be thrown if a backoff operation is already in progress.
*
* In practice, this method should be called after a failed attempt to perform a
* sensitive operation (connecting to a database, downloading a resource over the
* network, etc.).
*/
backoff(error?: any): void;
/**
* Resets the backoff delay to the initial backoff delay and stop any backoff
* operation in progress. After reset, a backoff instance can and should be
* reused.
*
* In practice, this method should be called after having successfully completed
* the sensitive operation guarded by the backoff instance or if the client code
* request to stop any reconnection attempt.
*/
reset(): void;
/**
* Emitted when a backoff operation is started. Signals to the client how long
* the next backoff delay will be.
* @param number: number of backoffs since last reset, starting at 0
* @param delay: backoff delay in milliseconds
* @param err: optional error parameter passed to `backoff.backoff([err])`
*/
addListener(event: 'backoff', listener: (number: number, delay: number, error?: any) => void): this;
/**
* Emitted when a backoff operation is done. Signals that the failing operation
* should be retried.
*
* @param number: number of backoffs since last reset, starting at 0
* @param delay: backoff delay in milliseconds
*/
addListener(event: 'ready', listener: (number: number, delay: number) => void): this;
/**
* Emitted when the maximum number of backoffs is reached. This event will only
* be emitted if the client has set a limit on the number of backoffs by calling
* `backoff.failAfter(numberOfBackoffs)`. The backoff instance is automatically
* reset after this event is emitted.
*
* @param err: optional error parameter passed to `backoff.backoff([err])`
*/
addListener(event: 'fail', listener: (error?: any) => void): this;
on(event: 'backoff', listener: (number: number, delay: number, error?: any) => void): this;
on(event: 'ready', listener: (number: number, delay: number) => void): this;
on(event: 'fail', listener: (error?: any) => void): this;
once(event: 'backoff', listener: (number: number, delay: number, error?: any) => void): this;
once(event: 'ready', listener: (number: number, delay: number) => void): this;
once(event: 'fail', listener: (error?: any) => void): this;
prependListener(event: 'backoff', listener: (number: number, delay: number, error?: any) => void): this;
prependListener(event: 'ready', listener: (number: number, delay: number) => void): this;
prependListener(event: 'fail', listener: (error?: any) => void): this;
prependOnceListener(event: 'backoff', listener: (number: number, delay: number, error?: any) => void): this;
prependOnceListener(event: 'ready', listener: (number: number, delay: number) => void): this;
prependOnceListener(event: 'fail', listener: (error?: any) => void): this;
removeListener(event: 'backoff', listener: (number: number, delay: number, error?: any) => void): this;
removeListener(event: 'ready', listener: (number: number, delay: number) => void): this;
removeListener(event: 'fail', listener: (error?: any) => void): this;
removeAllListeners(event?: 'backoff' | 'ready' | 'fail'): this;
listeners(event: 'backoff'): Array<(number: number, delay: number, error?: any) => void>;
listeners(event: 'ready'): Array<(number: number, delay: number) => void>;
listeners(event: 'fail'): Array<(error?: any) => void>;
emit(event: 'backoff', number: number, delay: number, error?: any): boolean;
emit(event: 'ready', number: number, delay: number): boolean;
emit(event: 'fail', error?: any): boolean;
eventNames(): Array<'backoff' | 'ready' | 'fail'>;
listenerCount(type: 'backoff' | 'ready' | 'fail'): number;
}
export abstract class BackoffStrategy {
/**
* The options are the following.
*
* @param options.randomisationFactor: defaults to 0, must be between 0 and 1
* @param options.initialDelay: defaults to 100 ms
* @param options.maxDelay: defaults to 10000 ms
*/
constructor(options?: Options);
getMaxDelay(): number;
getInitialDelay(): number;
/**
* Computes and returns the next backoff delay.
*/
next(): number;
/**
* Resets the backoff delay to its initial value.
*/
reset(): void;
protected abstract next_(): number;
protected abstract reset_(): void;
}
/**
* Exponential (10, 20, 40, 80, etc.) backoff strategy implementation.
*/
export class ExponentialStrategy extends BackoffStrategy {
/**
* The options are the following.
*
* @param options.randomisationFactor: defaults to 0, must be between 0 and 1
* @param options.initialDelay: defaults to 100 ms
* @param options.maxDelay: defaults to 10000 ms
* @param options.factor: defaults to 2, must be greater than 1
*/
constructor(options?: ExponentialOptions);
/**
* Computes and returns the next backoff delay.
*/
next(): number;
/**
* Resets the backoff delay to its initial value.
*/
reset(): void;
protected next_(): number;
protected reset_(): number;
}
/**
* Fibonacci (10, 10, 20, 30, 50, etc.) backoff strategy implementation.
*/
export class FibonacciStrategy extends BackoffStrategy {
/**
* The options are the following.
*
* @param options.randomisationFactor: defaults to 0, must be between 0 and 1
* @param options.initialDelay: defaults to 100 ms
* @param options.maxDelay: defaults to 10000 ms
*/
constructor(options?: Options);
next(): number;
reset(): void;
protected next_(): number;
protected reset_(): number;
}
/**
* This class manages the calling of an asynchronous function within a backoff
* loop.
*
* This class should rarely be instantiated directly since the factory method
* `backoff.call(fn, [args, ...], callback)` offers a more convenient and safer
* way to create `FunctionCall` instances.
*/
export const FunctionCall: FunctionCallConstructor;
/**
* Constructs a function handler for the given asynchronous function.
*
* @param fn: asynchronous function to call
* @param args: an array containing fn's args
* @param callback: fn's callback
*/
export interface FunctionCallConstructor {
new <R1, R2, R3, E>(wrappedFunction: (cb: (err: E, r1: R1, r2: R2, r3: R3) => void) => void,
args: undefined[],
callback: (error: E, r1: R1, r2: R2, r3: R3) => void): TypedFunctionCall<undefined[], E, R1, R2, R3>;
new <R1, R2, E>(wrappedFunction: (cb: (err: E, r1: R1, r2: R2) => void) => void,
args: undefined[],
callback: (error: E, r1: R1, r2: R2) => void): TypedFunctionCall<undefined[], E, R1, R2>;
new <R1, E>(wrappedFunction: (cb: (err: E, r1: R1) => void) => void,
args: undefined[],
callback: (error: E, r1: R1) => void): TypedFunctionCall<undefined[], E, R1>;
new <E>(wrappedFunction: (cb: (err: E) => void) => void,
args: undefined[],
callback: (err: E) => void): TypedFunctionCall<undefined[], E>;
new <T1, R1, R2, R3, E>(wrappedFunction: (t1: T1, cb: (err: E, r1: R1, r2: R2, r3: R3) => void) => void,
args: [T1],
callback: (error: E, r1: R1, r2: R2, r3: R3) => void): TypedFunctionCall<[T1], E, R1, R2, R3>;
new <T1, R1, R2, E>(wrappedFunction: (t1: T1, cb: (err: E, r1: R1, r2: R2) => void) => void,
args: [T1],
callback: (error: E, r1: R1, r2: R2) => void): TypedFunctionCall<[T1], E, R1, R2>;
new <T1, R1, E>(wrappedFunction: (t1: T1, cb: (err: E, r1: R1) => void) => void,
args: [T1],
callback: (error: E, r1: R1) => void): TypedFunctionCall<[T1], E, R1>;
new <T1, E>(wrappedFunction: (t1: T1, cb: (err: E) => void) => void,
args: [T1],
callback: (err: E) => void): TypedFunctionCall<[T1], E>;
new <T1, T2, R1, R2, R3, E>(wrappedFunction: (t1: T1, t2: T2, cb: (err: E, r1: R1, r2: R2, r3: R3) => void) => void,
args: [T1, T2],
callback: (error: E, r1: R1, r2: R2, r3: R3) => void): TypedFunctionCall<[T1, T2], E, R1, R2, R3>;
new <T1, T2, R1, R2, E>(wrappedFunction: (t1: T1, t2: T2, cb: (err: E, r1: R1, r2: R2) => void) => void,
args: [T1, T2],
callback: (error: E, r1: R1, r2: R2) => void): TypedFunctionCall<[T1, T2], E, R1, R2>;
new <T1, T2, R1, E>(wrappedFunction: (t1: T1, t2: T2, cb: (err: E, r1: R1) => void) => void,
args: [T1, T2],
callback: (error: E, r1: R1) => void): TypedFunctionCall<[T1, T2], E, R1>;
new <T1, T2, E>(wrappedFunction: (t1: T1, t2: T2, cb: (err: E) => void) => void,
args: [T1, T2],
callback: (err: E) => void): TypedFunctionCall<[T1, T2], E>;
new <T1, T2, T3, R1, R2, R3, E>(wrappedFunction: (t1: T1, t2: T2, t3: T3, cb: (err: E, r1: R1, r2: R2, r3: R3) => void) => void,
args: [T1, T2, T3],
callback: (error: E, r1: R1, r2: R2, r3: R3) => void): TypedFunctionCall<[T1, T2, T3], E, R1, R2, R3>;
new <T1, T2, T3, R1, R2, E>(wrappedFunction: (t1: T1, t2: T2, t3: T3, cb: (err: E, r1: R1, r2: R2) => void) => void,
args: [T1, T2, T3],
callback: (error: E, r1: R1, r2: R2) => void): TypedFunctionCall<[T1, T2, T3], E, R1, R2>;
new <T1, T2, T3, R1, E>(wrappedFunction: (t1: T1, t2: T2, t3: T3, cb: (err: E, r1: R1) => void) => void,
args: [T1, T2, T3],
callback: (error: E, r1: R1) => void): TypedFunctionCall<[T1, T2, T3], E, R1>;
new <T1, T2, T3, E>(wrappedFunction: (t1: T1, t2: T2, t3: T3, cb: (err: E) => void) => void,
args: [T1, T2, T3],
callback: (err: E) => void): TypedFunctionCall<[T1, T2, T3], E>;
new (wrappedFunction: (...args: any[]) => void,
args: any[],
callback: (error: any, ...resArgs: any[]) => void): FunctionCallAny;
}
export type TypedFunctionCall<T, E, R1 = undefined, R2 = undefined, R3 = undefined> = FunctionCall<T> & FunctionCallArgs<E, R1, R2, R3>;
export type FunctionCallAny = FunctionCall<any[]> & FunctionCallArgsAny;
export interface FunctionCall<T> extends EventEmitter {
/**
* Returns whether the call is pending, i.e. hasn't been started.
*/
isPending(): boolean;
/**
* Returns whether the call is in progress.
*/
isRunning(): boolean;
/**
* Returns whether the call is completed.
*/
isCompleted(): boolean;
/**
* Returns whether the call is aborted.
*/
isAborted(): boolean;
/**
* Sets the backoff strategy to use. This method should be called before
* `call.start()` otherwise an exception will be thrown.
*
* @param strategy: strategy instance to use, defaults to `FibonacciStrategy`.
*/
setStrategy(strategy: BackoffStrategy): this;
/**
* Sets the maximum number of backoffs before the call is aborted. By default,
* there is no limit on the number of backoffs that can be performed.
*
* This method should be called before `call.start()` otherwise an exception will
* be thrown.
*
* @param maxNumberOfBackoffs: maximum number of backoffs before the call is aborted
*/
failAfter(maxNumberOfBackoffs: number): this;
/**
* Sets the predicate which will be invoked to determine whether a given error
* should be retried or not, e.g. a network error would be retriable while a type
* error would stop the function call. By default, all errors are considered to be
* retriable.
*
* This method should be called before `call.start()` otherwise an exception will
* be thrown.
*
* @param predicate: a function which takes in as its argument the error returned
* by the wrapped function and determines whether it is retriable.
*/
retryIf(predicate: (error: any) => boolean): this;
/**
* Returns the number of times the wrapped function call was retried. For a
* wrapped function that succeeded immediately, this would return 0. This
* method can be called at any point in time during the call life cycle, i.e.
* before, during and after the wrapped function invocation.
*/
getNumRetries(): number;
/**
* Initiates the call the wrapped function. This method should only be called
* once otherwise an exception will be thrown.
*/
start(): void;
/**
* Aborts the call and causes the completion callback to be invoked with an abort
* error if the call was pending or running; does nothing otherwise. This method
* can safely be called multiple times.
*/
abort(): void;
/**
* Emitted each time the wrapped function is called.
* @param args: wrapped function's arguments
*/
addListener(event: 'call', listener: (args: T) => void): this;
/**
* Emitted each time a backoff operation is started.
*
* @param number: backoff number, starts at 0
* @param delay: backoff delay in milliseconds
* @param err: the error that triggered the backoff operation
*/
addListener(event: 'backoff', listener: (number: number, delay: number, error?: any) => void): this;
/**
* Emitted when a call is aborted.
*/
addListener(event: 'abort', listener: () => void): this;
on(event: 'call', listener: (args: T) => void): this;
on(event: 'backoff', listener: (number: number, delay: number, error?: any) => void): this;
on(event: 'abort', listener: () => void): this;
once(event: 'call', listener: (args: T) => void): this;
once(event: 'backoff', listener: (number: number, delay: number, error?: any) => void): this;
once(event: 'abort', listener: () => void): this;
prependListener(event: 'call', listener: (args: T) => void): this;
prependListener(event: 'backoff', listener: (number: number, delay: number, error?: any) => void): this;
prependListener(event: 'abort', listener: () => void): this;
prependOnceListener(event: 'call', listener: (args: T) => void): this;
prependOnceListener(event: 'backoff', listener: (number: number, delay: number, error?: any) => void): this;
prependOnceListener(event: 'abort', listener: () => void): this;
removeListener(event: 'call', listener: (args: T) => void): this;
removeListener(event: 'backoff', listener: (number: number, delay: number, error?: any) => void): this;
removeListener(event: 'abort', listener: () => void): this;
removeAllListeners(event?: 'call' | 'callback' | 'backoff' | 'abort'): this;
listeners(event: 'call'): Array<(args: T) => void>;
listeners(event: 'backoff'): Array<(number: number, delay: number, error?: any) => void>;
listeners(event: 'abort'): Array<() => void>;
emit(event: 'call', args: T): boolean;
emit(event: 'backoff', number: number, delay: number, error?: any): boolean;
emit(event: 'abort'): boolean;
eventNames(): Array<'call' | 'callback' | 'backoff' | 'abort'>;
listenerCount(type: 'call' | 'callback' | 'backoff' | 'abort'): number;
}
// Waiting for https://github.com/Microsoft/TypeScript/pull/17884
export interface FunctionCallArgs<E, R1 = undefined, R2 = undefined, R3 = undefined> {
/**
* Returns an array containing the last arguments passed to the completion callback
* of the wrapped function. For example, to get the error code returned by the last
* call, one would do the following.
*
* ``` js
* var results = call.getLastResult();
* // The error code is the first parameter of the callback.
* var error = results[0];
* ```
*
* Note that if the call was aborted, it will contain the abort error and not the
* last error returned by the wrapped function.
*/
getLastResult(): [E, R1, R2, R3];
/**
* Emitted each time the wrapped function invokes its callback
* @param results: wrapped function's return values
*/
addListener(event: 'callback', listener: (results: [E, R1, R2, R3]) => void): this;
on(event: 'callback', listener: (results: [E, R1, R2, R3]) => void): this;
once(event: 'callback', listener: (results: [E, R1, R2, R3]) => void): this;
prependListener(event: 'callback', listener: (results: [E, R1, R2, R3]) => void): this;
prependOnceListener(event: 'callback', listener: (results: [E, R1, R2, R3]) => void): this;
removeListener(event: 'callback', listener: (results: [E, R1, R2, R3]) => void): this;
listeners(event: 'callback'): Array<(results: [E, R1, R2, R3]) => void>;
emit(event: 'callback', results: [E, R1, R2, R3]): boolean;
}
export interface FunctionCallArgsAny {
/**
* Returns an array containing the last arguments passed to the completion callback
* of the wrapped function. For example, to get the error code returned by the last
* call, one would do the following.
*
* ``` js
* var results = call.getLastResult();
* // The error code is the first parameter of the callback.
* var error = results[0];
* ```
*
* Note that if the call was aborted, it will contain the abort error and not the
* last error returned by the wrapped function.
*/
getLastResult(): any[];
/**
* Emitted each time the wrapped function invokes its callback
* @param results: wrapped function's return values
*/
addListener(event: 'callback', listener: (results: any[]) => void): this;
on(event: 'callback', listener: (results: any[]) => void): this;
once(event: 'callback', listener: (results: any[]) => void): this;
prependListener(event: 'callback', listener: (results: any[]) => void): this;
prependOnceListener(event: 'callback', listener: (results: any[]) => void): this;
removeListener(event: 'callback', listener: (results: any[]) => void): this;
listeners(event: 'callback'): Array<(results: any[]) => void>;
emit(event: 'callback', results: any[]): boolean;
}

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",
"backoff-tests.ts"
]
}

View File

@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }

View File

@@ -43,7 +43,8 @@ declare namespace BMap {
displayOnMinLevel?: number
displayOnMaxLevel?: number
}
class Marker implements Overlay {
interface Marker extends Overlay {}
class Marker {
constructor(point: Point, opts?: MarkerOptions)
openInfoWindow(infoWnd: InfoWindow): void
closeInfoWindow(): void
@@ -100,7 +101,8 @@ declare namespace BMap {
class IconSequence {
constructor(symbol: Symbol, offset?: string, repeat?: string, fixedRotation?: boolean)
}
class PointCollection implements Overlay {
interface PointCollection extends Overlay {}
class PointCollection {
constructor(points: Point[], opts?: PointCollectionOption)
setPoints(points: Point[]): void
setStyles(styles: PointCollectionOption): void
@@ -121,7 +123,8 @@ declare namespace BMap {
shadow?: Icon
title?: string
}
class InfoWindow implements Overlay {
interface InfoWindow extends Overlay {}
class InfoWindow {
constructor(content: string | HTMLElement, opts?: InfoWindowOptions)
setWidth(width: number): void
setHeight(height: number): void
@@ -149,7 +152,8 @@ declare namespace BMap {
onrestore: (event: { type: string, target: any }) => void
onclickclose: (event: { type: string, target: any }) => void
}
class Polygon implements Overlay {
interface Polygon extends Overlay {}
class Polygon {
constructor(points: Array<Point>, opts?: PolygonOptions)
setPath(path: Point[]): void
getPath(): Point[]
@@ -213,7 +217,8 @@ declare namespace BMap {
enableClicking?: boolean
}
type ShapeType = number
class Icon implements Overlay {
interface Icon extends Overlay {}
class Icon {
constructor(url: string, size: Size, opts?: IconOptions)
anchor: Size
size: Size
@@ -230,7 +235,8 @@ declare namespace BMap {
setInfoWindowAnchor(anchor: Size): void
setPrintImageUrl(url: string): void
}
class Label implements Overlay {
interface Label extends Overlay {}
class Label {
constructor(content: string, opts?: LabelOptions)
setStyle(styles: Object): void
setContent(content: string): void
@@ -256,7 +262,8 @@ declare namespace BMap {
onremove: (event: { type: string, target: any }) => void
onrightclick: (event: { type: string, target: any }) => void
}
class Circle implements Overlay {
interface Circle extends Overlay {}
class Circle {
constructor(center: Point, radius: number, opts?: CircleOptions)
setCenter(center: Point): void
getCenter(): Point
@@ -315,7 +322,8 @@ declare namespace BMap {
enableEditing?: boolean
enableClicking?: boolean
}
class Hotspot implements Overlay {
interface Hotspot extends Overlay {}
class Hotspot {
constructor(position: Point, opts?: HotspotOptions)
setPosition(position: Point): void
getPosition(): Point
@@ -324,7 +332,8 @@ declare namespace BMap {
setUserData(data: any): void
getUserData(): any
}
class Symbol implements Overlay {
interface Symbol extends Overlay {}
class Symbol {
constructor(path: string | SymbolShapeType, opts?: SymbolOptions)
setPath(path: string | SymbolShapeType): void
setAnchor(anchor: Size): void
@@ -336,7 +345,8 @@ declare namespace BMap {
setFillOpacity(opacity: number): void
setFillColor(color: string): void
}
class Polyline implements Overlay {
interface Polyline extends Overlay {}
class Polyline {
constructor(points: Point[], opts?: PolylineOptions)
setPath(path: Point[]): void
getPath(): Point[]
@@ -371,7 +381,8 @@ declare namespace BMap {
onremove: (event: { type: string, target: any }) => void
onlineupdate: (event: { type: string, target: any }) => void
}
class GroundOverlay implements Overlay {
interface GroundOverlay extends Overlay {}
class GroundOverlay {
constructor(bounds: Bounds, opts?: GroundOverlayOptions)
setBounds(bounds: Bounds): void
getBounds(): Bounds

View File

@@ -1,6 +1,8 @@
{
"extends": "dtslint/dt.json",
"rules": {
"no-misused-new": false
// TODOs
"no-misused-new": false,
"no-any-union": false
}
}

View File

@@ -13,5 +13,6 @@ blobUtil.blobToBase64String(testBlob); // $ExpectType Promise<string>
blobUtil.blobToBinaryString(testBlob); // $ExpectType Promise<string>
blobUtil.canvasToBlob(new HTMLCanvasElement()); // $ExpectType Promise<Blob>
blobUtil.dataURLToBlob('data:abcd'); // $ExpectType Promise<Blob>
blobUtil.blobToDataURL(testBlob); // $ExpectType Promise<string>
blobUtil.imgSrcToDataURL('test.jpg'); // $ExpectType Promise<string>
blobUtil.revokeObjectURL('blob:example'); // $ExpectType void

View File

@@ -1,4 +1,4 @@
// Type definitions for blob-util 1.2
// Type definitions for blob-util 1.3
// Project: https://github.com/nolanlawson/blob-util#readme
// Definitions by: Max Battcher <https://github.com/WorldMaker>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
@@ -12,6 +12,7 @@ export function binaryStringToBlob(binary: string, type?: string): Promise<Blob>
export function blobToBase64String(blob: Blob): Promise<string>;
export function base64StringToBlob(base64: string, type?: string): Promise<Blob>;
export function dataURLToBlob(dataURL: string): Promise<Blob>;
export function blobToDataURL(blob: Blob): Promise<string>;
export function imgSrcToDataURL(src: string, type?: string, crossOrigin?: string): Promise<string>;
export function canvasToBlob(canvas: HTMLCanvasElement, type?: string): Promise<Blob>;
export function imgSrcToBlob(src: string, type?: string, crossOrigin?: string): Promise<Blob>;

View File

@@ -5,6 +5,7 @@
"no-empty-interface": false,
"array-type": false,
"unified-signatures": false,
"ban-types": false
"ban-types": false,
"no-unnecessary-generics": false
}
}

View File

@@ -13,8 +13,8 @@ var num: number;
var str: string;
var err: Error;
var x: any;
var f: Function;
var func: Function;
var f: (...args: any[]) => any;
var asyncfunc: (...args: any[]) => Promise<any>;
var arr: any[];
var exp: RegExp;
var anyArr: any[];
@@ -589,8 +589,10 @@ Promise.props({ num: 1, str: Promise.resolve('a') }).then(val => { propsValue =
Promise.props(Promise.props({ num: 1, str: Promise.resolve('a') })).then(val => { propsValue = val });
var propsMapValue: Map<number, string>;
Promise.resolve(new Map<number, Promise<string>>()).props().then(val => { propsMapValue = val });
Promise.props(new Map<number, Promise<string>>()).then(val => { propsMapValue = val });
Promise.resolve(new Map<number, string>()).props().then(val => { propsMapValue = val });
Promise.resolve(new Map<number, PromiseLike<string>>()).props().then(val => { propsMapValue = val });
Promise.props(new Map<number, string>()).then(val => { propsMapValue = val });
Promise.props(new Map<number, PromiseLike<string>>()).then(val => { propsMapValue = val });
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@@ -744,7 +746,7 @@ fooProm = Promise.attempt(() => {
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
func = Promise.method(function () {
asyncfunc = Promise.method(function () {
});
@@ -782,8 +784,8 @@ voidProm = Promise.delay(num);
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
func = Promise.promisify(f);
func = Promise.promisify(f, obj);
asyncfunc = Promise.promisify(f);
asyncfunc = Promise.promisify(f, obj);
obj = Promise.promisifyAll(obj);
anyProm = Promise.fromNode(callback => nodeCallbackFunc(callback));

View File

@@ -46,7 +46,7 @@ declare class Bluebird<R> implements PromiseLike<R>, Bluebird.Inspection<R> {
* Promises/A+ `.then()`. 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.
*/
// Based on PromiseLike.then, but returns a Bluebird instance.
then<U>(onFulfill?: (value: R) => U | Bluebird.Thenable<U>, onReject?: (error: any) => U | Bluebird.Thenable<U>): Bluebird<U>; // For simpler signature help.
then<U>(onFulfill?: (value: R) => U | PromiseLike<U>, onReject?: (error: any) => U | PromiseLike<U>): Bluebird<U>; // For simpler signature help.
then<TResult1 = R, TResult2 = never>(onfulfilled?: ((value: R) => TResult1 | PromiseLike<TResult1>) | undefined | null, onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | undefined | null): Bluebird<TResult1 | TResult2>;
/**
@@ -609,7 +609,7 @@ declare class Bluebird<R> implements PromiseLike<R>, Bluebird.Inspection<R> {
* Like calling `.then`, but the fulfillment value or rejection reason is assumed to be an array, which is flattened to the formal parameters of the handlers.
*/
spread<U, W>(fulfilledHandler: (...values: W[]) => U | PromiseLike<U>): Bluebird<U>;
spread<U>(fulfilledHandler: Function): Bluebird<U>;
spread<U>(fulfilledHandler: (...args: any[]) => U | PromiseLike<U>): Bluebird<U>;
/**
* Same as calling `Promise.all(thisPromise)`. With the exception that if this promise is bound to a value, the returned promise is bound to that value too.
@@ -620,7 +620,7 @@ declare class Bluebird<R> implements PromiseLike<R>, Bluebird.Inspection<R> {
/**
* Same as calling `Promise.props(thisPromise)`. With the exception that if this promise is bound to a value, the returned promise is bound to that value too.
*/
props<K, V>(this: PromiseLike<Map<K, Bluebird.Thenable<V> | V>>): Bluebird<Map<K, V>>;
props<K, V>(this: PromiseLike<Map<K, PromiseLike<V> | V>>): Bluebird<Map<K, V>>;
props<T>(this: PromiseLike<Bluebird.ResolvableProps<T>>): Bluebird<T>;
/**
@@ -695,7 +695,7 @@ declare class Bluebird<R> implements PromiseLike<R>, Bluebird.Inspection<R> {
* Returns a new function that wraps the given function `fn`. The new function will always return a promise that is fulfilled with the original functions return values or rejected with thrown exceptions from the original function.
* This method is convenient when a function can sometimes return synchronously or throw synchronously.
*/
static method(fn: Function): Function;
static method<R>(fn: (...args: any[]) => R | PromiseLike<R>): (...args: any[]) => Bluebird<R>;
/**
* Create a promise that is resolved with the given `value`. If `value` is a thenable or promise, the returned promise will assume its state.
@@ -749,13 +749,13 @@ declare class Bluebird<R> implements PromiseLike<R>, Bluebird.Inspection<R> {
*
* If you pass a `receiver`, the `nodeFunction` will be called as a method on the `receiver`.
*/
static promisify<T>(func: (callback: (err: any, result: T) => void) => void, options?: Bluebird.PromisifyOptions): () => Bluebird<T>;
static promisify<T, A1>(func: (arg1: A1, callback: (err: any, result: T) => void) => void, options?: Bluebird.PromisifyOptions): (arg1: A1) => Bluebird<T>;
static promisify<T, A1, A2>(func: (arg1: A1, arg2: A2, callback: (err: any, result: T) => void) => void, options?: Bluebird.PromisifyOptions): (arg1: A1, arg2: A2) => Bluebird<T>;
static promisify<T, A1, A2, A3>(func: (arg1: A1, arg2: A2, arg3: A3, callback: (err: any, result: T) => void) => void, options?: Bluebird.PromisifyOptions): (arg1: A1, arg2: A2, arg3: A3) => Bluebird<T>;
static promisify<T, A1, A2, A3, A4>(func: (arg1: A1, arg2: A2, arg3: A3, arg4: A4, callback: (err: any, result: T) => void) => void, options?: Bluebird.PromisifyOptions): (arg1: A1, arg2: A2, arg3: A3, arg4: A4) => Bluebird<T>;
static promisify<T, A1, A2, A3, A4, A5>(func: (arg1: A1, arg2: A2, arg3: A3, arg4: A4, arg5: A5, callback: (err: any, result: T) => void) => void, options?: Bluebird.PromisifyOptions): (arg1: A1, arg2: A2, arg3: A3, arg4: A4, arg5: A5) => Bluebird<T>;
static promisify(nodeFunction: Function, options?: Bluebird.PromisifyOptions): Function;
static promisify<T>(func: (callback: (err: any, result?: T) => void) => void, options?: Bluebird.PromisifyOptions): () => Bluebird<T>;
static promisify<T, A1>(func: (arg1: A1, callback: (err: any, result?: T) => void) => void, options?: Bluebird.PromisifyOptions): (arg1: A1) => Bluebird<T>;
static promisify<T, A1, A2>(func: (arg1: A1, arg2: A2, callback: (err: any, result?: T) => void) => void, options?: Bluebird.PromisifyOptions): (arg1: A1, arg2: A2) => Bluebird<T>;
static promisify<T, A1, A2, A3>(func: (arg1: A1, arg2: A2, arg3: A3, callback: (err: any, result?: T) => void) => void, options?: Bluebird.PromisifyOptions): (arg1: A1, arg2: A2, arg3: A3) => Bluebird<T>;
static promisify<T, A1, A2, A3, A4>(func: (arg1: A1, arg2: A2, arg3: A3, arg4: A4, callback: (err: any, result?: T) => void) => void, options?: Bluebird.PromisifyOptions): (arg1: A1, arg2: A2, arg3: A3, arg4: A4) => Bluebird<T>;
static promisify<T, A1, A2, A3, A4, A5>(func: (arg1: A1, arg2: A2, arg3: A3, arg4: A4, arg5: A5, callback: (err: any, result?: T) => void) => void, options?: Bluebird.PromisifyOptions): (arg1: A1, arg2: A2, arg3: A3, arg4: A4, arg5: A5) => Bluebird<T>;
static promisify(nodeFunction: (...args: any[]) => void, options?: Bluebird.PromisifyOptions): (...args: any[]) => Bluebird<any>;
/**
* Promisifies the entire object by going through the object's properties and creating an async equivalent of each function on the object and its prototype chain. The promisified method name will be the original method name postfixed with `Async`. Returns the input object.
@@ -777,7 +777,7 @@ declare class Bluebird<R> implements PromiseLike<R>, Bluebird.Inspection<R> {
* Returns a function that can use `yield` to run asynchronous code synchronously. This feature requires the support of generators which are drafted in the next version of the language. Node version greater than `0.11.2` is required and needs to be executed with the `--harmony-generators` (or `--harmony`) command-line switch.
*/
// TODO fix coroutine GeneratorFunction
static coroutine<R>(generatorFunction: Function): Function;
static coroutine(generatorFunction: (...args: any[]) => IterableIterator<any>): (...args: any[]) => Bluebird<any>;
/**
* Add `handler` as the handler to call when there is a possibly unhandled rejection. The default handler logs the error stack to stderr or `console.error` in browsers.
@@ -1011,9 +1011,9 @@ declare namespace Bluebird {
}
export interface PromisifyAllOptions extends PromisifyOptions {
suffix?: string;
filter?: (name: string, func: Function, target?: any, passesDefaultFilter?: boolean) => boolean;
filter?: (name: string, func: (...args: any[]) => any, target?: any, passesDefaultFilter?: boolean) => boolean;
// The promisifier gets a reference to the original method and should return a function which returns a promise
promisifier?: (originalMethod: Function) => () => PromiseLike<any>;
promisifier?: (originalMethod: (...args: any[]) => any, defaultPromisifer: (...args: any[]) => (...args: any[]) => Bluebird<any>) => () => PromiseLike<any>;
}
/**

View File

@@ -6,12 +6,18 @@
/// <reference types="jquery"/>
type DatepickerEvents = "show"|"hide"|"clearDate"|"changeDate"|"changeMonth"|"changeYear"|"changeDecade"|"changeCentury";
type DatepickerViewModes = 0|"days"|1|"months"|2|"years"|3|"decades"|4|"centuries"|"millenium";
type DatepickerOrientations = "auto"|"left top"|"left bottom"|"right top"|"right bottom";
/**
* All options that take a “Date” can handle a Date object; a String
* formatted according to the given format; or a timedelta relative
* to today, eg “-1d”, “+6m +1y”, etc, where valid units are “d” (day),
* “w” (week), “m” (month), and “y” (year).
*
*
* See online docs for more info:
* https://bootstrap-datepicker.readthedocs.io/en/latest/options.html
*/
@@ -35,11 +41,11 @@ interface DatepickerOptions {
daysOfWeekDisabled?: number[];
forceParse?: boolean;
inputs?: any[];
minViewMode?: 0|"days"|1|"months"|2|"years"|3|"decades"|4|"centuries"|"millenium";
maxViewMode?: 0|"days"|1|"months"|2|"years"|3|"decades"|4|"centuries"|"millenium";
minViewMode?: DatepickerViewModes;
maxViewMode?: DatepickerViewModes;
multidate?: boolean|number;
multidateSeparator?: string;
orientation?: "auto"|"left top"|"left bottom"|"right top"|"right bottom";
orientation?: DatepickerOrientations;
assumeNearbyYear?: boolean|number;
viewMode?: string;
templates?: any;
@@ -91,10 +97,10 @@ interface JQuery {
datepicker(methodName: string, params: any): any;
datepicker(options: DatepickerOptions): JQuery;
off(events: "changeDate", selector?: string, handler?: (eventObject: DatepickerEventObject) => any): JQuery;
off(events: "changeDate", handler: (eventObject: DatepickerEventObject) => any): JQuery;
off(events: DatepickerEvents, selector?: string, handler?: (eventObject: DatepickerEventObject) => any): JQuery;
off(events: DatepickerEvents, handler: (eventObject: DatepickerEventObject) => any): JQuery;
on(events: "changeDate", selector: string, data: any, handler?: (eventObject: DatepickerEventObject) => any): JQuery;
on(events: "changeDate", selector: string, handler: (eventObject: DatepickerEventObject) => any): JQuery;
on(events: 'changeDate', handler: (eventObject: DatepickerEventObject) => any): JQuery;
on(events: DatepickerEvents, selector: string, data: any, handler?: (eventObject: DatepickerEventObject) => any): JQuery;
on(events: DatepickerEvents, selector: string, handler: (eventObject: DatepickerEventObject) => any): JQuery;
on(events: DatepickerEvents, handler: (eventObject: DatepickerEventObject) => any): JQuery;
}

View File

@@ -1,13 +1,13 @@
// Type definitions for bootstrap.timepicker
// Project: https://github.com/jdewit/bootstrap-timepicker
// Definitions by: derikwhittaker <https://github.com/derikwhittaker>
// Definitions by: derikwhittaker <https://github.com/derikwhittaker>, Heather Booker <https://github.com/heatherbooker>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.3
/// <reference types="jquery"/>
interface TimepickerOptions {
defaultTime?: string|boolean;
defaultTime?: string|boolean|Date;
disableFocus?: boolean;
disableMousewheel?: boolean;
explicitMode?: boolean;

View File

@@ -1,4 +1,5 @@
{
"private": true,
"dependencies": {
"moment": ">=2.14.0"
}

View File

@@ -1,6 +1,7 @@
{
"extends": "dtslint/dt.json",
"rules": {
"no-any-union": false, // TODO
"quotemark": [true, "double", "avoid-escape"]
}
}

View File

@@ -1,4 +1,5 @@
{
"private": true,
"dependencies": {
"moment": ">=2.14.0"
}

View File

@@ -0,0 +1,7 @@
_N(0, 1);
_C(() => void 0);
Sleep(1e3);
const data: botvs.Record | undefined = void 0;
console.log(data);
TA.Alligator([]);
talib.help('XML');

4106
types/botvs/index.d.ts vendored Normal file

File diff suppressed because it is too large Load Diff

22
types/botvs/tsconfig.json Normal file
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",
"botvs-tests.ts"
]
}

6
types/botvs/tslint.json Normal file
View File

@@ -0,0 +1,6 @@
{
"extends": "dtslint/dt.json",
"rules": {
"no-unnecessary-generics": false
}
}

View File

@@ -7,6 +7,4 @@ declare class PostBuffer extends BufferStream {
constructor(req: http.IncomingMessage);
/** set a callback to get all post data from a http server request */
onEnd(callback: (data: any) => void): void;
/** pumps data into another stream to allow incoming streams given options will be passed to Stream.pipe */
pipe(stream: NodeJS.WritableStream, options?: { end?: boolean }): NodeJS.ReadableStream;
}

View File

@@ -104,6 +104,11 @@ declare namespace Bull {
* since pubsub does not give any guarantees.
*/
finished(): Promise<void>;
/**
* Promotes a job that is currently "delayed" to the "waiting" state and executed as soon as possible.
*/
promote(): Promise<void>;
}
type JobStatus = 'completed' | 'waiting' | 'active' | 'delayed' | 'failed';

View File

@@ -1,3 +1,6 @@
{
"extends": "dtslint/dt.json"
"extends": "dtslint/dt.json",
"rules": {
"no-unnecessary-generics": false
}
}

View File

@@ -47,7 +47,8 @@ const options: Logger.LoggerOptions = {
}, {
type: 'raw',
stream: ringBuffer,
level: Logger.ERROR
level: Logger.ERROR,
reemitErrorEvents: true
}]
};

View File

@@ -234,6 +234,7 @@ declare namespace Logger {
period?: string;
count?: number;
name?: string;
reemitErrorEvents?: boolean;
}
interface LoggerOptions {

View File

@@ -1,5 +1,6 @@
{
"private": true,
"dependencies": {
"moment": ">=2.14.0"
}
}
}

View File

@@ -0,0 +1,35 @@
import valid = require('card-validator');
const numberValidation = valid.number('4111');
if (!numberValidation.isPotentiallyValid && numberValidation.card) {
numberValidation.card.type;
}
valid.expirationDate('10/19');
const dateTest2 = valid.expirationDate({month: '1', year: '2019'});
if (dateTest2.isPotentiallyValid) {
dateTest2.month;
}
const expirationMonthCheck = valid.expirationMonth('10');
if (expirationMonthCheck.isPotentiallyValid) {
expirationMonthCheck.isValidForThisYear;
}
const expirationYearCheck = valid.expirationYear('10');
if (expirationYearCheck.isPotentiallyValid) {
expirationYearCheck.isCurrentYear;
}
let postalCodeCheck = valid.postalCode('123');
if (postalCodeCheck.isValid) {
postalCodeCheck = valid.postalCode('123', {});
postalCodeCheck = valid.postalCode('123', {minLength: 5});
}
const cvvCeck = valid.cvv('1234');
if (cvvCeck.isValid) {
valid.cvv('12345', 4);
}

43
types/card-validator/index.d.ts vendored Normal file
View File

@@ -0,0 +1,43 @@
// Type definitions for card-validator 4.1
// Project: https://github.com/braintree/card-validator
// Definitions by: Gregory Moore <https://github.com/ChanceM>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
export interface Card {
niceType: string;
type: string;
pattern: string;
isAmex: boolean;
gaps: number[];
lengths: number[];
code: {name: string, size: number};
}
export interface valid {
isPotentiallyValid: boolean;
isValid: boolean;
}
export interface validNumber extends valid {
card: Card | null;
}
export interface validExpirationDate extends valid {
month: string | null;
year: string | null;
}
export interface validExpirationMonth extends valid {
isValidForThisYear: boolean;
}
export interface validExpirationYear extends valid {
isCurrentYear: boolean;
}
export function number(value: string): validNumber;
export function expirationDate(value: string | {month: string, year: string}): validExpirationDate;
export function expirationMonth(value: string): validExpirationMonth;
export function expirationYear(value: string): validExpirationYear;
export function cvv(value: string, maxLength?: number): valid;
export function postalCode(value: string, options?: {minLength?: number}): valid;

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",
"card-validator-tests.ts"
]
}

View File

@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }

View File

@@ -4,6 +4,11 @@ import * as util from 'util';
var client = new cassandra.Client({ contactPoints: ['h1', 'h2'], keyspace: 'ks1'});
var query = 'SELECT email, last_name FROM user_profiles WHERE key=?';
client.execute(query, ['guy'], function(err: any, result: any) {
client.execute(query, ['guy'], function(err, result) {
console.log('got user profile with email ' + result.rows[0].email);
});
});
client.execute(query, [ 'guy' ], { prepare: true }).then(
(result) => console.log(result.first().email),
(error) => console.log(error)
);

View File

@@ -1,7 +1,8 @@
// Type definitions for nodejs-driver v0.8.2
// Type definitions for cassandra-driver v3.2.2
// Project: https://github.com/datastax/nodejs-driver
// Definitions by: Marc Fisher <https://github.com/Svjard>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.2
/// <reference types="node" />
/// <reference types="long" />
@@ -378,6 +379,7 @@ export namespace types {
values(): Array<{ [key: string]: any; }>;
keys(): Array<string>;
forEach(callback: Callback): void;
[key: string]: any;
}
interface TimeUuidStatic {
@@ -506,10 +508,15 @@ export interface Client extends events.EventEmitter {
metadata: metadata.Metadata;
batch(queries: Array<string> | Array<{ query: string, params?: any }>, options: QueryOptions, callback: ResultCallback): void;
batch(queries: Array<string> | Array<{ query: string, params?: any }>, callback: ResultCallback): void;
batch(queries: Array<string> | Array<{ query: string, params?: any }>, options?: QueryOptions): Promise<types.ResultSet>;
connect(callback: Callback): void;
eachRow(query: string, params?: any, options?: QueryOptions, rowCallback?: Callback, callback?: Callback): void;
execute(query: string, params?: any, callback?: ResultCallback): void;
execute(query: string, params?: any, options?: QueryOptions, callback?: ResultCallback): void;
execute(query: string, params: any, options: QueryOptions, callback: ResultCallback): void;
execute(query: string, params: any, callback: ResultCallback): void;
execute(query: string, callback: ResultCallback): void;
execute(query: string, params?: any, options?: QueryOptions): Promise<types.ResultSet>;
getReplicas(keyspace: string, token: Buffer): Array<any>; // TODO: Should this be a more explicit return?
shutdown(callback?: Callback): void;
stream(query: string, params?: any, options?: QueryOptions, callback?: Callback): NodeJS.ReadableStream;

View File

@@ -26,6 +26,7 @@ thenableNum = chai.expect(thenableNum).to.notify(() => console.log('done'));
// BDD API (should)
thenableNum = thenableNum.should.be.fulfilled;
thenableNum = thenableNum.should.eventually.deep.equal(3);
thenableNum = thenableNum.should.eventually.become(3);
thenableNum = thenableNum.should.become(3);
thenableNum = thenableNum.should.be.rejected;
thenableNum = thenableNum.should.be.rejectedWith(Error);

View File

@@ -1,6 +1,10 @@
// Type definitions for chai-as-promised
// Type definitions for chai-as-promised 7.1.0
// Project: https://github.com/domenic/chai-as-promised/
// Definitions by: jt000 <https://github.com/jt000>, Yuki Kokubun <https://github.com/Kuniwak>, Leonard Thieu <https://github.com/leonard-thieu>
// Definitions by: jt000 <https://github.com/jt000>,
// Yuki Kokubun <https://github.com/Kuniwak>,
// Leonard Thieu <https://github.com/leonard-thieu>,
// Mike Lazer-Walker <https://github.com/lazerwalker>,
// Matt Bishop <https://github.com/mattbishop>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference types="chai" />
@@ -25,22 +29,25 @@ declare namespace Chai {
become(expected: any): PromisedAssertion;
fulfilled: PromisedAssertion;
rejected: PromisedAssertion;
rejectedWith(expected: any, message?: string | RegExp): PromisedAssertion;
rejectedWith: PromisedThrow;
notify(fn: Function): PromisedAssertion;
}
// Eventually does not have .then(), but PromisedAssertion have.
interface Eventually extends PromisedLanguageChains, PromisedNumericComparison, PromisedTypeComparison {
// From chai-as-promised
become(expected: PromiseLike<any>): PromisedAssertion;
become(expected: any): PromisedAssertion;
fulfilled: PromisedAssertion;
rejected: PromisedAssertion;
rejectedWith(expected: any, message?: string | RegExp): PromisedAssertion;
rejectedWith: PromisedThrow;
notify(fn: Function): PromisedAssertion;
// From chai
not: PromisedAssertion;
deep: PromisedDeep;
ordered: PromisedOrdered;
nested: PromisedNested;
any: PromisedKeyFilter;
all: PromisedKeyFilter;
a: PromisedTypeComparison;
an: PromisedTypeComparison;
@@ -51,6 +58,7 @@ declare namespace Chai {
false: PromisedAssertion;
null: PromisedAssertion;
undefined: PromisedAssertion;
NaN: PromisedAssertion;
exist: PromisedAssertion;
empty: PromisedAssertion;
arguments: PromisedAssertion;
@@ -63,20 +71,36 @@ declare namespace Chai {
property: PromisedProperty;
ownProperty: PromisedOwnProperty;
haveOwnProperty: PromisedOwnProperty;
ownPropertyDescriptor: PromisedOwnPropertyDescriptor;
haveOwnPropertyDescriptor: PromisedOwnPropertyDescriptor;
length: PromisedLength;
lengthOf: PromisedLength;
match(regexp: RegExp | string, message?: string): PromisedAssertion;
match: PromisedMatch;
matches: PromisedMatch;
string(string: string, message?: string): PromisedAssertion;
keys: PromisedKeys;
key(string: string): PromisedAssertion;
throw: PromisedThrow;
throws: PromisedThrow;
Throw: PromisedThrow;
respondTo(method: string, message?: string): PromisedAssertion;
respondTo: PromisedRespondTo;
respondsTo: PromisedRespondTo;
itself: PromisedAssertion;
satisfy(matcher: Function, message?: string): PromisedAssertion;
closeTo(expected: number, delta: number, message?: string): PromisedAssertion;
satisfy: PromisedSatisfy;
satisfies: PromisedSatisfy;
closeTo: PromisedCloseTo;
approximately: PromisedCloseTo;
members: PromisedMembers;
increase: PromisedPropertyChange;
increases: PromisedPropertyChange;
decrease: PromisedPropertyChange;
decreases: PromisedPropertyChange;
change: PromisedPropertyChange;
changes: PromisedPropertyChange;
extensible: PromisedAssertion;
sealed: PromisedAssertion;
frozen: PromisedAssertion;
oneOf(list: any[], message?: string): PromisedAssertion;
}
interface PromisedAssertion extends Eventually, PromiseLike<any> {
@@ -99,6 +123,8 @@ declare namespace Chai {
at: PromisedAssertion;
of: PromisedAssertion;
same: PromisedAssertion;
but: PromisedAssertion;
does: PromisedAssertion;
}
interface PromisedNumericComparison {
@@ -129,10 +155,28 @@ declare namespace Chai {
(constructor: Object, message?: string): PromisedAssertion;
}
interface PromisedDeep {
equal: PromisedEqual;
interface PromisedCloseTo {
(expected: number, delta: number, message?: string): PromisedAssertion;
}
interface PromisedNested {
include: PromisedInclude;
property: PromisedProperty;
members: PromisedMembers;
}
interface PromisedDeep {
equal: PromisedEqual;
equals: PromisedEqual;
eq: PromisedEqual;
include: PromisedInclude;
property: PromisedProperty;
members: PromisedMembers;
ordered: PromisedOrdered
}
interface PromisedOrdered {
members: PromisedMembers;
}
interface PromisedKeyFilter {
@@ -151,6 +195,11 @@ declare namespace Chai {
(name: string, message?: string): PromisedAssertion;
}
interface PromisedOwnPropertyDescriptor {
(name: string, descriptor: PropertyDescriptor, message?: string): PromisedAssertion;
(name: string, message?: string): PromisedAssertion;
}
interface PromisedLength extends PromisedLanguageChains, PromisedNumericComparison {
(length: number, message?: string): PromisedAssertion;
}
@@ -160,13 +209,21 @@ declare namespace Chai {
(value: string, message?: string): PromisedAssertion;
(value: number, message?: string): PromisedAssertion;
keys: PromisedKeys;
deep: PromisedDeep;
ordered: PromisedOrdered;
members: PromisedMembers;
any: PromisedKeyFilter;
all: PromisedKeyFilter;
}
interface PromisedMatch {
(regexp: RegExp | string, message?: string): PromisedAssertion;
}
interface PromisedKeys {
(...keys: string[]): PromisedAssertion;
(keys: any[]): PromisedAssertion;
(keys: Object): PromisedAssertion;
}
interface PromisedThrow {
@@ -179,10 +236,22 @@ declare namespace Chai {
(constructor: Function, expected?: RegExp, message?: string): PromisedAssertion;
}
interface PromisedRespondTo {
(method: string, message?: string): PromisedAssertion;
}
interface PromisedSatisfy {
(matcher: Function, message?: string): PromisedAssertion;
}
interface PromisedMembers {
(set: any[], message?: string): PromisedAssertion;
}
interface PromisedPropertyChange {
(object: Object, property: string, message?: string): PromisedAssertion;
}
// For Assert API
interface Assert {
eventually: PromisedAssert;
@@ -198,7 +267,9 @@ declare namespace Chai {
export interface PromisedAssert {
fail(actual?: any, expected?: any, msg?: string, operator?: string): PromiseLike<void>;
isOk(val: any, msg?: string): PromiseLike<void>;
ok(val: any, msg?: string): PromiseLike<void>;
isNotOk(val: any, msg?: string): PromiseLike<void>;
notOk(val: any, msg?: string): PromiseLike<void>;
equal(act: any, exp: any, msg?: string): PromiseLike<void>;
@@ -210,12 +281,26 @@ declare namespace Chai {
deepEqual(act: any, exp: any, msg?: string): PromiseLike<void>;
notDeepEqual(act: any, exp: any, msg?: string): PromiseLike<void>;
isAbove(val: number, above: number, msg?: string): PromiseLike<void>;
isAtLeast(val: number, atLeast: number, msg?: string): PromiseLike<void>;
isAtBelow(val: number, below: number, msg?: string): PromiseLike<void>;
isAtMost(val: number, atMost: number, msg?: string): PromiseLike<void>;
isTrue(val: any, msg?: string): PromiseLike<void>;
isFalse(val: any, msg?: string): PromiseLike<void>;
isNotTrue(val: any, msg?: string): PromiseLike<void>;
isNotFalse(val: any, msg?: string): PromiseLike<void>;
isNull(val: any, msg?: string): PromiseLike<void>;
isNotNull(val: any, msg?: string): PromiseLike<void>;
isNaN(val: any, msg?: string): PromiseLike<void>;
isNotNaN(val: any, msg?: string): PromiseLike<void>;
exists(val: any, msg?: string): PromiseLike<void>;
notExists(val: any, msg?: string): PromiseLike<void>;
isUndefined(val: any, msg?: string): PromiseLike<void>;
isDefined(val: any, msg?: string): PromiseLike<void>;
@@ -287,10 +372,46 @@ declare namespace Chai {
operator(val: any, operator: string, val2: any, msg?: string): PromiseLike<void>;
closeTo(act: number, exp: number, delta: number, msg?: string): PromiseLike<void>;
approximately(act: number, exp: number, delta: number, msg?: string): PromiseLike<void>;
sameMembers(set1: any[], set2: any[], msg?: string): PromiseLike<void>;
sameDeepMembers(set1: any[], set2: any[], msg?: string): PromiseLike<void>;
sameOrderedMembers(set1: any[], set2: any[], msg?: string): PromiseLike<void>;
notSameOrderedMembers(set1: any[], set2: any[], msg?: string): PromiseLike<void>;
sameDeepOrderedMembers(set1: any[], set2: any[], msg?: string): PromiseLike<void>;
notSameDeepOrderedMembers(set1: any[], set2: any[], msg?: string): PromiseLike<void>;
includeOrderedMembers(set1: any[], set2: any[], msg?: string): PromiseLike<void>;
notIncludeOrderedMembers(set1: any[], set2: any[], msg?: string): PromiseLike<void>;
includeDeepOrderedMembers(set1: any[], set2: any[], msg?: string): PromiseLike<void>;
notIncludeDeepOrderedMembers(set1: any[], set2: any[], msg?: string): PromiseLike<void>;
includeMembers(set1: any[], set2: any[], msg?: string): PromiseLike<void>;
includeDeepMembers(set1: any[], set2: any[], msg?: string): PromiseLike<void>;
oneOf(val: any, list: any[], msg?: string): PromiseLike<void>;
changes(modifier: Function, obj: Object, property: string, msg?: string): PromiseLike<void>;
doesNotChange(modifier: Function, obj: Object, property: string, msg?: string): PromiseLike<void>;
increases(modifier: Function, obj: Object, property: string, msg?: string): PromiseLike<void>;
doesNotIncrease(modifier: Function, obj: Object, property: string, msg?: string): PromiseLike<void>;
decreases(modifier: Function, obj: Object, property: string, msg?: string): PromiseLike<void>;
doesNotDecrease(modifier: Function, obj: Object, property: string, msg?: string): PromiseLike<void>;
ifError(val: any, msg?: string): PromiseLike<void>;
isExtensible(obj: Object, msg?: string): PromiseLike<void>;
isNotExtensible(obj: Object, msg?: string): PromiseLike<void>;
isSealed(obj: Object, msg?: string): PromiseLike<void>;
sealed(obj: Object, msg?: string): PromiseLike<void>;
isNotSealed(obj: Object, msg?: string): PromiseLike<void>;
notSealed(obj: Object, msg?: string): PromiseLike<void>;
isFrozen(obj: Object, msg?: string): PromiseLike<void>;
frozen(obj: Object, msg?: string): PromiseLike<void>;
isNotFrozen(obj: Object, msg?: string): PromiseLike<void>;
notFrozen(obj: Object, msg?: string): PromiseLike<void>;
isEmpty(val: any, msg?: string): PromiseLike<void>;
isNotEmpty(val: any, msg?: string): PromiseLike<void>;
}
}

View File

@@ -30,6 +30,7 @@ expect(wrapper).to.have.ref("test");
expect(wrapper).to.be.selected();
expect(wrapper).to.have.tagName("div");
expect(wrapper).to.have.text("");
expect(wrapper).to.contain.text("");
expect(wrapper).to.have.type(Test);
expect(wrapper).to.have.value("test");
expect(wrapper).to.have.attr("test", "test");

View File

@@ -26,6 +26,12 @@ declare namespace Chai {
* @param code
*/
(selector: EnzymeSelector): Assertion;
/**
* Assert that the given wrapper has the supplied text:
* @param str
*/
text(str?: string): Assertion;
}
interface Assertion {
/**

View File

@@ -41,6 +41,16 @@ chai.request(app)
.get('/search')
.query({ name: 'foo', limit: 10 });
chai.request(app)
.get('/download')
.buffer()
.parse((res, cb) => {
let data = '';
res.setEncoding('binary');
res.on('data', (chunk: any) => { data += chunk; });
res.on('end', () => { cb(undefined, new Buffer(data, 'binary')); });
});
chai.request(app)
.put('/user/me')
.send({ passsword: '123', confirmPassword: '123' })

View File

@@ -49,6 +49,8 @@ declare global {
type: string;
status: number;
text: string;
setEncoding(encoding: string): void;
on(event: string, fn: (...args: any[]) => void): void;
}
interface Request extends FinishedRequest {
@@ -59,6 +61,7 @@ declare global {
auth(user: string, name: string): Request;
field(name: string, val: string): Request;
buffer(): Request;
parse(fn: (res: Response, cb: (e?: Error, r?: any) => void) => void): Request;
end(callback?: (err: any, res: Response) => void): FinishedRequest;
}

View File

@@ -4,15 +4,15 @@
// Fabien Lavocat <https://github.com/FabienLavocat>
// KentarouTakeda <https://github.com/KentarouTakeda>
// Larry Bahr <https://github.com/larrybahr>
// Daniel Luz <https://github.com/mernen>
// Joseph Page <https://github.com/josefpaij>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.3
/// <reference types="jquery" />
declare class Chart {
static readonly Chart: typeof Chart;
constructor(
context: string | JQuery | CanvasRenderingContext2D | HTMLCanvasElement | string[] | CanvasRenderingContext2D[] | HTMLCanvasElement[],
context: string | CanvasRenderingContext2D | HTMLCanvasElement | ArrayLike<CanvasRenderingContext2D | HTMLCanvasElement>,
options: Chart.ChartConfiguration
);
config: Chart.ChartConfiguration;
@@ -34,7 +34,7 @@ declare class Chart {
static pluginService: PluginServiceStatic;
static defaults: {
global: Chart.ChartOptions;
global: Chart.ChartOptions & Chart.ChartFontOptions;
};
}
declare class PluginServiceStatic {
@@ -83,6 +83,8 @@ declare namespace Chart {
type ScaleType = 'category' | 'linear' | 'logarithmic' | 'time' | 'radialLinear';
type PointStyle = 'circle' | 'cross' | 'crossRot' | 'dash' | 'line' | 'rect' | 'rectRounded' | 'rectRot' | 'star' | 'triangle';
type PositionType = 'left' | 'right' | 'top' | 'bottom';
interface ChartArea {
@@ -175,7 +177,7 @@ declare namespace Chart {
interface ChartTitleOptions {
display?: boolean;
position?: string;
position?: PositionType;
fullWdith?: boolean;
fontSize?: number;
fontFamily?: string;
@@ -187,10 +189,12 @@ declare namespace Chart {
interface ChartLegendOptions {
display?: boolean;
position?: string;
position?: PositionType;
fullWidth?: boolean;
onClick?(event: any, legendItem: any): void;
onClick?(event: MouseEvent, legendItem: ChartLegendItem): void;
onHover?(event: MouseEvent, legendItem: ChartLegendItem): void;
labels?: ChartLegendLabelOptions;
reverse?: boolean;
}
interface ChartLegendLabelOptions {
@@ -293,7 +297,7 @@ declare namespace Chart {
interface ChartPointOptions {
radius?: number;
pointStyle?: string;
pointStyle?: PointStyle;
backgroundColor?: ChartColor;
borderWidth?: number;
borderColor?: ChartColor;
@@ -332,6 +336,7 @@ declare namespace Chart {
interface TickOptions {
autoSkip?: boolean;
autoSkipPadding?: boolean;
callback?(value: any, index: any, values: any): string|number;
display?: boolean;
fontColor?: ChartColor;
@@ -386,7 +391,7 @@ declare namespace Chart {
type ChartColor = string | CanvasGradient | CanvasPattern | string[];
interface ChartDataSets {
cubicInterpolationMode?: string;
cubicInterpolationMode?: 'default' | 'monotone';
backgroundColor?: ChartColor | ChartColor[];
borderWidth?: number;
borderColor?: ChartColor;
@@ -394,10 +399,15 @@ declare namespace Chart {
borderDash?: number[];
borderDashOffset?: number;
borderJoinStyle?: string;
borderSkipped?: PositionType;
data?: number[] | ChartPoint[];
fill?: boolean;
fill?: boolean | number | string;
hoverBackgroundColor?: string | string[];
hoverBorderColor?: string | string[];
hoverBorderWidth?: number | number[];
label?: string;
lineTension?: number;
steppedLine?: 'before' | 'after' | boolean;
pointBorderColor?: ChartColor | ChartColor[];
pointBackgroundColor?: ChartColor | ChartColor[];
pointBorderWidth?: number | number[];
@@ -407,14 +417,15 @@ declare namespace Chart {
pointHoverBackgroundColor?: ChartColor | ChartColor[];
pointHoverBorderColor?: ChartColor | ChartColor[];
pointHoverBorderWidth?: number | number[];
pointStyle?: string | string[] | HTMLImageElement | HTMLImageElement[];
pointStyle?: PointStyle | HTMLImageElement | Array<PointStyle | HTMLImageElement>;
xAxisID?: string;
yAxisID?: string;
type?: string;
hidden?: boolean;
hideInLegendAndTooltip?: boolean;
showLine?: boolean;
stack?: string;
spanGaps?: string;
spanGaps?: boolean;
}
interface ChartScales {

View File

@@ -1 +1,6 @@
{ "extends": "dtslint/dt.json" }
{
"extends": "dtslint/dt.json",
"rules": {
"no-any-union": false
}
}

View File

@@ -5,6 +5,8 @@
"adjacent-overload-signatures": false,
"ban-types": false,
"dt-header": false,
"unified-signatures": false
"no-any-union": false,
"unified-signatures": false,
"no-unnecessary-generics": false
}
}

View File

@@ -1,6 +1,8 @@
// Type definitions for chokidar 1.7.0
// Type definitions for chokidar 1.7.1
// Project: https://github.com/paulmillr/chokidar
// Definitions by: Stefan Steinhart <https://github.com/reppners>, Felix Becker <https://github.com/felixfbecker>
// Definitions by: Stefan Steinhart <https://github.com/reppners>
// Felix Becker <https://github.com/felixfbecker>
// Zach Cardoza <https://github.com/bayssmekanique>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference types="node" />
@@ -18,6 +20,11 @@ export interface WatchedPaths {
export class FSWatcher extends EventEmitter implements fs.FSWatcher {
/**
* Constructs a new FSWatcher instance with optional WatchOptions parameter.
*/
constructor(options?: WatchOptions);
/**
* Add files, directories, or glob patterns for tracking. Takes an array of strings or just one
* string.

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