Skip to content

Commit

Permalink
Merge pull request #5 from DefinitelyTyped/master
Browse files Browse the repository at this point in the history
Merge upstream
  • Loading branch information
smac89 committed Jul 22, 2017
2 parents d4f6232 + 045b2ea commit e6eac62
Show file tree
Hide file tree
Showing 250 changed files with 15,292 additions and 4,315 deletions.
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
root = true

[*]
indent_size = 4
trim_trailing_whitespace = true
insert_final_newline = true

[{*.json,*.yml}]
indent_style = space
indent_size = 2
5 changes: 5 additions & 0 deletions types/angular-strap/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,14 @@ declare namespace mgcrea.ngStrap {
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;
}

interface IModalScope extends ng.IScope {
Expand Down
2 changes: 2 additions & 0 deletions types/babel-core/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
// Type definitions for babel-core v6.7
// Project: https://github.com/babel/babel/tree/master/packages/babel-core
// Definitions by: Troy Gerwien <https://github.com/yortus>
// Marvin Hagemeister <https://github.com/marvinhagemeister>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.3

/// <reference types="babel-template" />
/// <reference types="babel-traverse" />
Expand Down
10 changes: 10 additions & 0 deletions types/babel-plugin-syntax-jsx/babel-plugin-syntax-jsx-tests.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import jsx from "babel-plugin-syntax-jsx";

// Example taken from the babel plugin handbook:
// https://github.com/thejameskyle/babel-handbook/blob/master/translations/en/plugin-handbook.md#-enabling-syntax-in-plugins
export default function myBabelPlugin() {
return {
visitor: {},
inherits: jsx,
};
}
13 changes: 13 additions & 0 deletions types/babel-plugin-syntax-jsx/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// Type definitions for babel-plugin-syntax-jsx 6.18
// Project: https://github.com/babel/babel/tree/master/packages/babel-plugin-syntax-jsx
// Definitions by: Marvin Hagemeister <https://github.com/marvinhagemeister>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped

// NB: This export doesn't match the handbook example, where `jsx` is the default export.
// But it does match the runtime behaviour (at least at the time of this writing). For some reason,
// babel-plugin-syntax-jsx/lib/index.js has this line at the bottom: module.exports = exports["default"];
declare function jsx(): {
manipulateOptions(opts: any, parserOpts: { plugins: string[] }): void;
};

export default jsx;
22 changes: 22 additions & 0 deletions types/babel-plugin-syntax-jsx/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": false,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"babel-plugin-syntax-jsx-tests.ts"
]
}
1 change: 1 addition & 0 deletions types/babel-plugin-syntax-jsx/tslint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }
2 changes: 2 additions & 0 deletions types/babel-template/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
// Type definitions for babel-template v6.7
// Project: https://github.com/babel/babel/tree/master/packages/babel-template
// Definitions by: Troy Gerwien <https://github.com/yortus>
// Marvin Hagemeister <https://github.com/marvinhagemeister>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.3

/// <reference types="babylon" />
/// <reference types="babel-types" />
Expand Down
2 changes: 2 additions & 0 deletions types/babel-traverse/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
// Type definitions for babel-traverse v6.7
// Project: https://github.com/babel/babel/tree/master/packages/babel-traverse
// Definitions by: Troy Gerwien <https://github.com/yortus>
// Marvin Hagemeister <https://github.com/marvinhagemeister>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.3

/// <reference types="babel-types" />

Expand Down
8 changes: 2 additions & 6 deletions types/babel-types/babel-types-tests.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@

/// <reference types="babel-traverse" />


// Examples from https://github.com/thejameskyle/babel-handbook/blob/master/translations/en/plugin-handbook.md#babel-types
import traverse from "babel-traverse";
import * as t from "babel-types";
Expand All @@ -25,13 +21,13 @@ if (t.isBinaryExpression(ast)) {
ast.right;
ast.operator;
}

t.assertBinaryExpression(ast);
t.assertBinaryExpression(ast, { operator: "*" });

var exp: t.Expression = t.nullLiteral();
const exp: t.Expression = t.nullLiteral();

// React examples:

