Merge remote-tracking branch 'upstream/master'

This commit is contained in:
Stefan Profanter
2015-10-12 18:21:38 +02:00
35 changed files with 15761 additions and 11010 deletions
+137
View File
@@ -0,0 +1,137 @@
/// <reference path="ag-grid" />
checkGridOptions(<ag.grid.GridOptions>{});
checkColDef(<ag.grid.ColDef>{});
function checkGridOptions(gridOptions: ag.grid.GridOptions): void {
gridOptions.virtualPaging = true;
gridOptions.toolPanelSuppressPivot = true;
gridOptions.toolPanelSuppressValues = true;
gridOptions.rowsAlreadyGrouped = true;
gridOptions.suppressRowClickSelection = true;
gridOptions.suppressCellSelection = true;
gridOptions.sortingOrder = ['asc','desc'];
gridOptions.suppressMultiSort = true;
gridOptions.suppressHorizontalScroll = true;
gridOptions.unSortIcon = true;
gridOptions.rowHeight = 0;
gridOptions.rowBuffer = 0;
gridOptions.enableColResize = true;
gridOptions.enableCellExpressions = true;
gridOptions.enableSorting = true;
gridOptions.enableServerSideSorting = true;
gridOptions.enableFilter = true;
gridOptions.enableServerSideFilter = true;
gridOptions.colWidth = 0;
gridOptions.suppressMenuHide = true;
gridOptions.singleClickEdit = true;
gridOptions.debug = true;
gridOptions.icons = {};
gridOptions.angularCompileRows = true;
gridOptions.angularCompileFilters = true;
gridOptions.angularCompileHeaders = true;
gridOptions.localeText = {};
gridOptions.localeTextFunc = function() {}
gridOptions.suppressScrollLag = true;
gridOptions.groupSuppressAutoColumn = true;
gridOptions.groupSelectsChildren = true;
gridOptions.groupHidePivotColumns = true;
gridOptions.groupIncludeFooter = true;
gridOptions.groupUseEntireRow = true;
gridOptions.groupSuppressRow = true;
gridOptions.groupSuppressBlankHeader = true;
gridOptions.forPrint = true;
gridOptions.groupColumnDef = {};
gridOptions.context = {};
gridOptions.rowStyle = {color: 'red'};
gridOptions.rowClass = 'green';
gridOptions.groupDefaultExpanded = false;
gridOptions.slaveGrids = [];
gridOptions.rowSelection = 'single';
gridOptions.rowDeselection = true;
gridOptions.rowData = [];
gridOptions.floatingTopRowData = [];
gridOptions.floatingBottomRowData = [];
gridOptions.showToolPanel = true;
gridOptions.groupKeys = ['a','b']
gridOptions.groupAggFields = ['a','b']
gridOptions.columnDefs = [];
gridOptions.datasource = {};
gridOptions.pinnedColumnCount = 0;
gridOptions.groupHeaders = true;
gridOptions.headerHeight = 0;
gridOptions.groupRowInnerRenderer = function(params) {};
gridOptions.groupRowRenderer = {};
gridOptions.isScrollLag = function() {return true;}
gridOptions.isExternalFilterPresent = function() { return true; };
gridOptions.doesExternalFilterPass = function(node: ag.grid.RowNode) { return false; };
gridOptions.getRowStyle = function() {};
gridOptions.getRowClass = function() {};
gridOptions.headerCellRenderer = function() {};
gridOptions.groupAggFunction = function(nodes: any[]) {};
gridOptions.onReady = function(api: any) {};
gridOptions.onModelUpdated = function() {};
gridOptions.onCellClicked = function(params) {};
gridOptions.onCellDoubleClicked = function(params) {};
gridOptions.onCellContextMenu = function(params) {};
gridOptions.onCellValueChanged = function(params) {};
gridOptions.onCellFocused = function(params) {};
gridOptions.onRowSelected = function(params) {};
gridOptions.onSelectionChanged = function() {};
gridOptions.onBeforeFilterChanged = function() {};
gridOptions.onAfterFilterChanged = function() {};
gridOptions.onFilterModified = function() {};
gridOptions.onBeforeSortChanged = function() {};
gridOptions.onAfterSortChanged = function() {};
gridOptions.onVirtualRowRemoved = function(params) {};
gridOptions.onRowClicked = function(params) {};
gridOptions.api = null;
gridOptions.columnApi = null;
}
function checkColDef(colDef: ag.grid.ColDef): void {
colDef.sort = 'test';
colDef.sortedAt = 0;
colDef.sortingOrder = ['asc','desc'];
colDef.headerName = 'test';
colDef.field = 'test';
colDef.headerValueGetter = 'test';
colDef.colId = 'test';
colDef.hide = true;
colDef.headerTooltip = 'test';
colDef.valueGetter = 'test';
colDef.headerCellRenderer = {};
colDef.headerClass = 'test';
colDef.width = 0;
colDef.minWidth = 0;
colDef.maxWidth = 0;
colDef.cellClass = 'test';
colDef.cellStyle = {color: 'test'};
colDef.cellRenderer = function() {};
colDef.floatingCellRenderer = function() {};
colDef.aggFunc = 'test';
colDef.comparator = function() {};
colDef.checkboxSelection = true;
colDef.suppressMenu = true;
colDef.suppressSorting = true;
colDef.unSortIcon = true;
colDef.suppressSizeToFit = true;
colDef.suppressResize = true;
colDef.headerGroup = 'test';
colDef.headerGroupShow = 'test';
colDef.editable = true;
colDef.newValueHandler = function() {};
colDef.volatile = true;
colDef.template = 'test';
colDef.templateUrl = 'test';
colDef.filter = 'test';
colDef.filterParams = {};
colDef.onCellValueChanged = function() {};
colDef.onCellClicked = function() {};
colDef.onCellDoubleClicked = function() {};
colDef.onCellContextMenu = function() {};
colDef.cellClassRules = {};
}
File diff suppressed because it is too large Load Diff
+1991
View File
File diff suppressed because it is too large Load Diff
+375
View File
@@ -0,0 +1,375 @@
// Type definitions for Backbone 1.0.0
// Project: http://backbonejs.org/
// Definitions by: Boris Yankov <https://github.com/borisyankov/>, Natan Vivo <https://github.com/nvivo/>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
/// <reference path="../jquery/jquery.d.ts" />
declare module Backbone {
interface AddOptions extends Silenceable {
at?: number;
}
interface HistoryOptions extends Silenceable {
pushState?: boolean;
root?: string;
}
interface NavigateOptions {
trigger?: boolean;
replace?: boolean;
}
interface RouterOptions {
routes: any;
}
interface Silenceable {
silent?: boolean;
}
interface Validable {
validate?: boolean;
}
interface Waitable {
wait?: boolean;
}
interface Parseable {
parse?: any;
}
interface PersistenceOptions {
url?: string;
beforeSend?: (jqxhr: JQueryXHR) => void;
success?: (modelOrCollection?: any, response?: any, options?: any) => void;
error?: (modelOrCollection?: any, jqxhr?: JQueryXHR, options?: any) => void;
}
interface ModelSetOptions extends Silenceable, Validable {
}
interface ModelFetchOptions extends PersistenceOptions, ModelSetOptions, Parseable {
}
interface ModelSaveOptions extends Silenceable, Waitable, Validable, Parseable, PersistenceOptions {
patch?: boolean;
}
interface ModelDestroyOptions extends Waitable, PersistenceOptions {
}
interface CollectionFetchOptions extends PersistenceOptions, Parseable {
reset?: boolean;
}
class Events {
on(eventName: string, callback?: Function, context?: any): any;
off(eventName?: string, callback?: Function, context?: any): any;
trigger(eventName: string, ...args: any[]): any;
bind(eventName: string, callback: Function, context?: any): any;
unbind(eventName?: string, callback?: Function, context?: any): any;
once(events: string, callback: Function, context?: any): any;
listenTo(object: any, events: string, callback: Function): any;
listenToOnce(object: any, events: string, callback: Function): any;
stopListening(object?: any, events?: string, callback?: Function): any;
}
class ModelBase extends Events {
url: any;
parse(response: any, options?: any): any;
toJSON(options?: any): any;
sync(...arg: any[]): JQueryXHR;
}
class Model extends ModelBase {
/**
* Do not use, prefer TypeScript's extend functionality.
**/
private static extend(properties: any, classProperties?: any): any;
attributes: any;
changed: any[];
cid: string;
collection: Collection<any>;
/**
* Default attributes for the model. It can be an object hash or a method returning an object hash.
* For assigning an object hash, do it like this: this.defaults = <any>{ attribute: value, ... };
* That works only if you set it in the constructor or the initialize method.
**/
defaults(): any;
id: any;
idAttribute: string;
validationError: any;
urlRoot: any;
constructor(attributes?: any, options?: any);
initialize(attributes?: any, options?: any): void;
fetch(options?: ModelFetchOptions): JQueryXHR;
/**
* For strongly-typed access to attributes, use the `get` method only privately in public getter properties.
* @example
* get name(): string {
* return super.get("name");
* }
**/
/*private*/ get(attributeName: string): any;
/**
* For strongly-typed assignment of attributes, use the `set` method only privately in public setter properties.
* @example
* set name(value: string) {
* super.set("name", value);
* }
**/
/*private*/ set(attributeName: string, value: any, options?: ModelSetOptions): Model;
set(obj: any, options?: ModelSetOptions): Model;
change(): any;
changedAttributes(attributes?: any): any[];
clear(options?: Silenceable): any;
clone(): Model;
destroy(options?: ModelDestroyOptions): any;
escape(attribute: string): string;
has(attribute: string): boolean;
hasChanged(attribute?: string): boolean;
isNew(): boolean;
isValid(options?:any): boolean;
previous(attribute: string): any;
previousAttributes(): any[];
save(attributes?: any, options?: ModelSaveOptions): any;
unset(attribute: string, options?: Silenceable): Model;
validate(attributes: any, options?: any): any;
private _validate(attributes: any, options: any): boolean;
// mixins from underscore
keys(): string[];
values(): any[];
pairs(): any[];
invert(): any;
pick(keys: string[]): any;
pick(...keys: string[]): any;
omit(keys: string[]): any;
omit(...keys: string[]): any;
}
class Collection<TModel extends Model> extends ModelBase {
/**
* Do not use, prefer TypeScript's extend functionality.
**/
private static extend(properties: any, classProperties?: any): any;
model: new (...args:any[]) => TModel;
models: TModel[];
length: number;
constructor(models?: TModel[] | Object[], options?: any);
initialize(models?: TModel[] | Object[], options?: any): void;
fetch(options?: CollectionFetchOptions): JQueryXHR;
comparator(element: TModel): number;
comparator(compare: TModel, to?: TModel): number;
add(model: {}|TModel, options?: AddOptions): TModel;
add(models: ({}|TModel)[], options?: AddOptions): TModel[];
at(index: number): TModel;
/**
* Get a model from a collection, specified by an id, a cid, or by passing in a model.
**/
get(id: number|string|Model): TModel;
create(attributes: any, options?: ModelSaveOptions): TModel;
pluck(attribute: string): any[];
push(model: TModel, options?: AddOptions): TModel;
pop(options?: Silenceable): TModel;
remove(model: TModel, options?: Silenceable): TModel;
remove(models: TModel[], options?: Silenceable): TModel[];
reset(models?: TModel[], options?: Silenceable): TModel[];
set(models?: TModel[], options?: Silenceable): TModel[];
shift(options?: Silenceable): TModel;
sort(options?: Silenceable): Collection<TModel>;
unshift(model: TModel, options?: AddOptions): TModel;
where(properties: any): TModel[];
findWhere(properties: any): TModel;
private _prepareModel(attributes?: any, options?: any): any;
private _removeReference(model: TModel): void;
private _onModelEvent(event: string, model: TModel, collection: Collection<TModel>, options: any): void;
// mixins from underscore
all(iterator: (element: TModel, index: number) => boolean, context?: any): boolean;
any(iterator: (element: TModel, index: number) => boolean, context?: any): boolean;
collect(iterator: (element: TModel, index: number, context?: any) => any[], context?: any): any[];
chain(): any;
contains(value: any): boolean;
countBy(iterator: (element: TModel, index: number) => any): _.Dictionary<number>;
countBy(attribute: string): _.Dictionary<number>;
detect(iterator: (item: any) => boolean, context?: any): any; // ???
drop(): TModel;
drop(n: number): TModel[];
each(iterator: (element: TModel, index: number, list?: any) => void, context?: any): any;
every(iterator: (element: TModel, index: number) => boolean, context?: any): boolean;
filter(iterator: (element: TModel, index: number) => boolean, context?: any): TModel[];
find(iterator: (element: TModel, index: number) => boolean, context?: any): TModel;
first(): TModel;
first(n: number): TModel[];
foldl(iterator: (memo: any, element: TModel, index: number) => any, initialMemo: any, context?: any): any;
forEach(iterator: (element: TModel, index: number, list?: any) => void, context?: any): any;
groupBy(iterator: (element: TModel, index: number) => string, context?: any): _.Dictionary<TModel[]>;
groupBy(attribute: string, context?: any): _.Dictionary<TModel[]>;
include(value: any): boolean;
indexOf(element: TModel, isSorted?: boolean): number;
initial(): TModel;
initial(n: number): TModel[];
inject(iterator: (memo: any, element: TModel, index: number) => any, initialMemo: any, context?: any): any;
isEmpty(object: any): boolean;
invoke(methodName: string, args?: any[]): any;
last(): TModel;
last(n: number): TModel[];
lastIndexOf(element: TModel, fromIndex?: number): number;
map(iterator: (element: TModel, index: number, context?: any) => any, context?: any): any[];
max(iterator?: (element: TModel, index: number) => any, context?: any): TModel;
min(iterator?: (element: TModel, index: number) => any, context?: any): TModel;
reduce(iterator: (memo: any, element: TModel, index: number) => any, initialMemo: any, context?: any): any;
select(iterator: any, context?: any): any[];
size(): number;
shuffle(): any[];
slice(min: number, max?: number): TModel[];
some(iterator: (element: TModel, index: number) => boolean, context?: any): boolean;
sortBy(iterator: (element: TModel, index: number) => number, context?: any): TModel[];
sortBy(attribute: string, context?: any): TModel[];
sortedIndex(element: TModel, iterator?: (element: TModel, index: number) => number): number;
reduceRight(iterator: (memo: any, element: TModel, index: number) => any, initialMemo: any, context?: any): any[];
reject(iterator: (element: TModel, index: number) => boolean, context?: any): TModel[];
rest(): TModel;
rest(n: number): TModel[];
tail(): TModel;
tail(n: number): TModel[];
toArray(): any[];
without(...values: any[]): TModel[];
}
class Router extends Events {
/**
* Do not use, prefer TypeScript's extend functionality.
**/
private static extend(properties: any, classProperties?: any): any;
/**
* Routes hash or a method returning the routes hash that maps URLs with parameters to methods on your Router.
* For assigning routes as object hash, do it like this: this.routes = <any>{ "route": callback, ... };
* That works only if you set it in the constructor or the initialize method.
**/
routes: any;
constructor(options?: RouterOptions);
initialize(options?: RouterOptions): void;
route(route: string|RegExp, name: string, callback?: Function): Router;
navigate(fragment: string, options?: NavigateOptions): Router;
navigate(fragment: string, trigger?: boolean): Router;
private _bindRoutes(): void;
private _routeToRegExp(route: string): RegExp;
private _extractParameters(route: RegExp, fragment: string): string[];
}
var history: History;
class History extends Events {
handlers: any[];
interval: number;
start(options?: HistoryOptions): boolean;
getHash(window?: Window): string;
getFragment(fragment?: string, forcePushState?: boolean): string;
stop(): void;
route(route: string, callback: Function): number;
checkUrl(e?: any): void;
loadUrl(fragmentOverride: string): boolean;
navigate(fragment: string, options?: any): boolean;
started: boolean;
options: any;
private _updateHash(location: Location, fragment: string, replace: boolean): void;
}
interface ViewOptions<TModel extends Model> {
model?: TModel;
// TODO: quickfix, this can't be fixed easy. The collection does not need to have the same model as the parent view.
collection?: Backbone.Collection<any>;
el?: any;
id?: string;
className?: string;
tagName?: string;
attributes?: {[id: string]: any};
}
class View<TModel extends Model> extends Events {
/**
* Do not use, prefer TypeScript's extend functionality.
**/
private static extend(properties: any, classProperties?: any): any;
constructor(options?: ViewOptions<TModel>);
initialize(options?: ViewOptions<TModel>): void;
/**
* Events hash or a method returning the events hash that maps events/selectors to methods on your View.
* For assigning events as object hash, do it like this: this.events = <any>{ "event:selector": callback, ... };
* That works only if you set it in the constructor or the initialize method.
**/
events(): any;
$(selector: string): JQuery;
model: TModel;
collection: Collection<TModel>;
//template: (json, options?) => string;
setElement(element: HTMLElement|JQuery, delegate?: boolean): View<TModel>;
id: string;
cid: string;
className: string;
tagName: string;
el: any;
$el: JQuery;
setElement(element: any): View<TModel>;
attributes: any;
$(selector: any): JQuery;
render(): View<TModel>;
remove(): View<TModel>;
make(tagName: any, attributes?: any, content?: any): any;
delegateEvents(events?: any): any;
undelegateEvents(): any;
_ensureElement(): void;
}
// SYNC
function sync(method: string, model: Model, options?: JQueryAjaxSettings): any;
function ajax(options?: JQueryAjaxSettings): JQueryXHR;
var emulateHTTP: boolean;
var emulateJSON: boolean;
// Utility
function noConflict(): typeof Backbone;
var $: JQueryStatic;
}
declare module "backbone" {
export = Backbone;
}
+314
View File
@@ -0,0 +1,314 @@
/// <reference path="../jquery/jquery.d.ts" />
/// <reference path="../lodash/lodash.d.ts" />
/// <reference path="./backbone-global.d.ts" />
function test_events() {
var object = new Backbone.Events();
object.on("alert", (eventName: string) => alert("Triggered " + eventName));
object.trigger("alert", "an event");
var onChange = () => alert('whatever');
var context: any;
object.off("change", onChange);
object.off("change");
object.off(null, onChange);
object.off(null, null, context);
object.off();
}
class SettingDefaults extends Backbone.Model {
// 'defaults' could be set in one of the following ways:
defaults() {
return {
name: "Joe"
}
}
constructor(attributes?: any, options?: any) {
this.defaults = <any>{
name: "Joe"
}
// super has to come last
super(attributes, options);
}
// or set it like this
initialize() {
this.defaults = <any>{
name: "Joe"
}
}
// same patterns could be used for setting 'Router.routes' and 'View.events'
}
class Sidebar extends Backbone.Model {
promptColor() {
var cssColor = prompt("Please enter a CSS color:");
this.set({ color: cssColor });
}
}
class Note extends Backbone.Model {
initialize() { }
author() { }
coordinates() { }
allowedToEdit(account: any) {
return true;
}
}
class PrivateNote extends Note {
allowedToEdit(account: any) {
return account.owns(this);
}
set(attributes: any, options?: any): Backbone.Model {
return Backbone.Model.prototype.set.call(this, attributes, options);
}
}
function test_models() {
var sidebar = new Sidebar();
sidebar.on('change:color', (model: {}, color: string) => $('#sidebar').css({ background: color }));
sidebar.set({ color: 'white' });
sidebar.promptColor();
//////////
var note = new PrivateNote();
note.get("title");
note.set({ title: "March 20", content: "In his eyes she eclipses..." });
note.set("title", "A Scandal in Bohemia");
}
class Employee extends Backbone.Model {
reports: EmployeeCollection;
constructor(attributes?: any, options?: any) {
super(options);
this.reports = new EmployeeCollection();
this.reports.url = '../api/employees/' + this.id + '/reports';
}
more() {
this.reports.reset();
}
}
class EmployeeCollection extends Backbone.Collection<Employee> {
findByName(key: any) { }
}
class Book extends Backbone.Model {
title: string;
author: string;
published: boolean;
}
class Library extends Backbone.Collection<Book> {
// This model definition is here only to test type compatibility of the model, but it
// is not necessary in working code as it is automatically inferred through generics.
model: typeof Book;
}
class Books extends Backbone.Collection<Book> { }
function test_collection() {
var books = new Books();
var book1: Book = new Book({ title: "Title 1", author: "Mike" });
books.add(book1);
// Objects can be added to collection by casting to model type.
// Compiler will check if object properties are valid for the cast.
// This gives better type checking than declaring an `any` overload.
books.add(<Book>{ title: "Title 2", author: "Mikey" });
var model: Book = book1.collection.first();
if (model !== book1) {
throw new Error("Error");
}
books.each(book =>
book.get("title"));
var titles = books.map(book =>
book.get("title"));
var publishedBooks = books.filter(book =>
book.get("published") === true);
var alphabetical = books.sortBy((book: Book): number => null);
}
//////////
Backbone.history.start();
module v1Changes {
module events {
function test_once() {
var model = new Employee;
model.once('invalid', () => { }, this);
model.once('invalid', () => { });
}
function test_listenTo() {
var model = new Employee;
var view = new Backbone.View<Employee>();
view.listenTo(model, 'invalid', () => { });
}
function test_listenToOnce() {
var model = new Employee;
var view = new Backbone.View<Employee>();
view.listenToOnce(model, 'invalid', () => { });
}
function test_stopListening() {
var model = new Employee;
var view = new Backbone.View<Employee>();
view.stopListening(model, 'invalid', () => { });
view.stopListening(model, 'invalid');
view.stopListening(model);
}
}
module ModelAndCollection {
function test_url() {
Employee.prototype.url = () => '/employees';
EmployeeCollection.prototype.url = () => '/employees';
}
function test_parse() {
var model = new Employee();
model.parse('{}', {});
var collection = new EmployeeCollection;
collection.parse('{}', {});
}
function test_toJSON() {
var model = new Employee();
model.toJSON({});
var collection = new EmployeeCollection;
collection.toJSON({});
}
function test_sync() {
var model = new Employee();
model.sync();
var collection = new EmployeeCollection;
collection.sync();
}
}
module Model {
function test_validationError() {
var model = new Employee;
if (model.validationError) {
console.log('has validation errors');
}
}
function test_fetch() {
var model = new Employee({ id: 1 });
model.fetch({
success: () => { },
error: () => { }
});
}
function test_set() {
var model = new Employee;
model.set({ name: 'JoeDoe', age: 21 }, { validate: false });
model.set('name', 'JoeDoes', { validate: false });
}
function test_destroy() {
var model = new Employee;
model.destroy({
wait: true,
success: (m?, response?, options?) => { },
error: (m?, jqxhr?, options?) => { }
});
model.destroy({
success: (m?, response?, options?) => { },
error: (m?, jqxhr?) => { }
});
model.destroy({
success: () => { },
error: (m?, jqxhr?) => { }
});
}
function test_save() {
var model = new Employee;
model.save({
name: 'Joe Doe',
age: 21
},
{
wait: true,
validate: false,
success: (m?, response?, options?) => { },
error: (m?, jqxhr?, options?) => { }
});
model.save({
name: 'Joe Doe',
age: 21
},
{
success: () => { },
error: (m?, jqxhr?) => { }
});
}
function test_validate() {
var model = new Employee;
model.validate({ name: 'JoeDoe', age: 21 }, { validateAge: false })
}
}
module Collection {
function test_fetch() {
var collection = new EmployeeCollection;
collection.fetch({ reset: true });
}
function test_create() {
var collection = new EmployeeCollection;
var model = new Employee;
collection.create(model, {
validate: false
});
}
}
module Router {
function test_navigate() {
var router = new Backbone.Router;
router.navigate('/employees', { trigger: true });
router.navigate('/employees', true);
}
}
}
+1 -370
View File
@@ -3,374 +3,5 @@
// Definitions by: Boris Yankov <https://github.com/borisyankov/>, Natan Vivo <https://github.com/nvivo/>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
/// <reference path="../jquery/jquery.d.ts" />
/// <reference path="../underscore/underscore.d.ts" />
declare module Backbone {
interface AddOptions extends Silenceable {
at?: number;
}
interface HistoryOptions extends Silenceable {
pushState?: boolean;
root?: string;
}
interface NavigateOptions {
trigger?: boolean;
replace?: boolean;
}
interface RouterOptions {
routes: any;
}
interface Silenceable {
silent?: boolean;
}
interface Validable {
validate?: boolean;
}
interface Waitable {
wait?: boolean;
}
interface Parseable {
parse?: any;
}
interface PersistenceOptions {
url?: string;
beforeSend?: (jqxhr: JQueryXHR) => void;
success?: (modelOrCollection?: any, response?: any, options?: any) => void;
error?: (modelOrCollection?: any, jqxhr?: JQueryXHR, options?: any) => void;
}
interface ModelSetOptions extends Silenceable, Validable {
}
interface ModelFetchOptions extends PersistenceOptions, ModelSetOptions, Parseable {
}
interface ModelSaveOptions extends Silenceable, Waitable, Validable, Parseable, PersistenceOptions {
patch?: boolean;
}
interface ModelDestroyOptions extends Waitable, PersistenceOptions {
}
interface CollectionFetchOptions extends PersistenceOptions, Parseable {
reset?: boolean;
}
class Events {
on(eventName: string, callback?: Function, context?: any): any;
off(eventName?: string, callback?: Function, context?: any): any;
trigger(eventName: string, ...args: any[]): any;
bind(eventName: string, callback: Function, context?: any): any;
unbind(eventName?: string, callback?: Function, context?: any): any;
once(events: string, callback: Function, context?: any): any;
listenTo(object: any, events: string, callback: Function): any;
listenToOnce(object: any, events: string, callback: Function): any;
stopListening(object?: any, events?: string, callback?: Function): any;
}
class ModelBase extends Events {
url: any;
parse(response: any, options?: any): any;
toJSON(options?: any): any;
sync(...arg: any[]): JQueryXHR;
}
class Model extends ModelBase {
/**
* Do not use, prefer TypeScript's extend functionality.
**/
private static extend(properties: any, classProperties?: any): any;
attributes: any;
changed: any[];
cid: string;
collection: Collection<any>;
/**
* Default attributes for the model. It can be an object hash or a method returning an object hash.
* For assigning an object hash, do it like this: this.defaults = <any>{ attribute: value, ... };
* That works only if you set it in the constructor or the initialize method.
**/
defaults(): any;
id: any;
idAttribute: string;
validationError: any;
urlRoot: any;
constructor(attributes?: any, options?: any);
initialize(attributes?: any, options?: any): void;
fetch(options?: ModelFetchOptions): JQueryXHR;
/**
* For strongly-typed access to attributes, use the `get` method only privately in public getter properties.
* @example
* get name(): string {
* return super.get("name");
* }
**/
/*private*/ get(attributeName: string): any;
/**
* For strongly-typed assignment of attributes, use the `set` method only privately in public setter properties.
* @example
* set name(value: string) {
* super.set("name", value);
* }
**/
/*private*/ set(attributeName: string, value: any, options?: ModelSetOptions): Model;
set(obj: any, options?: ModelSetOptions): Model;
change(): any;
changedAttributes(attributes?: any): any[];
clear(options?: Silenceable): any;
clone(): Model;
destroy(options?: ModelDestroyOptions): any;
escape(attribute: string): string;
has(attribute: string): boolean;
hasChanged(attribute?: string): boolean;
isNew(): boolean;
isValid(options?:any): boolean;
previous(attribute: string): any;
previousAttributes(): any[];
save(attributes?: any, options?: ModelSaveOptions): any;
unset(attribute: string, options?: Silenceable): Model;
validate(attributes: any, options?: any): any;
private _validate(attributes: any, options: any): boolean;
// mixins from underscore
keys(): string[];
values(): any[];
pairs(): any[];
invert(): any;
pick(keys: string[]): any;
pick(...keys: string[]): any;
omit(keys: string[]): any;
omit(...keys: string[]): any;
}
class Collection<TModel extends Model> extends ModelBase {
/**
* Do not use, prefer TypeScript's extend functionality.
**/
private static extend(properties: any, classProperties?: any): any;
model: new (...args:any[]) => TModel;
models: TModel[];
length: number;
constructor(models?: TModel[] | Object[], options?: any);
initialize(models?: TModel[] | Object[], options?: any): void;
fetch(options?: CollectionFetchOptions): JQueryXHR;
comparator(element: TModel): number;
comparator(compare: TModel, to?: TModel): number;
add(model: {}|TModel, options?: AddOptions): TModel;
add(models: ({}|TModel)[], options?: AddOptions): TModel[];
at(index: number): TModel;
/**
* Get a model from a collection, specified by an id, a cid, or by passing in a model.
**/
get(id: number|string|Model): TModel;
create(attributes: any, options?: ModelSaveOptions): TModel;
pluck(attribute: string): any[];
push(model: TModel, options?: AddOptions): TModel;
pop(options?: Silenceable): TModel;
remove(model: TModel, options?: Silenceable): TModel;
remove(models: TModel[], options?: Silenceable): TModel[];
reset(models?: TModel[], options?: Silenceable): TModel[];
set(models?: TModel[], options?: Silenceable): TModel[];
shift(options?: Silenceable): TModel;
sort(options?: Silenceable): Collection<TModel>;
unshift(model: TModel, options?: AddOptions): TModel;
where(properties: any): TModel[];
findWhere(properties: any): TModel;
private _prepareModel(attributes?: any, options?: any): any;
private _removeReference(model: TModel): void;
private _onModelEvent(event: string, model: TModel, collection: Collection<TModel>, options: any): void;
// mixins from underscore
all(iterator: (element: TModel, index: number) => boolean, context?: any): boolean;
any(iterator: (element: TModel, index: number) => boolean, context?: any): boolean;
collect(iterator: (element: TModel, index: number, context?: any) => any[], context?: any): any[];
chain(): any;
contains(value: any): boolean;
countBy(iterator: (element: TModel, index: number) => any): _.Dictionary<number>;
countBy(attribute: string): _.Dictionary<number>;
detect(iterator: (item: any) => boolean, context?: any): any; // ???
drop(): TModel;
drop(n: number): TModel[];
each(iterator: (element: TModel, index: number, list?: any) => void, context?: any): any;
every(iterator: (element: TModel, index: number) => boolean, context?: any): boolean;
filter(iterator: (element: TModel, index: number) => boolean, context?: any): TModel[];
find(iterator: (element: TModel, index: number) => boolean, context?: any): TModel;
first(): TModel;
first(n: number): TModel[];
foldl(iterator: (memo: any, element: TModel, index: number) => any, initialMemo: any, context?: any): any;
forEach(iterator: (element: TModel, index: number, list?: any) => void, context?: any): any;
groupBy(iterator: (element: TModel, index: number) => string, context?: any): _.Dictionary<TModel[]>;
groupBy(attribute: string, context?: any): _.Dictionary<TModel[]>;
include(value: any): boolean;
indexOf(element: TModel, isSorted?: boolean): number;
initial(): TModel;
initial(n: number): TModel[];
inject(iterator: (memo: any, element: TModel, index: number) => any, initialMemo: any, context?: any): any;
isEmpty(object: any): boolean;
invoke(methodName: string, args?: any[]): any;
last(): TModel;
last(n: number): TModel[];
lastIndexOf(element: TModel, fromIndex?: number): number;
map(iterator: (element: TModel, index: number, context?: any) => any, context?: any): any[];
max(iterator?: (element: TModel, index: number) => any, context?: any): TModel;
min(iterator?: (element: TModel, index: number) => any, context?: any): TModel;
reduce(iterator: (memo: any, element: TModel, index: number) => any, initialMemo: any, context?: any): any;
select(iterator: any, context?: any): any[];
size(): number;
shuffle(): any[];
slice(min: number, max?: number): TModel[];
some(iterator: (element: TModel, index: number) => boolean, context?: any): boolean;
sortBy(iterator: (element: TModel, index: number) => number, context?: any): TModel[];
sortBy(attribute: string, context?: any): TModel[];
sortedIndex(element: TModel, iterator?: (element: TModel, index: number) => number): number;
reduceRight(iterator: (memo: any, element: TModel, index: number) => any, initialMemo: any, context?: any): any[];
reject(iterator: (element: TModel, index: number) => boolean, context?: any): TModel[];
rest(): TModel;
rest(n: number): TModel[];
tail(): TModel;
tail(n: number): TModel[];
toArray(): any[];
without(...values: any[]): TModel[];
}
class Router extends Events {
/**
* Do not use, prefer TypeScript's extend functionality.
**/
private static extend(properties: any, classProperties?: any): any;
/**
* Routes hash or a method returning the routes hash that maps URLs with parameters to methods on your Router.
* For assigning routes as object hash, do it like this: this.routes = <any>{ "route": callback, ... };
* That works only if you set it in the constructor or the initialize method.
**/
routes: any;
constructor(options?: RouterOptions);
initialize(options?: RouterOptions): void;
route(route: string|RegExp, name: string, callback?: Function): Router;
navigate(fragment: string, options?: NavigateOptions): Router;
navigate(fragment: string, trigger?: boolean): Router;
private _bindRoutes(): void;
private _routeToRegExp(route: string): RegExp;
private _extractParameters(route: RegExp, fragment: string): string[];
}
var history: History;
class History extends Events {
handlers: any[];
interval: number;
start(options?: HistoryOptions): boolean;
getHash(window?: Window): string;
getFragment(fragment?: string, forcePushState?: boolean): string;
stop(): void;
route(route: string, callback: Function): number;
checkUrl(e?: any): void;
loadUrl(fragmentOverride: string): boolean;
navigate(fragment: string, options?: any): boolean;
started: boolean;
options: any;
private _updateHash(location: Location, fragment: string, replace: boolean): void;
}
interface ViewOptions<TModel extends Model> {
model?: TModel;
// TODO: quickfix, this can't be fixed easy. The collection does not need to have the same model as the parent view.
collection?: Backbone.Collection<any>;
el?: any;
id?: string;
className?: string;
tagName?: string;
attributes?: {[id: string]: any};
}
class View<TModel extends Model> extends Events {
/**
* Do not use, prefer TypeScript's extend functionality.
**/
private static extend(properties: any, classProperties?: any): any;
constructor(options?: ViewOptions<TModel>);
initialize(options?: ViewOptions<TModel>): void;
/**
* Events hash or a method returning the events hash that maps events/selectors to methods on your View.
* For assigning events as object hash, do it like this: this.events = <any>{ "event:selector": callback, ... };
* That works only if you set it in the constructor or the initialize method.
**/
events(): any;
$(selector: string): JQuery;
model: TModel;
collection: Collection<TModel>;
//template: (json, options?) => string;
setElement(element: HTMLElement|JQuery, delegate?: boolean): View<TModel>;
id: string;
cid: string;
className: string;
tagName: string;
el: any;
$el: JQuery;
setElement(element: any): View<TModel>;
attributes: any;
$(selector: any): JQuery;
render(): View<TModel>;
remove(): View<TModel>;
make(tagName: any, attributes?: any, content?: any): any;
delegateEvents(events?: any): any;
undelegateEvents(): any;
_ensureElement(): void;
}
// SYNC
function sync(method: string, model: Model, options?: JQueryAjaxSettings): any;
function ajax(options?: JQueryAjaxSettings): JQueryXHR;
var emulateHTTP: boolean;
var emulateJSON: boolean;
// Utility
function noConflict(): typeof Backbone;
var $: JQueryStatic;
}
declare module "backbone" {
export = Backbone;
}
/// <reference path="./backbone-global.d.ts" />
+2 -1
View File
@@ -17,6 +17,7 @@ $('#myModal').modal('toggle');
$('.dropdown-toggle').dropdown();
$('#navbar').scrollspy();
$('body').scrollspy({ target: '#navbar-example' });
$('#element').tooltip('show');
@@ -42,4 +43,4 @@ $('.typeahead').typeahead({
highlighter: item => ""
});
$('#navbar').affix();
$('#navbar').affix();
+1
View File
@@ -22,6 +22,7 @@ interface ModalOptionsBackdropString {
interface ScrollSpyOptions {
offset?: number;
target?: string;
}
interface TooltipOptions {
+4 -1
View File
@@ -79,9 +79,12 @@ bs.init({
bs.reload();
function browserSyncInit(): browserSync.BrowserSync {
function browserSyncInit() {
var browser = browserSync.create();
browser.init();
console.log(browser.name);
console.log(browserSync.name);
return browser;
}
var browser = browserSyncInit();
browser.exit();
+323 -26
View File
@@ -1,6 +1,6 @@
// Type definitions for browser-sync
// Project: http://www.browsersync.io/
// Definitions by: Asana <https://asana.com>
// Definitions by: Asana <https://asana.com>, Joe Skeen <http://github.com/joeskeen>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
/// <reference path="../chokidar/chokidar.d.ts"/>
@@ -12,55 +12,280 @@ declare module "browser-sync" {
import http = require("http");
interface Options {
/**
* Browsersync includes a user-interface that is accessed via a separate port. The UI allows to controls
* all devices, push sync updates and much more.
*
* port - Default: 3001
* weinre.port - Default: 8080
* Note: requires at least version 2.0.0
*/
ui?: UIOptions;
/**
* Browsersync can watch your files as you work. Changes you make will either be injected into the page (CSS
* & images) or will cause all browsers to do a full-page refresh. See anymatch for more information on glob
* patterns.
* Default: false
*/
files?: string | string[];
watchOptions?: GazeOptions;
/**
* File watching options that get passed along to Chokidar. Check their docs for available options
* Default: undefined
* Note: requires at least version 2.6.0
*/
watchOptions?: ChokidarOptions;
/**
* Use the built-in static server for basic HTML/JS/CSS websites.
* Default: false
*/
server?: ServerOptions;
proxy?: string | boolean;
/**
* Proxy an EXISTING vhost. Browsersync will wrap your vhost with a proxy URL to view your site.
* target - Default: undefined
* ws - Default: undefined
* middleware - Default: undefined
* reqHeaders - Default: undefined
* proxyRes - Default: undefined
*/
proxy?: string | boolean | ProxyOptions;
/**
* Use a specific port (instead of the one auto-detected by Browsersync)
* Default: 3000
*/
port?: number;
/**
* Add additional directories from which static files should be served.
* Should only be used in proxy or snippet mode.
* Default: []
* Note: requires at least version 2.8.0
*/
serveStatic?: string[];
/**
* Enable https for localhost development.
* Note - this is not needed for proxy option as it will be inferred from your target url.
* Note: requires at least version 1.3.0
*/
https?: boolean;
/**
* Clicks, Scrolls & Form inputs on any device will be mirrored to all others.
* clicks - Default: true
* scroll - Default: true
* forms - Default: true
*/
ghostMode?: GhostOptions | boolean;
/**
* Can be either "info", "debug", "warn", or "silent"
* Default: info
*/
logLevel?: string;
/**
* Change the console logging prefix. Useful if you're creating your own project based on Browsersync
* Default: BS
* Note: requires at least version 1.5.1
*/
logPrefix?: string;
/**
* Whether or not to log connections
* Default: false
*/
logConnections?: boolean;
/**
* Whether or not to log information about changed files
* Default: false
*/
logFileChanges?: boolean;
/**
* Log the snippet to the console when you're in snippet mode (no proxy/server)
* Default: true
* Note: requires at least version 1.5.2
*/
logSnippet?: boolean;
/**
* You can control how the snippet is injected onto each page via a custom regex + function.
* You can also provide patterns for certain urls that should be ignored from the snippet injection.
* Note: requires at least version 2.0.0
*/
snippetOptions?: SnippetOptions;
/**
* Add additional HTML rewriting rules.
* Default: false
* Note: requires at least version 2.4.0
*/
rewriteRules?: boolean | RewriteRules[];
/**
* Tunnel the Browsersync server through a random Public URL
* Default: null
*/
tunnel?: string | boolean;
/**
* Some features of Browsersync (such as xip & tunnel) require an internet connection, but if you're
* working offline, you can reduce start-up time by setting this option to false
*/
online?: boolean;
/**
* Default: true
* Decide which URL to open automatically when Browsersync starts. Defaults to "local" if none set.
* Can be true, local, external, ui, ui-external, tunnel or false
*/
open?: string | boolean;
/**
* The browser(s) to open
* Default: default
*/
browser?: string | string[];
/**
* Requires an internet connection - useful for services such as Typekit as it allows you to configure
* domains such as *.xip.io in your kit settings
* Default: false
*/
xip?: boolean;
/**
* Reload each browser when Browsersync is restarted.
* Default: false
*/
reloadOnRestart?: boolean;
/**
* The small pop-over notifications in the browser are not always needed/wanted.
* Default: true
*/
notify?: boolean;
scrollProportionally?: boolean;
/**
* scrollProportionally: false // Sync viewports to TOP position
* Default: true
*/
scrollProportionally?: boolean
/**
* How often to send scroll events
* Default: 0
*/
scrollThrottle?: number;
/**
* Decide which technique should be used to restore scroll position following a reload.
* Can be window.name or cookie
* Default: 'window.name'
*/
scrollRestoreTechnique?: string;
/**
* Sync the scroll position of any element on the page. Add any amount of CSS selectors
* Default: []
* Note: requires at least version 2.9.0
*/
scrollElements?: string[];
/**
* Default: []
* Note: requires at least version 2.9.0
* Sync the scroll position of any element on the page - where any scrolled element will cause
* all others to match scroll position. This is helpful when a breakpoint alters which element
* is actually scrolling
*/
scrollElementMapping?: string[];
/**
* Time, in milliseconds, to wait before instructing the browser to reload/inject following a file change event
* Default: 0
*/
reloadDelay?: number;
/**
* Restrict the frequency in which browser:reload events can be emitted to connected clients
* Default: 0
* Note: requires at least version 2.6.0
*/
reloadDebounce?: number;
/**
* User provided plugins
* Default: []
* Note: requires at least version 2.6.0
*/
plugins?: any[];
/**
* Whether to inject changes (rather than a page refresh)
* Default: true
*/
injectChanges?: boolean;
/**
* The initial path to load
*/
startPath?: string;
/**
* Whether to minify the client script
* Default: true
*/
minify?: boolean;
/**
* Override host detection if you know the correct IP to use
*/
host?: string;
/**
* Send file-change events to the browser
* Default: true
*/
codeSync?: boolean;
/**
* Append timestamps to injected files
* Default: true
*/
timestamps?: boolean;
/**
* Alter the script path for complete control over where the Browsersync Javascript is served
* from. Whatever you return from this function will be used as the script path.
* Note: requires at least version 1.5.0
*/
scriptPath?: (path: string) => string;
/**
* Configure the Socket.IO path and namespace & domain to avoid collisions.
* path - Default: "/browser-sync/socket.io"
* clientPath - Default: "/browser-sync"
* namespace - Default: "/browser-sync"
* domain - Default: undefined
* port - Default: undefined
* clients.heartbeatTimeout - Default: 5000
* Note: requires at least version 1.6.2
*/
socket?: SocketOptions;
}
interface GazeOptions {
interface Hash<T> {
[path: string]: T;
}
interface ChokidarOptions {
interval?: number;
debounceDelay?: number;
mode?: string;
cwd?: string;
}
interface UIOptions {
/** set the default port */
port?: number;
/** set the default weinre port */
weinre?: {
port?: number;
};
}
interface ServerOptions {
/** set base directory */
baseDir?: string | string[];
/** enable directory listing */
directory?: boolean;
/** set index filename */
index?: string;
routes?: {[path: string]: string};
/**
* key-value object hash, where the key is the url to match,
* and the value is the folder to serve (relative to your working directory)
* */
routes?: Hash<string>;
/** configure custom middleware */
middleware?: MiddlewareHandler[];
}
interface ProxyOptions {
target?: string;
middleware?: MiddlewareHandler;
ws: boolean;
reqHeaders: (config: any) => Hash<any>;
proxyRes: (res: http.ServerResponse, req: http.ServerRequest, next: Function) => any;
}
interface MiddlewareHandler {
(req: http.ServerRequest, res: http.ServerResponse, next: Function): any;
@@ -81,6 +306,9 @@ declare module "browser-sync" {
path?: string;
clientPath?: string;
namespace?: string;
domain?: string;
port?: number;
clients?: { heartbeatTimeout?: number; };
}
interface RewriteRules {
@@ -88,30 +316,99 @@ declare module "browser-sync" {
fn: (match: string) => string;
}
module browserSync {
interface BrowserSync {
init(config?: Options, callback?: (err: Error, bs: Object) => any): void;
reload(): void;
reload(file: string): void;
reload(files: string[]): void;
reload(options: {stream: boolean}): NodeJS.ReadWriteStream;
notify(message: string, timeout?: number): void;
exit(): void;
watch(patterns: string, opts?: chokidar.WatchOptions, fn?: (event: string, file: fs.Stats) => any): NodeJS.EventEmitter;
pause(): void;
resume(): void;
emitter: NodeJS.EventEmitter;
active: boolean;
paused: boolean;
}
interface BrowserSyncStatic extends BrowserSyncInstance {
/**
* Start the Browsersync service. This will launch a server, proxy or start the snippet mode
* depending on your use-case.
*/
(config?: Options, callback?: (err: Error, bs: Object) => any): BrowserSyncInstance;
/**
* Create a Browsersync instance
* @param name an identifier that can used for retrieval later
*/
create(name?: string): BrowserSyncInstance;
/**
* Get a single instance by name. This is useful if you have your build scripts in separate files
* @param name the identifier used for retrieval
*/
get(name: string): BrowserSyncInstance;
}
interface Exports extends browserSync.BrowserSync {
create(): browserSync.BrowserSync;
(config?: Options, callback?: (err: Error, bs: Object) => any): void;
interface BrowserSyncInstance {
/** the name of this instance of browser-sync */
name: string;
/**
* Start the Browsersync service. This will launch a server, proxy or start the snippet mode
* depending on your use-case.
*/
init(config?: Options, callback?: (err: Error, bs: Object) => any): BrowserSyncInstance;
/**
* Reload the browser
* The reload method will inform all browsers about changed files and will either cause the browser
* to refresh, or inject the files where possible.
*/
reload(): void;
/**
* Reload a single file
* The reload method will inform all browsers about changed files and will either cause the browser
* to refresh, or inject the files where possible.
*/
reload(file: string): void;
/**
* Reload multiple files
* The reload method will inform all browsers about changed files and will either cause the browser
* to refresh, or inject the files where possible.
*/
reload(files: string[]): void;
/**
* The reload method will inform all browsers about changed files and will either cause the browser
* to refresh, or inject the files where possible.
*/
reload(options: {stream: boolean}): NodeJS.ReadWriteStream;
/**
* The stream method returns a transform stream and can act once or on many files.
* @param opts Configuration for the stream method
*/
stream(opts: {once: boolean}): NodeJS.ReadWriteStream;
/**
* Helper method for browser notifications
* @param message Can be a simple message such as 'Connected' or HTML
* @param timeout How long the message will remain in the browser. @since 1.3.0
*/
notify(message: string, timeout?: number): void;
/**
* This method will close any running server, stop file watching & exit the current process.
*/
exit(): void;
/**
* Stand alone file-watcher. Use this along with Browsersync to create your own, minimal build system
*/
watch(patterns: string, opts?: chokidar.WatchOptions, fn?: (event: string, file: fs.Stats) => any)
: NodeJS.EventEmitter;
/**
* Method to pause file change events
*/
pause(): void;
/**
* Method to resume paused watchers
*/
resume(): void;
/**
* The internal Event Emitter used by the running Browsersync instance (if there is one). You can use
* this to emit your own events, such as changed files, logging etc.
*/
emitter: NodeJS.EventEmitter;
/**
* A simple true/false flag that you can use to determine if there's a currently-running Browsersync instance.
*/
active: boolean;
/**
* A simple true/false flag to determine if the current instance is paused
*/
paused: boolean;
}
var browserSync: Exports;
const browserSync: BrowserSyncStatic;
export = browserSync;
}
+9 -8
View File
@@ -7,11 +7,11 @@ del(["tmp/*.js", "!tmp/unicorn.js"]);
del(["tmp/*.js", "!tmp/unicorn.js"], {force: true});
del(["tmp/*.js", "!tmp/unicorn.js"], (err, paths) => {
del(["tmp/*.js", "!tmp/unicorn.js"]).then((paths: string[]) => {
console.log('Deleted files/folders:\n', paths.join('\n'));
});
del(["tmp/*.js", "!tmp/unicorn.js"], {force: true}, (err, paths) => {
del(["tmp/*.js", "!tmp/unicorn.js"], {force: true}).then((paths: string[]) => {
console.log('Deleted files/folders:\n', paths.join('\n'));
});
@@ -19,18 +19,19 @@ del("tmp/*.js");
del("tmp/*.js", {force: true});
del("tmp/*.js", (err, paths) => {
del("tmp/*.js").then((paths: string[]) => {
console.log('Deleted files/folders:\n', paths.join('\n'));
});
del("tmp/*.js", {force: true}, (err, paths) => {
del("tmp/*.js", {force: true}).then((paths: string[]) => {
console.log('Deleted files/folders:\n', paths.join('\n'));
});
del.sync(["tmp/*.js", "!tmp/unicorn.js"]);
var paths: string[];
paths = del.sync(["tmp/*.js", "!tmp/unicorn.js"]);
del.sync(["tmp/*.js", "!tmp/unicorn.js"], {force: true});
paths = del.sync(["tmp/*.js", "!tmp/unicorn.js"], {force: true});
del.sync("tmp/*.js");
paths = del.sync("tmp/*.js");
del.sync("tmp/*.js", {force: true});
paths = del.sync("tmp/*.js", {force: true});
+7 -10
View File
@@ -4,23 +4,20 @@
// Definitions: https://github.com/borisyankov/DefinitelyTyped
/// <reference path="../glob/glob.d.ts"/>
/// <reference path="../es6-promise/es6-promise.d.ts" />
declare module "del" {
import glob = require("glob");
function Del(pattern: string): void;
function Del(pattern: string, options: Del.Options): void;
function Del(pattern: string, callback: (err: Error, deletedFiles: string[]) => any): void;
function Del(pattern: string, options: Del.Options, callback: (err: Error, deletedFiles: string[]) => any): void;
function Del(pattern: string): Promise<string[]>;
function Del(pattern: string, options: Del.Options): Promise<string[]>;
function Del(patterns: string[]): void;
function Del(patterns: string[], options: Del.Options): void;
function Del(patterns: string[], callback: (err: Error, deletedFiles: string[]) => any): void;
function Del(patterns: string[], options: Del.Options, callback: (err: Error, deletedFiles: string[]) => any): void;
function Del(patterns: string[]): Promise<string[]>;
function Del(patterns: string[], options: Del.Options): Promise<string[]>;
module Del {
function sync(pattern: string, options?: Options): void;
function sync(patterns: string[], options?: Options): void;
function sync(pattern: string, options?: Options): string[];
function sync(patterns: string[], options?: Options): string[];
interface Options extends glob.IOptions {
force?: boolean
@@ -3041,7 +3041,7 @@ declare module DevExpress.ui {
lookup?: {
/** Specifies whether or not a user can nullify values of a lookup column. */
allowClearing?: boolean;
/**
/**
* Specifies the data source providing data for a lookup column.
*/
dataSource?: any;
@@ -3076,9 +3076,6 @@ declare module DevExpress.ui {
showInColumnChooser?: boolean;
/** Specifies the identifier of the column. */
name?: string;
// NOTE https://github.com/borisyankov/DefinitelyTyped/pull/5590
text?: string;
value?: any;
}
export interface dxDataGridOptions extends WidgetOptions {
/** Specifies whether the outer borders of the grid are visible or not. */
@@ -3174,7 +3171,7 @@ declare module DevExpress.ui {
cancel?: string;
}
};
/**
/**
* An array of grid columns.
*/
columns?: dxDataGridColumn[];
@@ -3274,7 +3271,7 @@ declare module DevExpress.ui {
autoExpandAll?: boolean;
/** Specifies the message displayed in a group row when the corresponding group is continued from the previous page. */
groupContinuedMessage?: string;
/**
/**
* Specifies the message displayed in a group row when the corresponding group continues on the next page.
*/
groupContinuesMessage?: string;
@@ -3656,7 +3653,7 @@ declare module DevExpress.ui {
removeRow(rowIndex: number): void;
/** Saves changes made in a grid. */
saveEditData(): void;
/**
/**
* Searches grid records by a search string.
*/
searchByText(text: string): void;
@@ -5955,7 +5952,7 @@ declare module DevExpress.viz.rangeSelector {
behavior?: {
/** Indicates whether or not you can swap sliders. */
allowSlidersSwap?: boolean;
/**
/**
Indicates whether or not animation is enabled.
*/
animationEnabled?: boolean;
@@ -6070,7 +6067,7 @@ Indicates whether or not animation is enabled.
maxRange?: any;
/** Specifies the number of minor ticks between neighboring major ticks. */
minorTickCount?: number;
/**
/**
Specifies an interval between minor ticks.
*/
minorTickInterval?: any;
@@ -1,4 +1,4 @@
/// <reference path="dx.devextreme.d.ts" />
/// <reference path="devextreme.d.ts" />
module Tests.ui {
var dataGridOptions: DevExpress.ui.dxDataGridOptions = {
+6572
View File
File diff suppressed because it is too large Load Diff
+7 -5
View File
@@ -282,9 +282,7 @@ interface KnockoutUtils {
arrayFilter<T>(array: T[], predicate: (item: T) => boolean): T[];
arrayPushAll<T>(array: T[], valuesToPush: T[]): T[];
arrayPushAll<T>(array: KnockoutObservableArray<T>, valuesToPush: T[]): T[];
arrayPushAll<T>(array: T[] | KnockoutObservableArray<T>, valuesToPush: T[]): T[];
extend(target: Object, source: Object): Object;
@@ -320,8 +318,8 @@ interface KnockoutUtils {
toggleDomNodeCssClass(node: any, className: string, shouldHaveClass: boolean): void;
//setTextContent(element: any, textContent: string): void; // NOT PART OF THE MINIFIED API SURFACE (ONLY IN knockout-{version}.debug.js) https://github.com/SteveSanderson/knockout/issues/670
setTextContent(element: any, textContent: string | KnockoutObservable<string>): void; // IT's PART OF THE MINIFIED API SURFACE https://github.com/knockout/knockout/blob/master/src/utils.js#L599
setElementName(element: any, name: string): void;
forceRefresh(node: any): void;
@@ -345,6 +343,10 @@ interface KnockoutUtils {
isIe6: boolean;
isIe7: boolean;
objectForEach(obj: any, action: (key: any, value: any) => void): void;
addOrRemoveItem<T>(array: T[] | KnockoutObservable<T>, value: T, included: T): void;
}
interface KnockoutArrayChange<T> {
+122 -23
View File
@@ -240,6 +240,42 @@ module TestDropRight {
result = _(list).dropRight<TResult>(42).value();
}
// _.dropRightWhile
module TestDropRightWhile {
let array: TResult[];
let list: _.List<TResult>;
let predicateFn: (value: TResult, index: number, collection: _.List<TResult>) => boolean;
let result: TResult[];
result = _.dropRightWhile<TResult>(array);
result = _.dropRightWhile<TResult>(array, predicateFn);
result = _.dropRightWhile<TResult>(array, predicateFn, any);
result = _.dropRightWhile<TResult>(array, '');
result = _.dropRightWhile<TResult>(array, '', any);
result = _.dropRightWhile<{a: number;}, TResult>(array, {a: 42});
result = _.dropRightWhile<TResult>(list);
result = _.dropRightWhile<TResult>(list, predicateFn);
result = _.dropRightWhile<TResult>(list, predicateFn, any);
result = _.dropRightWhile<TResult>(list, '');
result = _.dropRightWhile<TResult>(list, '', any);
result = _.dropRightWhile<{a: number;}, TResult>(list, {a: 42});
result = _(array).dropRightWhile().value();
result = _(array).dropRightWhile(predicateFn).value();
result = _(array).dropRightWhile(predicateFn, any).value();
result = _(array).dropRightWhile('').value();
result = _(array).dropRightWhile('', any).value();
result = _(array).dropRightWhile<{a: number;}>({a: 42}).value();
result = _(list).dropRightWhile<TResult>().value();
result = _(list).dropRightWhile<TResult>(predicateFn).value();
result = _(list).dropRightWhile<TResult>(predicateFn, any).value();
result = _(list).dropRightWhile<TResult>('').value();
result = _(list).dropRightWhile<TResult>('', any).value();
result = _(list).dropRightWhile<{a: number;}, TResult>({a: 42}).value();
}
// _.dropWhile
module TestDropWhile {
let array: TResult[];
@@ -250,14 +286,14 @@ module TestDropWhile {
result = _.dropWhile<TResult>(array);
result = _.dropWhile<TResult>(array, predicateFn);
result = _.dropWhile<TResult>(array, predicateFn, any);
result = _.dropWhile<TResult>(array, '')
result = _.dropWhile<TResult>(array, '');
result = _.dropWhile<TResult>(array, '', any);
result = _.dropWhile<{a: number;}, TResult>(array, {a: 42});
result = _.dropWhile<TResult>(list);
result = _.dropWhile<TResult>(list, predicateFn);
result = _.dropWhile<TResult>(list, predicateFn, any);
result = _.dropWhile<TResult>(list, '')
result = _.dropWhile<TResult>(list, '');
result = _.dropWhile<TResult>(list, '', any);
result = _.dropWhile<{a: number;}, TResult>(list, {a: 42});
@@ -276,18 +312,6 @@ module TestDropWhile {
result = _(list).dropWhile<{a: number;}, TResult>({a: 42}).value();
}
result = <number[]>_.rest([1, 2, 3]);
result = <number[]>_.rest([1, 2, 3], 2);
result = <number[]>_.rest([1, 2, 3], (num) => num < 3)
result = <IFoodOrganic[]>_.rest(foodsOrganic, 'test');
result = <IFoodType[]>_.rest(foodsType, { 'type': 'value' });
result = <number[]>_.tail([1, 2, 3])
result = <number[]>_.tail([1, 2, 3], 2)
result = <number[]>_.tail([1, 2, 3], (num) => num < 3)
result = <IFoodOrganic[]>_.tail(foodsOrganic, 'test')
result = <IFoodType[]> _.tail(foodsType, { 'type': 'value' })
// _.fill
var testFillArray = [1, 2, 3];
var testFillList: _.List<number> = {0: 1, 1: 2, 2: 3, length: 3};
@@ -388,14 +412,40 @@ result = <Array<number>>_.flatten([1, [2], [[3]]], true);
result = <Array<number>>_.flatten<number>([1, [2], [3, [[4]]]], true);
result = <Array<number|boolean>>_.flatten<number|boolean>([1, [2], [3, [[false]]]], true);
result = <Array<number>>_.flattenDeep<number>([[[[1]]]]);
result = <_.LoDashArrayWrapper<number>>_([[1, 2], [3, 4], 5, 6]).flatten();
result = <_.LoDashArrayWrapper<number|Array<Array<number>>>>_([1, [2], [3, [[4]]]]).flatten();
result = <_.LoDashArrayWrapper<number>>_([1, [2], [3, [[4]]]]).flatten(true);
result = <_.LoDashArrayWrapper<number>>_([1, [2], [3, [[4]]]]).flattenDeep();
// _.flattenDeep
module TestFlattenDeep {
interface RecursiveArray<T> extends Array<T|RecursiveArray<T>> {}
interface ListOfRecursiveArraysOrValues<T> extends _.List<T|RecursiveArray<T>> {}
interface RecursiveList<T> extends _.List<T|RecursiveList<T>> { }
let recursiveArray: RecursiveArray<TResult>;
let listOfMaybeRecursiveArraysOrValues: ListOfRecursiveArraysOrValues<TResult>;
let recursiveList: RecursiveList<TResult>;
{
let result: TResult[];
result = _.flattenDeep<TResult>(recursiveArray);
result = _.flattenDeep<TResult>(listOfMaybeRecursiveArraysOrValues);
result = _(recursiveArray).flattenDeep<TResult>().value();
result = _(listOfMaybeRecursiveArraysOrValues).flattenDeep<TResult>().value();
}
{
let result: any;
result = _.flattenDeep<TResult>(recursiveList);
result = _(recursiveList).flattenDeep().value();
}
}
// _.head
module TestHead {
@@ -584,6 +634,18 @@ module TestRemove {
result = _(list).remove<{a: number}, TResult>({a: 42}).value();
}
// _.rest
module TestRest {
let array: TResult[];
let list: _.List<TResult>;
let result: TResult[];
result = _.rest<TResult>(array);
result = _.rest<TResult>(list);
result = _(array).rest().value();
result = _(list).rest<TResult>().value();
}
// _.slice
{
let testSliceArray: TResult[];
@@ -608,6 +670,18 @@ result = <number>_.sortedIndex(['twenty', 'thirty', 'fifty'], 'fourty', function
return this.wordToNumber[word];
}, sortedIndexDict);
// _.tail
module TestTail {
let array: TResult[];
let list: _.List<TResult>;
let result: TResult[];
result = _.tail<TResult>(array);
result = _.tail<TResult>(list);
result = _(array).tail().value();
result = _(list).tail<TResult>().value();
}
// _.take
module TestTake {
let array: TResult[];
@@ -648,14 +722,14 @@ module TestTakeRightWhile {
result = _.takeRightWhile<TResult>(array);
result = _.takeRightWhile<TResult>(array, predicateFn);
result = _.takeRightWhile<TResult>(array, predicateFn, any);
result = _.takeRightWhile<TResult>(array, '')
result = _.takeRightWhile<TResult>(array, '');
result = _.takeRightWhile<TResult>(array, '', any);
result = _.takeRightWhile<{a: number;}, TResult>(array, {a: 42});
result = _.takeRightWhile<TResult>(list);
result = _.takeRightWhile<TResult>(list, predicateFn);
result = _.takeRightWhile<TResult>(list, predicateFn, any);
result = _.takeRightWhile<TResult>(list, '')
result = _.takeRightWhile<TResult>(list, '');
result = _.takeRightWhile<TResult>(list, '', any);
result = _.takeRightWhile<{a: number;}, TResult>(list, {a: 42});
@@ -684,14 +758,14 @@ module TestTakeWhile {
result = _.takeWhile<TResult>(array);
result = _.takeWhile<TResult>(array, predicateFn);
result = _.takeWhile<TResult>(array, predicateFn, any);
result = _.takeWhile<TResult>(array, '')
result = _.takeWhile<TResult>(array, '');
result = _.takeWhile<TResult>(array, '', any);
result = _.takeWhile<{a: number;}, TResult>(array, {a: 42});
result = _.takeWhile<TResult>(list);
result = _.takeWhile<TResult>(list, predicateFn);
result = _.takeWhile<TResult>(list, predicateFn, any);
result = _.takeWhile<TResult>(list, '')
result = _.takeWhile<TResult>(list, '');
result = _.takeWhile<TResult>(list, '', any);
result = _.takeWhile<{a: number;}, TResult>(list, {a: 42});
@@ -710,9 +784,34 @@ module TestTakeWhile {
result = _(list).takeWhile<{a: number;}, TResult>({a: 42}).value();
}
result = <number[]>_.union([1, 2, 3], [101, 2, 1, 10], [2, 1]);
// _.union
module TestUnion {
let array: TResult[];
let list: _.List<TResult>;
let result: TResult[];
result = <number[]>_([1, 2, 3]).union([101, 2, 1, 10], [2, 1]).value();
result = _.union<TResult>();
result = _.union<TResult>(array);
result = _.union<TResult>(array, list);
result = _.union<TResult>(array, list, array);
result = _.union<TResult>(list);
result = _.union<TResult>(list, array);
result = _.union<TResult>(list, array, list);
result = _(array).union().value();
result = _(array).union(list).value();
result = _(array).union(list, array).value();
result = _(array).union<TResult>().value();
result = _(array).union<TResult>(list).value();
result = _(array).union<TResult>(list, array).value();
result = _(list).union<TResult>().value();
result = _(list).union<TResult>(array).value();
result = _(list).union<TResult>(array, list).value();
}
result = <number[]>_.uniq([1, 2, 1, 3, 1]);
result = <number[]>_.uniq([1, 1, 2, 2, 3], true);
+187 -168
View File
@@ -457,6 +457,100 @@ declare module _ {
dropRight<TResult>(n?: number): LoDashArrayWrapper<TResult>;
}
//_.dropRightWhile
interface LoDashStatic {
/**
* Creates a slice of array excluding elements dropped from the end. Elements are dropped until predicate
* returns falsey. The predicate is bound to thisArg and invoked with three arguments: (value, index, array).
*
* If a property name is provided for predicate the created _.property style callback returns the property
* value of the given element.
*
* If a value is also provided for thisArg the created _.matchesProperty style callback returns true for
* elements that have a matching property value, else false.
*
* If an object is provided for predicate the created _.matches style callback returns true for elements that
* match the properties of the given object, else false.
*
* @param array The array to query.
* @param predicate The function invoked per iteration.
* @param thisArg The this binding of predicate.
* @return Returns the slice of array.
*/
dropRightWhile<TValue>(
array: List<TValue>,
predicate?: ListIterator<TValue, boolean>,
thisArg?: any
): TValue[];
/**
* @see _.dropRightWhile
*/
dropRightWhile<TValue>(
array: List<TValue>,
predicate?: string,
thisArg?: any
): TValue[];
/**
* @see _.dropRightWhile
*/
dropRightWhile<TWhere, TValue>(
array: List<TValue>,
predicate?: TWhere
): TValue[];
}
interface LoDashArrayWrapper<T> {
/**
* @see _.dropRightWhile
*/
dropRightWhile(
predicate?: ListIterator<T, boolean>,
thisArg?: any
): LoDashArrayWrapper<T>;
/**
* @see _.dropRightWhile
*/
dropRightWhile(
predicate?: string,
thisArg?: any
): LoDashArrayWrapper<T>;
/**
* @see _.dropRightWhile
*/
dropRightWhile<TWhere>(
predicate?: TWhere
): LoDashArrayWrapper<T>;
}
interface LoDashObjectWrapper<T> {
/**
* @see _.dropRightWhile
*/
dropRightWhile<TValue>(
predicate?: ListIterator<TValue, boolean>,
thisArg?: any
): LoDashArrayWrapper<TValue>;
/**
* @see _.dropRightWhile
*/
dropRightWhile<TValue>(
predicate?: string,
thisArg?: any
): LoDashArrayWrapper<TValue>;
/**
* @see _.dropRightWhile
*/
dropRightWhile<TWhere, TValue>(
predicate?: TWhere
): LoDashArrayWrapper<TValue>;
}
//_.dropWhile
interface LoDashStatic {
/**
@@ -766,6 +860,8 @@ declare module _ {
}
interface MaybeNestedList<T> extends List<T|List<T>> { }
interface RecursiveArray<T> extends Array<T|RecursiveArray<T>> { }
interface ListOfRecursiveArraysOrValues<T> extends List<T|RecursiveArray<T>> { }
interface RecursiveList<T> extends List<T|RecursiveList<T>> { }
//_.flatten
@@ -792,16 +888,6 @@ declare module _ {
* @return `array` flattened.
**/
flatten<T>(array: RecursiveList<T>, isDeep: boolean): List<T> | RecursiveList<T>;
/**
* Recursively flattens a nested array.
*
* _.flattenDeep(x) is equivalent to _.flatten(x, true);
*
* @param array The array to flatten
* @return `array` recursively flattened
*/
flattenDeep<T>(array: RecursiveList<T>): List<T>
}
interface LoDashArrayWrapper<T> {
@@ -814,11 +900,41 @@ declare module _ {
* @see _.flatten
**/
flatten<T>(isShallow: boolean): LoDashArrayWrapper<any>;
}
//_.flattenDeep
interface LoDashStatic {
/**
* Recursively flattens a nested array.
*
* @param array The array to recursively flatten.
* @return Returns the new flattened array.
*/
flattenDeep<T>(array: RecursiveArray<T>): T[];
/**
* @see _.flattenDeep
*/
flattenDeep<T>(): LoDashArrayWrapper<any>;
flattenDeep<T>(array: ListOfRecursiveArraysOrValues<T>): T[];
/**
* @see _.flattenDeep
*/
flattenDeep<T>(array: RecursiveList<T>): any[];
}
interface LoDashArrayWrapper<T> {
/**
* @see _.flattenDeep
*/
flattenDeep<TResult>(): LoDashArrayWrapper<TResult>;
}
interface LoDashObjectWrapper<T> {
/**
* @see _.flattenDeep
*/
flattenDeep<TResult>(): LoDashArrayWrapper<TResult>;
}
//_.head
@@ -1165,155 +1281,28 @@ declare module _ {
//_.rest
interface LoDashStatic {
/**
* The opposite of _.initial this method gets all but the first element or first n elements of
* an array. If a callback function is provided elements at the beginning of the array are excluded
* from the result as long as the callback returns truey. The callback is bound to thisArg and
* invoked with three arguments; (value, index, array).
*
* If a property name is provided for callback the created "_.pluck" style callback will return
* the property value of the given element.
*
* If an object is provided for callback the created "_.where" style callback will return true
* for elements that have the properties of the given object, else false.
* @param array The array to query.
* @param {(Function|Object|number|string)} [callback=1] The function called per element or the number
* of elements to exclude. If a property name or object is provided it will be used to create a
* ".pluck" or ".where" style callback, respectively.
* @param {*} [thisArg] The this binding of callback.
* @return Returns a slice of array.
**/
rest<T>(array: Array<T>): T[];
/**
* @see _.rest
**/
* Gets all but the first element of array.
*
* @alias _.tail
*
* @param array The array to query.
* @return Returns the slice of array.
*/
rest<T>(array: List<T>): T[];
}
interface LoDashArrayWrapper<T> {
/**
* @see _.rest
**/
rest<T>(
array: Array<T>,
callback: ListIterator<T, boolean>,
thisArg?: any): T[];
* @see _.rest
*/
rest(): LoDashArrayWrapper<T>;
}
interface LoDashObjectWrapper<T> {
/**
* @see _.rest
**/
rest<T>(
array: List<T>,
callback: ListIterator<T, boolean>,
thisArg?: any): T[];
/**
* @see _.rest
**/
rest<T>(
array: Array<T>,
n: number): T[];
/**
* @see _.rest
**/
rest<T>(
array: List<T>,
n: number): T[];
/**
* @see _.rest
**/
rest<T>(
array: Array<T>,
pluckValue: string): T[];
/**
* @see _.rest
**/
rest<T>(
array: List<T>,
pluckValue: string): T[];
/**
* @see _.rest
**/
rest<W, T>(
array: Array<T>,
whereValue: W): T[];
/**
* @see _.rest
**/
rest<W, T>(
array: List<T>,
whereValue: W): T[];
/**
* @see _.rest
**/
tail<T>(array: Array<T>): T[];
/**
* @see _.rest
**/
tail<T>(array: List<T>): T[];
/**
* @see _.rest
**/
tail<T>(
array: Array<T>,
callback: ListIterator<T, boolean>,
thisArg?: any): T[];
/**
* @see _.rest
**/
tail<T>(
array: List<T>,
callback: ListIterator<T, boolean>,
thisArg?: any): T[];
/**
* @see _.rest
**/
tail<T>(
array: Array<T>,
n: number): T[];
/**
* @see _.rest
**/
tail<T>(
array: List<T>,
n: number): T[];
/**
* @see _.rest
**/
tail<T>(
array: Array<T>,
pluckValue: string): T[];
/**
* @see _.rest
**/
tail<T>(
array: List<T>,
pluckValue: string): T[];
/**
* @see _.rest
**/
tail<W, T>(
array: Array<T>,
whereValue: W): T[];
/**
* @see _.rest
**/
tail<W, T>(
array: List<T>,
whereValue: W): T[];
* @see _.rest
*/
rest<TResult>(): LoDashArrayWrapper<TResult>;
}
//_.slice
@@ -1413,6 +1402,28 @@ declare module _ {
whereValue: W): number;
}
//_.tail
interface LoDashStatic {
/**
* @see _.rest
*/
tail<T>(array: List<T>): T[];
}
interface LoDashArrayWrapper<T> {
/**
* @see _.rest
*/
tail(): LoDashArrayWrapper<T>;
}
interface LoDashObjectWrapper<T> {
/**
* @see _.rest
*/
tail<TResult>(): LoDashArrayWrapper<TResult>;
}
//_.take
interface LoDashStatic {
/**
@@ -1662,24 +1673,32 @@ declare module _ {
//_.union
interface LoDashStatic {
/**
* Creates an array of unique values, in order, of the provided arrays using strict
* equality for comparisons, i.e. ===.
* @param arrays The arrays to inspect.
* @return Returns an array of composite values.
**/
union<T>(...arrays: Array<T>[]): T[];
/**
* @see _.union
**/
* Creates an array of unique values, in order, from all of the provided arrays using SameValueZero for
* equality comparisons.
*
* @param arrays The arrays to inspect.
* @return Returns the new array of combined values.
*/
union<T>(...arrays: List<T>[]): T[];
}
interface LoDashArrayWrapper<T> {
/**
* @see _.union
**/
union<T>(...arrays: (Array<T>|List<T>)[]): LoDashArrayWrapper<T>;
* @see _.union
*/
union(...arrays: List<T>[]): LoDashArrayWrapper<T>;
/**
* @see _.union
*/
union<T>(...arrays: List<T>[]): LoDashArrayWrapper<T>;
}
interface LoDashObjectWrapper<T> {
/**
* @see _.union
*/
union<T>(...arrays: List<T>[]): LoDashArrayWrapper<T>;
}
//_.uniq
+2 -2
View File
@@ -18,8 +18,8 @@ declare module L.mapbox {
/**
* Create and automatically configure a map with layers, markers, and interactivity.
*/
function map(element: string, id: string, options?: MapOptions): L.mapbox.Map;
function map(element: string, tilejson: any, options?: MapOptions): L.mapbox.Map;
function map(element: string|Element, id: string, options?: MapOptions): L.mapbox.Map;
function map(element: string|Element, tilejson: any, options?: MapOptions): L.mapbox.Map;
interface MapOptions extends L.Map.MapOptions {
featureLayer? : FeatureLayerOptions;
+41 -23
View File
@@ -1,6 +1,6 @@
# Meteor Type Definitions
These are the definitions for version 1.1.0.1 of Meteor.
These are the definitions for version 1.2.0.2 of Meteor.
Although these definitions can be downloaded separately for use, the recommended way to use these definitions in a Meteor application is by installing the
[typescript-libs](https://atmospherejs.com/meteortypescript/typescript-libs) Meteor smart package from atmosphere. The smart package contains TypeScript
@@ -14,14 +14,14 @@ These definitions were generated from the from the same [Meteor data.js file] (h
to generate the official [Meteor docs] (http://docs.meteor.com/).
## Usage
## Usage (OSX/Linux)
1. Add a symbolic link to the definitions from within some directory within your project (e.g. ".typescript" or "lib"). The definitions can be found somewhere
deep within `<project_root_dir>/.meteor/...`. The following will probably work:
1. Add a symbolic link to the definitions from within some directory within your project (e.g. ".typescript" or "lib"). The definitions can be found somewhere deep within `<project_root_dir>/.meteor/...`. The following will probably work:
$ ln -s ../.meteor/local/build/programs/server/assets/packages/meteortypescript_typescript-libs/definitions package_defs
If the definitions can't be found within the .meteor directory, you will have to manually pull down the definitions from github and add them to your project:
If the definitions can't be found within the .meteor directory, you will have to manually pull down the definitions from github and add them to your project:
<https://github.com/meteor-typescript/meteor-typescript-libs>
2. Install the [Typescript compiler for Meteor](https://github.com/meteor-typescript/meteor-typescript-compiler) or an [IDE which can transpile TypeScript to JavaScript](#transpiling-typescript).
@@ -29,12 +29,23 @@ deep within `<project_root_dir>/.meteor/...`. The following will probably work:
/// <reference path=".typescript/package_defs/all-definitions.d.ts" /> (substitute path in your project)
Or you can reference definition files individually:
Or you can reference definition files individually:
/// <reference path=".typescript/package_defs/meteor.d.ts" /> (substitue path in your project)
/// <reference path=".typescript/package_defs/meteor.d.ts" /> (substitute path in your project)
/// <reference path=".typescript/package_defs/underscore.d.ts" />
/// <reference path=".typescript/package_defs/jquery.d.ts" />
Meteor core definitions can be referenced in an "all-in-one" definition file ( *meteor.d.ts* ) or definition files specific to the locus of execution:
- *meteor.d.ts*: all meteor core definitions
- *meteor.common.d.ts*: meteor core code running on both client and server
- *meteor.client.d.ts*: meteor core client-only code
- *meteor.server.d.ts*: meteor core server-only code
- *meteor.package.d.ts*: meteor core package-only code
- *meteor.build.d.ts*: meteor core build-only code
*meteor.d.ts* contains all of the definitions found in *meteor.common.d.ts*, *meteor.client.d.ts*, *meteor.server.d.ts*, *meteor.package.d.ts*, and *meteor.build.d.ts*
4. Be aware of differences in coding styles when using TypeScript (see below)
@@ -42,14 +53,15 @@ deep within `<project_root_dir>/.meteor/...`. The following will probably work:
### References
Meteor code can run on the client and the server, for this reason you should try to stay away from referencing *file.ts* directly: you may get unexpected results.
Rather generate a *file.d.ts* using `tsc --reference file.ts`, and reference it in your file.
Meteor code can run on the client and the server, for this reason you should try to stay away from referencing *file.ts* directly: you may get unexpected results.
Rather generate a *file.d.ts* using `tsc --declaration file.ts`, and reference it in your file.
Compilation will be much faster and code cleaner - it's always better to split definition from implementation anyways.
Compilation will be much faster and code will be cleaner - it's always better to split definition from implementation anyways.
### Templates
With the exception of the **body** and **head** templates, Meteor's Template dot notation cannot be used (ie. *Template.mytemplate*). Thanks to Typescript static typing checks, you will need to used the *bracket notation* to access the Template.
With the exception of the **body** and **head** templates, Meteor's Template dot notation cannot be used (ie. *Template.mytemplate*). Thanks to Typescript static typing checks, you will need to use the *bracket notation* to access the Template.
Template['myTemplateName'].helpers({
@@ -58,16 +70,16 @@ With the exception of the **body** and **head** templates, Meteor's Template dot
}
});
Template['myTemplateName'].rendered = function ( ) { ... }
Template['myTemplateName'].onRendered(function ( ) { ... });
### Form fields
Form fields typically need to be casted to <HTMLInputElement>. For instance to read a form field value, use `(<HTMLInputElement>evt.target).value`.
Form fields typically need to be cast to `<HTMLInputElement>`. For instance to read a form field value, use `(<HTMLInputElement>evt.target).value`.
### Global variables
Preface any global variable declarations with a TypeScript "declare var" statement:
Preface any global variable declarations with a TypeScript "declare var" statement (or place the statement in a definition file):
declare var NavbarHelpers;
NavbarHelpers = {};
@@ -75,8 +87,7 @@ Preface any global variable declarations with a TypeScript "declare var" stateme
### Collections
The majority of extra work required to use TypeScript with Meteor is creating and maintaining the collection interfaces. However, doing so also provides the
additional benefit of succinctly documenting collection schema definitions (that are actually enforced).
The majority of extra work required to use TypeScript with Meteor is creating and maintaining the collection interfaces. However, doing so also provides the additional benefit of succinctly documenting collection schema definitions (that are actually enforced).
To define collections, you will need to create an interface representing the collection and then declare a Collection type variable with that interface type (as a generic):
@@ -104,8 +115,7 @@ If you have lots of custom definitions for a project, you can:
- Create multiple definition files and include individual references to each definition file.
- Create one huge monolithic definition file so you only have to refer to that file.
- Create multiple definition files, and create a definition file with references to the other definitions files so that you only have to maintain one reference
for all of you custom definitions. e.g. contents of ".typescript/custom_defs/custom-definitions.d.ts":
- Create multiple definition files, and create a definition file with references to the other definitions files so that you only have to maintain one reference for all of you custom definitions. e.g. contents of ".typescript/custom_defs/custom-definitions.d.ts":
/// <reference path='collections.ts' />
/// <reference path='paraview_helpers.d.ts'/>
@@ -116,18 +126,26 @@ for all of you custom definitions. e.g. contents of ".typescript/custom_defs/cu
## Transpiling TypeScript
### Meteor plugin
One solution for transpiling typescript is to install the following meteor package [https://github.com/meteor-typescript/meteor-typescript-compiler](https://github.com/meteor-typescript/meteor-typescript-compiler)
One solution for transpiling typescript is to install the following meteor package: [https://github.com/meteor-typescript/meteor-typescript-compiler](https://github.com/meteor-typescript/meteor-typescript-compiler)
### IDE/Editor Transpilation
WebStorm is a good TypeScript-aware editor. It can automatically transpile your TypeScript code into JavaScript every time you save a file. To enable this
feature in WebStorm on OSX, first install the TypeScript transpiler on your system:
WebStorm, SublimeText, Atom, and VisualStudio all support TypeScript. They can automatically transpile your TypeScript code into JavaScript every time you save a file.
#### WebStorm ####
To support TypeScript in WebStorm on OSX, first install the TypeScript transpiler on your system:
$ [sudo -H] npm install -g typescript
Then, within WebStorm, go to Preferences -> File Watchers -> "+" symbol and add TypeScript.
On version 10 of WebStorm or later, got to Preferences -> Languages & Frameworks -> TypeScript and check "Enable TypeScript Compiler"
On older versions of WebStorm (9 or earlier), go to Preferences -> File Watchers -> "+" symbol and add TypeScript.
#### SublimeText, Atom, and VisualStudio ####
Please refer to the documentation for these editors.
### Command line
Last option, is to compile code from the command line. With node and the typescript compiler installed:
The last option is to compile code from the command line. With node and the TypeScript compiler installed:
$ tsc *.ts
+54 -28
View File
@@ -92,8 +92,8 @@ Tracker.autorun(function () {
});
console.log("Current room has " +
Counts.find(Session.get("roomId")).count +
" messages.");
Counts.find(Session.get("roomId")).count +
" messages.");
/**
* From Publish and Subscribe, Meteor.subscribe section
@@ -128,6 +128,22 @@ Meteor.methods({
}
});
/**
* From Methods, Meteor.Error section
*/
throw new Meteor.Error("logged-out",
"The user must be logged in to post a comment.");
Meteor.call("methodName", function (error) {
if (error.error === "logged-out") {
Session.set("errorMessage", "Please log in to post a comment.");
}
});
var error = new Meteor.Error("logged-out", "The user must be logged in to post a comment.");
console.log(error.error === "logged-out");
console.log(error.reason === "The user must be logged in to post a comment.");
console.log(error.details !== "");
/**
* From Methods, Meteor.call section
*/
@@ -183,8 +199,10 @@ Animal.prototype = {
interface AnimalDAO {
_id: string;
makeNoise: () => void;
_id?: string;
name: string;
sound: string;
makeNoise?: () => void;
}
// Define a Collection that uses Animal as its document
@@ -224,8 +242,8 @@ Template['adminDashboard'].events({
Meteor.methods({
declareWinners: function () {
Players.update({score: {$gt: 10}},
{$addToSet: {badges: "Winner"}},
{multi: true});
{$addToSet: {badges: "Winner"}},
{multi: true});
}
});
@@ -251,18 +269,26 @@ Meteor.startup(function () {
/***
* From Collections, collection.allow section
*/
Posts = new Mongo.Collection("posts");
interface iPost {
_id: string;
owner: string;
userId: string;
locked: boolean;
}
Posts = new Mongo.Collection<iPost>("posts");
Posts.allow({
insert: function (userId, doc) {
insert: function (userId, doc: iPost) {
// the user must be logged in, and the document must be owned by the user
return (userId && doc.owner === userId);
},
update: function (userId, doc, fields, modifier) {
update: function (userId, doc: iPost, fields, modifier) {
// can only change your own documents
return doc.owner === userId;
},
remove: function (userId, doc) {
remove: function (userId, doc: iPost) {
// can only remove your own documents
return doc.owner === userId;
},
@@ -270,11 +296,11 @@ Posts.allow({
});
Posts.deny({
update: function (userId, docs, fields, modifier) {
update: function (userId, doc: iPost, fields, modifier) {
// can't change owners
return docs.userId !== userId;
return doc.userId !== userId;
},
remove: function (userId, doc) {
remove: function (userId, doc: iPost) {
// can't remove locked documents
return doc.locked;
},
@@ -347,7 +373,7 @@ Session.equals("key", value);
*/
Meteor.publish("userData", function () {
return Meteor.users.find({_id: this.userId},
{fields: {'other': 1, 'things': 1}});
{fields: {'other': 1, 'things': 1}});
});
Meteor.users.deny({update: function () { return true; }});
@@ -411,8 +437,8 @@ Accounts.emailTemplates.enrollAccount.subject = function (user) {
};
Accounts.emailTemplates.enrollAccount.text = function (user, url) {
return "You have been selected to participate in building a better future!"
+ " To activate your account, simply click the link below:\n\n"
+ url;
+ " To activate your account, simply click the link below:\n\n"
+ url;
};
/**
@@ -441,7 +467,7 @@ Template['newTemplate'].destroyed = function () {
};
Template['newTemplate'].events({
'click .something': function (event) {
'click .something': function (event: Meteor.Event, template: Blaze.TemplateInstance) {
}
});
@@ -540,7 +566,7 @@ Meteor.methods({checkTwitter: function (userId) {
check(userId, String);
this.unblock();
var result = HTTP.call("GET", "http://api.twitter.com/xyz",
{params: {user: userId}});
{params: {user: userId}});
if (result.statusCode === 200)
return true
return false;
@@ -548,12 +574,12 @@ Meteor.methods({checkTwitter: function (userId) {
HTTP.call("POST", "http://api.twitter.com/xyz",
{data: {some: "json", stuff: 1}},
function (error, result) {
if (result.statusCode === 200) {
Session.set("twizzled", true);
}
});
{data: {some: "json", stuff: 1}},
function (error, result) {
if (result.statusCode === 200) {
Session.set("twizzled", true);
}
});
/**
* From Email, Email.send section
@@ -570,9 +596,9 @@ Meteor.methods({
// In your client code: asynchronously send an email
Meteor.call('sendEmail',
'alice@example.com',
'Hello from Meteor!',
'This is a test of Email.send.');
'alice@example.com',
'Hello from Meteor!',
'This is a test of Email.send.');
var testTemplate = new Blaze.Template();
var testView = new Blaze.View();
@@ -594,4 +620,4 @@ var reactiveVar1 = new ReactiveVar<string>('test value');
var reactiveVar2 = new ReactiveVar<string>('test value', function(oldVal) { return true; });
var varValue: string = reactiveVar1.get();
reactiveVar1.set('new value');
reactiveVar1.set('new value');
+281 -194
View File
@@ -1,10 +1,10 @@
// Type definitions for Meteor 1.1.0.1
// Type definitions for Meteor 1.2.0.2
// Project: http://www.meteor.com/
// Definitions by: Dave Allen <https://github.com/fullflavedave>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
/**
* These are the modules and interfaces that can't be automatically generated from the Meteor data.js file
* These are the common (for client and server) modules and interfaces that can't be automatically generated from the Meteor data.js file
*/
interface EJSONable {
@@ -16,59 +16,20 @@ interface JSONable {
interface EJSON extends EJSONable {}
declare module Match {
var Any:any;
var String:any;
var Integer:any;
var Boolean:any;
var undefined:any;
var Any: any;
var String: any;
var Integer: any;
var Boolean: any;
var undefined: any;
//function null(); // not allowed in TypeScript
var Object:any;
function Optional(pattern:any):boolean;
function ObjectIncluding(dico:any):boolean;
function OneOf(...patterns:any[]):any;
function Where(condition:any):any;
var Object: any;
function Optional(pattern: any):boolean;
function ObjectIncluding(dico: any):boolean;
function OneOf(...patterns: any[]): any;
function Where(condition: any): any;
}
declare module Meteor {
/** Start definitions for Template **/
interface Event {
type:string;
target:HTMLElement;
currentTarget:HTMLElement;
which: number;
stopPropagation():void;
stopImmediatePropagation():void;
preventDefault():void;
isPropagationStopped():boolean;
isImmediatePropagationStopped():boolean;
isDefaultPrevented():boolean;
}
interface EventHandlerFunction extends Function {
(event?:Meteor.Event):void;
}
interface EventMap {
[id:string]:Meteor.EventHandlerFunction;
}
/** End definitions for Template **/
interface LoginWithExternalServiceOptions {
requestPermissions?: string[];
requestOfflineToken?: Boolean;
forceApprovalPrompt?: Boolean;
userEmail?: string;
loginStyle?: string;
}
function loginWithMeteorDeveloperAccount(options?: Meteor.LoginWithExternalServiceOptions, callback?: Function): void;
function loginWithFacebook(options?: Meteor.LoginWithExternalServiceOptions, callback?: Function): void;
function loginWithGithub(options?: Meteor.LoginWithExternalServiceOptions, callback?: Function): void;
function loginWithGoogle(options?: Meteor.LoginWithExternalServiceOptions, callback?: Function): void;
function loginWithMeetup(options?: Meteor.LoginWithExternalServiceOptions, callback?: Function): void;
function loginWithTwitter(options?: Meteor.LoginWithExternalServiceOptions, callback?: Function): void;
function loginWithWeibo(options?: Meteor.LoginWithExternalServiceOptions, callback?: Function): void;
interface UserEmail {
address:string;
verified:boolean;
@@ -83,16 +44,6 @@ declare module Meteor {
services?: any;
}
interface SubscriptionHandle {
stop(): void;
ready(): boolean;
}
interface Tinytest {
add(name:string, func:Function):any;
addAsync(name:string, func:Function):any;
}
enum StatusEnum {
connected,
connecting,
@@ -104,53 +55,40 @@ declare module Meteor {
interface LiveQueryHandle {
stop(): void;
}
}
interface EmailFields {
subject?: Function;
text?: Function;
declare module DDP {
interface DDPStatic {
subscribe(name: string, ...rest: any[]): Meteor.SubscriptionHandle;
call(method: string, ...parameters: any[]):void;
apply(method: string, ...parameters: any[]):void;
methods(IMeteorMethodsDictionary: any): any;
status():DDPStatus;
reconnect(): void;
disconnect(): void;
onReconnect(): void;
}
interface EmailTemplates {
from: string;
siteName: string;
resetPassword: Meteor.EmailFields;
enrollAccount: Meteor.EmailFields;
verifyEmail: Meteor.EmailFields;
}
interface Error {
error: number;
interface DDPStatus {
connected: boolean;
status: Meteor.StatusEnum;
retryCount: number;
//To turn this into an interval until the next reconnection, use retryTime - (new Date()).getTime()
retryTime?: number;
reason?: string;
details?: string;
}
interface Connection {
id: string;
close: Function;
onClose: Function;
clientAddress: string;
httpHeaders: Object;
}
}
declare module Mongo {
interface Selector {}
interface Selector {
[key: string]:any;
}
interface Selector extends Object {}
interface Modifier {}
interface SortSpecifier {}
interface FieldSpecifier {
[id: string]: Number;
}
enum IdGenerationEnum {
STRING,
MONGO
}
interface AllowDenyOptions {
insert?: (userId:string, doc:any) => boolean;
update?: (userId:string, doc:any, fieldNames:string[], modifier:any) => boolean;
remove?: (userId:string, doc:any) => boolean;
fetch?: string[];
transform?: Function;
}
}
declare module HTTP {
@@ -178,43 +116,6 @@ declare module HTTP {
function get(url: string, callOptions?: HTTP.HTTPRequest, asyncCallback?: Function): HTTP.HTTPResponse;
function post(url: string, callOptions?: HTTP.HTTPRequest, asyncCallback?: Function): HTTP.HTTPResponse;
function put(url: string, callOptions?: HTTP.HTTPRequest, asyncCallback?: Function): HTTP.HTTPResponse;
}
declare module Email {
interface EmailMessage {
from: string;
to: string|string[];
cc?: string|string[];
bcc?: string|string[];
replyTo?: string|string[];
subject: string;
text?: string;
html?: string;
headers?: {[id: string]: string};
}
}
declare module DDP {
interface DDPStatic {
subscribe(name:string, ...rest:any[]):void;
call(method:string, ...parameters:any[]):void;
apply(method:string, ...parameters:any[]):void;
methods(IMeteorMethodsDictionary:any):any;
status():DDPStatus;
reconnect():void;
disconnect():void;
onReconnect():void;
}
interface DDPStatus {
connected: boolean;
status: Meteor.StatusEnum;
retryCount: number;
//To turn this into an interval until the next reconnection, use retryTime - (new Date()).getTime()
retryTime?: number;
reason?: string;
}
}
declare module Random {
@@ -226,6 +127,56 @@ declare module Random {
function choice(str:string):string; // @param str, @return a random char in str
}
/**
* These are the client modules and interfaces that can't be automatically generated from the Meteor data.js file
*/
declare module Meteor {
/** Start definitions for Template **/
interface Event {
type:string;
target:HTMLElement;
currentTarget:HTMLElement;
which: number;
stopPropagation():void;
stopImmediatePropagation():void;
preventDefault():void;
isPropagationStopped():boolean;
isImmediatePropagationStopped():boolean;
isDefaultPrevented():boolean;
}
interface EventHandlerFunction extends Function {
(event?:Meteor.Event, templateInstance?: Blaze.TemplateInstance):void;
}
interface EventMap {
[id:string]:Meteor.EventHandlerFunction;
}
/** End definitions for Template **/
interface LoginWithExternalServiceOptions {
requestPermissions?: string[];
requestOfflineToken?: Boolean;
forceApprovalPrompt?: Boolean;
userEmail?: string;
loginStyle?: string;
}
function loginWithMeteorDeveloperAccount(options?: Meteor.LoginWithExternalServiceOptions, callback?: Function): void;
function loginWithFacebook(options?: Meteor.LoginWithExternalServiceOptions, callback?: Function): void;
function loginWithGithub(options?: Meteor.LoginWithExternalServiceOptions, callback?: Function): void;
function loginWithGoogle(options?: Meteor.LoginWithExternalServiceOptions, callback?: Function): void;
function loginWithMeetup(options?: Meteor.LoginWithExternalServiceOptions, callback?: Function): void;
function loginWithTwitter(options?: Meteor.LoginWithExternalServiceOptions, callback?: Function): void;
function loginWithWeibo(options?: Meteor.LoginWithExternalServiceOptions, callback?: Function): void;
interface SubscriptionHandle {
stop(): void;
ready(): boolean;
}
}
declare module Blaze {
interface View {
name: string;
@@ -286,25 +237,113 @@ declare module BrowserPolicy {
}
}
declare module Tracker {
export var ComputationFunction: (computation: Tracker.Computation) => void;
}
declare var IterationCallback: <T>(doc: T, index: number, cursor: Mongo.Cursor<T>) => void;
/**
* These modules and interfaces are automatically generated from the Meteor api.js file
* These are the server modules and interfaces that can't be automatically generated from the Meteor data.js file
*/
declare module Meteor {
interface EmailFields {
subject?: Function;
text?: Function;
}
interface EmailTemplates {
from: string;
siteName: string;
resetPassword: Meteor.EmailFields;
enrollAccount: Meteor.EmailFields;
verifyEmail: Meteor.EmailFields;
}
interface Connection {
id: string;
close: Function;
onClose: Function;
clientAddress: string;
httpHeaders: Object;
}
}
declare module Mongo {
interface AllowDenyOptions {
insert?: (userId: string, doc: any) => boolean;
update?: (userId: string, doc: any, fieldNames: string[], modifier: any) => boolean;
remove?: (userId: string, doc: any) => boolean;
fetch?: string[];
transform?: Function;
}
}
interface MailComposerOptions {
escapeSMTP: boolean;
encoding: string;
charset: string;
keepBcc: boolean;
forceEmbeddedImages: boolean;
}
declare var MailComposer: MailComposerStatic;
interface MailComposerStatic {
new(options: MailComposerOptions): MailComposer;
}
interface MailComposer {
addHeader(name: string, value: string): void;
setMessageOption(from: string, to: string, body: string, html: string): void;
streamMessage(): void;
pipe(stream: any /** fs.WriteStream **/): void;
}
/**
* These are the modules and interfaces for packages that can't be automatically generated from the Meteor data.js file
*/
interface ILengthAble {
length: number;
}
interface ITinytestAssertions {
ok(doc: Object): void;
expect_fail(): void;
fail(doc: Object): void;
runId(): string;
equal<T>(actual: T, expected: T, message?: string, not?: boolean): void;
notEqual<T>(actual: T, expected: T, message?: string): void;
instanceOf(obj : Object, klass: Function, message?: string): void;
notInstanceOf(obj : Object, klass: Function, message?: string): void;
matches(actual : any, regexp: RegExp, message?: string): void;
notMatches(actual : any, regexp: RegExp, message?: string): void;
throws(f: Function, expected?: string|RegExp): void;
isTrue(v: boolean, msg?: string): void;
isFalse(v: boolean, msg?: string): void;
isNull(v: any, msg?: string): void;
isNotNull(v: any, msg?: string): void;
isUndefined(v: any, msg?: string): void;
isNotUndefined(v: any, msg?: string): void;
isNan(v: any, msg?: string): void;
isNotNan(v: any, msg?: string): void;
include<T>(s: Array<T>|Object|string, value: any, msg?: string, not?: boolean): void;
notInclude<T>(s: Array<T>|Object|string, value: any, msg?: string, not?: boolean): void;
length(obj: ILengthAble, expected_length: number, msg?: string): void;
_stringEqual(actual: string, expected: string, msg?: string): void;
}
declare module Tinytest {
function add(description : string , func : (test : ITinytestAssertions) => void) : void;
function addAsync(description : string , func : (test : ITinytestAssertions) => void) : void;
}
// Kept in for backwards compatibility
declare module Meteor {
interface Tinytest {
add(description : string , func : (test : ITinytestAssertions) => void) : void;
addAsync(description : string , func : (test : ITinytestAssertions) => void) : void;
}
}
declare module Accounts {
function addEmail(userId: string, newEmail: string, verified?: boolean): void;
function changePassword(oldPassword: string, newPassword: string, callback?: Function): void;
function config(options: {
sendVerificationEmail?: boolean;
forbidClientAccountCreation?: boolean;
restrictCreationByEmailDomain?: string | Function;
loginExpirationInDays?: number;
oauthSecretKey?: string;
}): void;
function createUser(options: {
username?: string;
email?: string;
@@ -312,15 +351,15 @@ declare module Accounts {
profile?: Object;
}, callback?: Function): string;
var emailTemplates: Meteor.EmailTemplates;
function findUserByEmail(email: string): Object;
function findUserByUsername(username: string): Object;
function forgotPassword(options: {
email?: string;
}, callback?: Function): void;
function onCreateUser(func: Function): void;
function onEmailVerificationLink(callback: Function): void;
function onEnrollmentLink(callback: Function): void;
function onLogin(func: Function): {stop: Function};
function onLoginFailure(func: Function): {stop: Function};
function onResetPasswordLink(callback: Function): void;
function removeEmail(userId: string, email: string): void;
function resetPassword(token: string, newPassword: string, callback?: Function): void;
function sendEnrollmentEmail(userId: string, email?: string): void;
function sendResetPasswordEmail(userId: string, email?: string): void;
@@ -328,6 +367,7 @@ declare module Accounts {
function setPassword(userId: string, newPassword: string, options?: {
logout?: Object;
}): void;
function setUsername(userId: string, newUsername: string): void;
var ui: {
config(options: {
requestPermissions?: Object;
@@ -336,16 +376,31 @@ declare module Accounts {
passwordSignupFields?: string;
}): void;
};
function validateLoginAttempt(func: Function): {stop: Function};
function validateNewUser(func: Function): void;
function verifyEmail(token: string, callback?: Function): void;
function config(options: {
sendVerificationEmail?: boolean;
forbidClientAccountCreation?: boolean;
restrictCreationByEmailDomain?: string | Function;
loginExpirationInDays?: number;
oauthSecretKey?: string;
}): void;
function onLogin(func: Function): { stop: () => void };
function onLoginFailure(func: Function): { stop: () => void };
function user(): Meteor.User;
function userId(): string;
function loggingIn(): boolean;
function logout(callback?: Function): void;
function logoutOtherClients(callback?: Function): void;
function onCreateUser(func: Function): void;
function validateLoginAttempt(func: Function): { stop: () => void };
function validateNewUser(func: Function): boolean;
}
declare module App {
function accessRule(domainRule: string, options?: {
launchExternal?: boolean;
}):any; /** TODO: add return value **/
function configurePlugin(pluginName: string, config: Object): void;
}): void;
function configurePlugin(id: string, config: Object): void;
function icons(icons: Object): void;
function info(options: {
id?: string;
@@ -357,7 +412,7 @@ function configurePlugin(pluginName: string, config: Object): void;
website?: string;
}): void;
function launchScreens(launchScreens: Object): void;
function setPreference(name: string, value: string): void;
function setPreference(name: string, value: string, platform?: string): void;
}
declare module Assets {
@@ -368,6 +423,7 @@ declare module Assets {
declare module Blaze {
function Each(argFunc: Function, contentFunc: Function, elseFunc?: Function): Blaze.View;
function If(conditionFunc: Function, contentFunc: Function, elseFunc?: Function): Blaze.View;
function Let(bindings: Function, contentFunc: Function): Blaze.View;
var Template: TemplateStatic;
interface TemplateStatic {
new(viewName?: string, renderFunction?: Function): Template;
@@ -426,6 +482,11 @@ declare module DDP {
function connect(url: string): DDP.DDPStatic;
}
declare module DDPCommon {
function MethodInvocation(options: {
}): any;
}
declare module EJSON {
var CustomType: CustomTypeStatic;
interface CustomTypeStatic {
@@ -434,16 +495,16 @@ declare module EJSON {
interface CustomType {
clone(): EJSON.CustomType;
equals(other: Object): boolean;
toJSONValue(): JSON;
toJSONValue(): JSONable;
typeName(): string;
}
function addType(name: string, factory: (val: EJSONable) => JSONable): void;
function addType(name: string, factory: (val: JSONable) => EJSON.CustomType): void;
function clone<T>(val:T): T;
function equals(a: EJSON, b: EJSON, options?: {
keyOrderSensitive?: boolean;
}): boolean;
function fromJSONValue(val: JSON): any;
function fromJSONValue(val: JSONable): any;
function isBinary(x: Object): boolean;
var newBinary: any;
function parse(str: string): EJSON;
@@ -451,7 +512,7 @@ declare module EJSON {
indent?: boolean | number | string;
canonical?: boolean;
}): string;
function toJSONValue(val: EJSON): JSON;
function toJSONValue(val: EJSON): JSONable;
}
declare module Match {
@@ -464,8 +525,10 @@ declare module Meteor {
new(error: string, reason?: string, details?: string): Error;
}
interface Error {
error: string;
reason?: string;
details?: string;
}
function absoluteUrl(path?: string, options?: {
secure?: boolean;
replaceLocalhost?: boolean;
@@ -486,9 +549,10 @@ declare module Meteor {
function loginWith<ExternalService>(options?: {
requestPermissions?: string[];
requestOfflineToken?: boolean;
forceApprovalPrompt?: boolean;
loginUrlParameters?: Object;
userEmail?: string;
loginStyle?: string;
redirectUrl?: string;
}, callback?: Function): void;
function loginWithPassword(user: Object | string, password: string, callback?: Function): void;
function logout(callback?: Function): void;
@@ -521,20 +585,20 @@ declare module Mongo {
}
interface Collection<T> {
allow(options: {
insert?: (userId:string, doc:any) => boolean;
update?: (userId:string, doc:any, fieldNames:string[], modifier:any) => boolean;
remove?: (userId:string, doc:any) => boolean;
insert?: (userId: string, doc: T) => boolean;
update?: (userId: string, doc: T, fieldNames: string[], modifier: any) => boolean;
remove?: (userId: string, doc: T) => boolean;
fetch?: string[];
transform?: Function;
}): boolean;
deny(options: {
insert?: (userId:string, doc:any) => boolean;
update?: (userId:string, doc:any, fieldNames:string[], modifier:any) => boolean;
remove?: (userId:string, doc:any) => boolean;
insert?: (userId: string, doc: T) => boolean;
update?: (userId: string, doc: T, fieldNames: string[], modifier: any) => boolean;
remove?: (userId: string, doc: T) => boolean;
fetch?: string[];
transform?: Function;
}): boolean;
find(selector?: Mongo.Selector, options?: {
find(selector?: Mongo.Selector | Mongo.ObjectID | string, options?: {
sort?: Mongo.SortSpecifier;
skip?: number;
limit?: number;
@@ -542,20 +606,22 @@ declare module Mongo {
reactive?: boolean;
transform?: Function;
}): Mongo.Cursor<T>;
findOne(selector?: Mongo.Selector, options?: {
findOne(selector?: Mongo.Selector | Mongo.ObjectID | string, options?: {
sort?: Mongo.SortSpecifier;
skip?: number;
fields?: Mongo.FieldSpecifier;
reactive?: boolean;
transform?: Function;
}): T;
insert(doc: Object, callback?: Function): string;
remove(selector: Mongo.Selector, callback?: Function): void;
update(selector: Mongo.Selector, modifier: Mongo.Modifier, options?: {
insert(doc: T, callback?: Function): string;
rawCollection(): any;
rawDatabase(): any;
remove(selector: Mongo.Selector | Mongo.ObjectID | string, callback?: Function): void;
update(selector: Mongo.Selector | Mongo.ObjectID | string, modifier: Mongo.Modifier, options?: {
multi?: boolean;
upsert?: boolean;
}, callback?: Function): number;
upsert(selector: Mongo.Selector, modifier: Mongo.Modifier, options?: {
upsert(selector: Mongo.Selector | Mongo.ObjectID | string, modifier: Mongo.Modifier, options?: {
multi?: boolean;
}, callback?: Function): {numberAffected?: number; insertedId?: string;};
_ensureIndex(indexName: string, options?: {[key: string]: any}): void;
@@ -569,7 +635,7 @@ declare module Mongo {
count(): number;
fetch(): Array<T>;
forEach(callback: <T>(doc: T, index: number, cursor: Mongo.Cursor<T>) => void, thisArg?: any): void;
map(callback: <T>(doc: T, index: number, cursor: Mongo.Cursor<T>) => void, thisArg?: any): Array<T>;
map<U>(callback: (doc: T, index: number, cursor: Mongo.Cursor<T>) => U, thisArg?: any): Array<U>;
observe(callbacks: Object): Meteor.LiveQueryHandle;
observeChanges(callbacks: Object): Meteor.LiveQueryHandle;
}
@@ -595,6 +661,8 @@ declare module Package {
name?: string;
git?: string;
documentation?: string;
debugOnly?: boolean;
prodOnly?: boolean;
}): void;
function onTest(func: Function): void;
function onUse(func: Function): void;
@@ -613,6 +681,7 @@ declare module Tracker {
invalidate(): void;
invalidated: boolean;
onInvalidate(callback: Function): void;
onStop(callback: Function): void;
stop(): void;
stopped: boolean;
}
@@ -656,6 +725,7 @@ declare module HTTP {
timeout?: number;
followRedirects?: boolean;
npmRequestOptions?: Object;
beforeSend?: Function;
}, asyncCallback?: Function): HTTP.HTTPResponse;
function del(url: string, callOptions?: Object, asyncCallback?: Function): HTTP.HTTPResponse;
function get(url: string, callOptions?: Object, asyncCallback?: Function): HTTP.HTTPResponse;
@@ -675,6 +745,7 @@ declare module Email {
html?: string;
headers?: Object;
attachments?: Object[];
mailComposer?: MailComposer;
}): void;
}
@@ -684,30 +755,30 @@ interface CompileStepStatic {
}
interface CompileStep {
addAsset(options: {
}, path: string, data: any /** Buffer **/ | string): any; /** TODO: add return value **/
}, path: string, data: any /** Buffer **/ | string): any;
addHtml(options: {
section?: string;
data?: string;
}): any; /** TODO: add return value **/
}): any;
addJavaScript(options: {
path?: string;
data?: string;
sourcePath?: string;
}): any; /** TODO: add return value **/
}): any;
addStylesheet(options: {
}, path: string, data: string, sourceMap: string): any; /** TODO: add return value **/
arch: any; /** TODO: add return value **/
declaredExports: any; /** TODO: add return value **/
}, path: string, data: string, sourceMap: string): any;
arch: any;
declaredExports: any;
error(options: {
}, message: string, sourcePath?: string, line?: number, func?: string): any; /** TODO: add return value **/
fileOptions: any; /** TODO: add return value **/
fullInputPath: any; /** TODO: add return value **/
inputPath: any; /** TODO: add return value **/
inputSize: any; /** TODO: add return value **/
packageName: any; /** TODO: add return value **/
pathForSourceMap: any; /** TODO: add return value **/
}, message: string, sourcePath?: string, line?: number, func?: string): any;
fileOptions: any;
fullInputPath: any;
inputPath: any;
inputSize: any;
packageName: any;
pathForSourceMap: any;
read(n?: number): any;
rootOutputPath: any; /** TODO: add return value **/
rootOutputPath: any;
}
declare var PackageAPI: PackageAPIStatic;
@@ -715,10 +786,13 @@ interface PackageAPIStatic {
new(): PackageAPI;
}
interface PackageAPI {
addFiles(filename: string | string[], architecture?: string): void;
export(exportedObject: string, architecture?: string): void;
imply(packageSpecs: string | string[]): void;
use(packageNames: string | string[], architecture?: string, options?: {
addAssets(filenames: string | string[], architecture: string | string[]): void;
addFiles(filenames: string | string[], architecture?: string | string[], options?: {
bare?: boolean;
}): void;
export(exportedObjects: string | string[], architecture?: string | string[], exportOptions?: Object, testOnly?: boolean): void;
imply(packageNames: string | string[], architecture?: string | string[]): void;
use(packageNames: string | string[], architecture?: string | string[], options?: {
weak?: boolean;
unordered?: boolean;
}): void;
@@ -768,7 +842,7 @@ interface TemplateStatic {
interface Template {
created: Function;
destroyed: Function;
events(eventMap: {[actions: string]: Function}): void;
events(eventMap: Meteor.EventMap): void;
helpers(helpers:{[id:string]: any}): void;
onCreated: Function;
onDestroyed: Function;
@@ -776,6 +850,19 @@ interface Template {
rendered: Function;
}
declare function MethodInvocation(options: {
}): any; /** TODO: add return value **/
declare function check(value: any, pattern: any): void;
declare function execFileAsync(command: string, args?: any[], options?: {
cwd?: Object;
env?: Object;
stdio?: any[] | string;
destination?: any;
waitForClose?: string;
}): any;
declare function execFileSync(command: string, args?: any[], options?: {
cwd?: Object;
env?: Object;
stdio?: any[] | string;
destination?: any;
waitForClose?: string;
}): String;
declare function getExtension(): String;
+4 -4
View File
@@ -13,7 +13,7 @@ import DragSource = ReactDnd.DragSource;
import DropTarget = ReactDnd.DropTarget;
import DragLayer = ReactDnd.DragLayer;
import DragDropContext = ReactDnd.DragDropContext;
import HTML5Backend = require('react-dnd/modules/backends/HTML5');
import HTML5Backend, { getEmptyImage } from 'react-dnd/modules/backends/HTML5';
import TestBackend = require('react-dnd/modules/backends/Test');
// Game Component
@@ -82,11 +82,11 @@ module Knight {
export class Knight extends React.Component<KnightP, {}> {
static defaultProps: KnightP;
static create = React.createFactory(Knight);
componentDidMount() {
var img = HTML5Backend.getEmptyImage();
var img = getEmptyImage();
img.onload = () => this.props.connectDragPreview(img);
}
@@ -157,7 +157,7 @@ module BoardSquare {
export class BoardSquare extends React.Component<BoardSquareP, {}> {
static defaultProps: BoardSquareP;
private _renderOverlay = (color: string) => {
return r.div({
style: {
+3 -7
View File
@@ -176,13 +176,9 @@ declare module "react-dnd" {
}
declare module "react-dnd/modules/backends/HTML5" {
enum _NativeTypes { FILE, URL, TEXT }
class HTML5Backend implements __ReactDnd.Backend {
static getEmptyImage(): any; // Image
static NativeTypes: _NativeTypes;
}
export = HTML5Backend;
export enum NativeTypes { FILE, URL, TEXT }
export function getEmptyImage(): any; // Image
export default class HTML5Backend implements __ReactDnd.Backend {}
}
declare module "react-dnd/modules/backends/Test" {
+7
View File
@@ -0,0 +1,7 @@
/// <reference path="domready.d.ts" />
import domReady = require("domReady");
domReady(() => {
return domReady.version;
});
@@ -0,0 +1 @@
--noImplicitAny --target es5 --module amd
+15
View File
@@ -0,0 +1,15 @@
// Type definitions for domReady 2.0.1
// Project: https://github.com/requirejs/domReady
// Definitions by: Nobuhiro Nakamura <https://github.com/lefb766>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
declare module "domReady" {
interface DomReady {
(callback: () => any): DomReady;
version: string;
}
let domReady: DomReady;
export = domReady;
}
+13
View File
@@ -115,6 +115,19 @@ interface RequireConfig {
};
};
/**
* Allows pointing multiple module IDs to a module ID that contains a bundle of modules.
*
* @example
* requirejs.config({
* bundles: {
* 'primary': ['main', 'util', 'text', 'text!template.html'],
* 'secondary': ['text!secondary.html']
* }
* });
**/
bundles?: { [key: string]: string[]; };
/**
* AMD configurations, use module.config() to access in
* define() functions
+17
View File
@@ -316,6 +316,19 @@ declare module Bloodhound
* The ajax settings object passed to jQuery.ajax.
*/
ajax?: JQueryAjaxSettings;
/**
* A function that provides a hook to allow you to prepare the settings object passed to transport
* when a request is about to be made. The function signature should be prepare(query, settings),
* where query is the query #search was called with and settings is the default settings object
* created internally by the Bloodhound instance. The prepare function should return a settings object.
* [Note: Added in 0.11.1]
*
* @param query The query #search was called with.
* @param settings The default settings object created internally by Bloodhound.
* @returns A JqueryAjaxSettings object.
*/
prepare?: (query: string, settings: JQueryAjaxSettings) => JQueryAjaxSettings;
}
/**
@@ -411,3 +424,7 @@ declare class Bloodhound<T> {
*/
public static tokenizers: Bloodhound.Tokenizers;
}
declare module "bloodhound" {
export = Bloodhound;
}
@@ -1,8 +1,23 @@
/// <reference path="./typescriptServices.d.ts"/>
import ts = require('typescript-services');
// transpile
function transpile(input: string): string {
return ts.transpile(input, { module: ts.ModuleKind.CommonJS });
}
// formatter:
var snapshot = ts.SimpleText.fromString('var foo = 123;');
var formatter = new ts.Services.Formatting.TextSnapshot(snapshot);
console.log(formatter);
// compile
function compile(fileNames: string[], options: ts.CompilerOptions): number {
let program = ts.createProgram(fileNames, options);
let emitResult = program.emit();
let allDiagnostics = ts.getPreEmitDiagnostics(program).concat(emitResult.diagnostics);
allDiagnostics.forEach(diagnostic => {
let { line, character } = diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start);
let message = ts.flattenDiagnosticMessageText(diagnostic.messageText, '\n');
console.log(`${diagnostic.file.fileName} (${line + 1},${character + 1}): ${message}`);
});
let exitCode = emitResult.emitSkipped ? 1 : 0;
return exitCode;
}
+2148 -9314
View File
File diff suppressed because it is too large Load Diff
+1105 -811
View File
File diff suppressed because it is too large Load Diff