// https://github.com/babel/babel/blob/4e50b2d9d9c376cee7a2cbf56553fe5b982ea53c/packages/babel-plugin-transform-react-inline-elements/src/index.js#L61
traverse(ast, {
JSXElement(path, file) {
Expand Down
815 changes: 431 additions & 384 deletions types/babel-types/index.d.ts

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions types/babel-types/tslint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }
2 changes: 2 additions & 0 deletions types/babelify/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
// Type definitions for babelify v7.3.0
// Project: https://github.com/babel/babelify
// Definitions by: TeamworkGuy2 <https://github.com/TeamworkGuy2>
// Marvin Hagemeister <https://github.com/marvinhagemeister>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.3

/// <reference types="node" />

Expand Down
1 change: 0 additions & 1 deletion types/babylon/babylon-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ assert(node.start === 0);
assert(node.end === 38);
assert(node.loc.start > node.loc.end);


babylon.parse(code, {
sourceType: "module", // default: "script"
plugins: ["jsx"] // default: []
Expand Down
6 changes: 3 additions & 3 deletions types/babylon/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// Type definitions for babylon v6.16.1
// Type definitions for babylon 6.16
// Project: https://github.com/babel/babylon
// Definitions by: Troy Gerwien <https://github.com/yortus>
// Marvin Hagemeister <https://github.com/marvinhagemeister>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped

/// <reference types="babel-types" />
// TypeScript Version: 2.3

import { File, Expression } from 'babel-types';

Expand Down
1 change: 1 addition & 0 deletions types/babylon/tslint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }
54 changes: 45 additions & 9 deletions types/bintrees/bintrees-tests.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,50 @@
/// <reference types="mocha" />
/// <reference types="node" />
import assert = require('assert');
import { BinTree, RBTree } from 'bintrees';

let treeA = new RBTree((a:number, b:number) => a - b);
describe('bintrees', () => {
it('builds a simple tree', () => {
let treeA = new RBTree((a: number, b: number) => a - b);

treeA.insert(5);
treeA.insert(3);
treeA.remove(3);
treeA.insert(5);
treeA.insert(3);
treeA.remove(3);

let treeB = new BinTree((a:string, b:string) => a.length - b.length);
assert.equal(treeA.size, 1);
});

it('builds a tree of strings', () => {
let treeB = new BinTree((a:string, b:string) => a.length - b.length);

treeB.insert('hi');
treeB.insert('there');
treeB.insert('how');
treeB.insert('are'); // ignored
treeB.remove('how');

assert.equal(treeB.size, 2);
assert.equal(treeB.min(), 'hi');
});

it('maintains a tree of objects', () => {

interface C {
id: number
}

let treeC = new BinTree<C>((a: C, b: C) => a.id - b.id);

treeC.insert({ id: 100 });
treeC.insert({ id: 110 });
treeC.insert({ id: 105 });

let ids: number[] = [];
treeC.each((val: C) => {
ids.push(val.id);
});

assert.deepEqual(ids, [100, 105, 110]);
});
});

treeB.insert('hi');
treeB.insert('there');
treeB.insert('how');
treeB.insert('are');
12 changes: 6 additions & 6 deletions types/bintrees/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@

declare module 'bintrees' {

type Callback = <T>(item: T) => void;
type Comparator = <T>(a: T, b: T) => number;
type Callback<T> = (item: T) => void;
type Comparator<T> = (a: T, b: T) => number;

class Iterator<T> {
constructor(tree: TreeBase<T>);
Expand Down Expand Up @@ -37,22 +37,22 @@ declare module 'bintrees' {

iterator(): Iterator<T>;

each(cb: Callback): void;
each(cb: Callback<T>): void;

reach(cb: Callback): void;
reach(cb: Callback<T>): void;
}


export class RBTree<T> extends TreeBase<T> {
constructor(comparator: Comparator);
constructor(comparator: Comparator<T>);

insert(item: T): boolean;

remove(item: T): boolean;
}

export class BinTree<T> extends TreeBase<T> {
constructor(comparator: Comparator);
constructor(comparator: Comparator<T>);

insert(item: T): boolean;

Expand Down
27 changes: 27 additions & 0 deletions types/catbox/catbox-tests.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import Catbox = require("catbox");

const Memory: Catbox.EnginePrototypeOrObject = {
start(callback: Catbox.CallBackNoResult) {},
stop() {},
get() {},
set() {},
drop() {},
isReady(): boolean { return true; },
validateSegmentName(segment: string): null { return null; },
};

const client = new Catbox.Client(Memory, { partition: 'cache' });

const cache = new Catbox.Policy({
expiresIn: 5000,
}, client, 'cache');

cache.set('foo', 'bar', 5000, () => {});

cache.get('foo', () => {});

cache.drop('foo', () => {});

cache.isReady();

cache.stats();
Loading

0 comments on commit e6eac62

Please sign in to comment.