From 613809f5d8d2dca46336cc6a8f5ac12136c900bc Mon Sep 17 00:00:00 2001 From: vcastro Date: Thu, 20 Jun 2013 23:03:16 +0100 Subject: [PATCH 01/37] Updated breeze.d.ts, durandal.d.ts and knockout.mapping.d.ts to better support TS 0.9. --- breeze/breeze.d.ts | 162 ++++++++++++------------- durandal/durandal.d.ts | 20 +-- knockout.mapping/knockout.mapping.d.ts | 4 +- 3 files changed, 93 insertions(+), 93 deletions(-) diff --git a/breeze/breeze.d.ts b/breeze/breeze.d.ts index de6650968..8ea397845 100644 --- a/breeze/breeze.d.ts +++ b/breeze/breeze.d.ts @@ -14,7 +14,7 @@ declare module breezeCore { } interface IEnum { - contains(object: any): bool; + contains(object: any): boolean; fromName(name: string): EnumSymbol; getNames(): string[]; getSymbols(): EnumSymbol[]; @@ -24,11 +24,11 @@ declare module breezeCore { constructor (name: string, methodObj?: any); addSymbol(propertiesObj?: any): EnumSymbol; - contains(object: any): bool; + contains(object: any): boolean; fromName(name: string): EnumSymbol; getNames(): string[]; getSymbols(): EnumSymbol[]; - static isSymbol(object: any): bool; + static isSymbol(object: any): boolean; seal(): void; } @@ -43,14 +43,14 @@ declare module breezeCore { constructor (name: string, publisher: any, defaultErrorCallback?: ErrorCallback); static enable(eventName: string, target: any): void; - static enable(eventName: string, target: any, isEnabled: bool): void; + static enable(eventName: string, target: any, isEnabled: boolean): void; static enable(eventName: string, target: any, isEnabled: Function): void; - static isEnabled(eventName: string, target: any): bool; - publish(data: any, publishAsync?: bool, errorCallback?: ErrorCallback): void; + static isEnabled(eventName: string, target: any): boolean; + publish(data: any, publishAsync?: boolean, errorCallback?: ErrorCallback): void; publishAsync(data: any, errorCallback?: ErrorCallback): void; subscribe(callback?: (data: any) => void ): number; - unsubscribe(unsubKey: number): bool; + unsubscribe(unsubKey: number): boolean; } } @@ -70,8 +70,8 @@ declare module breeze { name: string; parentEntityType: EntityType; validators: Validator[]; - isDataProperty: bool; - isNavigationProperty: bool; + isDataProperty: boolean; + isNavigationProperty: boolean; } interface IStructuralType { @@ -116,13 +116,13 @@ declare module breeze { concurrencyMode: string; dataType: DataTypeSymbol; defaultValue: any; - fixedLength: bool; - isComplexProperty: bool; - isDataProperty: bool; - isNavigationProperty: bool; - isNullable: bool; - isPartOfKey: bool; - isUnmapped: bool; + fixedLength: boolean; + isComplexProperty: boolean; + isDataProperty: boolean; + isNavigationProperty: boolean; + isNullable: boolean; + isPartOfKey: boolean; + isUnmapped: boolean; maxLength: number; name: string; @@ -138,10 +138,10 @@ declare module breeze { concurrencyMode?: string; dataType?: DataTypeSymbol; defaultValue?: any; - fixedLength?: bool; - isNullable?: bool; - isPartOfKey?: bool; - isUnmapped?: bool; + fixedLength?: boolean; + isNullable?: boolean; + isPartOfKey?: boolean; + isUnmapped?: boolean; maxLength?: number; name?: string; nameOnServer?: string; @@ -150,7 +150,7 @@ declare module breeze { class DataService { adapterName: string; - hasServerMetadata: bool; + hasServerMetadata: boolean; serviceName: string; jsonResultsAdapter: JsonResultsAdapter; constructor(config: DataServiceOptions); @@ -158,7 +158,7 @@ declare module breeze { interface DataServiceOptions { adapterName?: string; - hasServerMetadata?: bool; + hasServerMetadata?: boolean; serviceName?: string; jsonResultsAdapter?: JsonResultsAdapter; } @@ -166,11 +166,11 @@ declare module breeze { class JsonResultsAdapter { name: string; extractResults: (data: {}) => {}; - visitNode: (node: {}, queryContext: QueryContext, nodeContext: NodeContext) => { entityType?: EntityType; nodeId?: any; nodeRefId?: any; ignore?: bool; }; + visitNode: (node: {}, queryContext: QueryContext, nodeContext: NodeContext) => { entityType?: EntityType; nodeId?: any; nodeRefId?: any; ignore?: boolean; }; constructor(config: { name: string; extractResults?: (data: {}) => {}; - visitNode: (node: {}, queryContext: QueryContext, nodeContext: NodeContext) => { entityType?: EntityType; nodeId?: any; nodeRefId?: any; ignore?: bool; }; + visitNode: (node: {}, queryContext: QueryContext, nodeContext: NodeContext) => { entityType?: EntityType; nodeId?: any; nodeRefId?: any; ignore?: boolean; }; }); } @@ -189,11 +189,11 @@ declare module breeze { class DataTypeSymbol extends breezeCore.EnumSymbol { defaultValue: any; - isNumeric: bool; + isNumeric: boolean; } interface DataType extends breezeCore.IEnum { Binary: DataTypeSymbol; - Boolean: DataTypeSymbol; + booleanean: DataTypeSymbol; Byte: DataTypeSymbol; DateTime: DataTypeSymbol; Decimal: DataTypeSymbol; @@ -210,7 +210,7 @@ declare module breeze { parseDateFromServer(date: any): Date; } - declare var DataType: DataType; + var DataType: DataType; class EntityActionSymbol extends breezeCore.EnumSymbol { } @@ -234,7 +234,7 @@ declare module breeze { entity: Entity; entityManager: EntityManager; entityState: EntityStateSymbol; - isBeingSaved: bool; + isBeingSaved: boolean; originalValues: any; propertyChanged: PropertyChangedEvent; @@ -243,7 +243,7 @@ declare module breeze { acceptChanges(): void; addValidationError(validationError: ValidationError): void; clearValidationErrors(): void; - getKey(forceRefresh?: bool): EntityKey; + getKey(forceRefresh?: boolean): EntityKey; getValidationErrors(): ValidationError[]; getValidationErrors(property: string): ValidationError[]; @@ -261,11 +261,11 @@ declare module breeze { setDeleted(): void; setModified(): void; setUnchanged(): void; - validateEntity(): bool; + validateEntity(): boolean; - validateProperty(property: string, context?: any): bool; - validateProperty(property: DataProperty, context?: any): bool; - validateProperty(property: NavigationProperty, context?: any): bool; + validateProperty(property: string, context?: any): boolean; + validateProperty(property: DataProperty, context?: any): boolean; + validateProperty(property: NavigationProperty, context?: any): boolean; } class PropertyChangedEventArgs { @@ -293,8 +293,8 @@ declare module breeze { constructor (entityType: EntityType, keyValue: any); constructor (entityType: EntityType, keyValues: any[]); - equals(entityKey: EntityKey): bool; - static equals(k1: EntityKey, k2: EntityKey): bool; + equals(entityKey: EntityKey): boolean; + static equals(k1: EntityKey, k2: EntityKey): boolean; } class EntityManager { @@ -317,14 +317,14 @@ declare module breeze { clear(): void; createEmptyCopy(): EntityManager; createEntity(typeName: string, config?: {}, entityState?: EntityStateSymbol) : Entity; - detachEntity(entity: Entity): bool; + detachEntity(entity: Entity): boolean; executeQuery(query: string, callback?: ExecuteQuerySuccessCallback, errorCallback?: ExecuteQueryErrorCallback): Promise; executeQuery(query: EntityQuery, callback?: ExecuteQuerySuccessCallback, errorCallback?: ExecuteQueryErrorCallback): Promise; executeQueryLocally(query: EntityQuery): Entity[]; exportEntities(entities?: Entity[]): string; - fetchEntityByKey(typeName: string, keyValue: any, checkLocalCacheFirst?: bool): Promise; - fetchEntityByKey(typeName: string, keyValues: any[], checkLocalCacheFirst?: bool): Promise; + fetchEntityByKey(typeName: string, keyValue: any, checkLocalCacheFirst?: boolean): Promise; + fetchEntityByKey(typeName: string, keyValues: any[], checkLocalCacheFirst?: boolean): Promise; fetchEntityByKey(entityKey: EntityKey): Promise; fetchMetadata(callback?: (schema: any) => void , errorCallback?: breezeCore.ErrorCallback): Promise; generateTempKeyValue(entity: Entity): any; @@ -348,11 +348,11 @@ declare module breeze { getEntityByKey(typeName: string, keyValues: any[]): Entity; getEntityByKey(entityKey: EntityKey): Entity; - hasChanges(): bool; - hasChanges(entityTypeName: string): bool; - hasChanges(entityTypeNames: string[]): bool; - hasChanges(entityType: EntityType): bool; - hasChanges(entityTypes: EntityType[]): bool; + hasChanges(): boolean; + hasChanges(entityTypeName: string): boolean; + hasChanges(entityTypeNames: string[]): boolean; + hasChanges(entityType: EntityType): boolean; + hasChanges(entityTypes: EntityType[]): boolean; static importEntities(exportedString: string, config?: { mergeStrategy?: MergeStrategySymbol; }): EntityManager; importEntities(exportedString: string, config?: { mergeStrategy?: MergeStrategySymbol; }): EntityManager; @@ -362,10 +362,10 @@ declare module breeze { setProperties(config: EntityManagerProperties): void; helper: { - unwrapInstance(structObj: Entity, isOData: bool): any; - unwrapOriginalValues(target: Entity, metadataStore: MetadataStore, isOData: bool): any; - unwrapChangedValues(target: Entity, metadataStore: MetadataStore, isOData: bool): any; - getEntityKeyFromRawEntity(rawEntity: any, entityType: EntityType, isClient: bool): EntityKey; + unwrapInstance(structObj: Entity, isOData: boolean): any; + unwrapOriginalValues(target: Entity, metadataStore: MetadataStore, isOData: boolean): any; + unwrapChangedValues(target: Entity, metadataStore: MetadataStore, isOData: boolean): any; + getEntityKeyFromRawEntity(rawEntity: any, entityType: EntityType, isClient: boolean): EntityKey; }; } @@ -416,7 +416,7 @@ declare module breeze { class HasChangesChangedEventArgs { entityManager: EntityManager; - hasChanges: bool; + hasChanges: boolean; } class HasChangesChangedEvent extends breezeCore.Event { @@ -445,7 +445,7 @@ declare module breeze { static fromEntities(entities: Entity[]): EntityQuery; static fromEntityKey(entityKey: EntityKey): EntityQuery; static fromEntityNavigation(entity: Entity, navigationProperty: NavigationProperty): EntityQuery; - inlineCount(enabled?: bool): EntityQuery; + inlineCount(enabled?: boolean): EntityQuery; orderBy(propertyPaths: string): EntityQuery; orderBy(propertyPaths: string[]): EntityQuery; orderByDesc(propertyPaths: string): EntityQuery; @@ -474,13 +474,13 @@ declare module breeze { } class EntityStateSymbol extends breezeCore.EnumSymbol { - isAdded(): bool; - isAddedModifiedOrDeleted(): bool; - isDeleted(): bool; - isDetached(): bool; - isModified(): bool; - isUnchanged(): bool; - isUnchangedOrModified(): bool; + isAdded(): boolean; + isAddedModifiedOrDeleted(): boolean; + isDeleted(): boolean; + isDetached(): boolean; + isModified(): boolean; + isUnchanged(): boolean; + isUnchangedOrModified(): boolean; } interface EntityState extends breezeCore.IEnum { Added: EntityStateSymbol; @@ -517,7 +517,7 @@ declare module breeze { getEntityCtor(): Function; getNavigationProperty(propertyName: string): NavigationProperty; getProperties(): IProperty[]; - getProperty(propertyPath: string, throwIfNotFound?: bool): IProperty; + getProperty(propertyPath: string, throwIfNotFound?: boolean): IProperty; getPropertyNames(): string[]; setProperties(config: EntityTypeProperties): void; toString(): string; @@ -562,7 +562,7 @@ declare module breeze { static caseInsensitiveSQL: LocalQueryComparisonOptions; static defaultInstance: LocalQueryComparisonOptions; - constructor (config: { name?: string; isCaseSensitive?: bool; usesSql92CompliantStringComparison?: bool; }); + constructor (config: { name?: string; isCaseSensitive?: boolean; usesSql92CompliantStringComparison?: boolean; }); setAsDefault(): void; } @@ -585,12 +585,12 @@ declare module breeze { fetchMetadata(dataService: string, callback?: (data) => void , errorCallback?: breezeCore.ErrorCallback): Promise; fetchMetadata(dataService: DataService, callback?: (data) => void , errorCallback?: breezeCore.ErrorCallback): Promise; getDataService(serviceName: string): DataService; - getEntityType(entityTypeName: string, okIfNotFound?: bool): IStructuralType; + getEntityType(entityTypeName: string, okIfNotFound?: boolean): IStructuralType; getEntityTypes(): IStructuralType[]; - hasMetadataFor(serviceName: string): bool; + hasMetadataFor(serviceName: string): boolean; static importMetadata(exportedString: string): MetadataStore; importMetadata(exportedString: string): MetadataStore; - isEmpty(): bool; + isEmpty(): boolean; registerEntityTypeCtor(entityTypeName: string, entityCtor: Function, initializationFn?: (entity: Entity) =>void ): void; trackUnmappedType(entityCtor: Function, interceptor?: Function); setEntityTypeForResourceName(resourceName: string, entityTypeOrName: string): void; @@ -628,9 +628,9 @@ declare module breeze { entityType: EntityType; foreignKeyNames: string[]; inverse: NavigationProperty; - isDataProperty: bool; - isNavigationProperty: bool; - isScalar: bool; + isDataProperty: boolean; + isNavigationProperty: boolean; + isScalar: boolean; name: string; parentEntityType: EntityType; relatedDataProperties: DataProperty[]; @@ -643,7 +643,7 @@ declare module breeze { name?: string; nameOnServer?: string; entityTypeName: string; - isScalar?: bool; + isScalar?: boolean; associationName?: string; foreignKeyNames?: string[]; foreignKeyNamesOnServer?: string[]; @@ -651,15 +651,15 @@ declare module breeze { } class Predicate { - constructor (property: string, operator: string, value: any, valueIsLiteral?: bool); - constructor (property: string, operator: FilterQueryOpSymbol, value: any, valueIsLiteral?: bool); + constructor (property: string, operator: string, value: any, valueIsLiteral?: boolean); + constructor (property: string, operator: FilterQueryOpSymbol, value: any, valueIsLiteral?: boolean); and: PredicateMethod; static and: PredicateMethod; static create: PredicateMethod; - static isPredicate(o: any): bool; + static isPredicate(o: any): boolean; static not(predicate: Predicate): Predicate; not(): Predicate; @@ -675,8 +675,8 @@ declare module breeze { interface PredicateMethod { (predicates: Predicate[]): Predicate; (...predicates: Predicate[]): Predicate; - (property: string, operator: string, value: any, valueIsLiteral?: bool): Predicate; - (property: string, operator: FilterQueryOpSymbol, value: any, valueIsLiteral?: bool): Predicate; + (property: string, operator: string, value: any, valueIsLiteral?: boolean): Predicate; + (property: string, operator: FilterQueryOpSymbol, value: any, valueIsLiteral?: boolean): Predicate; } class Promise { @@ -704,10 +704,10 @@ declare module breeze { } class SaveOptions { - allowConcurrentSaves: bool; + allowConcurrentSaves: boolean; static defaultInstance: SaveOptions; - constructor (config?: { allowConcurrentSaves?: bool; }); + constructor (config?: { allowConcurrentSaves?: boolean; }); setAsDefault(): SaveOptions; } @@ -724,10 +724,10 @@ declare module breeze { class ValidationOptions { static defaultInstance: ValidationOptions; - validateOnAttach: bool; - validateOnPropertyChange: bool; - validateOnQuery: bool; - validateOnSave: bool; + validateOnAttach: boolean; + validateOnPropertyChange: boolean; + validateOnQuery: boolean; + validateOnSave: boolean; constructor (config?: ValidationOptionsConfiguration); @@ -736,10 +736,10 @@ declare module breeze { } interface ValidationOptionsConfiguration { - validateOnAttach?: bool; - validateOnSave?: bool; - validateOnQuery?: bool; - validateOnPropertyChange?: bool; + validateOnAttach?: boolean; + validateOnSave?: boolean; + validateOnQuery?: boolean; + validateOnPropertyChange?: boolean; } class Validator { @@ -747,7 +747,7 @@ declare module breeze { constructor (name: string, validatorFn: ValidatorFunction, context?: any); - static bool(): Validator; + static boolean(): Validator; static byte(): Validator; static date(): Validator; static duration(): Validator; diff --git a/durandal/durandal.d.ts b/durandal/durandal.d.ts index 33dd732f7..f23d43f25 100644 --- a/durandal/durandal.d.ts +++ b/durandal/durandal.d.ts @@ -284,7 +284,7 @@ interface IViewModelDefaults { * called after deactivating a module */ afterDeactivate(): any; -}; +} interface IDurandalViewModelActiveItem { /** @@ -339,7 +339,7 @@ interface IDurandalViewModelActiveItem { * Sets up a collection representing a pool of objects which the activator will activate. See below for details. Activators without an item bool always close their values on deactivate. Activators with an items pool only deactivate, but do not close them. */ forItems(items): IDurandalViewModelActiveItem; -}; +} /** * A router plugin, currently based on SammyJS. The router abstracts away the core configuration of Sammy and re-interprets it in terms of durandal's composition and activation mechanism. To use the router, you must require it, configure it and bind it in the UI. @@ -364,8 +364,8 @@ declare module "durandal/plugins/router" { settings: Object; hash: string; /** only present on visible routes to track if they are active in the nav */ - isActive?: KnockoutComputed; - }; + isActive?: KnockoutComputed; + } /** * Parameters to the map function. e only required parameter is url the rest can be derived. The derivation * happens by stripping parameters from the url and casing where appropriate. You can always explicitly provide @@ -389,19 +389,19 @@ declare module "durandal/plugins/router" { /** * observable that is called when the router is ready */ - export var ready: KnockoutObservableBool; + export var ready: KnockoutObservable; /** * An observable array containing all route info objects. */ - export var allRoutes: KnockoutObservableArray; + export var allRoutes: KnockoutObservableArray; /** * An observable array containing route info objects configured with visible:true (or by calling the mapNav function). */ - export var visibleRoutes: KnockoutObservableArray; + export var visibleRoutes: KnockoutObservableArray; /** * An observable boolean which is true while navigation is in process; false otherwise. */ - export var isNavigating: KnockoutObservableBool; + export var isNavigating: KnockoutObservable; /** * An observable whose value is the currently active item/module/page. */ @@ -409,7 +409,7 @@ declare module "durandal/plugins/router" { /** * An observable whose value is the currently active route. */ - export var activeRoute: KnockoutObservableAny; + export var activeRoute: KnockoutObservable; /** * called after an a new module is composed */ @@ -475,7 +475,7 @@ declare module "durandal/plugins/router" { export var map: { (routeOrRouteArray: IRouteInfoParameters): IRouteInfo; (routeOrRouteArray: IRouteInfoParameters[]): IRouteInfo[]; - }; + } /** * After you've configured the router, you need to activate it. This is usually done in your shell. The activate function of the router returns a promise that resolves when the router is ready to start. To use the router, you should add an activate function to your shell and return the result from that. The application startup infrastructure of Durandal will detect your shell's activate function and call it at the appropriate time, waiting for it's promise to resolve. This allows Durandal to properly orchestrate the timing of composition and databinding along with animations and splash screen display. */ diff --git a/knockout.mapping/knockout.mapping.d.ts b/knockout.mapping/knockout.mapping.d.ts index 010f18801..2213d87c3 100644 --- a/knockout.mapping/knockout.mapping.d.ts +++ b/knockout.mapping/knockout.mapping.d.ts @@ -21,14 +21,14 @@ interface KnockoutMappingOptions { include?: string[]; copy?: string[]; mappedProperties?: string[]; - deferEvaluation?: bool; + deferEvaluation?: boolean; create?: (options: KnockoutMappingCreateOptions) => void; update?: (options: KnockoutMappingUpdateOptions) => void; key?: (data: any) => any; } interface KnockoutMapping { - isMapped(viewModel: any): bool; + isMapped(viewModel: any): boolean; fromJS(jsObject: any): any; fromJS(jsObject: any, targetOrOptions: any): any; fromJS(jsObject: any, inputOptions: any, target: any): any; From b8f655a0968590da81cc418c5c4e254c661a10de Mon Sep 17 00:00:00 2001 From: vcastro Date: Fri, 21 Jun 2013 07:32:08 +0100 Subject: [PATCH 02/37] Fixed typo in breeze.d.ts --- breeze/breeze.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/breeze/breeze.d.ts b/breeze/breeze.d.ts index 8ea397845..cc9feb848 100644 --- a/breeze/breeze.d.ts +++ b/breeze/breeze.d.ts @@ -193,7 +193,7 @@ declare module breeze { } interface DataType extends breezeCore.IEnum { Binary: DataTypeSymbol; - booleanean: DataTypeSymbol; + Boolean: DataTypeSymbol; Byte: DataTypeSymbol; DateTime: DataTypeSymbol; Decimal: DataTypeSymbol; From 95db172afc397a156de98ed3a2719688c0891d09 Mon Sep 17 00:00:00 2001 From: Alexey Vagarenko Date: Fri, 21 Jun 2013 20:24:45 +0500 Subject: [PATCH 03/37] Add generics and new module system support --- underscore/underscore-tests.ts | 13 +- underscore/underscore.d.ts | 410 ++++++++++++++++----------------- 2 files changed, 209 insertions(+), 214 deletions(-) diff --git a/underscore/underscore-tests.ts b/underscore/underscore-tests.ts index 5fbab818b..17398a3dd 100644 --- a/underscore/underscore-tests.ts +++ b/underscore/underscore-tests.ts @@ -1,6 +1,7 @@ -/// +import _ = require("underscore") declare var $; +declare function alert(any); _.each([1, 2, 3], (num) => alert(num)); _.each({ one: 1, two: 2, three: 3 }, (num, key) => alert(num)); @@ -205,7 +206,7 @@ var moe2 = { name: 'moe' }; moe2 === _.identity(moe); var genie; -_(3).times(function(n){ genie.grantWishNumber(n); }); +_(3).times(function (n) { genie.grantWishNumber(n); }); _.random(0, 100); @@ -240,10 +241,8 @@ var template2 = _.template("Hello {{ name }}!"); template2({ name: "Mustache" }); _.template("Using 'with': <%= data.answer %>", { answer: 'no' }, { variable: 'data' }); -// fix: http://stackoverflow.com/questions/14585324/how-to-use-underscore-lib-from-definitelytyped-with-typescript -// fix: https://github.com/borisyankov/DefinitelyTyped/issues/225 -declare var _: UnderscoreStatic; -_.countBy([1,2,3], function(item) { - return item%2; + +_.countBy([1, 2, 3], function (item) { + return item % 2; }); \ No newline at end of file diff --git a/underscore/underscore.d.ts b/underscore/underscore.d.ts index 42d4abeb5..88dc84584 100644 --- a/underscore/underscore.d.ts +++ b/underscore/underscore.d.ts @@ -5,8 +5,8 @@ interface UnderscoreWrappedObject { - value () : any; - filter(arg?) : any; + value(): any; + filter(arg?): any; } interface TemplateSettings { @@ -15,218 +15,214 @@ interface TemplateSettings { escape?: RegExp; } -interface ListIterator { - (value, key, list?): void; +interface ListIterator { + (value: T, index: number, list?: List): TResult; } -interface ObjectIterator { - (element, index, list?): void; +interface ObjectIterator { + (element: T, key: string, list?: any): TResult; } +interface Collection { } + // Common interface between Arrays and jQuery objects -interface List { - [index: number]: any; +interface List extends Collection { + [index: number]: T; length: number; } -interface UnderscoreStatic { - (arg?:any) : any; - - /**** - Collections - *****/ - each(list: List, iterator: ListIterator, context?: any): any[]; - each(object: any, iterator: ObjectIterator, context?: any): any[]; - forEach(list: List, iterator: ObjectIterator, context?: any): any[]; - forEach(object: any, iterator: ListIterator, context?: any): any[]; - - map(list: List, iterator: ListIterator, context?: any): any[]; - map(object: any, iterator: ObjectIterator, context?: any): any[]; - collect(list: List, iterator: ListIterator, context?: any): any[]; - collect(object: any, iterator: ObjectIterator, context?: any): any[]; - - reduce(list: List, iterator: any, memo: any, context?: any): any; - reduce(list: any[], iterator: any, memo: any, context?: any): any; - inject(list: List, iterator: any, memo: any, context?: any): any; - inject(list: any[], iterator: any, memo: any, context?: any): any; - foldl(list: List, iterator: any, memo: any, context?: any): any; - foldl(list: any[], iterator: any, memo: any, context?: any): any; - - reduceRight(list: List, iterator: any, memo: any, context?: any): any[]; - reduceRight(list: any[], iterator: any, memo: any, context?: any): any[]; - foldr(list: List, iterator: any, memo: any, context?: any): any[]; - foldr(list: any[], iterator: any, memo: any, context?: any): any[]; - - find(list: List, iterator: any, context?: any): any; - find(list: any[], iterator: any, context?: any): any; - detect(list: List, iterator: any, context?: any): any; - detect(list: any[], iterator: any, context?: any): any; - - filter(list: List, iterator: any, context?: any): any[]; - filter(list: any[], iterator: any, context?: any): any[]; - select(list: List, iterator: any, context?: any): any[]; - select(list: any[], iterator: any, context?: any): any[]; - - where(list: List, properties: any): any[]; - where(list: any[], properties: any): any[]; - - reject(list: List, iterator: any, context?: any): any[]; - reject(list: any[], iterator: any, context?: any): any[]; - - all(list: List, iterator: any, context?: any): bool; - all(list: any[], iterator: any, context?: any): bool; - every(list: List, iterator: any, context?: any): bool; - every(list: any[], iterator: any, context?: any): bool; - - any(list: List, iterator?: any, context?: any): bool; - any(list: any[], iterator?: any, context?: any): bool; - some(list: List, iterator?: any, context?: any): bool; - some(list: any[], iterator?: any, context?: any): bool; - - contains(list: any, value: any): bool; - contains(list: List, value: any): bool; - include(list: any, value: any): bool; - include(list: List, value: any): bool; - - invoke(list: List, methodName: string, arguments: any[]): any; - invoke(object: any, methodName: string, ...arguments: any[]): any; - - pluck(list: List, propertyName: string): string[]; - pluck(list: any[], propertyName: string): string[]; - max(list: List, iterator?: any, context?: any): any; - max(list: any[], iterator?: any, context?: any): any; - min(list: List, iterator?: any, context?: any): any; - min(list: any[], iterator?: any, context?: any): any; - sortBy(list: List, iterator?: any, context?: any): any; - sortBy(list: any[], iterator?: any, context?: any): any; - groupBy(list: List, iterator: any): any; - groupBy(list: any[], iterator: any): any; - countBy(list: List, iterator: any): any; - countBy(list: any[], iterator: any): any; - shuffle(list: any[]): any[]; - toArray(list: any): any[]; - size(list: any): number; - - /**** - Arrays - *****/ - first(array: List, n?: number): any; - first(array: any[], n?: number): any; - head(array: List, n?: number): any; - head(array: any[], n?: number): any; - take(array: List, n?: number): any; - take(array: any[], n?: number): any; - - initial(array: List, n?: number): any[]; - initial(array: any[], n?: number): any[]; - - last(array: List, n?: number): any; - last(array: any[], n?: number): any; - - rest(array: List, n?: number): any[]; - rest(array: any[], n?: number): any[]; - tail(array: List, n?: number): any[]; - tail(array: any[], n?: number): any[]; - drop(array: List, n?: number): any[]; - drop(array: any[], n?: number): any[]; - - compact(array: any[]): any[]; - flatten(array: List, shallow?: bool): any[]; - flatten(array: any[], shallow?: bool): any[]; - without(array: List, ...values: any[]): any[]; - without(array: any[], ...values: any[]): any[]; - union(...arrays: any[][]): any[]; - intersection(...arrays: any[][]): any[]; - difference(array: List, ...others: any[][]): any[]; - difference(array: any[], ...others: any[][]): any[]; - - uniq(array: List, isSorted?: bool, iterator?: any): any[]; - uniq(array: any[], isSorted?: bool, iterator?: any): any[]; - unique(array: List, isSorted?: bool, iterator?: any): any[]; - unique(array: any[], isSorted?: bool, iterator?: any): any[]; - - zip(...arrays: any[]): any[]; - object(list: List, values?: any[]): any; - object(list: any[], values?: any[]): any; - indexOf(array: List, value: any, isSorted?: bool): number; - indexOf(array: any[], value: any, isSorted?: bool): number; - lastIndexOf(array: List, value: any, fromIndex?: number): number; - lastIndexOf(array: any[], value: any, fromIndex?: number): number; - sortedIndex(list: List, valueL: any, iterator?: any): number; - sortedIndex(list: any[], valueL: any, iterator?: any): number; - range(stop: number): any[]; - range(start: number, stop: number, step?: number): any[]; - - /**** - Functions - *****/ - bind(func: (...as : any[]) => any, context: any, ...arguments: any[]): () => any; - bindAll(object: any, ...methodNames: string[]): any; - memoize(func: any, hashFunction?: any): any; - defer(func: () => any); - delay(func: any, wait: number, ...arguments: any[]): any; - delay(func: any, ...arguments: any[]): any; - throttle(func: any, wait: number): any; - debounce(func: any, wait: number, immediate?: bool): any; - once(func: any): any; - after(count: number, func: any): any; - wrap(func: (...as : any[]) => any, wrapper: any): () => any; - compose(...functions: any[]): any; - - /**** - Objects - *****/ - keys(object: any): any[]; - values(object: any): any[]; - pairs(object: any): any[]; - invert(object: any): any; - - functions(object: any): string[]; - methods(object: any): string[]; - - extend(destination: any, ...sources: any[]): any; - pick(object: any, ...keys: string[]): any; - omit(object: any, ...keys: string[]): any; - defaults(object: any, ...defaults: any[]): any; - clone(object: any): any; - tap(object: any, interceptor: (...as : any[]) => any): any; - has(object: any, key: string): bool; - isEqual(object: any, other: any): bool; - isEmpty(object: any): bool; - isElement(object: any): bool; - isArray(object: any): bool; - isObject(value: any): bool; - isArguments(object: any): bool; - isFunction(object: any): bool; - isString(object: any): bool; - isNumber(object: any): bool; - isFinite(object: any): bool; - isBoolean(object: any): bool; - isDate(object: any): bool; - isRegExp(object: any): bool; - isNaN(object: any): bool; - isNull(object: any): bool; - isUndefined(value: any): bool; - - /**** - Utility - *****/ - noConflict(): any; - identity(value: any): any; - times(n: number, iterator: (index : number) => void, context?: any): void; - random(min: number, max: number): number; - mixin(object: any): void; - uniqueId(prefix: string): string; - uniqueId(): number; - escape(str: string): string; - result(object: any, property: string): any; - templateSettings: TemplateSettings; - template(templateString: string, data?: any, settings?: any): (...data: any[]) => string; - - /**** - Chaining - *****/ - chain(object: any): UnderscoreWrappedObject; +interface Dictionary extends Collection { + [index: string]: T; } -declare var _: UnderscoreStatic; \ No newline at end of file +declare module "underscore" { + function underscore(arg?: any): any; + + module underscore { + /**** + Collections + *****/ + export function each(list: List, iterator: ListIterator, context?: any): void; + export function each(object: Dictionary, iterator: ObjectIterator, context?: any): void; + export function forEach(list: List, iterator: ListIterator, context?: any): void; + export function forEach(object: Dictionary, iterator: ObjectIterator, context?: any): void; + + export function map(list: List, iterator: ListIterator, context?: any): TResult[]; + export function map(object: Dictionary, iterator: ObjectIterator, context?: any): TResult[]; + export function collect(list: List, iterator: ListIterator, context?: any): TResult[]; + export function collect(object: Dictionary, iterator: ObjectIterator, context?: any): TResult[]; + + export function reduce(list: Collection, iterator: (prev: TResult, curr: T) => TResult, memo: TResult, context?: any): TResult; + export function inject(list: Collection, iterator: (prev: TResult, curr: T) => TResult, memo: TResult, context?: any): TResult; + + export function reduceRight(list: Collection, iterator: (prev: TResult, curr: T) => TResult, memo: TResult, context?: any): TResult; + export function foldr(list: Collection, iterator: (prev: TResult, curr: T) => TResult, memo: TResult, context?: any): TResult; + + export function find(list: Collection, iterator: (x: T) => boolean, context?: any): T; + export function detect(list: Collection, iterator: (x: T) => boolean, context?: any): T; + + export function filter(list: Collection, iterator: (x: T) => boolean, context?: any): T[]; + export function select(list: Collection, iterator: (x: T) => boolean, context?: any): T[]; + + export function where(list: Collection, properties: any): T[]; + + export function reject(list: Collection, iterator: (x: T) => boolean, context?: any): T[]; + + export function all(list: Collection, iterator: (x: T) => boolean, context?: any): boolean; + export function every(list: Collection, iterator: (x: T) => boolean, context?: any): boolean; + + export function any(list: Collection, iterator?: (x: T) => boolean, context?: any): boolean; + export function some(list: Collection, iterator?: (x: T) => boolean, context?: any): boolean; + + export function contains(list: Collection, value: T): boolean; + export function include(list: Collection, value: T): boolean; + + export function invoke(list: Collection, methodName: string, ...arguments: any[]): any; + + export function pluck(list: Collection, propertyName: string): any[]; + + export function max(list: Collection, iterator?: (x: T) => any, context?: any): T; + + export function min(list: Collection, iterator?: (x: T) => any, context?: any): T; + + export function sortBy(list: List, iterator?: (x: T) => any, context?: any): T[]; + export function sortBy(list: any, iterator?: (x: T) => any, context?: any): T[]; + export function sortBy(list: List, iterator: string, context?: any): T[]; + export function sortBy(list: any, iterator: string, context?: any): T[]; + + export function groupBy(list: List, iterator?: (x: T) => any, context?: any): Dictionary>; + export function groupBy(list: any, iterator?: (x: T) => any, context?: any): Dictionary>; + export function groupBy(list: List, iterator: string, context?: any): Dictionary>; + export function groupBy(list: any, iterator: string, context?: any): Dictionary>; + + export function countBy(list: List, iterator?: (x: T) => any, context?: any): Dictionary>; + export function countBy(list: any, iterator?: (x: T) => any, context?: any): Dictionary>; + export function countBy(list: List, iterator: string, context?: any): Dictionary>; + export function countBy(list: any, iterator: string, context?: any): Dictionary>; + + export function shuffle(list: Collection): T[]; + + export function toArray(list: Collection): T[]; + + export function size(list: Collection): number; + + /**** + Arrays + *****/ + export function first(array: List): T; + export function first(array: List, n: number): T[]; + export function head(array: List): T; + export function head(array: List, n: number): T[]; + export function take(array: List): T; + export function take(array: List, n: number): T[]; + + export function initial(array: List, n?: number): T[]; + + export function last(array: List): T; + export function last(array: List, n: number): T[]; + + export function rest(array: List, n?: number): T[]; + export function tail(array: List, n?: number): T[]; + export function drop(array: List, n?: number): T[]; + + export function compact(array: List): T[]; + + export function flatten(array: any[], shallow?: boolean): any[]; + + export function without(array: List, ...values: T[]): T[]; + + export function union(...arrays: List[]): T[]; + + export function intersection(...arrays: List[]): T[]; + + export function difference(array: List, ...others: List[]): T[]; + + export function uniq(array: List, isSorted?: boolean, iterator?: (x: T) => any): T[]; + export function unique(array: List, isSorted?: boolean, iterator?: (x: T) => any): T[]; + + export function zip(...arrays: any[]): any[]; + + export function object(list: any[], values?: any): any; + + export function indexOf(array: List, value: T, isSorted?: boolean): number; + export function indexOf(array: List, value: T, startFrom: number): number; + + export function lastIndexOf(array: List, value: T, fromIndex?: number): number; + + export function sortedIndex(list: List, value: T, iterator?: (x: T) => any, context?: any): number; + + export function range(stop: number): any[]; + export function range(start: number, stop: number, step?: number): any[]; + + /**** + Functions + *****/ + export function bind(func: (...as: any[]) => any, context: any, ...arguments: any[]): () => any; + export function bindAll(object: any, ...methodNames: string[]): any; + export function memoize(func: any, hashFunction?: any): any; + export function defer(func: () => any); + export function delay(func: any, wait: number, ...arguments: any[]): any; + export function delay(func: any, ...arguments: any[]): any; + export function throttle(func: any, wait: number): any; + export function debounce(func: any, wait: number, immediate?: boolean): any; + export function once(func: any): any; + export function after(count: number, func: any): any; + export function wrap(func: (...as: any[]) => any, wrapper: any): () => any; + export function compose(...functions: any[]): any; + + /**** + Objects + *****/ + export function keys(object: any): string[]; + export function values(object: Dictionary): T[]; + export function pairs(object: any): any[]; + export function invert(object: any): any; + export function functions(object: any): string[]; + export function methods(object: any): string[]; + export function extend(destination: any, ...sources: any[]): any; + export function pick(object: any, ...keys: string[]): any; + export function omit(object: any, ...keys: string[]): any; + export function defaults(object: any, ...defaults: any[]): any; + export function clone(object: any): any; + export function tap(object: any, interceptor: (...as: any[]) => any): any; + export function has(object: any, key: string): boolean; + export function isEqual(object: any, other: any): boolean; + export function isEmpty(object: any): boolean; + export function isElement(object: any): boolean; + export function isArray(object: any): boolean; + export function isObject(value: any): boolean; + export function isArguments(object: any): boolean; + export function isFunction(object: any): boolean; + export function isString(object: any): boolean; + export function isNumber(object: any): boolean; + export function isFinite(object: any): boolean; + export function isBoolean(object: any): boolean; + export function isDate(object: any): boolean; + export function isRegExp(object: any): boolean; + export function isNaN(object: any): boolean; + export function isNull(object: any): boolean; + export function isUndefined(value: any): boolean; + + /**** + Utility + *****/ + export function noConflict(): any; + export function identity(value: any): any; + export function times(n: number, iterator: (index: number) => void , context?: any): void; + export function random(min: number, max: number): number; + export function mixin(object: any): void; + export function uniqueId(prefix: string): string; + export function uniqueId(): number; + export function escape(str: string): string; + export function result(object: any, property: string): any; + export var templateSettings: TemplateSettings; + export function template(templateString: string, data?: any, settings?: any): (...data: any[]) => string; + + /**** + Chaining + *****/ + export function chain(object: any): UnderscoreWrappedObject; + } + + export = underscore; +} \ No newline at end of file From 875a9283735bfb91f824c2f29ee7bfe68cd24ddc Mon Sep 17 00:00:00 2001 From: Natan Vivo Date: Sat, 22 Jun 2013 09:49:06 -0300 Subject: [PATCH 04/37] Remove template property from View, its not part of the class. --- backbone/backbone.d.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/backbone/backbone.d.ts b/backbone/backbone.d.ts index 2a4a60819..49b6234ff 100644 --- a/backbone/backbone.d.ts +++ b/backbone/backbone.d.ts @@ -266,7 +266,6 @@ declare module Backbone { $(selector: string): JQuery; model: Model; collection: Collection; - template: (data?: any) => string; make(tagName: string, attrs?, opts?): View; setElement(element: HTMLElement, delegate?: boolean); id: string; From 364bdc1176aeb8747bdd9bd2044d27ba245c51f9 Mon Sep 17 00:00:00 2001 From: Natan Vivo Date: Sat, 22 Jun 2013 09:53:33 -0300 Subject: [PATCH 05/37] Remove unused code. --- backbone/backbone.d.ts | 7 ------- 1 file changed, 7 deletions(-) diff --git a/backbone/backbone.d.ts b/backbone/backbone.d.ts index 49b6234ff..7c5daeb42 100644 --- a/backbone/backbone.d.ts +++ b/backbone/backbone.d.ts @@ -66,12 +66,6 @@ declare module Backbone { reset?: boolean; } - interface on { (eventName: string, callback: (...args: any[]) => void, context?: any): any; } - interface off { (eventName?: string, callback?: (...args: any[]) => void, context?: any): any; } - interface trigger { (eventName: string, ...args: any[]): any; } - interface bind { (eventName: string, callback: (...args: any[]) => void, context?: any): any; } - interface unbind { (eventName?: string, callback?: (...args: any[]) => void, context?: any): any; } - class Events { on(eventName: string, callback: (...args:any[]) => void, context?: any): any; off(eventName?: string, callback?: (...args:any[]) => void, context?: any): any; @@ -281,7 +275,6 @@ declare module Backbone { render(): View; remove(): View; make(tagName, attributes?, content?); - //delegateEvents: any; delegateEvents(events?: any): any; undelegateEvents(); } From 08259b232b5e69cf23d0ad64e4801bd95e202ae3 Mon Sep 17 00:00:00 2001 From: Natan Vivo Date: Sat, 22 Jun 2013 10:24:07 -0300 Subject: [PATCH 06/37] Improvements to definition. * Model.urlRoot should be any, as it may be a string or a function. * Added internal methods to Router. * Improved definition of History: - Extends Events - Remove pushState method, it doesn't exist in the source - Added internal methods to definition. --- backbone/backbone.d.ts | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/backbone/backbone.d.ts b/backbone/backbone.d.ts index 7c5daeb42..90684b32d 100644 --- a/backbone/backbone.d.ts +++ b/backbone/backbone.d.ts @@ -86,7 +86,6 @@ declare module Backbone { sync(...arg: any[]): JQueryXHR; } - class Model extends ModelBase { static extend(properties: any, classProperties?: any): any; // do not use, prefer TypeScript's extend functionality @@ -97,7 +96,7 @@ declare module Backbone { id: any; idAttribute: string; validationError: any; - urlRoot(): string; + urlRoot: any; constructor (attributes?: any, options?: any); initialize(attributes?: any); @@ -229,16 +228,31 @@ declare module Backbone { route(route: string, name: string, callback?: (...parameter: any[]) => void); navigate(fragment: string, options?: NavigateOptions); navigate(fragment: string, trigger?: boolean); + + _bindRoutes(): void; + _routeToRegExp(route: string): RegExp; + _extractParameters(route: RegExp, fragment: string): string[]; } var history: History; - class History { + + class History extends Events { + + handlers: any[]; + interval: number; + start(options?: HistoryOptions); - navigate(fragment: string, options: any); - pushSate(); - getFragment(fragment?: string, forcePushState?: boolean): string; + getHash(window?: Window): string; + getFragment(fragment?: string, forcePushState?: boolean): string; + stop(): void; + route(route: string, callback: (...args: any[]) => void ); + checkUrl(e?: any): void; + loadUrl(fragmentOverride: string): boolean; + navigate(fragment: string, options?: any); started: boolean; + + _updateHash(location: Location, fragment: string, replace: bool); } interface ViewOptions { @@ -294,3 +308,4 @@ declare module Backbone { function setDomLibrary(jQueryNew); } + From d6c2d01c5cc77110ec1a095bce3a28b73d0c1162 Mon Sep 17 00:00:00 2001 From: Natan Vivo Date: Sat, 22 Jun 2013 10:54:14 -0300 Subject: [PATCH 07/37] Add internal methods and mixins to Model and Collection. --- backbone/backbone.d.ts | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/backbone/backbone.d.ts b/backbone/backbone.d.ts index 90684b32d..b2a5092cb 100644 --- a/backbone/backbone.d.ts +++ b/backbone/backbone.d.ts @@ -123,6 +123,19 @@ declare module Backbone { save(attributes?: any, options?: ModelSaveOptions); unset(attribute: string, options?: Silenceable); validate(attributes: any, options?: any): any; + + _validate(attrs: 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 extends ModelBase { @@ -158,6 +171,12 @@ declare module Backbone { unshift(model: Model, options?: AddOptions); where(properies: any): Model[]; + _prepareModel(attrs?: any, options?: any): any; + _removeReference(model: Model): void; + _onModelEvent(event: string, model: Model, collection: Collection, options: any): void; + + // mixins from underscore + all(iterator: (element: Model, index: number) => boolean, context?: any): boolean; any(iterator: (element: Model, index: number) => boolean, context?: any): boolean; collect(iterator: (element: Model, index: number, context?: any) => any[], context?: any): any[]; From 38e50c8b104da6a2674f9be9f5c9aaefd7e3ea47 Mon Sep 17 00:00:00 2001 From: Natan Vivo Date: Sat, 22 Jun 2013 11:06:05 -0300 Subject: [PATCH 08/37] Add internal method to View. --- backbone/backbone.d.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/backbone/backbone.d.ts b/backbone/backbone.d.ts index b2a5092cb..c1030dcfc 100644 --- a/backbone/backbone.d.ts +++ b/backbone/backbone.d.ts @@ -310,6 +310,8 @@ declare module Backbone { make(tagName, attributes?, content?); delegateEvents(events?: any): any; undelegateEvents(); + + _ensureElement() : void; } // SYNC From 2167e6f5b0277a2847eafa0eb08a0ac1759fc3d0 Mon Sep 17 00:00:00 2001 From: Natan Vivo Date: Sat, 22 Jun 2013 11:43:21 -0300 Subject: [PATCH 09/37] Fix test, remove duplicated declaration for _ and $. --- backbone/backbone-tests.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/backbone/backbone-tests.ts b/backbone/backbone-tests.ts index 2a2bf3b41..c1292c1c2 100644 --- a/backbone/backbone-tests.ts +++ b/backbone/backbone-tests.ts @@ -1,8 +1,6 @@ /// /// -declare var _, $; - function test_events() { var object = new Backbone.Events(); From 3c72be6a9318ef1e8ec92ab98b2a9707b212819f Mon Sep 17 00:00:00 2001 From: Natan Vivo Date: Sat, 22 Jun 2013 12:39:21 -0300 Subject: [PATCH 10/37] Add missing property View.cid. --- backbone/backbone.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/backbone/backbone.d.ts b/backbone/backbone.d.ts index c1030dcfc..79a7be1ab 100644 --- a/backbone/backbone.d.ts +++ b/backbone/backbone.d.ts @@ -296,6 +296,7 @@ declare module Backbone { make(tagName: string, attrs?, opts?): View; setElement(element: HTMLElement, delegate?: boolean); id: string; + cid: string; className: string; tagName: string; events: any; From bcb5914a8686c259dc1720056b4cc5234200ab81 Mon Sep 17 00:00:00 2001 From: Natan Vivo Date: Sat, 22 Jun 2013 12:39:21 -0300 Subject: [PATCH 11/37] Add missing property View.cid. --- backbone/backbone.d.ts | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/backbone/backbone.d.ts b/backbone/backbone.d.ts index 79a7be1ab..cfc3c3d2f 100644 --- a/backbone/backbone.d.ts +++ b/backbone/backbone.d.ts @@ -67,11 +67,11 @@ declare module Backbone { } class Events { - on(eventName: string, callback: (...args:any[]) => void, context?: any): any; - off(eventName?: string, callback?: (...args:any[]) => void, context?: any): any; + on(eventName: string, callback: (...args: any[]) => void , context?: any): any; + off(eventName?: string, callback?: (...args: any[]) => void , context?: any): any; trigger(eventName: string, ...args: any[]): any; - bind(eventName: string, callback: (...args:any[]) => void, context?: any): any; - unbind(eventName?: string, callback?: (...args:any[]) => void, context?: any): any; + bind(eventName: string, callback: (...args: any[]) => void , context?: any): any; + unbind(eventName?: string, callback?: (...args: any[]) => void , context?: any): any; once(events: string, callback: (...args: any[]) => void , context?: any): any; listenTo(object: any, events: string, callback: (...args: any[]) => void ): any; @@ -98,7 +98,7 @@ declare module Backbone { validationError: any; urlRoot: any; - constructor (attributes?: any, options?: any); + constructor(attributes?: any, options?: any); initialize(attributes?: any); fetch(options?: ModelFetchOptions): JQueryXHR; @@ -147,7 +147,7 @@ declare module Backbone { collection: Model; length: number; - constructor (models?: any, options?: any); + constructor(models?: any, options?: any); fetch(options?: CollectionFetchOptions): JQueryXHR; @@ -189,7 +189,7 @@ declare module Backbone { difference(...model: Model[]): Model[]; drop(): Model; drop(n: number): Model[]; - each(iterator: (element: Model, index: number, list?: any) => void, context?: any); + each(iterator: (element: Model, index: number, list?: any) => void , context?: any); every(iterator: (element: Model, index: number) => boolean, context?: any): boolean; filter(iterator: (element: Model, index: number) => boolean, context?: any): Model[]; find(iterator: (element: Model, index: number) => boolean, context?: any): Model; @@ -197,7 +197,7 @@ declare module Backbone { first(n: number): Model[]; flatten(shallow?: boolean): Model[]; foldl(iterator: (memo: any, element: Model, index: number) => any, initialMemo: any, context?: any): any; - forEach(iterator: (element: Model, index: number, list?: any) => void, context?: any); + forEach(iterator: (element: Model, index: number, list?: any) => void , context?: any); include(value: any): boolean; indexOf(element: Model, isSorted?: boolean): number; initial(): Model; @@ -242,9 +242,9 @@ declare module Backbone { routes: any; - constructor (options?: RouterOptions); - initialize (options?: RouterOptions); - route(route: string, name: string, callback?: (...parameter: any[]) => void); + constructor(options?: RouterOptions); + initialize(options?: RouterOptions); + route(route: string, name: string, callback?: (...parameter: any[]) => void ); navigate(fragment: string, options?: NavigateOptions); navigate(fragment: string, trigger?: boolean); @@ -288,7 +288,7 @@ declare module Backbone { static extend(properties: any, classProperties?: any): any; // do not use, prefer TypeScript's extend functionality - constructor (options?: ViewOptions); + constructor(options?: ViewOptions); $(selector: string): JQuery; model: Model; @@ -296,7 +296,7 @@ declare module Backbone { make(tagName: string, attrs?, opts?): View; setElement(element: HTMLElement, delegate?: boolean); id: string; - cid: string; + cid: string; className: string; tagName: string; events: any; @@ -312,19 +312,19 @@ declare module Backbone { delegateEvents(events?: any): any; undelegateEvents(); - _ensureElement() : void; + _ensureElement(): void; } // SYNC function sync(method, model, options?: JQueryAjaxSettings); - var emulateHTTP: boolean; - var emulateJSONBackbone: boolean; + var emulateHTTP: boolean; + var emulateJSONBackbone: boolean; // Utility // 0.9 cannot return modules anymore, and "typeof " is not compiling for some reason // returning "any" until this is fixed - + //function noConflict(): typeof Backbone; function noConflict(): any; From 6c9592fdc4adae98b845725fb8fe109ae888cf14 Mon Sep 17 00:00:00 2001 From: Nicholas Wolverson Date: Mon, 24 Jun 2013 09:28:01 +0100 Subject: [PATCH 12/37] Simplify optional overloads --- knockout/knockout.d.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/knockout/knockout.d.ts b/knockout/knockout.d.ts index 6016a6598..b9c1e9cb7 100644 --- a/knockout/knockout.d.ts +++ b/knockout/knockout.d.ts @@ -79,8 +79,7 @@ interface KnockoutObservableArrayStatic { fn: KnockoutObservableArrayFunctions; - (): KnockoutObservableArray; - (value: T[]): KnockoutObservableArray; + (value?: T[]): KnockoutObservableArray; } interface KnockoutObservableArray extends KnockoutObservableArrayFunctions { @@ -95,7 +94,6 @@ interface KnockoutObservableStatic { fn: KnockoutObservableFunctions; (value?: T): KnockoutObservable; - (): KnockoutObservable; } /** use as method to get/set the value */ From 6543a55f8ff30f5008bd6fc4f59314a06f2bf07e Mon Sep 17 00:00:00 2001 From: vcastro Date: Mon, 24 Jun 2013 10:03:45 +0100 Subject: [PATCH 13/37] Updates to breeze.d.ts according to changes in Breeze 1.3.6: -Added setDetached method to EntityAspect -Changed the signature of EntityManager.importEntities to accept either a string or a JSON object. --- breeze/breeze.d.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/breeze/breeze.d.ts b/breeze/breeze.d.ts index cc9feb848..1522d1cd4 100644 --- a/breeze/breeze.d.ts +++ b/breeze/breeze.d.ts @@ -261,6 +261,7 @@ declare module breeze { setDeleted(): void; setModified(): void; setUnchanged(): void; + setDetached(): boolean; validateEntity(): boolean; validateProperty(property: string, context?: any): boolean; @@ -355,7 +356,7 @@ declare module breeze { hasChanges(entityTypes: EntityType[]): boolean; static importEntities(exportedString: string, config?: { mergeStrategy?: MergeStrategySymbol; }): EntityManager; - importEntities(exportedString: string, config?: { mergeStrategy?: MergeStrategySymbol; }): EntityManager; + importEntities(exportedString: any, config?: { mergeStrategy?: MergeStrategySymbol; }): EntityManager; rejectChanges(): Entity[]; saveChanges(entities?: Entity[], saveOptions?: SaveOptions, callback?: SaveChangesSuccessCallback, errorCallback?: SaveChangesErrorCallback): Promise; From 182b290dc4b32ce6b27bc0c9a6f3a0d6fb9aa536 Mon Sep 17 00:00:00 2001 From: Neil Stalker Date: Mon, 24 Jun 2013 12:49:31 +0100 Subject: [PATCH 14/37] fix filewriter, restify and chrome definitions --- chrome/chrome-tests.ts | 155 ++++++++++++ chrome/chrome.d.ts | 226 +++++++++--------- filewriter/filewriter.d.ts | 2 +- restify/{restify-test.ts => restify-tests.ts} | 0 restify/restify.d.ts | 34 +-- 5 files changed, 286 insertions(+), 131 deletions(-) create mode 100644 chrome/chrome-tests.ts rename restify/{restify-test.ts => restify-tests.ts} (100%) diff --git a/chrome/chrome-tests.ts b/chrome/chrome-tests.ts new file mode 100644 index 000000000..1d041a79b --- /dev/null +++ b/chrome/chrome-tests.ts @@ -0,0 +1,155 @@ +/// +/// +/// + +// https://developer.chrome.com/extensions/examples/api/bookmarks/basic/popup.js +function bookmarksExample() { + $(function () { + $('#search').change(function () { + $('#bookmarks').empty(); + dumpBookmarks($('#search').val()); + }); + }); + // Traverse the bookmark tree, and print the folder and nodes. + function dumpBookmarks(query?) { + var bookmarkTreeNodes = chrome.bookmarks.getTree( + function (bookmarkTreeNodes) { + $('#bookmarks').append(dumpTreeNodes(bookmarkTreeNodes, query)); + }); + } + function dumpTreeNodes(bookmarkNodes, query) { + var list = $('
    '); + var i; + for (i = 0; i < bookmarkNodes.length; i++) { + list.append(dumpNode(bookmarkNodes[i], query)); + } + return list; + } + function dumpNode(bookmarkNode, query) { + if (bookmarkNode.title) { + if (query && !bookmarkNode.children) { + if (String(bookmarkNode.title).indexOf(query) == -1) { + return $(''); + } + } + var anchor = $(''); + anchor.attr('href', bookmarkNode.url); + anchor.text(bookmarkNode.title); + /* + * When clicking on a bookmark in the extension, a new tab is fired with + * the bookmark url. + */ + anchor.click(function () { + chrome.tabs.create({ url: bookmarkNode.url }); + }); + var span = $(''); + var options = bookmarkNode.children ? + $('[Add]') : + $('[Edit Delete]'); + var edit = bookmarkNode.children ? $('
    Name' + + '
    URL' + + '
    ') : $(''); + // Show add and edit links when hover over. + span.hover(function () { + span.append(options); + $('#deletelink').click(function () { + $('#deletedialog').empty().dialog({ + autoOpen: false, + title: 'Confirm Deletion', + resizable: false, + height: 140, + modal: true, + overlay: { + backgroundColor: '#000', + opacity: 0.5 + }, + buttons: { + 'Yes, Delete It!': function () { + chrome.bookmarks.remove(String(bookmarkNode.id)); + span.parent().remove(); + $(this).dialog('destroy'); + }, + Cancel: function () { + $(this).dialog('destroy'); + } + } + }).dialog('open'); + }); + $('#addlink').click(function () { + $('#adddialog').empty().append(edit).dialog({ + autoOpen: false, + closeOnEscape: true, title: 'Add New Bookmark', modal: true, + buttons: { + 'Add': function () { + chrome.bookmarks.create({ + parentId: bookmarkNode.id, + title: $('#title').val(), url: $('#url').val() + }); + $('#bookmarks').empty(); + $(this).dialog('destroy'); + dumpBookmarks(); + }, + 'Cancel': function () { + $(this).dialog('destroy'); + } + } + }).dialog('open'); + }); + $('#editlink').click(function () { + edit.val(anchor.text()); + $('#editdialog').empty().append(edit).dialog({ + autoOpen: false, + closeOnEscape: true, title: 'Edit Title', modal: true, + show: 'slide', buttons: { + 'Save': function () { + chrome.bookmarks.update(String(bookmarkNode.id), { + title: edit.val() + }); + anchor.text(edit.val()); + options.show(); + $(this).dialog('destroy'); + }, + 'Cancel': function () { + $(this).dialog('destroy'); + } + } + }).dialog('open'); + }); + options.fadeIn(); + }, + // unhover + function () { + options.remove(); + }).append(anchor); + } + var li = $(bookmarkNode.title ? '
  • ' : '
    ').append(span); + if (bookmarkNode.children && bookmarkNode.children.length > 0) { + li.append(dumpTreeNodes(bookmarkNode.children, query)); + } + return li; + } + + document.addEventListener('DOMContentLoaded', function () { + dumpBookmarks(); + }); +} + +// https://developer.chrome.com/extensions/examples/api/browserAction/make_page_red/background.js +function pageRedder() { + chrome.browserAction.onClicked.addListener(function (tab) { + // No tabs or host permissions needed! + console.log('Turning ' + tab.url + ' red!'); + chrome.tabs.executeScript({ + code: 'document.body.style.backgroundColor="red"' + }); + }); +} + +// https://developer.chrome.com/extensions/examples/api/browserAction/print/background.js +function printPage() { + chrome.browserAction.onClicked.addListener(function (tab) { + var action_url = "javascript:window.print();"; + chrome.tabs.update(tab.id, { url: action_url }); + }); +} \ No newline at end of file diff --git a/chrome/chrome.d.ts b/chrome/chrome.d.ts index 6d5884f1c..5c1e4abb9 100644 --- a/chrome/chrome.d.ts +++ b/chrome/chrome.d.ts @@ -31,7 +31,7 @@ declare module chrome.alarms { export function get(callback: (alarm: Alarm) => void): void; export function get(name: string, callback: (alarm: Alarm) => void): void; - declare var onAlarm: AlarmEvent; + var onAlarm: AlarmEvent; } //////////////////// @@ -98,8 +98,8 @@ declare module chrome.bookmarks { addListener(callback: (id: string, reorderInfo: BookmarkReorderInfo) => void); } - declare var MAX_WRITE_OPERATIONS_PER_HOUR: number; - declare var MAX_SUSTAINED_WRITE_OPERATIONS_PER_MINUTE: number; + var MAX_WRITE_OPERATIONS_PER_HOUR: number; + var MAX_SUSTAINED_WRITE_OPERATIONS_PER_MINUTE: number; export function search(query: string, callback: (results: BookmarkTreeNode[]) => void): void; export function getTree(callback: (results: BookmarkTreeNode[]) => void): void; @@ -114,12 +114,12 @@ declare module chrome.bookmarks { export function getSubTree(id: string, callback: (results: BookmarkTreeNode[]) => void): void; export function removeTree(id: string, callback?: Function): void; - declare var onRemoved: chrome.alarms.AlarmEvent; - declare var onImportEnded: BookmarkImportEndedEvent; - declare var onImportBegan: BookmarkImportBeganEvent; - declare var onChanged: BookmarkChangedEvent; - declare var onCreated: BookmarkCreatedEvent; - declare var onChildrenReordered: BookmarkChildrenReordered; + var onRemoved: chrome.alarms.AlarmEvent; + var onImportEnded: BookmarkImportEndedEvent; + var onImportBegan: BookmarkImportBeganEvent; + var onChanged: BookmarkChangedEvent; + var onCreated: BookmarkCreatedEvent; + var onChildrenReordered: BookmarkChildrenReordered; } //////////////////// @@ -172,7 +172,7 @@ declare module chrome.browserAction { export function getPopup(details: TabDetails, callback: (result: string) => void): void; export function setIcon(details: TabIconDetails, callback?: Function): void; - declare var onClicked: BrowserClickedEvent; + var onClicked: BrowserClickedEvent; } //////////////////// @@ -229,7 +229,7 @@ declare module chrome.commands { addListener(callback: (command: string) => void); } - declare var onCommand: CommandEvent; + var onCommand: CommandEvent; } //////////////////// @@ -271,12 +271,12 @@ declare module chrome.contentSettings { description?: string; } - declare var cookies: ContentSetting; - declare var popups: ContentSetting; - declare var javascript: ContentSetting; - declare var notifications: ContentSetting; - declare var plugins: ContentSetting; - declare var images: ContentSetting; + var cookies: ContentSetting; + var popups: ContentSetting; + var javascript: ContentSetting; + var notifications: ContentSetting; + var plugins: ContentSetting; + var images: ContentSetting; } //////////////////// @@ -330,7 +330,7 @@ declare module chrome.contextMenus { export function update(id: any, updateProperties: UpdateProperties, callback?: Function): void; export function remove(menuItemId: any, callback?: Function): void; - declare var onClicked: MenuClickedEvent; + var onClicked: MenuClickedEvent; } //////////////////// @@ -399,7 +399,7 @@ declare module chrome.cookies { export function remove(details: Details, callback?: (details: Details) => void): void; export function get(details: Details, callback: (cookie?: Cookie) => void): void; - declare var onChanged: CookieChangedEvent; + var onChanged: CookieChangedEvent; } //////////////////// @@ -422,8 +422,8 @@ declare module "chrome.debugger" { export function detach(target: Debuggee, callback?: Function): void; export function sendCommand(target: Debuggee, method: string, commandParams?: Object, callback?: (result: Object) => void): void; - declare var onDetach: DebuggerDetachedEvent; - declare var onEvent: DebuggerEventEvent; + var onDetach: DebuggerDetachedEvent; + var onEvent: DebuggerEventEvent; } //////////////////// @@ -534,7 +534,7 @@ declare module chrome.declarativeWebRequest { addListener(callback: Function): void; } - declare var onRequest: RequestedEvent; + var onRequest: RequestedEvent; } //////////////////// @@ -561,14 +561,14 @@ declare module chrome.devtools.inspectedWindow { addListener(callback: (resource: Resource, content: string) => void): void; } - declare var tabId: number; + var tabId: number; export function reload(reloadOptions: ReloadOptions): void; export function eval(expression: string, callback?: (result: Object, isException: boolean) => void): void; export function getResources(callback: (resources: Resource[]) => void): void; - declare var onResourceAdded: ResourceAddedEvent; - declare var onResourceContentCommitted: ResourceContentCommittedEvent; + var onResourceAdded: ResourceAddedEvent; + var onResourceContentCommitted: ResourceContentCommittedEvent; } //////////////////// @@ -589,8 +589,8 @@ declare module chrome.devtools.network { export function getHAR(callback: (harLog: Object) => void): void; - declare var onRequestFinished: RequestFinishedEvent; - declare var onNavigated: NavigatedEvent; + var onRequestFinished: RequestFinishedEvent; + var onNavigated: NavigatedEvent; } //////////////////// @@ -651,7 +651,7 @@ declare module chrome.devtools.panels { onHidden: ExtensionSidebarPaneHiddenEvent; } - declare var elements: ElementsPanel; + var elements: ElementsPanel; export function create(title: string, iconPath: string, pagePath: string, callback?: (panel: ExtensionPanel) => void): void; export function setOpenResourceHandler(callback: (resource: chrome.devtools.inspectedWindow.Resource) => void): void; @@ -776,9 +776,9 @@ declare module chrome.downloads { export function cancel(downloadId: number, callback?: Function): void; export function download(options: DownloadOptions, callback?: (downloadId: number) => void): void; - declare var onChanged: DownloadChangedEvent; - declare var onCreated: DownloadCreatedEvent; - declare var onErased: DownloadErasedEvent; + var onChanged: DownloadChangedEvent; + var onCreated: DownloadCreatedEvent; + var onErased: DownloadErasedEvent; } //////////////////// @@ -868,8 +868,8 @@ declare module chrome.extension { addListener(callback: (port: Port) => void): void; } - declare var inIncognitoContext: boolean; - declare var lastError: Object; + var inIncognitoContext: boolean; + var lastError: Object; export function getBackgroundPage(): Window; export function getURL(path: string): string; @@ -881,10 +881,10 @@ declare module chrome.extension { export function connect(extensionId?: string, connectInfo?: ConnectInfo): Port; export function isAllowedIncognitoAccess(callback: (isAllowedAccess) => void): void; - declare var onMessage: ExtensionMessageEvent; - declare var onMessageExternal: ExtensionMessageExternalEvent; - declare var onConnect: ExtensionConnectEvent; - declare var onConnectExternal: ExtensionConnectExternalEvent; + var onMessage: ExtensionMessageEvent; + var onMessageExternal: ExtensionMessageExternalEvent; + var onConnect: ExtensionConnectEvent; + var onConnectExternal: ExtensionConnectExternalEvent; } //////////////////// @@ -911,7 +911,7 @@ declare module chrome.fileBrowserHandler { addListener(callback: (id: string, details: FileHandlerExecuteEventDetails) => void): void; } - declare var onExecute: FileBrowserHandlerExecuteEvent; + var onExecute: FileBrowserHandlerExecuteEvent; } //////////////////// @@ -989,10 +989,10 @@ declare module chrome.fontSettings { export function getFontList(callback: (results: FontName[]) => void): void; export function clearDefaultFixedFontSize(details: Object, callback?: Function): void; - declare var onDefaultFixedFontSizeChanged: DefaultFixedFontSizeChangedEvent; - declare var onDefaultFontSizeChanged: DefaultFontSizeChangedEvent; - declare var onMinimumFontSizeChanged: MinimumFontSizeChangedEvent; - declare var onFontChanged: FontChangedEvent; + var onDefaultFixedFontSizeChanged: DefaultFixedFontSizeChangedEvent; + var onDefaultFontSizeChanged: DefaultFontSizeChangedEvent; + var onMinimumFontSizeChanged: MinimumFontSizeChangedEvent; + var onFontChanged: FontChangedEvent; } //////////////////// @@ -1052,8 +1052,8 @@ declare module chrome.history { export function getVisits(details: Url, callback: (results: VisitItem[]) => void): void; export function deleteUrl(details: Url, callback?: Function): void; - declare var onVisited: HistoryVisitedEvent; - declare var onVisitRemoved: HistoryVisitRemovedEvent; + var onVisited: HistoryVisitedEvent; + var onVisitRemoved: HistoryVisitRemovedEvent; } //////////////////// @@ -1074,7 +1074,7 @@ declare module chrome.idle { export function queryState(thresholdSeconds: number, callback: (newState: string) => void): void; - declare var onStateChanged: IdleStateChangedEvent; + var onStateChanged: IdleStateChangedEvent; } //////////////////// @@ -1183,14 +1183,14 @@ declare module chrome.input.ime { export function clearComposition(parameters: ClearCompositionParameters, callback?: (success: boolean) => void): void; export function setCursorPosition(parameters: CursorPositionParameters, callback?: (success: boolean) => void): void; - declare var onBlur: BlurEvent; - declare var onCandidateClicked: CandidateClickedEvent; - declare var onKeyEvent: KeyEventEvent; - declare var onDeactivated: DeactivatedEvent; - declare var onInputContextUpdate: InputContextUpdateEvent; - declare var onActivate: ActivateEvent; - declare var onFocus: FocusEvent; - declare var onMenuItemActivated: MenuItemActivatedEvent; + var onBlur: BlurEvent; + var onCandidateClicked: CandidateClickedEvent; + var onKeyEvent: KeyEventEvent; + var onDeactivated: DeactivatedEvent; + var onInputContextUpdate: InputContextUpdateEvent; + var onActivate: ActivateEvent; + var onFocus: FocusEvent; + var onMenuItemActivated: MenuItemActivatedEvent; } //////////////////// @@ -1250,10 +1250,10 @@ declare module chrome.management { export function launchApp(id: string, callback?: Function): void; export function uninstall(id: string, options: UninstallOptions, callback?: Function): void; - declare var onDisabled: ManagementDisabledEvent; - declare var onUninstalled: ManagementUninstalledEvent; - declare var onInstalled: ManagementInstalledEvent; - declare var onEnabled: ManagementEnabledEvent; + var onDisabled: ManagementDisabledEvent; + var onUninstalled: ManagementUninstalledEvent; + var onInstalled: ManagementInstalledEvent; + var onEnabled: ManagementEnabledEvent; } //////////////////// @@ -1287,10 +1287,10 @@ declare module chrome.omnibox { export function setDefaultSuggestion(suggestion: Suggestion): void; - declare var onInputEntered: OmniboxInputEnteredEvent; - declare var onInputChanged: OmniboxInputChangedEvent; - declare var onInputStarted: OmniboxInputStartedEvent; - declare var onInputCancelled: OmniboxInputCancelledEvent; + var onInputEntered: OmniboxInputEnteredEvent; + var onInputChanged: OmniboxInputChangedEvent; + var onInputStarted: OmniboxInputStartedEvent; + var onInputCancelled: OmniboxInputCancelledEvent; } //////////////////// @@ -1330,7 +1330,7 @@ declare module chrome.pageAction { export function getPopup(details: GetDetails, callback: (result: string) => void): void; export function setIcon(details: IconDetails, callback?: Function): void; - declare var onClicked: PageActionClickedEvent; + var onClicked: PageActionClickedEvent; } //////////////////// @@ -1366,8 +1366,8 @@ declare module chrome.permissions { export function request(permissions: Permissions, callback?: (granted: boolean) => void): void; export function remove(permissions: Permissions, callback?: (removed: boolean) => void): void; - declare var onRemoved: PermissionsRemovedEvent; - declare var onAdded: PermissionsAddedEvent; + var onRemoved: PermissionsRemovedEvent; + var onAdded: PermissionsAddedEvent; } //////////////////// @@ -1395,9 +1395,9 @@ declare module chrome.privacy { protectedContentEnabled: chrome.types.ChromeSetting; } - declare var services: Services; - declare var network: Network; - declare var websites: Websites; + var services: Services; + var network: Network; + var websites: Websites; } //////////////////// @@ -1441,16 +1441,16 @@ declare module chrome.proxy { addListener(callback: (details: ErrorDetails) => void): void; } - declare var settings: chrome.types.ChromeSetting; - declare var onProxyError: ProxyErrorEvent; + var settings: chrome.types.ChromeSetting; + var onProxyError: ProxyErrorEvent; } //////////////////// // Runtime //////////////////// declare module chrome.runtime { - declare var lastError: Object; - declare var id: string; + var lastError: Object; + var id: string; interface InstalledDetails { reason: string; @@ -1477,10 +1477,10 @@ declare module chrome.runtime { export function getManifest(): Object; export function getURL(path: string): string; - declare var onSuspend: RuntimeSuspendEvent; - declare var onStartup: RuntimeStartupEvent; - declare var onInstalled: RuntimeInstalledEvent; - declare var onSuspendCanceled: RuntimeSuspendCanceledEvent; + var onSuspend: RuntimeSuspendEvent; + var onStartup: RuntimeStartupEvent; + var onInstalled: RuntimeInstalledEvent; + var onSuspendCanceled: RuntimeSuspendCanceledEvent; } //////////////////// @@ -1508,7 +1508,7 @@ declare module chrome.scriptBadge { export function getAttention(details: AttentionDetails): void; export function setPopup(details: SetPopupDetails): void; - declare var onClicked: ScriptBadgeClickedEvent; + var onClicked: ScriptBadgeClickedEvent; } //////////////////// @@ -1550,10 +1550,10 @@ declare module chrome.storage { addListener(callback: (changes: Object, areaName: string) => void): void; } - declare var local: Local; - declare var sync: Sync; + var local: Local; + var sync: Sync; - declare var onChanged: StorageChangedEvent; + var onChanged: StorageChangedEvent; } //////////////////// @@ -1788,14 +1788,14 @@ declare module chrome.tabs { export function detectLanguage(callback: (language: string) => void): void; export function detectLanguage(tabId: number, callback: (language: string) => void): void; - declare var onHighlighted: TabHighlightedEvent; - declare var onRemoved: TabRemovedEvent; - declare var onUpdated: TabUpdatedEvent; - declare var onAttached: TabAttachedEvent; - declare var onMoved: TabMovedEvent; - declare var onDetached: TabDetachedEvent; - declare var onCreated: TabCreatedEvent; - declare var onActivated: TabActivatedEvent; + var onHighlighted: TabHighlightedEvent; + var onRemoved: TabRemovedEvent; + var onUpdated: TabUpdatedEvent; + var onAttached: TabAttachedEvent; + var onMoved: TabMovedEvent; + var onDetached: TabDetachedEvent; + var onCreated: TabCreatedEvent; + var onActivated: TabActivatedEvent; } //////////////////// @@ -1869,8 +1869,8 @@ declare module chrome.ttsEngine { addListener(callback: Function): void; } - declare var onSpeak: TtsEngineSpeakEvent; - declare var onStop: TtsEngineStopEvent; + var onSpeak: TtsEngineSpeakEvent; + var onStop: TtsEngineStopEvent; } //////////////////// @@ -2043,15 +2043,15 @@ declare module chrome.webNavigation { export function getFrame(details: GetFrameDetails, callback: (details?: GetFrameResultDetails) => void): void; export function getAllFrames(details: GetAllFrameDetails, callback: (details?: Object[]) => void): void; - declare var onReferenceFragmentUpdated: WebNavigationReferenceFragmentUpdatedEvent; - declare var onCompleted: WebNavigationCompletedEvent; - declare var onHistoryStateUpdated: WebNavigationHistoryStateUpdatedEvent; - declare var onCreatedNavigationTarget: WebNavigationCreatedNavigationTargetEvent; - declare var onTabReplaced: WebNavigationTabReplacedEvent; - declare var onBeforeNavigate: WebNavigationBeforeNavigateEvent; - declare var onCommitted: WebNavigationCommittedEvent; - declare var onDOMContentLoaded: WebNavigationDomContentLoadedEvent; - declare var onErrorOccurred: WebNavigationErrorOccurredEvent; + var onReferenceFragmentUpdated: WebNavigationReferenceFragmentUpdatedEvent; + var onCompleted: WebNavigationCompletedEvent; + var onHistoryStateUpdated: WebNavigationHistoryStateUpdatedEvent; + var onCreatedNavigationTarget: WebNavigationCreatedNavigationTargetEvent; + var onTabReplaced: WebNavigationTabReplacedEvent; + var onBeforeNavigate: WebNavigationBeforeNavigateEvent; + var onCommitted: WebNavigationCommittedEvent; + var onDOMContentLoaded: WebNavigationDomContentLoadedEvent; + var onErrorOccurred: WebNavigationErrorOccurredEvent; } //////////////////// @@ -2256,19 +2256,19 @@ declare module chrome.webRequest { addListener(callback: (details: OnBeforeRequestDetails) => void): void; } - declare var MAX_HANDLER_BEHAVIOR_CHANGED_CALLS_PER_10_MINUTES: number; + var MAX_HANDLER_BEHAVIOR_CHANGED_CALLS_PER_10_MINUTES: number; export function handlerBehaviorChanged(callback?: Function): void; - declare var onCompleted: WebRequestCompletedEvent; - declare var onHeadersReceived: WebRequestHeadersReceivedEvent; - declare var onBeforeRedirect: WebRequestBeforeRedirectEvent; - declare var onAuthRequired: WebRequestAuthRequiredEvent; - declare var onBeforeSendHeaders: WebRequestBeforeSendHeadersEvent; - declare var onErrorOccurred: WebRequestErrorOccurredEvent; - declare var onResponseStarted: WebRequestResponseStartedEvent; - declare var onSendHeaders: WebRequestSendHeadersEvent; - declare var onBeforeRequest: WebRequestBeforeRequestEvent; + var onCompleted: WebRequestCompletedEvent; + var onHeadersReceived: WebRequestHeadersReceivedEvent; + var onBeforeRedirect: WebRequestBeforeRedirectEvent; + var onAuthRequired: WebRequestAuthRequiredEvent; + var onBeforeSendHeaders: WebRequestBeforeSendHeadersEvent; + var onErrorOccurred: WebRequestErrorOccurredEvent; + var onResponseStarted: WebRequestResponseStartedEvent; + var onSendHeaders: WebRequestSendHeadersEvent; + var onBeforeRequest: WebRequestBeforeRequestEvent; } //////////////////// @@ -2334,8 +2334,8 @@ declare module chrome.windows { addListener(callback: (windowId: number) => void): void; } - declare var WINDOW_ID_CURRENT: number; - declare var WINDOW_ID_NONE: number; + var WINDOW_ID_CURRENT: number; + var WINDOW_ID_NONE: number; export function get(windowId: number, callback: (window: chrome.windows.Window) => void): void; export function get(windowId: number, getInfo: GetInfo, callback: (window: chrome.windows.Window) => void): void; @@ -2349,7 +2349,7 @@ declare module chrome.windows { export function getLastFocused(callback: (window: chrome.windows.Window) => void): void; export function getLastFocused(getInfo: GetInfo, callback: (window: chrome.windows.Window) => void): void; - declare var onRemoved: WindowRemovedEvent; - declare var onCreated: WindowCreatedEvent; - declare var onFocusChanged: WindowFocusChangedEvent; + var onRemoved: WindowRemovedEvent; + var onCreated: WindowCreatedEvent; + var onFocusChanged: WindowFocusChangedEvent; } diff --git a/filewriter/filewriter.d.ts b/filewriter/filewriter.d.ts index 2257ee9eb..f0d958afa 100644 --- a/filewriter/filewriter.d.ts +++ b/filewriter/filewriter.d.ts @@ -89,7 +89,7 @@ interface FileSaver extends EventTarget { onwriteend:Function; } -var FileSaver: { +declare var FileSaver: { /** * When the FileSaver constructor is called, the user agent must return a new FileSaver object with readyState set to INIT. * This constructor must be visible when the script's global object is either a Window object or an object implementing the WorkerUtils interface. diff --git a/restify/restify-test.ts b/restify/restify-tests.ts similarity index 100% rename from restify/restify-test.ts rename to restify/restify-tests.ts diff --git a/restify/restify.d.ts b/restify/restify.d.ts index 11752d7be..bf4239703 100644 --- a/restify/restify.d.ts +++ b/restify/restify.d.ts @@ -122,23 +122,23 @@ declare module "restify" { export function createStringClient(options?: ClientOptions): Client; export function createClient(options?: ClientOptions): HttpClient; - export class ConflictError { constructor(message?: any); }; - export class InvalidArguementError { constructor(message?: any); }; - export class RestError { constructor(message?: any); }; - export class BadDigestError { constructor(message: any); }; - export class BadMethodError { constructor(message: any); }; - export class BadRequestError { constructor(message: any); }; - export class InternalError { constructor(message: any); }; - export class InvalidContentError { constructor(message: any); }; - export class InvalidCredentialsError { constructor(message: any); }; - export class InvalidHeaderError { constructor(message: any); }; - export class InvalidVersionError { constructor(message: any); }; - export class MissingParameterError { constructor(message: any); }; - export class NotAuthorizedError { constructor(message: any); }; - export class RequestExpiredError { constructor(message: any); }; - export class RequestThrottledError { constructor(message: any); }; - export class ResourceNotFoundError { constructor(message: any); }; - export class WrongAcceptError { constructor(message: any); }; + export class ConflictError { constructor(message?: any); } + export class InvalidArguementError { constructor(message?: any); } + export class RestError { constructor(message?: any); } + export class BadDigestError { constructor(message: any); } + export class BadMethodError { constructor(message: any); } + export class BadRequestError { constructor(message: any); } + export class InternalError { constructor(message: any); } + export class InvalidContentError { constructor(message: any); } + export class InvalidCredentialsError { constructor(message: any); } + export class InvalidHeaderError { constructor(message: any); } + export class InvalidVersionError { constructor(message: any); } + export class MissingParameterError { constructor(message: any); } + export class NotAuthorizedError { constructor(message: any); } + export class RequestExpiredError { constructor(message: any); } + export class RequestThrottledError { constructor(message: any); } + export class ResourceNotFoundError { constructor(message: any); } + export class WrongAcceptError { constructor(message: any); } export function acceptParser(parser: any); export function authorizationParser(); From 54d7df39e7313d12c5299b6fe557417c5a514c2a Mon Sep 17 00:00:00 2001 From: vcastro Date: Mon, 24 Jun 2013 15:16:16 +0100 Subject: [PATCH 15/37] Updated the durandal router plugin: - Added definition for the guardRoute 'abstract' router function. --- durandal/durandal.d.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/durandal/durandal.d.ts b/durandal/durandal.d.ts index 1122cbbad..5f98beac1 100644 --- a/durandal/durandal.d.ts +++ b/durandal/durandal.d.ts @@ -480,6 +480,10 @@ declare module "durandal/plugins/router" { * After you've configured the router, you need to activate it. This is usually done in your shell. The activate function of the router returns a promise that resolves when the router is ready to start. To use the router, you should add an activate function to your shell and return the result from that. The application startup infrastructure of Durandal will detect your shell's activate function and call it at the appropriate time, waiting for it's promise to resolve. This allows Durandal to properly orchestrate the timing of composition and databinding along with animations and splash screen display. */ export var activate: (defaultRoute: string) => JQueryPromise; + /** + * Before any route is activated, the guardRoute funtion is called. You can plug into this function to add custom logic to allow, deny or redirect based on the requested route. To allow, return true. To deny, return false. To redirect, return a string with the hash or url. You may also return a promise for any of these values. + */ + export var guardRoute: (routeInfo: IRouteInfo, params: any, instance: any) => any } declare module "durandal/widget" { From cee8f3ebc245150eca07055350064d0b4ad1c2b3 Mon Sep 17 00:00:00 2001 From: Neil Stalker Date: Mon, 24 Jun 2013 17:26:24 +0100 Subject: [PATCH 16/37] Fix iScroll and angular definitions --- angularjs/angular-cookies.d.ts | 2 +- angularjs/angular-sanitize.d.ts | 2 +- iscroll/iscroll-lite.d.ts | 2 +- iscroll/iscroll.d.ts | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/angularjs/angular-cookies.d.ts b/angularjs/angular-cookies.d.ts index 29d1e5aa5..4dc2e038e 100644 --- a/angularjs/angular-cookies.d.ts +++ b/angularjs/angular-cookies.d.ts @@ -9,7 +9,7 @@ /////////////////////////////////////////////////////////////////////////////// // ngCookies module (angular-cookies.js) /////////////////////////////////////////////////////////////////////////////// -module ng.cookies { +declare module ng.cookies { /////////////////////////////////////////////////////////////////////////// // CookieService diff --git a/angularjs/angular-sanitize.d.ts b/angularjs/angular-sanitize.d.ts index 9b7e68194..56a3bc2ae 100644 --- a/angularjs/angular-sanitize.d.ts +++ b/angularjs/angular-sanitize.d.ts @@ -9,7 +9,7 @@ /////////////////////////////////////////////////////////////////////////////// // ngSanitize module (angular-sanitize.js) /////////////////////////////////////////////////////////////////////////////// -module ng.sanitize { +declare module ng.sanitize { /////////////////////////////////////////////////////////////////////////// // SanitizeService diff --git a/iscroll/iscroll-lite.d.ts b/iscroll/iscroll-lite.d.ts index 8964b8b74..f956ee8f3 100644 --- a/iscroll/iscroll-lite.d.ts +++ b/iscroll/iscroll-lite.d.ts @@ -32,7 +32,7 @@ interface iScrollOptions { onDestroy?: iScrollEvent; } -class iScroll { +declare class iScroll { constructor (element: string); constructor (element: string, options: iScrollOptions); diff --git a/iscroll/iscroll.d.ts b/iscroll/iscroll.d.ts index aee179cac..4990e18b7 100644 --- a/iscroll/iscroll.d.ts +++ b/iscroll/iscroll.d.ts @@ -57,7 +57,7 @@ interface iScrollOptions { onZoomEnd?: iScrollEvent; } -class iScroll { +declare class iScroll { constructor (element: string); constructor (element: string, options: iScrollOptions); From 484487ff17d820e408d3f9a7271625daa6d4e372 Mon Sep 17 00:00:00 2001 From: Neil Stalker Date: Mon, 24 Jun 2013 18:09:09 +0100 Subject: [PATCH 17/37] Fix rx.js definition --- rx.js/rx.js.d.ts | 142 +++++++++++++++++++++--------------------- rx.js/rx.js.html.d.ts | 2 + 2 files changed, 73 insertions(+), 71 deletions(-) diff --git a/rx.js/rx.js.d.ts b/rx.js/rx.js.d.ts index 144e1aca8..481603a7c 100644 --- a/rx.js/rx.js.d.ts +++ b/rx.js/rx.js.d.ts @@ -50,8 +50,8 @@ declare module Rx { contains(item: _IDisposable): bool; toArray(): _IDisposable[]; } - export module CompositeDisposable { - function new (...disposables: _IDisposable[]): ICompositeDisposable; + export interface CompositeDisposable { + (...disposables: _IDisposable[]): ICompositeDisposable; } // Main disposable class @@ -61,11 +61,11 @@ declare module Rx { dispose(): void; } - export module Disposable { - function new (action: () =>void ): IDisposable; + export interface Disposable { + (action: () =>void ): IDisposable; - function create(action: () =>void ): _IDisposable; - var empty: _IDisposable; + create(action: () =>void ): _IDisposable; + empty: _IDisposable; } // Single assignment @@ -78,8 +78,8 @@ declare module Rx { getDisposable(): _IDisposable; setDisposable(value: _IDisposable): void; } - export module SingleAssignmentDisposable { - function new (): ISingleAssignmentDisposable; + export interface SingleAssignmentDisposable { + (): ISingleAssignmentDisposable; } // Multiple assignment disposable @@ -92,8 +92,8 @@ declare module Rx { setDisposable(value: _IDisposable): void; disposable(value?: _IDisposable): _IDisposable; } - export module SerialDisposable { - function new (): ISerialDisposable; + export interface SerialDisposable { + (): ISerialDisposable; } interface IRefCountDisposable { @@ -105,8 +105,8 @@ declare module Rx { dispose(): void; getDisposable(): _IDisposable; } - export module RefCountDisposable { - function new (disposable: _IDisposable): IRefCountDisposable; + export interface RefCountDisposable { + (disposable: _IDisposable): IRefCountDisposable; } interface IScheduledItem { @@ -146,19 +146,19 @@ declare module Rx { scheduleRecursiveWithAbsolute(dueTime: number, action: (action: (dueTime: number) =>void ) =>void ): _IDisposable; scheduleRecursiveWithAbsoluteAndState(state: any, dueTime: number, action: (state: any, action: (state: any, dueTime: number) =>void ) =>void ): _IDisposable; } - export module Scheduler { - function new (now: () =>number, + export interface Scheduler { + (now: () =>number, schedule: (state: any, action: (scheduler: IScheduler, state: any) =>_IDisposable) => _IDisposable, scheduleRelative: (state: any, dueTime: number, action: (scheduler: IScheduler, state: any) =>_IDisposable) =>_IDisposable, scheduleAbsolute: (state: any, dueTime: number, action: (scheduler: IScheduler, state: any) =>_IDisposable) =>_IDisposable ): IScheduler; - function now(): number; - function normalize(timeSpan: number): number; + now(): number; + normalize(timeSpan: number): number; - var immediate: IScheduler; - var currentThread: ICurrentScheduler;//IScheduler; - var timeout: IScheduler; + immediate: IScheduler; + currentThread: ICurrentScheduler;//IScheduler; + timeout: IScheduler; } // Current Thread IScheduler @@ -207,13 +207,13 @@ declare module Rx { value?: any; exception?: any; } - export module Notification { + export interface Notification { //abstract //function new (): INotification; - function createOnNext(value: any): INotification;//ON - function createOnError(exception): INotification;//OE - function createOnCompleted(): INotification;//OC + createOnNext(value: any): INotification;//ON + createOnError(exception): INotification;//OE + createOnCompleted(): INotification;//OC } export module Internals { @@ -223,10 +223,10 @@ declare module Rx { getCurrent(): any; dispose(): void; } - export module Enumerator { - function new (moveNext: () =>bool, getCurrent: () => any, dispose: () =>void ): IEnumerator; + export interface Enumerator { + (moveNext: () =>bool, getCurrent: () => any, dispose: () =>void ): IEnumerator; - function create(moveNext: () =>bool, getCurrent: () =>any, dispose?: () =>void ): IEnumerator; + create(moveNext: () =>bool, getCurrent: () =>any, dispose?: () =>void ): IEnumerator; } // Enumerable @@ -236,12 +236,12 @@ declare module Rx { concat(): IObservable; catchException(): IObservable; } - export module Enumerable { - function new (getEnumerator: () =>IEnumerator): IEnumerable; + export interface Enumerable { + (getEnumerator: () =>IEnumerator): IEnumerable; - function repeat(value: any, repeatCount?: number): IEnumerable; - function forEach(source: any[], selector?: (element: any, index: number) =>any): IEnumerable; - function forEach(source: { length: number;[index: number]: any; }, selector?: (element: any, index: number) =>any): IEnumerable; + repeat(value: any, repeatCount?: number): IEnumerable; + forEach(source: any[], selector?: (element: any, index: number) =>any): IEnumerable; + forEach(source: { length: number;[index: number]: any; }, selector?: (element: any, index: number) =>any): IEnumerable; } } @@ -285,8 +285,8 @@ declare module Rx { _onError: (exception: any) =>void; _onCompleted: () =>void; } - export module AnonymousObserver { - function new (onNext: (value: any) =>void , onError: (exception: any) =>void , onCompleted: () =>void ): IAnonymousObserver; + export interface AnonymousObserver { + (onNext: (value: any) =>void , onError: (exception: any) =>void , onCompleted: () =>void ): IAnonymousObserver; } interface ICheckedObserver extends IObserver { @@ -306,8 +306,8 @@ declare module Rx { ensureActive(): void; } - export module ScheduledObserver { - function new (scheduler: IScheduler, observer: IObserver): IScheduledObserver; + export interface ScheduledObserver { + (scheduler: IScheduler, observer: IObserver): IScheduledObserver; } } @@ -379,7 +379,7 @@ declare module Rx { takeWhile(predicate: (value: any, index?: number) =>bool): IObservable; where(predicate: (value: any, index?: number) => bool): IObservable; - // time + // time delay(dueTime: number, scheduler?: IScheduler): IObservable; throttle(dueTime: number, scheduler?: IScheduler): IObservable; windowWithTime(dueTime: number, timeShiftOrScheduler?: any, scheduler?: IScheduler): IObservable; @@ -389,41 +389,41 @@ declare module Rx { timeout(dueTime: number, other?: IObservable, scheduler?: IScheduler): IObservable; delaySubscription(dueTime: number, scheduler?: IScheduler): IObservable; } - export module Observable { - function new (subscribe: (observer: IObserver) =>_IDisposable): IObservable; + export interface Observable { + (subscribe: (observer: IObserver) =>_IDisposable): IObservable; - function start(func: () =>any, scheduler?: IScheduler, context?: any): IObservable; - function toAsync(func: Function, scheduler?: IScheduler, context?: any): (...arguments: any[]) => IObservable; - function create(subscribe: (Observer) =>() =>void ): IObservable; - function createWithDisposable(subscribe: (Observer) =>_IDisposable): IObservable; - function defer(observableFactory: () =>IObservable): IObservable; - function empty(scheduler?: IScheduler): IObservable; - function fromArray(array: any[], scheduler?: IScheduler): IObservable; - function fromArray(array: { length: number;[index: number]: any; }, scheduler?: IScheduler): IObservable; - function generate(initialState: any, condition: (state: any) =>bool, iterate: (state: any) =>any, resultSelector: (state: any) =>any, scheduler?: IScheduler): IObservable; - function never(): IObservable; - function range(start: number, count: number, scheduler?: IScheduler): IObservable; - function repeat(value: any, repeatCount?: number, scheduler?: IScheduler): IObservable; - function returnValue(value: any, scheduler?: IScheduler): IObservable; - function throwException(exception: any, scheduler?: IScheduler): IObservable; - function using(resourceFactory: () =>any, observableFactory: (resource: any) =>IObservable): IObservable; - function amb(...sources: IObservable[]): IObservable; - function catchException(sources: IObservable[]): IObservable; - function catchException(...sources: IObservable[]): IObservable; - function concat(...sources: IObservable[]): IObservable; - function concat(sources: IObservable[]): IObservable; - function merge(...sources: IObservable[]): IObservable; - function merge(sources: IObservable[]): IObservable; - function merge(scheduler: IScheduler, ...sources: IObservable[]): IObservable; - function merge(scheduler: IScheduler, sources: IObservable[]): IObservable; - function onErrorResumeNext(...sources: IObservable[]): IObservable; - function onErrorResumeNext(sources: IObservable[]): IObservable; + start(func: () =>any, scheduler?: IScheduler, context?: any): IObservable; + toAsync(func: Function, scheduler?: IScheduler, context?: any): (...arguments: any[]) => IObservable; + create(subscribe: (Observer) =>() =>void ): IObservable; + createWithDisposable(subscribe: (Observer) =>_IDisposable): IObservable; + defer(observableFactory: () =>IObservable): IObservable; + empty(scheduler?: IScheduler): IObservable; + fromArray(array: any[], scheduler?: IScheduler): IObservable; + fromArray(array: { length: number;[index: number]: any; }, scheduler?: IScheduler): IObservable; + generate(initialState: any, condition: (state: any) =>bool, iterate: (state: any) =>any, resultSelector: (state: any) =>any, scheduler?: IScheduler): IObservable; + never(): IObservable; + range(start: number, count: number, scheduler?: IScheduler): IObservable; + repeat(value: any, repeatCount?: number, scheduler?: IScheduler): IObservable; + returnValue(value: any, scheduler?: IScheduler): IObservable; + throwException(exception: any, scheduler?: IScheduler): IObservable; + using(resourceFactory: () =>any, observableFactory: (resource: any) =>IObservable): IObservable; + amb(...sources: IObservable[]): IObservable; + catchException(sources: IObservable[]): IObservable; + catchException(...sources: IObservable[]): IObservable; + concat(...sources: IObservable[]): IObservable; + concat(sources: IObservable[]): IObservable; + merge(...sources: IObservable[]): IObservable; + merge(sources: IObservable[]): IObservable; + merge(scheduler: IScheduler, ...sources: IObservable[]): IObservable; + merge(scheduler: IScheduler, sources: IObservable[]): IObservable; + onErrorResumeNext(...sources: IObservable[]): IObservable; + onErrorResumeNext(sources: IObservable[]): IObservable; } export module Internals { interface IAnonymousObservable extends IObservable { } - export module AnonymousObservable { - function new (subscribe: (observer: IObserver) =>_IDisposable): IAnonymousObservable; + export interface AnonymousObservable { + (subscribe: (observer: IObserver) =>_IDisposable): IAnonymousObservable; } } @@ -439,10 +439,10 @@ declare module Rx { dispose(): void; } - export module Subject { - function new (): ISubject; + export interface Subject { + (): ISubject; - function create(observer: IObserver, observable: IObservable): ISubject; + create(observer: IObserver, observable: IObservable): ISubject; } interface IAsyncSubject extends IObservable, IObserver { @@ -454,8 +454,8 @@ declare module Rx { dispose(): void; } - export module AsyncSubject { - function new (): IAsyncSubject; + export interface AsyncSubject { + (): IAsyncSubject; } interface IAnonymousSubject extends IObservable { diff --git a/rx.js/rx.js.html.d.ts b/rx.js/rx.js.html.d.ts index 384ebad1a..4a9eb833f 100644 --- a/rx.js/rx.js.html.d.ts +++ b/rx.js/rx.js.html.d.ts @@ -1,3 +1,5 @@ +/// + declare module Rx { export module Observable { function fromEvent(element: HTMLElement, eventName: string) : IObservable; From d4c6dd3d4536f21aaad83f5f900dcfa2afee0257 Mon Sep 17 00:00:00 2001 From: Neil Stalker Date: Mon, 24 Jun 2013 18:40:03 +0100 Subject: [PATCH 18/37] fix webrtc definitions --- webrtc/MediaStream.d.ts | 20 ++++++++++---------- webrtc/RTCPeerConnection.d.ts | 28 ++++++++++++++-------------- 2 files changed, 24 insertions(+), 24 deletions(-) diff --git a/webrtc/MediaStream.d.ts b/webrtc/MediaStream.d.ts index 734c27031..02d5c1af8 100644 --- a/webrtc/MediaStream.d.ts +++ b/webrtc/MediaStream.d.ts @@ -110,7 +110,7 @@ interface MediaStreamTrack { onunmute: (event: Event) => void; onended: (event: Event) => void; } -var MediaStramTrack: { +declare var MediaStramTrack: { prototype: MediaStreamTrack; new (): MediaStreamTrack; LIVE: number; // = 0; @@ -118,19 +118,19 @@ var MediaStramTrack: { ENDED: number; // = 2; } -interface URL { - createObjectURL(stream: MediaStream): string; -} -var URL: { - prototype: MediaStreamTrack; - new (): URL; +interface streamURL extends URL { createObjectURL(stream: MediaStream): string; } +//declare var URL: { +// prototype: MediaStreamTrack; +// new (): URL; +// createObjectURL(stream: MediaStream): string; +//} -interface WebkitURL extends URL { +interface WebkitURL extends streamURL { } -var webkitURL: { +declare var webkitURL: { prototype: WebkitURL; - new (): URL; + new (): streamURL; createObjectURL(stream: MediaStream): string; } \ No newline at end of file diff --git a/webrtc/RTCPeerConnection.d.ts b/webrtc/RTCPeerConnection.d.ts index d1bc47fcf..e1131b281 100644 --- a/webrtc/RTCPeerConnection.d.ts +++ b/webrtc/RTCPeerConnection.d.ts @@ -9,7 +9,7 @@ interface RTCConfiguration { iceServers: RTCIceServer[]; } -var RTCConfiguration: { +declare var RTCConfiguration: { prototype: RTCConfiguration; new (): RTCConfiguration; } @@ -18,21 +18,21 @@ interface RTCIceServer { url: string; credential?: string; } -var RTCIceServer: { +declare var RTCIceServer: { prototype: RTCIceServer; new (): RTCIceServer; } interface webkitRTCPeerConnection extends RTCPeerConnection { } -var webkitRTCPeerConnection: { +declare var webkitRTCPeerConnection: { prototype: webkitRTCPeerConnection; new (settings: RTCPeerConnectionConfig, constraints?:MediaConstraints): webkitRTCPeerConnection; } interface IceState { } -var IceState: { +declare var IceState: { prototype: IceState; new (): IceState; } @@ -51,7 +51,7 @@ interface RTCSessionDescription { type?: RTCSdpType; sdp?: string; } -var RTCSessionDescription: { +declare var RTCSessionDescription: { prototype: RTCSessionDescription; new (descriptionInitDict?: RTCSessionDescriptionInit): RTCSessionDescription; } @@ -60,7 +60,7 @@ interface RTCSessionDescriptionInit { type: RTCSdpType; sdp: string; } -var RTCSessionDescriptionInit: { +declare var RTCSessionDescriptionInit: { prototype: RTCSessionDescriptionInit; new (): RTCSessionDescriptionInit; } @@ -75,13 +75,13 @@ interface RTCDataChannelInit { reliable: bool; } -enum RTCSdpType { +declare enum RTCSdpType { offer, pranswer, answer } -enum RTCDataChannelState { +declare enum RTCDataChannelState { connecting, open, closing, @@ -112,7 +112,7 @@ interface RTCDataChannelEvent extends Event { constructor (eventInitDict: RTCDataChannelEventInit); channel: RTCDataChannel; } -var RTCDataChannelEvent: { +declare var RTCDataChannelEvent: { prototype: RTCDataChannelEvent; new (eventInitDict: RTCDataChannelEventInit); } @@ -186,7 +186,7 @@ interface RTCPeerConnection { onicecandidate: (event: RTCIceCandidateEvent)=> void; onidentityresult: (event: Event)=> void; } -var RTCPeerConnection: { +declare var RTCPeerConnection: { prototype: RTCPeerConnection; new (configuration: RTCConfiguration, constraints?: MediaConstraints): RTCPeerConnection; } @@ -196,7 +196,7 @@ interface RTCIceCandidate { sdpMid?: string; sdpMLineIndex?: number; } -var RTCIceCandidate: { +declare var RTCIceCandidate: { prototype: RTCIceCandidate; new (candidateInitDict?: RTCIceCandidate); } @@ -206,7 +206,7 @@ interface RTCIceCandidateInit { sdpMid: string; sdpMLineIndex: number; } -var RTCIceCandidateInit:{ +declare var RTCIceCandidateInit:{ prototype: RTCIceCandidateInit; new (): RTCIceCandidateInit; } @@ -215,7 +215,7 @@ interface PeerConnectionIceEvent { peer: RTCPeerConnection; candidate: RTCIceCandidate; } -var PeerConnectionIceEvent: { +declare var PeerConnectionIceEvent: { prototype: PeerConnectionIceEvent; new (): PeerConnectionIceEvent; } @@ -223,7 +223,7 @@ var PeerConnectionIceEvent: { interface RTCPeerConnectionConfig { iceServers: RTCIceServer[]; } -var RTCPeerConnectionConfig: { +declare var RTCPeerConnectionConfig: { prototype: RTCPeerConnectionConfig; new (): RTCPeerConnectionConfig; } From d4e621d9ad5be9fdf56c7590239d59e887c0bf5c Mon Sep 17 00:00:00 2001 From: Neil Stalker Date: Mon, 24 Jun 2013 19:20:59 +0100 Subject: [PATCH 19/37] fix nvnc, zeromq, icheck and unity-webapi definitions --- icheck/icheck-tests.ts | 34 ++++++++++++++++++++++++++++++++++ icheck/icheck.d.ts | 6 +++--- noVNC/noVNC.d.ts | 2 +- node_zeromq/zmq-tests.ts | 3 +-- node_zeromq/zmq.d.ts | 2 +- unity-webapi/unity-webapi.d.ts | 2 +- 6 files changed, 41 insertions(+), 8 deletions(-) create mode 100644 icheck/icheck-tests.ts diff --git a/icheck/icheck-tests.ts b/icheck/icheck-tests.ts new file mode 100644 index 000000000..7998d8ed6 --- /dev/null +++ b/icheck/icheck-tests.ts @@ -0,0 +1,34 @@ +/// +/// + +$('input').iCheck({ + labelHover: false, + cursor: true +}); + +// customize all inputs (will search for checkboxes and radio buttons) +$('input').iCheck(); + +// handle inputs only inside $('.block') +$('.block input').iCheck(); + +// handle only checkboxes inside $('.test') +$('.test input').iCheck({ + handle: 'checkbox' +}); + +// handle .vote class elements (will search inside the element, if it's not an input) +$('.vote').iCheck(); + +// you can also change options after inputs are customized +$('input.some').iCheck({ + // different options +}); + +$('input').on('ifChecked', function (event) { + alert(event.type + ' callback'); +}); + +$('input').iCheck('check', function () { + alert('Well done, Sir'); +}); \ No newline at end of file diff --git a/icheck/icheck.d.ts b/icheck/icheck.d.ts index 2abdd10ad..e8e2b3126 100644 --- a/icheck/icheck.d.ts +++ b/icheck/icheck.d.ts @@ -3,7 +3,7 @@ // Definitions by: Dániel Tar https://github.com/qcz // Definitions: https://github.com/borisyankov/DefinitelyTyped -declare interface ICheckOptions { +interface ICheckOptions { /** * 'checkbox' or 'radio' to style only checkboxes or radio buttons, both by default */ @@ -106,7 +106,7 @@ declare interface ICheckOptions { insert?: string; } -declare interface JQuery { +interface JQuery { iCheck(options?: ICheckOptions): JQuery; - iCheck(command: string): void; + iCheck(command: string, callback?: () => void): void; } \ No newline at end of file diff --git a/noVNC/noVNC.d.ts b/noVNC/noVNC.d.ts index ff6f690ec..6352aed3d 100644 --- a/noVNC/noVNC.d.ts +++ b/noVNC/noVNC.d.ts @@ -87,7 +87,7 @@ interface NvRFBDefaults { onFBResize?: (rfb: RFB, width: number, height: number) => void; } -class RFB { +declare class RFB { constructor(defaults); set_local_cursor(cursor): void; get_display(): Display; diff --git a/node_zeromq/zmq-tests.ts b/node_zeromq/zmq-tests.ts index 26ffd2a20..a71bbaa10 100644 --- a/node_zeromq/zmq-tests.ts +++ b/node_zeromq/zmq-tests.ts @@ -1,7 +1,6 @@ /// -import zeromq = module('zmq'); -var zmq: zeromq; +import zmq = module('zmq'); function test1() { var sock = zmq.socket('push'); diff --git a/node_zeromq/zmq.d.ts b/node_zeromq/zmq.d.ts index 4297eded6..8e9224d91 100644 --- a/node_zeromq/zmq.d.ts +++ b/node_zeromq/zmq.d.ts @@ -3,7 +3,7 @@ // Definitions by: Dave McKeown // Definitions: https://github.com/borisyankov/DefinitelyTyped -declare interface EventEmitter {}; +interface EventEmitter {} declare module 'zmq' { diff --git a/unity-webapi/unity-webapi.d.ts b/unity-webapi/unity-webapi.d.ts index 419504971..451ddab6b 100644 --- a/unity-webapi/unity-webapi.d.ts +++ b/unity-webapi/unity-webapi.d.ts @@ -9,7 +9,7 @@ declare class UnitySettings { public onInit:Function; } -enum UnityPlaybackState { +declare enum UnityPlaybackState { Playing, Paused } From 5ac4ffc66ae0411be33a88db8066e377bf1703ad Mon Sep 17 00:00:00 2001 From: Natan Vivo Date: Mon, 24 Jun 2013 16:28:12 -0300 Subject: [PATCH 20/37] Allow underscore to be used as ambient declaration and external module. --- underscore/underscore.d.ts | 424 ++++++++++++++++++------------------- 1 file changed, 212 insertions(+), 212 deletions(-) diff --git a/underscore/underscore.d.ts b/underscore/underscore.d.ts index 88dc84584..414c7653b 100644 --- a/underscore/underscore.d.ts +++ b/underscore/underscore.d.ts @@ -3,226 +3,226 @@ // Definitions by: Boris Yankov // Definitions: https://github.com/borisyankov/DefinitelyTyped +declare function _(value): any; -interface UnderscoreWrappedObject { - value(): any; - filter(arg?): any; -} +declare module _ { -interface TemplateSettings { - evaluate?: RegExp; - interpolate?: RegExp; - escape?: RegExp; -} + interface UnderscoreWrappedObject { + value(): any; + filter(arg?): any; + } -interface ListIterator { - (value: T, index: number, list?: List): TResult; -} + interface TemplateSettings { + evaluate?: RegExp; + interpolate?: RegExp; + escape?: RegExp; + } -interface ObjectIterator { - (element: T, key: string, list?: any): TResult; -} + interface ListIterator { + (value: T, index: number, list?: List): TResult; + } -interface Collection { } + interface ObjectIterator { + (element: T, key: string, list?: any): TResult; + } -// Common interface between Arrays and jQuery objects -interface List extends Collection { - [index: number]: T; - length: number; -} + interface Collection { } -interface Dictionary extends Collection { - [index: string]: T; + // Common interface between Arrays and jQuery objects + interface List extends Collection { + [index: number]: T; + length: number; + } + + interface Dictionary extends Collection { + [index: string]: T; + } + + /**** + Collections + *****/ + export function each(list: List, iterator: ListIterator, context?: any): void; + export function each(object: Dictionary, iterator: ObjectIterator, context?: any): void; + export function forEach(list: List, iterator: ListIterator, context?: any): void; + export function forEach(object: Dictionary, iterator: ObjectIterator, context?: any): void; + + export function map(list: List, iterator: ListIterator, context?: any): TResult[]; + export function map(object: Dictionary, iterator: ObjectIterator, context?: any): TResult[]; + export function collect(list: List, iterator: ListIterator, context?: any): TResult[]; + export function collect(object: Dictionary, iterator: ObjectIterator, context?: any): TResult[]; + + export function reduce(list: Collection, iterator: (prev: TResult, curr: T) => TResult, memo: TResult, context?: any): TResult; + export function inject(list: Collection, iterator: (prev: TResult, curr: T) => TResult, memo: TResult, context?: any): TResult; + + export function reduceRight(list: Collection, iterator: (prev: TResult, curr: T) => TResult, memo: TResult, context?: any): TResult; + export function foldr(list: Collection, iterator: (prev: TResult, curr: T) => TResult, memo: TResult, context?: any): TResult; + + export function find(list: Collection, iterator: (x: T) => boolean, context?: any): T; + export function detect(list: Collection, iterator: (x: T) => boolean, context?: any): T; + + export function filter(list: Collection, iterator: (x: T) => boolean, context?: any): T[]; + export function select(list: Collection, iterator: (x: T) => boolean, context?: any): T[]; + + export function where(list: Collection, properties: any): T[]; + + export function reject(list: Collection, iterator: (x: T) => boolean, context?: any): T[]; + + export function all(list: Collection, iterator: (x: T) => boolean, context?: any): boolean; + export function every(list: Collection, iterator: (x: T) => boolean, context?: any): boolean; + + export function any(list: Collection, iterator?: (x: T) => boolean, context?: any): boolean; + export function some(list: Collection, iterator?: (x: T) => boolean, context?: any): boolean; + + export function contains(list: Collection, value: T): boolean; + export function include(list: Collection, value: T): boolean; + + export function invoke(list: Collection, methodName: string, ...arguments: any[]): any; + + export function pluck(list: Collection, propertyName: string): any[]; + + export function max(list: Collection, iterator?: (x: T) => any, context?: any): T; + + export function min(list: Collection, iterator?: (x: T) => any, context?: any): T; + + export function sortBy(list: List, iterator?: (x: T) => any, context?: any): T[]; + export function sortBy(list: any, iterator?: (x: T) => any, context?: any): T[]; + export function sortBy(list: List, iterator: string, context?: any): T[]; + export function sortBy(list: any, iterator: string, context?: any): T[]; + + export function groupBy(list: List, iterator?: (x: T) => any, context?: any): Dictionary>; + export function groupBy(list: any, iterator?: (x: T) => any, context?: any): Dictionary>; + export function groupBy(list: List, iterator: string, context?: any): Dictionary>; + export function groupBy(list: any, iterator: string, context?: any): Dictionary>; + + export function countBy(list: List, iterator?: (x: T) => any, context?: any): Dictionary>; + export function countBy(list: any, iterator?: (x: T) => any, context?: any): Dictionary>; + export function countBy(list: List, iterator: string, context?: any): Dictionary>; + export function countBy(list: any, iterator: string, context?: any): Dictionary>; + + export function shuffle(list: Collection): T[]; + + export function toArray(list: Collection): T[]; + + export function size(list: Collection): number; + + /**** + Arrays + *****/ + export function first(array: List): T; + export function first(array: List, n: number): T[]; + export function head(array: List): T; + export function head(array: List, n: number): T[]; + export function take(array: List): T; + export function take(array: List, n: number): T[]; + + export function initial(array: List, n?: number): T[]; + + export function last(array: List): T; + export function last(array: List, n: number): T[]; + + export function rest(array: List, n?: number): T[]; + export function tail(array: List, n?: number): T[]; + export function drop(array: List, n?: number): T[]; + + export function compact(array: List): T[]; + + export function flatten(array: any[], shallow?: boolean): any[]; + + export function without(array: List, ...values: T[]): T[]; + + export function union(...arrays: List[]): T[]; + + export function intersection(...arrays: List[]): T[]; + + export function difference(array: List, ...others: List[]): T[]; + + export function uniq(array: List, isSorted?: boolean, iterator?: (x: T) => any): T[]; + export function unique(array: List, isSorted?: boolean, iterator?: (x: T) => any): T[]; + + export function zip(...arrays: any[]): any[]; + + export function object(list: any[], values?: any): any; + + export function indexOf(array: List, value: T, isSorted?: boolean): number; + export function indexOf(array: List, value: T, startFrom: number): number; + + export function lastIndexOf(array: List, value: T, fromIndex?: number): number; + + export function sortedIndex(list: List, value: T, iterator?: (x: T) => any, context?: any): number; + + export function range(stop: number): any[]; + export function range(start: number, stop: number, step?: number): any[]; + + /**** + Functions + *****/ + export function bind(func: (...as: any[]) => any, context: any, ...arguments: any[]): () => any; + export function bindAll(object: any, ...methodNames: string[]): any; + export function memoize(func: any, hashFunction?: any): any; + export function defer(func: () => any); + export function delay(func: any, wait: number, ...arguments: any[]): any; + export function delay(func: any, ...arguments: any[]): any; + export function throttle(func: any, wait: number): any; + export function debounce(func: any, wait: number, immediate?: boolean): any; + export function once(func: any): any; + export function after(count: number, func: any): any; + export function wrap(func: (...as: any[]) => any, wrapper: any): () => any; + export function compose(...functions: any[]): any; + + /**** + Objects + *****/ + export function keys(object: any): string[]; + export function values(object: Dictionary): T[]; + export function pairs(object: any): any[]; + export function invert(object: any): any; + export function functions(object: any): string[]; + export function methods(object: any): string[]; + export function extend(destination: any, ...sources: any[]): any; + export function pick(object: any, ...keys: string[]): any; + export function omit(object: any, ...keys: string[]): any; + export function defaults(object: any, ...defaults: any[]): any; + export function clone(object: any): any; + export function tap(object: any, interceptor: (...as: any[]) => any): any; + export function has(object: any, key: string): boolean; + export function isEqual(object: any, other: any): boolean; + export function isEmpty(object: any): boolean; + export function isElement(object: any): boolean; + export function isArray(object: any): boolean; + export function isObject(value: any): boolean; + export function isArguments(object: any): boolean; + export function isFunction(object: any): boolean; + export function isString(object: any): boolean; + export function isNumber(object: any): boolean; + export function isFinite(object: any): boolean; + export function isBoolean(object: any): boolean; + export function isDate(object: any): boolean; + export function isRegExp(object: any): boolean; + export function isNaN(object: any): boolean; + export function isNull(object: any): boolean; + export function isUndefined(value: any): boolean; + + /**** + Utility + *****/ + export function noConflict(): any; + export function identity(value: any): any; + export function times(n: number, iterator: (index: number) => void , context?: any): void; + export function random(min: number, max: number): number; + export function mixin(object: any): void; + export function uniqueId(prefix: string): string; + export function uniqueId(): number; + export function escape(str: string): string; + export function result(object: any, property: string): any; + export var templateSettings: TemplateSettings; + export function template(templateString: string, data?: any, settings?: any): (...data: any[]) => string; + + /**** + Chaining + *****/ + export function chain(object: any): UnderscoreWrappedObject; } declare module "underscore" { - function underscore(arg?: any): any; - - module underscore { - /**** - Collections - *****/ - export function each(list: List, iterator: ListIterator, context?: any): void; - export function each(object: Dictionary, iterator: ObjectIterator, context?: any): void; - export function forEach(list: List, iterator: ListIterator, context?: any): void; - export function forEach(object: Dictionary, iterator: ObjectIterator, context?: any): void; - - export function map(list: List, iterator: ListIterator, context?: any): TResult[]; - export function map(object: Dictionary, iterator: ObjectIterator, context?: any): TResult[]; - export function collect(list: List, iterator: ListIterator, context?: any): TResult[]; - export function collect(object: Dictionary, iterator: ObjectIterator, context?: any): TResult[]; - - export function reduce(list: Collection, iterator: (prev: TResult, curr: T) => TResult, memo: TResult, context?: any): TResult; - export function inject(list: Collection, iterator: (prev: TResult, curr: T) => TResult, memo: TResult, context?: any): TResult; - - export function reduceRight(list: Collection, iterator: (prev: TResult, curr: T) => TResult, memo: TResult, context?: any): TResult; - export function foldr(list: Collection, iterator: (prev: TResult, curr: T) => TResult, memo: TResult, context?: any): TResult; - - export function find(list: Collection, iterator: (x: T) => boolean, context?: any): T; - export function detect(list: Collection, iterator: (x: T) => boolean, context?: any): T; - - export function filter(list: Collection, iterator: (x: T) => boolean, context?: any): T[]; - export function select(list: Collection, iterator: (x: T) => boolean, context?: any): T[]; - - export function where(list: Collection, properties: any): T[]; - - export function reject(list: Collection, iterator: (x: T) => boolean, context?: any): T[]; - - export function all(list: Collection, iterator: (x: T) => boolean, context?: any): boolean; - export function every(list: Collection, iterator: (x: T) => boolean, context?: any): boolean; - - export function any(list: Collection, iterator?: (x: T) => boolean, context?: any): boolean; - export function some(list: Collection, iterator?: (x: T) => boolean, context?: any): boolean; - - export function contains(list: Collection, value: T): boolean; - export function include(list: Collection, value: T): boolean; - - export function invoke(list: Collection, methodName: string, ...arguments: any[]): any; - - export function pluck(list: Collection, propertyName: string): any[]; - - export function max(list: Collection, iterator?: (x: T) => any, context?: any): T; - - export function min(list: Collection, iterator?: (x: T) => any, context?: any): T; - - export function sortBy(list: List, iterator?: (x: T) => any, context?: any): T[]; - export function sortBy(list: any, iterator?: (x: T) => any, context?: any): T[]; - export function sortBy(list: List, iterator: string, context?: any): T[]; - export function sortBy(list: any, iterator: string, context?: any): T[]; - - export function groupBy(list: List, iterator?: (x: T) => any, context?: any): Dictionary>; - export function groupBy(list: any, iterator?: (x: T) => any, context?: any): Dictionary>; - export function groupBy(list: List, iterator: string, context?: any): Dictionary>; - export function groupBy(list: any, iterator: string, context?: any): Dictionary>; - - export function countBy(list: List, iterator?: (x: T) => any, context?: any): Dictionary>; - export function countBy(list: any, iterator?: (x: T) => any, context?: any): Dictionary>; - export function countBy(list: List, iterator: string, context?: any): Dictionary>; - export function countBy(list: any, iterator: string, context?: any): Dictionary>; - - export function shuffle(list: Collection): T[]; - - export function toArray(list: Collection): T[]; - - export function size(list: Collection): number; - - /**** - Arrays - *****/ - export function first(array: List): T; - export function first(array: List, n: number): T[]; - export function head(array: List): T; - export function head(array: List, n: number): T[]; - export function take(array: List): T; - export function take(array: List, n: number): T[]; - - export function initial(array: List, n?: number): T[]; - - export function last(array: List): T; - export function last(array: List, n: number): T[]; - - export function rest(array: List, n?: number): T[]; - export function tail(array: List, n?: number): T[]; - export function drop(array: List, n?: number): T[]; - - export function compact(array: List): T[]; - - export function flatten(array: any[], shallow?: boolean): any[]; - - export function without(array: List, ...values: T[]): T[]; - - export function union(...arrays: List[]): T[]; - - export function intersection(...arrays: List[]): T[]; - - export function difference(array: List, ...others: List[]): T[]; - - export function uniq(array: List, isSorted?: boolean, iterator?: (x: T) => any): T[]; - export function unique(array: List, isSorted?: boolean, iterator?: (x: T) => any): T[]; - - export function zip(...arrays: any[]): any[]; - - export function object(list: any[], values?: any): any; - - export function indexOf(array: List, value: T, isSorted?: boolean): number; - export function indexOf(array: List, value: T, startFrom: number): number; - - export function lastIndexOf(array: List, value: T, fromIndex?: number): number; - - export function sortedIndex(list: List, value: T, iterator?: (x: T) => any, context?: any): number; - - export function range(stop: number): any[]; - export function range(start: number, stop: number, step?: number): any[]; - - /**** - Functions - *****/ - export function bind(func: (...as: any[]) => any, context: any, ...arguments: any[]): () => any; - export function bindAll(object: any, ...methodNames: string[]): any; - export function memoize(func: any, hashFunction?: any): any; - export function defer(func: () => any); - export function delay(func: any, wait: number, ...arguments: any[]): any; - export function delay(func: any, ...arguments: any[]): any; - export function throttle(func: any, wait: number): any; - export function debounce(func: any, wait: number, immediate?: boolean): any; - export function once(func: any): any; - export function after(count: number, func: any): any; - export function wrap(func: (...as: any[]) => any, wrapper: any): () => any; - export function compose(...functions: any[]): any; - - /**** - Objects - *****/ - export function keys(object: any): string[]; - export function values(object: Dictionary): T[]; - export function pairs(object: any): any[]; - export function invert(object: any): any; - export function functions(object: any): string[]; - export function methods(object: any): string[]; - export function extend(destination: any, ...sources: any[]): any; - export function pick(object: any, ...keys: string[]): any; - export function omit(object: any, ...keys: string[]): any; - export function defaults(object: any, ...defaults: any[]): any; - export function clone(object: any): any; - export function tap(object: any, interceptor: (...as: any[]) => any): any; - export function has(object: any, key: string): boolean; - export function isEqual(object: any, other: any): boolean; - export function isEmpty(object: any): boolean; - export function isElement(object: any): boolean; - export function isArray(object: any): boolean; - export function isObject(value: any): boolean; - export function isArguments(object: any): boolean; - export function isFunction(object: any): boolean; - export function isString(object: any): boolean; - export function isNumber(object: any): boolean; - export function isFinite(object: any): boolean; - export function isBoolean(object: any): boolean; - export function isDate(object: any): boolean; - export function isRegExp(object: any): boolean; - export function isNaN(object: any): boolean; - export function isNull(object: any): boolean; - export function isUndefined(value: any): boolean; - - /**** - Utility - *****/ - export function noConflict(): any; - export function identity(value: any): any; - export function times(n: number, iterator: (index: number) => void , context?: any): void; - export function random(min: number, max: number): number; - export function mixin(object: any): void; - export function uniqueId(prefix: string): string; - export function uniqueId(): number; - export function escape(str: string): string; - export function result(object: any, property: string): any; - export var templateSettings: TemplateSettings; - export function template(templateString: string, data?: any, settings?: any): (...data: any[]) => string; - - /**** - Chaining - *****/ - export function chain(object: any): UnderscoreWrappedObject; - } - - export = underscore; + export = _; } \ No newline at end of file From 126bf6115761736e20bc522ddb7d8d94e3f472b1 Mon Sep 17 00:00:00 2001 From: Neil Stalker Date: Mon, 24 Jun 2013 21:03:34 +0100 Subject: [PATCH 21/37] Update test runner to process files alphabetically --- _infrastructure/tests/runner.js | 4 ++-- _infrastructure/tests/runner.ts | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/_infrastructure/tests/runner.js b/_infrastructure/tests/runner.js index 8b1ff53dd..d0a23087a 100644 --- a/_infrastructure/tests/runner.js +++ b/_infrastructure/tests/runner.js @@ -567,7 +567,7 @@ var DefinitelyTyped; this.path = path; this.files = []; this.typings = []; - this.files = IO.dir(path, pattern, { recursive: true }); + this.files = IO.dir(path, pattern, { recursive: true }).sort(); } FileHandler.prototype.allTS = function () { return this.files; @@ -716,7 +716,7 @@ var DefinitelyTyped; }; Print.prototype.printSyntaxErrorCount = function (current, total) { - this.out(' \33[36m\33[1mSyntaxe error :\33[0m \33[31m\33[1m' + ((current / total) * 100).toFixed(2) + '% (' + current + '/' + total + ')\33[0m\n'); + this.out(' \33[36m\33[1mSyntax error :\33[0m \33[31m\33[1m' + ((current / total) * 100).toFixed(2) + '% (' + current + '/' + total + ')\33[0m\n'); }; Print.prototype.printTestErrorCount = function (current, total) { diff --git a/_infrastructure/tests/runner.ts b/_infrastructure/tests/runner.ts index 175194755..8d0eeae14 100644 --- a/_infrastructure/tests/runner.ts +++ b/_infrastructure/tests/runner.ts @@ -55,7 +55,7 @@ module DefinitelyTyped { public typings: Typing[] = []; constructor(public path: string, pattern: any) { - this.files = IO.dir(path, pattern, { recursive: true }); + this.files = IO.dir(path, pattern, { recursive: true }).sort(); } public allTS(): string[] { @@ -209,7 +209,7 @@ module DefinitelyTyped { } public printSyntaxErrorCount(current: number, total: number) { - this.out(' \33[36m\33[1mSyntaxe error :\33[0m \33[31m\33[1m' + ((current / total) * 100).toFixed(2) + '% (' + current + '/' + total + ')\33[0m\n'); + this.out(' \33[36m\33[1mSyntax error :\33[0m \33[31m\33[1m' + ((current / total) * 100).toFixed(2) + '% (' + current + '/' + total + ')\33[0m\n'); } public printTestErrorCount(current: number, total: number) { From 557b38099e1f6fc7301d1b9c5baf911677c3acb5 Mon Sep 17 00:00:00 2001 From: Neil Stalker Date: Mon, 24 Jun 2013 21:53:20 +0100 Subject: [PATCH 22/37] Fix fabric.js definition and tests --- fabricjs/fabricjs.d.ts | 53 +++++++++++-------- .../{tests/sample1.ts => sample1-tests.ts} | 2 +- .../{tests/sample2.ts => sample2-tests.ts} | 2 +- .../{tests/sample3.ts => sample3-tests.ts} | 4 +- .../{tests/sample4.ts => sample4-tests.ts} | 2 +- .../{tests/sample5.ts => sample5-tests.ts} | 2 +- .../{tests/sample6.ts => sample6-tests.ts} | 2 +- .../{tests/sample7.ts => sample7-tests.ts} | 2 +- .../{tests/sample8.ts => sample8-tests.ts} | 42 +++++++-------- 9 files changed, 60 insertions(+), 51 deletions(-) rename fabricjs/{tests/sample1.ts => sample1-tests.ts} (94%) rename fabricjs/{tests/sample2.ts => sample2-tests.ts} (97%) rename fabricjs/{tests/sample3.ts => sample3-tests.ts} (97%) rename fabricjs/{tests/sample4.ts => sample4-tests.ts} (96%) rename fabricjs/{tests/sample5.ts => sample5-tests.ts} (97%) rename fabricjs/{tests/sample6.ts => sample6-tests.ts} (94%) rename fabricjs/{tests/sample7.ts => sample7-tests.ts} (95%) rename fabricjs/{tests/sample8.ts => sample8-tests.ts} (94%) diff --git a/fabricjs/fabricjs.d.ts b/fabricjs/fabricjs.d.ts index e3f8da18b..26261abb4 100644 --- a/fabricjs/fabricjs.d.ts +++ b/fabricjs/fabricjs.d.ts @@ -149,6 +149,7 @@ declare module fabric { ry: number; complexity(): number; + initialize(options: any); initialize(points: number[], options: any): IRect; toObject(propertiesToInclude: any[]): any; toSVG(): string; @@ -172,6 +173,7 @@ declare module fabric { type: string; useNative: Boolean; + initialize(options: any); initialize(text: string, options: any): IText; toString(): string; render(ctx: CanvasRenderingContext2D, noTransform: bool); @@ -387,15 +389,16 @@ declare module fabric { destroy(): IGroup; getObjects(): IObject[]; hasMoved(): bool; + initialize(options: any); initialize(objects, options): any; item(index): IObject; - remove(object): IGroup; + remove(object?): IGroup; removeWithUpdate(object): IGroup; render(ctx, noTransform): void; saveCoords(): IGroup; setObjectsCoords(): IGroup; size(): number; - toGrayscale(): void; + toGrayscale(): IGroup; toObject(propertiesToInclude: any[]): any; tostring(): string; toSVG(): string; @@ -409,6 +412,7 @@ declare module fabric { y2: number; complexity(): number; + initialize(options: any); initialize(points: number[], options: any): ILine; toObject(propertiesToInclude: any[]): any; toSVG(): string; @@ -424,11 +428,13 @@ declare module fabric { filters: any; applyFilters(callback); + clone(callback?, propertiesToInclude?): IObject; clone(propertiesToInclude, callback); complexity(): number; getElement(): HTMLImageElement; getOriginalSize(): { width: number; height: number; }; getSrc(): string; + initialize(options: any); initialize(element: string, options: any); initialize(element: HTMLImageElement, options: any); render(ctx: CanvasRenderingContext2D, noTransform: bool); @@ -453,6 +459,7 @@ declare module fabric { export interface IPath extends IObject { complexity(): number; + initialize(options: any); initialize(path, options); render(ctx: CanvasRenderingContext2D, noTransform: bool); toDatalessObject(propertiesToInclude): any; @@ -463,6 +470,7 @@ declare module fabric { export interface IPolygon extends IObject { complexity(): number; + initialize(options: any); initialize(points, options); toObject(propertiesToInclude): any; toSVG(): string; @@ -470,6 +478,7 @@ declare module fabric { export interface IPolyline extends IObject { complexity(): number; + initialize(options: any); initialize(points, options); toObject(propertiesToInclude): any; toSVG(): string; @@ -477,11 +486,12 @@ declare module fabric { export interface IPathGroup extends IObject { complexity(): number; + initialize(options: any); initialize(paths, options); isSameColor(): bool; render(ctx: CanvasRenderingContext2D); toDatalessObject(propertiesToInclude): any; - toGrayscale(); + toGrayscale(): IPathGroup; toObject(propertiesToInclude): any; tostring(): string; toSVG(): string; @@ -660,18 +670,18 @@ declare module fabric { export interface ITriangleOptions extends IObjectOptions { } - declare var Rect: { + var Rect: { fromElement(element: SVGElement, options: IRectOptions): IRect; fromObject(object): IRect; new (options?: IRectOptions): IRect; prototype: any; } - declare var Triangle: { + var Triangle: { new (options?: ITriangleOptions): ITriangle; } - declare var Canvas: { + var Canvas: { new (element: HTMLCanvasElement, options?: ICanvasOptions): ICanvas; new (element: string, options?: ICanvasOptions): ICanvas; @@ -680,7 +690,7 @@ declare module fabric { prototype: any; } - declare var StaticCanvas: { + var StaticCanvas: { new (element: HTMLCanvasElement, options?: ICanvasOptions): ICanvas; new (element: string, options?: ICanvasOptions): ICanvas; @@ -689,7 +699,7 @@ declare module fabric { prototype: any; } - declare var Circle: { + var Circle: { ATTRIBUTE_NAMES: string[]; fromElement(element: SVGElement, options: ICircleOptions): ICircle; fromObject(object): ICircle; @@ -697,11 +707,11 @@ declare module fabric { prototype: any; } - declare var Group: { + var Group: { new (items?: any[], options?: IObjectOptions): IGroup; } - declare var Line: { + var Line: { ATTRIBUTE_NAMES: string[]; fromElement(element: SVGElement, options): ILine; fromObject(object): ILine; @@ -709,53 +719,53 @@ declare module fabric { new (points: number[], objObjects?: IObjectOptions): ILine; } - declare var Intersection: { + var Intersection: { intersectLineLine(a1, a2, b1, b2); intersectLinePolygon(a1, a2, points); intersectPolygonPolygon(points1, points2); intersectPolygonRectangle(points, r1, r2); } - declare var Path: { + var Path: { fromElement(element: SVGElement, options): IPath; fromObject(object): IPath; new (): IPath; } - declare var PathGroup: { + var PathGroup: { fromObject(object): IPathGroup; new (): IPathGroup; prototype: any; } - declare var Point: { + var Point: { new (x, y): IPoint; prototype: any; } - declare var Object: { + var Object: { prototype: any; } - declare var Polygon: { + var Polygon: { fromObject(object): IPolygon; fromElement(element: SVGElement, options): IPolygon; new (): IPolygon; prototype: any; } - declare var Polyline: { + var Polyline: { fromObject(object): IPolyline; fromElement(element: SVGElement, options): IPolyline; new (): IPolyline; prototype: any; } - declare var Text: { + var Text: { new (text: string, options?: ITextOptions): IText; } - declare var Image: { + var Image: { fromURL(url: string): IImage; fromURL(url: string, callback: (image: IImage) => any): IImage; fromURL(url: string, callback: (image: IImage) => any, objObjects: IObjectOptions): IImage; @@ -809,7 +819,7 @@ declare module fabric { } - declare var util: { + var util: { addClass(element: HTMLElement, className: string); addListener(element, eventName: string, handler); animate(options: { @@ -846,5 +856,4 @@ declare module fabric { toFixed(number, fractionDigits); wrapElement(element: HTMLElement, wrapper, attributes); } -}; - +} diff --git a/fabricjs/tests/sample1.ts b/fabricjs/sample1-tests.ts similarity index 94% rename from fabricjs/tests/sample1.ts rename to fabricjs/sample1-tests.ts index f494d84ce..08a80048f 100644 --- a/fabricjs/tests/sample1.ts +++ b/fabricjs/sample1-tests.ts @@ -1,4 +1,4 @@ -/// +/// var canvas = new fabric.Canvas('c', { hoverCursor: 'pointer', diff --git a/fabricjs/tests/sample2.ts b/fabricjs/sample2-tests.ts similarity index 97% rename from fabricjs/tests/sample2.ts rename to fabricjs/sample2-tests.ts index a04f2d1b8..0cf220d34 100644 --- a/fabricjs/tests/sample2.ts +++ b/fabricjs/sample2-tests.ts @@ -1,4 +1,4 @@ -/// +/// var dot, i, t1, t2, diff --git a/fabricjs/tests/sample3.ts b/fabricjs/sample3-tests.ts similarity index 97% rename from fabricjs/tests/sample3.ts rename to fabricjs/sample3-tests.ts index 5393f6c64..1d5ceab28 100644 --- a/fabricjs/tests/sample3.ts +++ b/fabricjs/sample3-tests.ts @@ -1,4 +1,4 @@ -/// +/// var $ = function(id){return document.getElementById(id)}; @@ -28,7 +28,7 @@ canvas.on({ for (var i = 0; i < filters.length; i++) { var checkBox = $(filters[i]); - var image = canvas.getActiveObject(); + var image = canvas.getActiveObject(); checkBox.checked = !!image.filters[i]; } }, diff --git a/fabricjs/tests/sample4.ts b/fabricjs/sample4-tests.ts similarity index 96% rename from fabricjs/tests/sample4.ts rename to fabricjs/sample4-tests.ts index a1cfd0e4c..18db919aa 100644 --- a/fabricjs/tests/sample4.ts +++ b/fabricjs/sample4-tests.ts @@ -1,4 +1,4 @@ -/// +/// var canvas = new fabric.Canvas('c'); var $ = function (id) { return document.getElementById(id); }; diff --git a/fabricjs/tests/sample5.ts b/fabricjs/sample5-tests.ts similarity index 97% rename from fabricjs/tests/sample5.ts rename to fabricjs/sample5-tests.ts index 399f32ad9..e3f2a6a5c 100644 --- a/fabricjs/tests/sample5.ts +++ b/fabricjs/sample5-tests.ts @@ -1,4 +1,4 @@ -/// +/// module fabric { export interface CircleWithLineInfos extends ICircle { diff --git a/fabricjs/tests/sample6.ts b/fabricjs/sample6-tests.ts similarity index 94% rename from fabricjs/tests/sample6.ts rename to fabricjs/sample6-tests.ts index 48123ce62..bd87ffec8 100644 --- a/fabricjs/tests/sample6.ts +++ b/fabricjs/sample6-tests.ts @@ -1,4 +1,4 @@ -/// +/// var canvas = new fabric.Canvas('c'); fabric.loadSVGFromURL('../assets/135.svg', function (objects) { diff --git a/fabricjs/tests/sample7.ts b/fabricjs/sample7-tests.ts similarity index 95% rename from fabricjs/tests/sample7.ts rename to fabricjs/sample7-tests.ts index 2fe0c74ba..892f47730 100644 --- a/fabricjs/tests/sample7.ts +++ b/fabricjs/sample7-tests.ts @@ -1,4 +1,4 @@ -/// +/// module fabric { export interface ImageWithInfo extends IImage { diff --git a/fabricjs/tests/sample8.ts b/fabricjs/sample8-tests.ts similarity index 94% rename from fabricjs/tests/sample8.ts rename to fabricjs/sample8-tests.ts index a8d8ef481..7e5f2e296 100644 --- a/fabricjs/tests/sample8.ts +++ b/fabricjs/sample8-tests.ts @@ -1,4 +1,4 @@ -/// +/// module fabric { export interface ImageWithInfo extends IImage { @@ -41,7 +41,7 @@ function updateComplexity() { }, 100); } -document.getElementById('commands').onclick = function (ev) { +document.getElementById('commands').onclick = function (ev: any) { var ev: any = ev || window.event; if (ev.preventDefault) { @@ -450,8 +450,8 @@ if (supportsColorpicker()) { }, 100); if (document.location.search.indexOf('guidelines') > -1) { - initCenteringGuidelines(canvas); - initAligningGuidelines(canvas); + //initCenteringGuidelines(canvas); + //initAligningGuidelines(canvas); } gradientifyBtn.onclick = function() { @@ -475,7 +475,7 @@ if (supportsColorpicker()) { var activeObject = canvas.getActiveObject(); if (activeObject && activeObject.type === 'text') { - this.value = (activeObject).text; + this.value = (activeObject).text; } }; textEl.onkeyup = function(e) { @@ -485,7 +485,7 @@ if (supportsColorpicker()) { canvas.discardActiveObject(); } else { - (activeObject).text = this.value; + (activeObject).text = this.value; } canvas.renderAll(); } @@ -497,7 +497,7 @@ if (supportsColorpicker()) { activeObjectButtons.push(cmdUnderlineBtn); cmdUnderlineBtn.disabled = true; cmdUnderlineBtn.onclick = function() { - var activeObject = canvas.getActiveObject(); + var activeObject = canvas.getActiveObject(); if (activeObject && activeObject.type === 'text') { activeObject.textDecoration = (activeObject.textDecoration == 'underline' ? '' : 'underline'); this.className = activeObject.textDecoration ? 'selected' : ''; @@ -511,7 +511,7 @@ if (supportsColorpicker()) { activeObjectButtons.push(cmdLinethroughBtn); cmdLinethroughBtn.disabled = true; cmdLinethroughBtn.onclick = function() { - var activeObject = canvas.getActiveObject(); + var activeObject = canvas.getActiveObject(); if (activeObject && activeObject.type === 'text') { activeObject.textDecoration = (activeObject.textDecoration == 'line-through' ? '' : 'line-through'); this.className = activeObject.textDecoration ? 'selected' : ''; @@ -525,7 +525,7 @@ if (supportsColorpicker()) { activeObjectButtons.push(cmdOverlineBtn); cmdOverlineBtn.disabled = true; cmdOverlineBtn.onclick = function() { - var activeObject = canvas.getActiveObject(); + var activeObject = canvas.getActiveObject(); if (activeObject && activeObject.type === 'text') { activeObject.textDecoration = (activeObject.textDecoration == 'overline' ? '' : 'overline'); this.className = activeObject.textDecoration ? 'selected' : ''; @@ -539,7 +539,7 @@ if (supportsColorpicker()) { activeObjectButtons.push(cmdBoldBtn); cmdBoldBtn.disabled = true; cmdBoldBtn.onclick = function() { - var activeObject = canvas.getActiveObject(); + var activeObject = canvas.getActiveObject(); if (activeObject && activeObject.type === 'text') { activeObject.fontWeight = (activeObject.fontWeight == 'bold' ? '' : 'bold'); this.className = activeObject.fontWeight ? 'selected' : ''; @@ -553,7 +553,7 @@ if (supportsColorpicker()) { activeObjectButtons.push(cmdItalicBtn); cmdItalicBtn.disabled = true; cmdItalicBtn.onclick = function() { - var activeObject = canvas.getActiveObject(); + var activeObject = canvas.getActiveObject(); if (activeObject && activeObject.type === 'text') { activeObject.fontStyle = (activeObject.fontStyle == 'italic' ? '' : 'italic'); this.className = activeObject.fontStyle ? 'selected' : ''; @@ -567,7 +567,7 @@ if (supportsColorpicker()) { activeObjectButtons.push(cmdShadowBtn); cmdShadowBtn.disabled = true; cmdShadowBtn.onclick = function() { - var activeObject = canvas.getActiveObject(); + var activeObject = canvas.getActiveObject(); if (activeObject && activeObject.type === 'text') { activeObject.textShadow = !activeObject.textShadow ? 'rgba(0,0,0,0.2) 2px 2px 10px' : ''; this.className = activeObject.textShadow ? 'selected' : ''; @@ -581,7 +581,7 @@ if (supportsColorpicker()) { activeObjectButtons.push(textAlignSwitch); textAlignSwitch.disabled = true; textAlignSwitch.onchange = function() { - var activeObject = canvas.getActiveObject(); + var activeObject = canvas.getActiveObject(); if (activeObject && activeObject.type === 'text') { activeObject.textAlign = this.value.toLowerCase(); canvas.renderAll(); @@ -594,7 +594,7 @@ if (supportsColorpicker()) { activeObjectButtons.push(fontFamilySwitch); fontFamilySwitch.disabled = true; fontFamilySwitch.onchange = function() { - var activeObject = canvas.getActiveObject(); + var activeObject = canvas.getActiveObject(); if (activeObject && activeObject.type === 'text') { activeObject.fontFamily = this.value; canvas.renderAll(); @@ -605,7 +605,7 @@ if (supportsColorpicker()) { var bgColorField = document.getElementById('text-bg-color'); if (bgColorField) { bgColorField.onchange = function() { - var activeObject = canvas.getActiveObject(); + var activeObject = canvas.getActiveObject(); if (activeObject && activeObject.type === 'text') { activeObject.backgroundColor = this.value; canvas.renderAll(); @@ -616,7 +616,7 @@ if (supportsColorpicker()) { var strokeColorField = document.getElementById('text-stroke-color'); if (strokeColorField) { strokeColorField.onchange = function() { - var activeObject = canvas.getActiveObject(); + var activeObject = canvas.getActiveObject(); if (activeObject && activeObject.type === 'text') { activeObject.strokeStyle = this.value; canvas.renderAll(); @@ -639,7 +639,7 @@ if (supportsColorpicker()) { label.appendChild(slider); slider.title = "Line height"; slider.onchange = function(){ - var activeObject = canvas.getActiveObject(); + var activeObject = canvas.getActiveObject(); if (activeObject && activeObject.type === 'text') { activeObject.lineHeight = this.value; canvas.renderAll(); @@ -661,7 +661,7 @@ if (supportsColorpicker()) { }); }; - if (typeof Cufon !== 'undefined') { - Cufon.fonts.delicious.offsetLeft = 75; - Cufon.fonts.delicious.offsetTop = 25; - } \ No newline at end of file + //if (typeof Cufon !== 'undefined') { + // Cufon.fonts.delicious.offsetLeft = 75; + // Cufon.fonts.delicious.offsetTop = 25; + //} \ No newline at end of file From 29e345ec325c986ac67010db12591a2df0c81ea4 Mon Sep 17 00:00:00 2001 From: Neil Stalker Date: Mon, 24 Jun 2013 21:57:05 +0100 Subject: [PATCH 23/37] fix webaudioapi --- webaudioapi/waa-20120802.d.ts | 2 +- webaudioapi/waa-nightly.d.ts | 2 +- webaudioapi/waa.d.ts | 8 ++++---- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/webaudioapi/waa-20120802.d.ts b/webaudioapi/waa-20120802.d.ts index b90c4b959..271bb4139 100644 --- a/webaudioapi/waa-20120802.d.ts +++ b/webaudioapi/waa-20120802.d.ts @@ -71,7 +71,7 @@ interface AudioNode { numberOfInputs: number; numberOfOutputs: number; -}; +} interface AudioSourceNode extends AudioNode { diff --git a/webaudioapi/waa-nightly.d.ts b/webaudioapi/waa-nightly.d.ts index 38ef2f401..edacc8e10 100644 --- a/webaudioapi/waa-nightly.d.ts +++ b/webaudioapi/waa-nightly.d.ts @@ -93,7 +93,7 @@ interface DelayNode extends AudioNode { delayTime: AudioParam; -}; +} interface AudioBuffer { diff --git a/webaudioapi/waa.d.ts b/webaudioapi/waa.d.ts index be6898d39..5479fe334 100644 --- a/webaudioapi/waa.d.ts +++ b/webaudioapi/waa.d.ts @@ -597,7 +597,7 @@ interface AudioProcessingEvent extends Event { outputBuffer: AudioBuffer; } -enum PanningModelType { +declare enum PanningModelType { /** * A simple and efficient spatialization algorithm using equal-power panning. */ @@ -614,7 +614,7 @@ enum PanningModelType { soundfield } -enum DistanceModelType { +declare enum DistanceModelType { /** * A linear distance model which calculates distanceGain according to: * 1 - rolloffFactor * (distance - refDistance) / (maxDistance - refDistance) @@ -895,7 +895,7 @@ interface DynamicsCompressorNode extends AudioNode { } -enum BiquadFilterType { +declare enum BiquadFilterType { /** * A lowpass filter allows frequencies below the cutoff frequency to pass through and attenuates frequencies above the cutoff. It implements a standard second-order resonant lowpass filter with 12dB/octave rolloff. * @@ -1043,7 +1043,7 @@ interface WaveShaperNode extends AudioNode { curve: Float32Array; } -enum OscillatorType { +declare enum OscillatorType { sine, square, sawtooth, From 6cb6cdbe83947bce50e33b9fb72f48814459951d Mon Sep 17 00:00:00 2001 From: Neil Stalker Date: Mon, 24 Jun 2013 22:17:48 +0100 Subject: [PATCH 24/37] fix threejs definition and tests --- threejs/three-r55.d.ts | 5 +- threejs/three-tests.ts | 132 +++++++++++++++++++++-------------------- threejs/three.d.ts | 7 ++- 3 files changed, 76 insertions(+), 68 deletions(-) diff --git a/threejs/three-r55.d.ts b/threejs/three-r55.d.ts index d14ab7de4..29b68a69e 100644 --- a/threejs/three-r55.d.ts +++ b/threejs/three-r55.d.ts @@ -7,9 +7,9 @@ * */ -interface WebGLRenderingContext {}; +interface WebGLRenderingContext {} -module THREE { +declare module THREE { export var REVISION: string; // GL STATE CONSTANTS @@ -5259,6 +5259,7 @@ module THREE { lensFlares: LensFlareProperty[]; positionScreen: Vector3; customUpdateCallback: () => void; + add(object: Object3D): void; add(texture?: Texture, size?: number, distance?: number, blending?: Blending, color?: number, opacity?: number): void; updateLensFlares(): void; } diff --git a/threejs/three-tests.ts b/threejs/three-tests.ts index 5b3bbb2ca..e075af9c5 100644 --- a/threejs/three-tests.ts +++ b/threejs/three-tests.ts @@ -3235,7 +3235,7 @@ interface HTMLElement{ // Cubes - var geometry = new THREE.CubeGeometry( 50, 50, 50 ); + geometry = new THREE.CubeGeometry( 50, 50, 50 ); var materialCube = new THREE.MeshLambertMaterial( { color: 0xffffff, shading: THREE.FlatShading, overdraw: true } ); for ( var i = 0; i < 100; i ++ ) { @@ -4085,7 +4085,7 @@ var container, stats; // line - var geometry = shape.createPointsGeometry(); + geometry = shape.createPointsGeometry(); var materialLine = new THREE.LineBasicMaterial( { linewidth: 10, color: 0x333333, transparent: true } ); var line = new THREE.Line( geometry, materialLine ); @@ -4783,7 +4783,7 @@ var container, stats; // Cubes - var geometry = new THREE.CubeGeometry( 50, 50, 50 ); + geometry = new THREE.CubeGeometry( 50, 50, 50 ); var cubeMaterial = new THREE.MeshLambertMaterial( { color: 0xffffff, shading: THREE.FlatShading, overdraw: true } ); for ( var i = 0; i < 100; i ++ ) { @@ -5725,7 +5725,7 @@ var container, stats; // Spheres - var geometry = new THREE.SphereGeometry( 100, 14, 7 ); + geometry = new THREE.SphereGeometry( 100, 14, 7 ); var materials:THREE.Material[] = [ @@ -6708,7 +6708,7 @@ var container, stats; // https://github.com/mrdoob/three.js/blob/master/examples/canvas_particles_sprites.html -()=>{ +() => { var container, stats; var camera, scene, renderer, particle; var mouseX = 0, mouseY = 0; @@ -6721,43 +6721,43 @@ var container, stats; function init() { - container = document.createElement( 'div' ); - document.body.appendChild( container ); + container = document.createElement('div'); + document.body.appendChild(container); - camera = new THREE.PerspectiveCamera( 75, window.innerWidth / window.innerHeight, 1, 5000 ); + camera = new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 1, 5000); camera.position.z = 1000; scene = new THREE.Scene(); - var material = new THREE.ParticleBasicMaterial( { map: new THREE.Texture( generateSprite() ), blending: THREE.AdditiveBlending } ); + var material = new THREE.ParticleBasicMaterial({ map: new THREE.Texture(generateSprite()), blending: THREE.AdditiveBlending }); - for ( var i = 0; i < 1000; i++ ) { + for (var i = 0; i < 1000; i++) { - particle = new THREE.Particle( material ); + particle = new THREE.Particle(material); - initParticle( particle, i * 10 ); + initParticle(particle, i * 10); - scene.add( particle ); + scene.add(particle); } renderer = new THREE.CanvasRenderer(); - renderer.setSize( window.innerWidth, window.innerHeight ); + renderer.setSize(window.innerWidth, window.innerHeight); renderer.sortElements = false; - renderer.setClearColorHex( 0x0000ff, 0.25 ); - container.appendChild( renderer.domElement ); + renderer.setClearColorHex(0x0000ff, 0.25); + container.appendChild(renderer.domElement); stats = new Stats(); stats.domElement.style.position = 'absolute'; stats.domElement.style.top = '0px'; - container.appendChild( stats.domElement ); + container.appendChild(stats.domElement); - document.addEventListener( 'mousemove', onDocumentMouseMove, false ); - document.addEventListener( 'touchstart', onDocumentTouchStart, false ); - document.addEventListener( 'touchmove', onDocumentTouchMove, false ); + document.addEventListener('mousemove', onDocumentMouseMove, false); + document.addEventListener('touchstart', onDocumentTouchStart, false); + document.addEventListener('touchmove', onDocumentTouchMove, false); // - window.addEventListener( 'resize', onWindowResize, false ); + window.addEventListener('resize', onWindowResize, false); } @@ -6769,31 +6769,31 @@ var container, stats; camera.aspect = window.innerWidth / window.innerHeight; camera.updateProjectionMatrix(); - renderer.setSize( window.innerWidth, window.innerHeight ); + renderer.setSize(window.innerWidth, window.innerHeight); } function generateSprite() { - var canvas = document.createElement( 'canvas' ); + var canvas = document.createElement('canvas'); canvas.width = 16; canvas.height = 16; - var context = canvas.getContext( '2d' ); - var gradient = context.createRadialGradient( canvas.width / 2, canvas.height / 2, 0, canvas.width / 2, canvas.height / 2, canvas.width / 2 ); - gradient.addColorStop( 0, 'rgba(255,255,255,1)' ); - gradient.addColorStop( 0.2, 'rgba(0,255,255,1)' ); - gradient.addColorStop( 0.4, 'rgba(0,0,64,1)' ); - gradient.addColorStop( 1, 'rgba(0,0,0,1)' ); + var context = canvas.getContext('2d'); + var gradient = context.createRadialGradient(canvas.width / 2, canvas.height / 2, 0, canvas.width / 2, canvas.height / 2, canvas.width / 2); + gradient.addColorStop(0, 'rgba(255,255,255,1)'); + gradient.addColorStop(0.2, 'rgba(0,255,255,1)'); + gradient.addColorStop(0.4, 'rgba(0,0,64,1)'); + gradient.addColorStop(1, 'rgba(0,0,0,1)'); context.fillStyle = gradient; - context.fillRect( 0, 0, canvas.width, canvas.height ); + context.fillRect(0, 0, canvas.width, canvas.height); return canvas; } - function initParticle( particle, delay ) { + function initParticle(particle, delay) { var particle = this instanceof THREE.Particle ? this : particle; var delay = delay !== undefined ? delay : 0; @@ -6803,53 +6803,53 @@ var container, stats; particle.position.z = 0; particle.scale.x = particle.scale.y = Math.random() * 3 + 1; - new TWEEN.Tween( particle ) - .delay( delay ) - .to( {}, 10000 ) - .onComplete( initParticle ) + new TWEEN.Tween(particle) + .delay(delay) + .to({}, 10000) + .onComplete(initParticle) .start(); - new TWEEN.Tween( particle.position ) - .delay( delay ) - .to( { x: Math.random() * 4000 - 2000, y: Math.random() * 1000 - 500, z: Math.random() * 4000 - 2000 }, 10000 ) + new TWEEN.Tween(particle.position) + .delay(delay) + .to({ x: Math.random() * 4000 - 2000, y: Math.random() * 1000 - 500, z: Math.random() * 4000 - 2000 }, 10000) .start(); - new TWEEN.Tween( particle.scale ) - .delay( delay ) - .to( { x: 0, y: 0 }, 10000 ) + new TWEEN.Tween(particle.scale) + .delay(delay) + .to({ x: 0, y: 0 }, 10000) .start(); } // - function onDocumentMouseMove( event ) { + function onDocumentMouseMove(event) { mouseX = event.clientX - windowHalfX; mouseY = event.clientY - windowHalfY; } - function onDocumentTouchStart( event ) { + function onDocumentTouchStart(event) { - if ( event.touches.length == 1 ) { + if (event.touches.length == 1) { event.preventDefault(); - mouseX = event.touches[ 0 ].pageX - windowHalfX; - mouseY = event.touches[ 0 ].pageY - windowHalfY; + mouseX = event.touches[0].pageX - windowHalfX; + mouseY = event.touches[0].pageY - windowHalfY; } } - function onDocumentTouchMove( event ) { + function onDocumentTouchMove(event) { - if ( event.touches.length == 1 ) { + if (event.touches.length == 1) { event.preventDefault(); - mouseX = event.touches[ 0 ].pageX - windowHalfX; - mouseY = event.touches[ 0 ].pageY - windowHalfY; + mouseX = event.touches[0].pageX - windowHalfX; + mouseY = event.touches[0].pageY - windowHalfY; } @@ -6859,7 +6859,7 @@ var container, stats; function animate() { - requestAnimationFrame( animate ); + requestAnimationFrame(animate); render(); stats.update(); @@ -6870,14 +6870,16 @@ var container, stats; TWEEN.update(); - camera.position.x += ( mouseX - camera.position.x ) * 0.05; - camera.position.y += ( - mouseY - camera.position.y ) * 0.05; - camera.lookAt( scene.position ); + camera.position.x += (mouseX - camera.position.x) * 0.05; + camera.position.y += (- mouseY - camera.position.y) * 0.05; + camera.lookAt(scene.position); - renderer.render( scene, camera ); + renderer.render(scene, camera); } -var container, stats; +}; +() => { + var container, stats; var camera, scene, renderer, particle; var mouseX = 0, mouseY = 0; @@ -16400,7 +16402,7 @@ function render() { F.prototype = klass.prototype; - return new F( klass, args ); + return F( klass, args ); }; @@ -17263,7 +17265,7 @@ function render() { F.prototype = klass.prototype; - return new F( klass, args ); + return F( klass, args ); }; @@ -20869,7 +20871,7 @@ function render() { objects = []; - var sphere, geometry, material; + var sphere, material; for ( var i = 0, l = materials.length; i < l; i ++ ) { @@ -21374,7 +21376,8 @@ function render() { object: null, buttons: null, - materials: null + materials: null, + mmap: null }, @@ -21390,7 +21393,8 @@ function render() { object: null, buttons: null, - materials: null + materials: null, + mmap: null }, @@ -21406,7 +21410,8 @@ function render() { object: null, buttons: null, - materials: null + materials: null, + mmap: null }, @@ -21422,7 +21427,8 @@ function render() { object: null, buttons: null, - materials: null + materials: null, + mmap: null } diff --git a/threejs/three.d.ts b/threejs/three.d.ts index 9a18dd72e..e8bf50d68 100644 --- a/threejs/three.d.ts +++ b/threejs/three.d.ts @@ -5,7 +5,7 @@ interface WebGLRenderingContext {} -module THREE { +declare module THREE { export var REVISION: string; // GL STATE CONSTANTS @@ -1277,7 +1277,7 @@ module THREE { degToRad(degrees: number): number; radToDeg(radians: number): number; - }; + } /** * @@ -5777,7 +5777,8 @@ module THREE { constructor(texture?: Texture, size?: number, distance?: number, blending?: Blending, color?: Color); lensFlares: LensFlareProperty[]; positionScreen: Vector3; - customUpdateCallback: (object:LensFlare) => void; + customUpdateCallback: (object: LensFlare) => void; + add(object: Object3D): void; add(texture?: Texture, size?: number, distance?: number, blending?: Blending, color?: Color, opacity?: number): void; updateLensFlares(): void; } From beae1ebd88845c6c0d3e82e5aad127fa26553b29 Mon Sep 17 00:00:00 2001 From: Neil Stalker Date: Mon, 24 Jun 2013 22:22:57 +0100 Subject: [PATCH 25/37] fix scroller, soundjs and youtube definitions --- scroller/easyscroller.d.ts | 2 +- scroller/scroller-tests.ts | 2 +- scroller/scroller.d.ts | 2 +- soundjs/soundjs.d.ts | 2 +- youtube/youtube.d.ts | 4 ++-- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/scroller/easyscroller.d.ts b/scroller/easyscroller.d.ts index 5b6477fe5..edc3c55d6 100644 --- a/scroller/easyscroller.d.ts +++ b/scroller/easyscroller.d.ts @@ -6,7 +6,7 @@ /// -class EasyScroller { +declare class EasyScroller { constructor (content: any, options: ScrollerOptions); render(): void; diff --git a/scroller/scroller-tests.ts b/scroller/scroller-tests.ts index ff12a8639..941e05ff1 100644 --- a/scroller/scroller-tests.ts +++ b/scroller/scroller-tests.ts @@ -41,7 +41,7 @@ function test_canvas() { function test_domlist() { var container = document.getElementById("container"); var content = document.getElementById("content"); - var refreshElem = content.getElementsByTagName("div")[0]; + var refreshElem = content.getElementsByTagName("div")[0]; var scroller = new Scroller(render, { scrollingX: false }); diff --git a/scroller/scroller.d.ts b/scroller/scroller.d.ts index 72bf30d2f..b1e439b0a 100644 --- a/scroller/scroller.d.ts +++ b/scroller/scroller.d.ts @@ -28,7 +28,7 @@ interface ScrollValuesWithZoom extends ScrollValues { zoom: number; } -class Scroller { +declare class Scroller { constructor (callback: (left: number, top: number, zoom: number) => void , options: ScrollerOptions); setDimensions(clientWidth: number, clientHeight: number, contentWidth: number, contentHeight: number): void; diff --git a/soundjs/soundjs.d.ts b/soundjs/soundjs.d.ts index a00d33775..24eeb0139 100644 --- a/soundjs/soundjs.d.ts +++ b/soundjs/soundjs.d.ts @@ -10,7 +10,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -module createjs { +declare module createjs { export class FlashPlugin { // properties static BASE_PATH: string; diff --git a/youtube/youtube.d.ts b/youtube/youtube.d.ts index 98e2334f1..fa74be939 100644 --- a/youtube/youtube.d.ts +++ b/youtube/youtube.d.ts @@ -4,7 +4,7 @@ // Updated by: Ian Obermiller // Definitions: https://github.com/borisyankov/DefinitelyTyped -module YT { +declare module YT { interface EventArgs { target: Player; data: any; @@ -148,5 +148,5 @@ module YT { ENDED, PAUSED, PLAYING - }; + } } From bb5d20d33363ddf8328124c79745bd257b4612a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Poul=20S=C3=B8rensen?= Date: Mon, 24 Jun 2013 23:39:56 +0200 Subject: [PATCH 26/37] Update node.d.ts --- node/node.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/node/node.d.ts b/node/node.d.ts index 2fbd81e55..c1a552869 100644 --- a/node/node.d.ts +++ b/node/node.d.ts @@ -929,7 +929,7 @@ declare module "crypto" { export function createHash(algorithm: string): Hash; export function createHmac(algorithm: string, key: string): Hmac; interface Hash { - update(data: any, input_encoding?: string): void; + update(data: any, input_encoding?: string): Hash; digest(encoding?: string): string; } interface Hmac { From 2192405a76f8960754b15e7aef6775bed056a47e Mon Sep 17 00:00:00 2001 From: Neil Stalker Date: Mon, 24 Jun 2013 22:51:29 +0100 Subject: [PATCH 27/37] Fix definitions for TS 0.9 hammer.js jake jszip.js dust.js google,analytics linq.js --- dustjs-linkedin/dustjs-linkedin.d.ts | 4 ++-- google.analytics/ga.d.ts | 2 +- hammerjs/hammerjs.d.ts | 2 +- jake/jake.d.ts | 24 ++++++++++++------------ jszip/jszip.d.ts | 2 +- linq/linq.d.ts | 2 +- 6 files changed, 18 insertions(+), 18 deletions(-) diff --git a/dustjs-linkedin/dustjs-linkedin.d.ts b/dustjs-linkedin/dustjs-linkedin.d.ts index fd6558332..9c7f63630 100644 --- a/dustjs-linkedin/dustjs-linkedin.d.ts +++ b/dustjs-linkedin/dustjs-linkedin.d.ts @@ -158,11 +158,11 @@ declare module "dustjs-linkedin" { export function escapeHtml(html: string): string; export function escapeJs(js: string): string; - declare var helpers: { + var helpers: { [key: string]: (chk: Chunk, ctx: Context, bodies?: any, params?: any) => any; }; - declare var filters: { + var filters: { [key: string]: (value: string) => string; }; } \ No newline at end of file diff --git a/google.analytics/ga.d.ts b/google.analytics/ga.d.ts index b24bc6649..c7de005e9 100644 --- a/google.analytics/ga.d.ts +++ b/google.analytics/ga.d.ts @@ -3,7 +3,7 @@ // Definitions by: Ronnie Haakon Hegelund // Definitions: https://github.com/borisyankov/DefinitelyTyped -class Tracker { +declare class Tracker { _trackPageview(): void; _getName(): string; _getAccount(): string; diff --git a/hammerjs/hammerjs.d.ts b/hammerjs/hammerjs.d.ts index 4283191bc..f933058ce 100644 --- a/hammerjs/hammerjs.d.ts +++ b/hammerjs/hammerjs.d.ts @@ -52,7 +52,7 @@ interface HammerDirectionEvent extends HammerEvent { distanceY: number; } -class Hammer { +declare class Hammer { constructor (element: any, options?: HammerOptions); ondragstart: (event: HammerDirectionEvent) => void; diff --git a/jake/jake.d.ts b/jake/jake.d.ts index ec6f20d2b..bf0f77a60 100644 --- a/jake/jake.d.ts +++ b/jake/jake.d.ts @@ -8,28 +8,28 @@ /** * Complets an asynchronous task, allowing Jake's execution to proceed to the next task */ -function complete(): void; +declare function complete(): void; /** * Creates a description for a Jake Task (or FileTask, DirectoryTask). When invoked, the description that iscreated will be associated with whatever Task is created next. * @param description The description for the Task */ -function desc(description:string): void; +declare function desc(description:string): void; /** * Creates a Jake DirectoryTask. Can be used as a prerequisite for FileTasks, or for simply ensuring a directory exists for use with a Task's action. * @param name The name of the DiretoryTask */ -function directory(name:string): jake.DirectoryTask; +declare function directory(name:string): jake.DirectoryTask; /** * Causes Jake execution to abort with an error. Allows passing an optional error code, which will be used to set the exit-code of exiting process. * @param err The error to thow when aborting execution. If this argument is an Error object, it will simply be thrown. If a String, it will be used as the error-message. (If it is a multi-line String, the first line will be used as the Error message, and the remaining lines will be used as the error-stack.) */ -function fail(...err:string[]): void; -function fail(...err:Error[]): void; -function fail(...err:any[]): void; +declare function fail(...err:string[]): void; +declare function fail(...err:Error[]): void; +declare function fail(...err:any[]): void; /** * Creates a Jake FileTask. @@ -38,14 +38,14 @@ function fail(...err:any[]): void; * @param action The action to perform for this task * @param opts Perform this task asynchronously. If you flag a task with this option, you must call the global `complete` method inside the task's action, for execution to proceed to the next task. */ -function file(name:string, prereqs?:string[], action?:()=>void, opts?:jake.FileTaskOptions): jake.FileTask; +declare function file(name:string, prereqs?:string[], action?:()=>void, opts?:jake.FileTaskOptions): jake.FileTask; /** * Creates a namespace which allows logical grouping of tasks, and prevents name-collisions with task-names. Namespaces can be nested inside of other namespaces. * @param name The name of the namespace * @param scope The enclosing scope for the namespaced tasks */ -function namespace(name:string, scope:()=>void): void; +declare function namespace(name:string, scope:()=>void): void; /** * @param name The name of the Task @@ -53,11 +53,11 @@ function namespace(name:string, scope:()=>void): void; * @param action The action to perform for this task * @param opts */ -function task(name:string, prereqs?:string[], action?:(...params:any[])=>any, opts?:jake.TaskOptions): jake.Task; -function task(name:string, action?:(...params:any[])=>any, opts?:jake.TaskOptions): jake.Task; -function task(name:string, opts?:jake.TaskOptions, action?:(...params:any[])=>any): jake.Task; +declare function task(name:string, prereqs?:string[], action?:(...params:any[])=>any, opts?:jake.TaskOptions): jake.Task; +declare function task(name:string, action?:(...params:any[])=>any, opts?:jake.TaskOptions): jake.Task; +declare function task(name:string, opts?:jake.TaskOptions, action?:(...params:any[])=>any): jake.Task; -module jake{ +declare module jake{ //////////////////////////////////////////////////////////////////////////////////// // File-utils ////////////////////////////////////////////////////////////////////// diff --git a/jszip/jszip.d.ts b/jszip/jszip.d.ts index af6c58329..0ed833fed 100644 --- a/jszip/jszip.d.ts +++ b/jszip/jszip.d.ts @@ -3,7 +3,7 @@ // Definitions by: mzeiher // Definitions: https://github.com/borisyankov/DefinitelyTyped -module jszip { +declare module jszip { export interface JSZip { /** * Get a file from the archive diff --git a/linq/linq.d.ts b/linq/linq.d.ts index 6cee18a08..960b20a90 100644 --- a/linq/linq.d.ts +++ b/linq/linq.d.ts @@ -5,7 +5,7 @@ // todo: jQuery plugin, RxJS Binding -module linq { +declare module linq { interface EnumerableStatic { Choice(...contents: any[]): Enumerable; From 44eb9bf8fff9f85f23a88f9fc761e7553402a03d Mon Sep 17 00:00:00 2001 From: Natan Vivo Date: Mon, 24 Jun 2013 19:06:59 -0300 Subject: [PATCH 28/37] Improvements to the underscore definition. * Added the OOP version of underscore _(value). * Pick/Omit accept arrays as well as list of arguments. * Clone of T now returns T instead of any. * Removed UnderscoreWrappedObject. It was just a hack to make the test work. Now chain() returns any. * Test can't test the result of mixin, as new there is the function _() returning the underscore object. --- underscore/underscore-tests.ts | 1 - underscore/underscore.d.ts | 195 ++++++++++++++++++++++++++++++--- 2 files changed, 177 insertions(+), 19 deletions(-) diff --git a/underscore/underscore-tests.ts b/underscore/underscore-tests.ts index 17398a3dd..97aaf0cbf 100644 --- a/underscore/underscore-tests.ts +++ b/underscore/underscore-tests.ts @@ -215,7 +215,6 @@ _.mixin({ return string.charAt(0).toUpperCase() + string.substring(1).toLowerCase(); } }); -_("fabio").capitalize(); _.uniqueId('contact_'); diff --git a/underscore/underscore.d.ts b/underscore/underscore.d.ts index 414c7653b..d0ad26e1b 100644 --- a/underscore/underscore.d.ts +++ b/underscore/underscore.d.ts @@ -3,15 +3,11 @@ // Definitions by: Boris Yankov // Definitions: https://github.com/borisyankov/DefinitelyTyped -declare function _(value): any; +declare function _(value: Array): _; +declare function _(value: T): _; declare module _ { - interface UnderscoreWrappedObject { - value(): any; - filter(arg?): any; - } - interface TemplateSettings { evaluate?: RegExp; interpolate?: RegExp; @@ -81,7 +77,6 @@ declare module _ { export function pluck(list: Collection, propertyName: string): any[]; export function max(list: Collection, iterator?: (x: T) => any, context?: any): T; - export function min(list: Collection, iterator?: (x: T) => any, context?: any): T; export function sortBy(list: List, iterator?: (x: T) => any, context?: any): T[]; @@ -116,18 +111,18 @@ declare module _ { export function take(array: List, n: number): T[]; export function initial(array: List, n?: number): T[]; - + export function last(array: List): T; export function last(array: List, n: number): T[]; - + export function rest(array: List, n?: number): T[]; export function tail(array: List, n?: number): T[]; export function drop(array: List, n?: number): T[]; - + export function compact(array: List): T[]; export function flatten(array: any[], shallow?: boolean): any[]; - + export function without(array: List, ...values: T[]): T[]; export function union(...arrays: List[]): T[]; @@ -138,18 +133,18 @@ declare module _ { export function uniq(array: List, isSorted?: boolean, iterator?: (x: T) => any): T[]; export function unique(array: List, isSorted?: boolean, iterator?: (x: T) => any): T[]; - + export function zip(...arrays: any[]): any[]; export function object(list: any[], values?: any): any; - + export function indexOf(array: List, value: T, isSorted?: boolean): number; export function indexOf(array: List, value: T, startFrom: number): number; export function lastIndexOf(array: List, value: T, fromIndex?: number): number; - + export function sortedIndex(list: List, value: T, iterator?: (x: T) => any, context?: any): number; - + export function range(stop: number): any[]; export function range(start: number, stop: number, step?: number): any[]; @@ -168,7 +163,7 @@ declare module _ { export function after(count: number, func: any): any; export function wrap(func: (...as: any[]) => any, wrapper: any): () => any; export function compose(...functions: any[]): any; - + /**** Objects *****/ @@ -179,10 +174,12 @@ declare module _ { export function functions(object: any): string[]; export function methods(object: any): string[]; export function extend(destination: any, ...sources: any[]): any; + export function pick(object: any, keys: string[]): any; export function pick(object: any, ...keys: string[]): any; + export function omit(object: any, keys: string[]): any; export function omit(object: any, ...keys: string[]): any; export function defaults(object: any, ...defaults: any[]): any; - export function clone(object: any): any; + export function clone(object: T): T; export function tap(object: any, interceptor: (...as: any[]) => any): any; export function has(object: any, key: string): boolean; export function isEqual(object: any, other: any): boolean; @@ -220,7 +217,169 @@ declare module _ { /**** Chaining *****/ - export function chain(object: any): UnderscoreWrappedObject; + export function chain(object): any; +} + +declare class _ { + + each(iterator: _.ListIterator, context?: any): void; + forEach(iterator: _.ListIterator, context?: any): void; + + map(iterator: _.ListIterator, context?: any): TResult[]; + collect(iterator: _.ListIterator, context?: any): TResult[]; + + reduce(iterator: (prev: TResult, curr: T) => TResult, memo: TResult, context?: any): TResult; + inject(iterator: (prev: TResult, curr: T) => TResult, memo: TResult, context?: any): TResult; + + reduceRight(iterator: (prev: TResult, curr: T) => TResult, memo: TResult, context?: any): TResult; + foldr(iterator: (prev: TResult, curr: T) => TResult, memo: TResult, context?: any): TResult; + + find(iterator: (x: T) => boolean, context?: any): T; + detect(iterator: (x: T) => boolean, context?: any): T; + + filter(iterator: (x: T) => boolean, context?: any): T[]; + select(iterator: (x: T) => boolean, context?: any): T[]; + + where(properties: any): T[]; + + reject(iterator: (x: T) => boolean, context?: any): T[]; + + all(iterator: (x: T) => boolean, context?: any): boolean; + every(iterator: (x: T) => boolean, context?: any): boolean; + + any(iterator?: (x: T) => boolean, context?: any): boolean; + some(iterator?: (x: T) => boolean, context?: any): boolean; + + contains(value: T): boolean; + include(value: T): boolean; + + invoke(methodName: string, ...arguments: any[]): any; + + pluck(propertyName: string): any[]; + + max(iterator?: (x: T) => any, context?: any): T; + min(iterator?: (x: T) => any, context?: any): T; + + sortBy(iterator?: (x: T) => any, context?: any): T[]; + sortBy(iterator: string, context?: any): T[]; + + groupBy(iterator?: (x: T) => any, context?: any): _.Dictionary<_.List>; + groupBy(iterator: string, context?: any): _.Dictionary<_.List>; + + countBy(iterator?: (x: T) => any, context?: any): _.Dictionary<_.List>; + countBy(iterator: string, context?: any): _.Dictionary<_.List>; + + shuffle(): T[]; + + toArray(): T[]; + + size(): number; + + /**** + Arrays + *****/ + first(n?: number): T[]; + head(n?: number): T[]; + take(n?: number): T[]; + initial(n?: number): T[]; + last(n?: number): T[]; + rest(n?: number): T[]; + tail(n?: number): T[]; + drop(n?: number): T[]; + + compact(): T[]; + + flatten(shallow?: boolean): any[]; + + without(...values: T[]): T[]; + + union(...arrays: _.List[]): T[]; + + intersection(...arrays: _.List[]): T[]; + + difference(...others: _.List[]): T[]; + + uniq(isSorted?: boolean, iterator?: (x: T) => any): T[]; + unique(isSorted?: boolean, iterator?: (x: T) => any): T[]; + + zip(...arrays: any[]): any[]; + + object(values?: any): any; + + indexOf(value: T, isSorted?: boolean): number; + indexOf(value: T, startFrom: number): number; + + lastIndexOf(value: T, fromIndex?: number): number; + + sortedIndex(value: T, iterator?: (x: T) => any, context?: any): number; + + /**** + Functions + *****/ + bind(func: (...as: any[]) => any, context: any, ...arguments: any[]): () => any; + bindAll(...methodNames: string[]): any; + memoize(hashFunction?: any): any; + defer(); + delay(wait: number, ...arguments: any[]): any; + delay(...arguments: any[]): any; + throttle(wait: number): any; + debounce(wait: number, immediate?: boolean): any; + once(): any; + after(func: any): any; + wrap(wrapper: any): () => any; + compose(...functions: any[]): any; + + /**** + Objects + *****/ + keys(): string[]; + values(): T[]; + pairs(): any[]; + invert(): any; + functions(): string[]; + methods(): string[]; + extend(...sources: any[]): any; + pick(keys: string[]): any; + pick(...keys: string[]): any; + omit(keys: string[]): any; + omit(...keys: string[]): any; + defaults(...defaults: any[]): any; + clone(): T; + tap(interceptor: (...as: any[]) => any): any; + has(key: string): boolean; + isEqual(other: any): boolean; + isEmpty(): boolean; + isElement(): boolean; + isArray(): boolean; + isObject(): boolean; + isArguments(): boolean; + isFunction(): boolean; + isString(): boolean; + isNumber(): boolean; + isFinite(): boolean; + isBoolean(): boolean; + isDate(): boolean; + isRegExp(): boolean; + isNaN(): boolean; + isNull(): boolean; + isUndefined(): boolean; + + /**** + Utility + *****/ + identity(): any; + times(iterator: (index: number) => void , context?: any): void; + random(max: number): number; + mixin(): void; + uniqueId(): string; + escape(): string; + result(property: string): any; + template(data?: any, settings?: any): (...data: any[]) => string; + + /**** + Chaining + *****/ + chain(): any; } declare module "underscore" { From 4d3992f9d2eb22bfba41b7ada22b648fa5b947f1 Mon Sep 17 00:00:00 2001 From: mihailik Date: Tue, 25 Jun 2013 02:02:29 +0200 Subject: [PATCH 29/37] Updated using features in TypeScript v0.9 Previously the module name couldn't match the global function name, so we had to declare module 'CM' and function CodeMirror. Now that TS can handle the naming clash correctly, we will go to the naming convention from CodeMirror docs. Additionally, that allows using constructor for CodeMirror.Doc. Previously because of naming CM.Doc that wouldn't work. Note that CodeMirror itself is not declared as a class, even though their actual implementation does allow 'newing' it internally. However, that is not advertised in the docs, so we assume it is a quirk for some edge case compatibility and leaving it out of the API declarations here. --- codemirror/codemirror.d.ts | 734 ++++++++++++++++++------------------- 1 file changed, 366 insertions(+), 368 deletions(-) diff --git a/codemirror/codemirror.d.ts b/codemirror/codemirror.d.ts index 5915758ba..9a3db7147 100644 --- a/codemirror/codemirror.d.ts +++ b/codemirror/codemirror.d.ts @@ -1,161 +1,159 @@ -declare var CodeMirror: CM.Static; +declare function CodeMirror(host: HTMLElement, options?: CodeMirror.EditorConfiguration): CodeMirror.Editor; +declare function CodeMirror(callback: (host: HTMLElement) => void , options?: CodeMirror.EditorConfiguration): CodeMirror.Editor; -declare module CM { - interface Static { - (host: HTMLElement, options?: Options.EditorConfiguration): Editor; - (callback: (host: HTMLElement) => void , options?: Options.EditorConfiguration): Editor; +declare module CodeMirror { + export var Pass: any; - fromTextArea(host: HTMLTextAreaElement, options?: Options.EditorConfiguration): Editor; + function fromTextArea(host: HTMLTextAreaElement, options?: EditorConfiguration): CodeMirror.Editor; - version: string; + var version: string; - /** If you want to define extra methods in terms of the CodeMirror API, it is possible to use defineExtension. - This will cause the given value(usually a method) to be added to all CodeMirror instances created from then on. */ - defineExtension(name: string, value: any); + /** If you want to define extra methods in terms of the CodeMirror API, it is possible to use defineExtension. + This will cause the given value(usually a method) to be added to all CodeMirror instances created from then on. */ + function defineExtension(name: string, value: any); - /** Like defineExtension, but the method will be added to the interface for Doc objects instead. */ - defineDocExtension(name: string, value: any); + /** Like defineExtension, but the method will be added to the interface for Doc objects instead. */ + function defineDocExtension(name: string, value: any); - /** Similarly, defineOption can be used to define new options for CodeMirror. - The updateFunc will be called with the editor instance and the new value when an editor is initialized, - and whenever the option is modified through setOption. */ - defineOption(name: string, default_: any, updateFunc: Function); + /** Similarly, defineOption can be used to define new options for CodeMirror. + The updateFunc will be called with the editor instance and the new value when an editor is initialized, + and whenever the option is modified through setOption. */ + function defineOption(name: string, default_: any, updateFunc: Function); - /** If your extention just needs to run some code whenever a CodeMirror instance is initialized, use CodeMirror.defineInitHook. - Give it a function as its only argument, and from then on, that function will be called (with the instance as argument) - whenever a new CodeMirror instance is initialized. */ - defineInitHook(func: Function); + /** If your extention just needs to run some code whenever a CodeMirror instance is initialized, use CodeMirror.defineInitHook. + Give it a function as its only argument, and from then on, that function will be called (with the instance as argument) + whenever a new CodeMirror instance is initialized. */ + function defineInitHook(func: Function); - on(element: any, eventName: string, handler: Function); - off(element: any, eventName: string, handler: Function); + function on(element: any, eventName: string, handler: Function); + function off(element: any, eventName: string, handler: Function); - /** Fired whenever a change occurs to the document. changeObj has a similar type as the object passed to the editor's "change" event, - but it never has a next property, because document change events are not batched (whereas editor change events are). */ - on(doc: Doc, eventName: 'change', handler: (instance: Doc, change: EditorChange) => void ); - off(doc: Doc, eventName: 'change', handler: (instance: Doc, change: EditorChange) => void ); + /** Fired whenever a change occurs to the document. changeObj has a similar type as the object passed to the editor's "change" event, + but it never has a next property, because document change events are not batched (whereas editor change events are). */ + function on(doc: Doc, eventName: 'change', handler: (instance: Doc, change: EditorChange) => void ); + function off(doc: Doc, eventName: 'change', handler: (instance: Doc, change: EditorChange) => void ); - /** See the description of the same event on editor instances. */ - on(doc: Doc, eventName: 'beforeChange', handler: (instance: Doc, change: EditorChangeCancellable) => void ); - off(doc: Doc, eventName: 'beforeChange', handler: (instance: Doc, change: EditorChangeCancellable) => void ); + /** See the description of the same event on editor instances. */ + function on(doc: Doc, eventName: 'beforeChange', handler: (instance: Doc, change: EditorChangeCancellable) => void ); + function off(doc: Doc, eventName: 'beforeChange', handler: (instance: Doc, change: EditorChangeCancellable) => void ); - /** Fired whenever the cursor or selection in this document changes. */ - on(doc: Doc, eventName: 'cursorActivity', handler: (instance: Editor) => void ); - off(doc: Doc, eventName: 'cursorActivity', handler: (instance: Editor) => void ); + /** Fired whenever the cursor or selection in this document changes. */ + function on(doc: Doc, eventName: 'cursorActivity', handler: (instance: CodeMirror.Editor) => void ); + function off(doc: Doc, eventName: 'cursorActivity', handler: (instance: CodeMirror.Editor) => void ); - /** Equivalent to the event by the same name as fired on editor instances. */ - on(doc: Doc, eventName: 'beforeSelectionChange', handler: (instance: Editor, selection: { head: Position; anchor: Position; }) => void ); - off(doc: Doc, eventName: 'beforeSelectionChange', handler: (instance: Editor, selection: { head: Position; anchor: Position; }) => void ); + /** Equivalent to the event by the same name as fired on editor instances. */ + function on(doc: Doc, eventName: 'beforeSelectionChange', handler: (instance: CodeMirror.Editor, selection: { head: Position; anchor: Position; }) => void ); + function off(doc: Doc, eventName: 'beforeSelectionChange', handler: (instance: CodeMirror.Editor, selection: { head: Position; anchor: Position; }) => void ); - /** Will be fired when the line object is deleted. A line object is associated with the start of the line. - Mostly useful when you need to find out when your gutter markers on a given line are removed. */ - on(line: LineHandle, eventName: 'delete', handler: () => void ); - off(line: LineHandle, eventName: 'delete', handler: () => void ); + /** Will be fired when the line object is deleted. A line object is associated with the start of the line. + Mostly useful when you need to find out when your gutter markers on a given line are removed. */ + function on(line: LineHandle, eventName: 'delete', handler: () => void ); + function off(line: LineHandle, eventName: 'delete', handler: () => void ); - /** Fires when the line's text content is changed in any way (but the line is not deleted outright). - The change object is similar to the one passed to change event on the editor object. */ - on(line: LineHandle, eventName: 'change', handler: (line: LineHandle, change: EditorChange) => void ); - off(line: LineHandle, eventName: 'change', handler: (line: LineHandle, change: EditorChange) => void ); + /** Fires when the line's text content is changed in any way (but the line is not deleted outright). + The change object is similar to the one passed to change event on the editor object. */ + function on(line: LineHandle, eventName: 'change', handler: (line: LineHandle, change: EditorChange) => void ); + function off(line: LineHandle, eventName: 'change', handler: (line: LineHandle, change: EditorChange) => void ); - /** Fired when the cursor enters the marked range. From this event handler, the editor state may be inspected but not modified, - with the exception that the range on which the event fires may be cleared. */ - on(marker: TextMarker, eventName: 'beforeCursorEnter', handler: () => void ); - off(marker: TextMarker, eventName: 'beforeCursorEnter', handler: () => void ); + /** Fired when the cursor enters the marked range. From this event handler, the editor state may be inspected but not modified, + with the exception that the range on which the event fires may be cleared. */ + function on(marker: TextMarker, eventName: 'beforeCursorEnter', handler: () => void ); + function off(marker: TextMarker, eventName: 'beforeCursorEnter', handler: () => void ); - /** Fired when the range is cleared, either through cursor movement in combination with clearOnEnter or through a call to its clear() method. - Will only be fired once per handle. Note that deleting the range through text editing does not fire this event, - because an undo action might bring the range back into existence. */ - on(marker: TextMarker, eventName: 'clear', handler: () => void ); - off(marker: TextMarker, eventName: 'clear', handler: () => void ); + /** Fired when the range is cleared, either through cursor movement in combination with clearOnEnter or through a call to its clear() method. + Will only be fired once per handle. Note that deleting the range through text editing does not fire this event, + because an undo action might bring the range back into existence. */ + function on(marker: TextMarker, eventName: 'clear', handler: () => void ); + function off(marker: TextMarker, eventName: 'clear', handler: () => void ); - /** Fired when the last part of the marker is removed from the document by editing operations. */ - on(marker: TextMarker, eventName: 'hide', handler: () => void ); - off(marker: TextMarker, eventName: 'hide', handler: () => void ); + /** Fired when the last part of the marker is removed from the document by editing operations. */ + function on(marker: TextMarker, eventName: 'hide', handler: () => void ); + function off(marker: TextMarker, eventName: 'hide', handler: () => void ); - /** Fired when, after the marker was removed by editing, a undo operation brought the marker back. */ - on(marker: TextMarker, eventName: 'unhide', handler: () => void ); - off(marker: TextMarker, eventName: 'unhide', handler: () => void ); + /** Fired when, after the marker was removed by editing, a undo operation brought the marker back. */ + function on(marker: TextMarker, eventName: 'unhide', handler: () => void ); + function off(marker: TextMarker, eventName: 'unhide', handler: () => void ); - /** Fired whenever the editor re-adds the widget to the DOM. This will happen once right after the widget is added (if it is scrolled into view), - and then again whenever it is scrolled out of view and back in again, or when changes to the editor options - or the line the widget is on require the widget to be redrawn. */ - on(line: LineWidget, eventName: 'redraw', handler: () => void ); - off(line: LineWidget, eventName: 'redraw', handler: () => void ); - } + /** Fired whenever the editor re-adds the widget to the DOM. This will happen once right after the widget is added (if it is scrolled into view), + and then again whenever it is scrolled out of view and back in again, or when changes to the editor options + or the line the widget is on require the widget to be redrawn. */ + function on(line: LineWidget, eventName: 'redraw', handler: () => void ); + function off(line: LineWidget, eventName: 'redraw', handler: () => void ); interface Editor { - + /** Tells you whether the editor currently has focus. */ hasFocus(): boolean; - + /** Used to find the target position for horizontal cursor motion.start is a { line , ch } object, amount an integer(may be negative), and unit one of the string "char", "column", or "word". Will return a position that is produced by moving amount times the distance specified by unit. When visually is true , motion in right - to - left text will be visual rather than logical. When the motion was clipped by hitting the end or start of the document, the returned value will have a hitSide property set to true. */ - findPosH(start: Position, amount: number, unit: string, visually: boolean): { line: number; ch: number; hitSide?: boolean; }; - + findPosH(start: CodeMirror.Position, amount: number, unit: string, visually: boolean): { line: number; ch: number; hitSide?: boolean; }; + /** Similar to findPosH , but used for vertical motion.unit may be "line" or "page". The other arguments and the returned value have the same interpretation as they have in findPosH. */ - findPosV(start: Position, amount: number, unit: string): { line: number; ch: number; hitSide?: boolean; }; - - + findPosV(start: CodeMirror.Position, amount: number, unit: string): { line: number; ch: number; hitSide?: boolean; }; + + /** Change the configuration of the editor. option should the name of an option, and value should be a valid value for that option. */ setOption(option: string, value: any); - + /** Retrieves the current value of the given option for this editor instance. */ getOption(option: string): any; - + /** Attach an additional keymap to the editor. This is mostly useful for add - ons that need to register some key handlers without trampling on the extraKeys option. Maps added in this way have a higher precedence than the extraKeys and keyMap options, and between them, the maps added earlier have a lower precedence than those added later, unless the bottom argument was passed, in which case they end up below other keymaps added with this method. */ - addKeyMap(map: any, bottom: boolean); - + addKeyMap(map: any, bottom?: boolean); + /** Disable a keymap added with addKeyMap.Either pass in the keymap object itself , or a string, which will be compared against the name property of the active keymaps. */ removeKeyMap(map: any); - + /** Enable a highlighting overlay.This is a stateless mini - mode that can be used to add extra highlighting. For example, the search add - on uses it to highlight the term that's currently being searched. mode can be a mode spec or a mode object (an object with a token method). The options parameter is optional. If given, it should be an object. Currently, only the opaque option is recognized. This defaults to off, but can be given to allow the overlay styling, when not null, to override the styling of the base mode entirely, instead of the two being applied together. */ addOverlay(mode: any, options?: any); - + /** Pass this the exact argument passed for the mode parameter to addOverlay to remove an overlay again. */ removeOverlay(mode: any); - - + + /** Retrieve the currently active document from an editor. */ - getDoc(): Doc; - - /** Attach a new document to the editor.Returns the old document , which is now no longer associated with an editor. */ - swapDoc(doc: Doc): Doc; - - - + getDoc(): CodeMirror.Doc; + + /** Attach a new document to the editor. Returns the old document, which is now no longer associated with an editor. */ + swapDoc(doc: CodeMirror.Doc): CodeMirror.Doc; + + + /** Sets the gutter marker for the given gutter (identified by its CSS class, see the gutters option) to the given value. Value can be either null, to clear the marker, or a DOM element, to set it. The DOM element will be shown in the specified gutter next to the specified line. */ - setGutterMarker(line: any, gutterID: string, value: HTMLElement): LineHandle; - + setGutterMarker(line: any, gutterID: string, value: HTMLElement): CodeMirror.LineHandle; + /** Remove all gutter markers in the gutter with the given ID. */ clearGutter(gutterID: string); - + /** Set a CSS class name for the given line.line can be a number or a line handle. where determines to which element this class should be applied, can can be one of "text" (the text element, which lies in front of the selection), "background"(a background element that will be behind the selection), or "wrap" (the wrapper node that wraps all of the line's elements, including gutter elements). class should be the name of the class to apply. */ - addLineClass(line: any, where: string, _class_: string): LineHandle; - + addLineClass(line: any, where: string, _class_: string): CodeMirror.LineHandle; + /** Remove a CSS class from a line.line can be a line handle or number. where should be one of "text", "background", or "wrap"(see addLineClass). class can be left off to remove all classes for the specified node, or be a string to remove only a specific class. */ - removeLineClass(line: any, where: string, class_: string): LineHandle; - + removeLineClass(line: any, where: string, class_: string): CodeMirror.LineHandle; + /** Returns the line number, text content, and marker status of the given line, which can be either a number or a line handle. */ lineInfo(line: any): { line: any; @@ -169,12 +167,12 @@ declare module CM { /** Array of line widgets attached to this line. */ widgets: any; }; - + /** Puts node, which should be an absolutely positioned DOM node, into the editor, positioned right below the given { line , ch } position. When scrollIntoView is true, the editor will ensure that the entire node is visible (if possible). To remove the widget again, simply use DOM methods (move it somewhere else, or call removeChild on its parent). */ - addWidget(pos: Position, node: HTMLElement, scrollIntoView: boolean); - + addWidget(pos: CodeMirror.Position, node: HTMLElement, scrollIntoView: boolean); + /** Adds a line widget, an element shown below a line, spanning the whole of the editor's width, and moving the lines below it downwards. line should be either an integer or a line handle, and node should be a DOM node, which will be displayed below the given line. options, when given, should be an object that configures the behavior of the widget. @@ -188,17 +186,17 @@ declare module CM { above: boolean; /** When true, will cause the widget to be rendered even if the line it is associated with is hidden. */ showIfHidden: boolean; - }): LineWidget; - - + }): CodeMirror.LineWidget; + + /** Programatically set the size of the editor (overriding the applicable CSS rules). width and height height can be either numbers(interpreted as pixels) or CSS units ("100%", for example). You can pass null for either of them to indicate that that dimension should not be changed. */ setSize(width: any, height: any); - + /** Scroll the editor to a given(pixel) position.Both arguments may be left as null or undefined to have no effect. */ scrollTo(x: number, y: number); - + /** Get an { left , top , width , height , clientWidth , clientHeight } object that represents the current scroll position, the size of the scrollable area, and the size of the visible area(minus scrollbars). */ getScrollInfo(): { @@ -209,55 +207,55 @@ declare module CM { clientWidth: any; clientHeight: any; } - + /** Scrolls the given element into view. pos is a { line , ch } position, referring to a given character, null, to refer to the cursor. The margin parameter is optional. When given, it indicates the amount of pixels around the given area that should be made visible as well. */ - scrollIntoView(pos: Position, margin?: number); - + scrollIntoView(pos: CodeMirror.Position, margin?: number); + /** Scrolls the given element into view. pos is a { left , top , right , bottom } object, in editor-local coordinates. The margin parameter is optional. When given, it indicates the amount of pixels around the given area that should be made visible as well. */ scrollIntoView(pos: { left: number; top: number; right: number; bottom: number; }, margin: number); - + /** Returns an { left , top , bottom } object containing the coordinates of the cursor position. If mode is "local" , they will be relative to the top-left corner of the editable document. If it is "page" or not given, they are relative to the top-left corner of the page. where is a boolean indicating whether you want the start(true) or the end(false) of the selection. */ cursorCoords(where: boolean, mode: string): { left: number; top: number; bottom: number; }; - + /** Returns an { left , top , bottom } object containing the coordinates of the cursor position. If mode is "local" , they will be relative to the top-left corner of the editable document. If it is "page" or not given, they are relative to the top-left corner of the page. where specifies the precise position at which you want to measure. */ - cursorCoords(where: Position, mode: string): { left: number; top: number; bottom: number; }; - + cursorCoords(where: CodeMirror.Position, mode: string): { left: number; top: number; bottom: number; }; + /** Returns the position and dimensions of an arbitrary character.pos should be a { line , ch } object. This differs from cursorCoords in that it'll give the size of the whole character, rather than just the position that the cursor would have when it would sit at that position. */ - charCoords(pos: Position, mode: string): { left: number; right: number; top: number; bottom: number; }; - + charCoords(pos: CodeMirror.Position, mode: string): { left: number; right: number; top: number; bottom: number; }; + /** Given an { left , top } object , returns the { line , ch } position that corresponds to it. The optional mode parameter determines relative to what the coordinates are interpreted. It may be "window" , "page"(the default) , or "local". */ - coordsChar(object: { left: number; top: number; }, mode?: string): Position; - + coordsChar(object: { left: number; top: number; }, mode?: string): CodeMirror.Position; + /** Returns the line height of the default font for the editor. */ defaultTextHeight(): number; - + /** Returns the pixel width of an 'x' in the default font for the editor. (Note that for non - monospace fonts , this is mostly useless, and even for monospace fonts, non - ascii characters might have a different width). */ defaultCharWidth(): number; - + /** Returns a { from , to } object indicating the start (inclusive) and end (exclusive) of the currently rendered part of the document. In big documents, when most content is scrolled out of view, CodeMirror will only render the visible part, and a margin around it. See also the viewportChange event. */ getViewport(): { from: number; to: number }; - + /** If your code does something to change the size of the editor element (window resizes are already listened for), or unhides it, you should probably follow up by calling this method to ensure CodeMirror is still looking as intended. */ refresh(); - - + + /** Retrieves information about the token the current mode found before the given position (a {line, ch} object). */ - getTokenAt(pos: Position): { + getTokenAt(pos: CodeMirror.Position): { /** The character(on the given line) at which the token starts. */ start: number; /** The character at which the token ends. */ @@ -269,18 +267,18 @@ declare module CM { /** The mode's state at the end of this token. */ state: any; }; - + /** Returns the mode's parser state, if any, at the end of the given line number. If no line number is given, the state at the end of the document is returned. This can be useful for storing parsing errors in the state, or getting other kinds of contextual information for a line. */ getStateAfter(line?: number): any; - + /** CodeMirror internally buffers changes and only updates its DOM structure after it has finished performing some operation. If you need to perform a lot of operations on a CodeMirror instance, you can call this method with a function argument. It will call the function, buffering up all changes, and only doing the expensive update after the function returns. This can be a lot faster. The return value from this method will be the return value of your function. */ operation(fn: ()=> T): T; - + /** Adjust the indentation of the given line. The second argument (which defaults to "smart") may be one of: "prev" Base indentation on the indentation of the previous line. @@ -288,86 +286,88 @@ declare module CM { "add" Increase the indentation of the line by one indent unit. "subtract" Reduce the indentation of the line. */ indentLine(line: number, dir?: string); - - + + /** Give the editor focus. */ focus(); - + /** Returns the hidden textarea used to read input. */ getInputField(): HTMLTextAreaElement; - + /** Returns the DOM node that represents the editor, and controls its size. Remove this from your tree to delete an editor instance. */ getWrapperElement(): HTMLElement; - + /** Returns the DOM node that is responsible for the scrolling of the editor. */ getScrollerElement(): HTMLElement; - + /** Fetches the DOM node that contains the editor gutters. */ getGutterElement(): HTMLElement; - - - + + + /** Events are registered with the on method (and removed with the off method). These are the events that fire on the instance object. The name of the event is followed by the arguments that will be passed to the handler. The instance argument always refers to the editor instance. */ - on(eventName: string, handler: (instance: Editor) => void ); - off(eventName: string, handler: (instance: Editor) => void ); - + on(eventName: string, handler: (instance: CodeMirror.Editor) => void ); + off(eventName: string, handler: (instance: CodeMirror.Editor) => void ); + /** Fires every time the content of the editor is changed. */ - on(eventName: 'change', handler: (instance: Editor, change: EditorChangeLinkedList) => void ); - off(eventName: 'change', handler: (instance: Editor, change: EditorChangeLinkedList) => void ); - + on(eventName: 'change', handler: (instance: CodeMirror.Editor, change: CodeMirror.EditorChangeLinkedList) => void ); + off(eventName: 'change', handler: (instance: CodeMirror.Editor, change: CodeMirror.EditorChangeLinkedList) => void ); + /** This event is fired before a change is applied, and its handler may choose to modify or cancel the change. The changeObj never has a next property, since this is fired for each individual change, and not batched per operation. Note: you may not do anything from a "beforeChange" handler that would cause changes to the document or its visualization. Doing so will, since this handler is called directly from the bowels of the CodeMirror implementation, probably cause the editor to become corrupted. */ - on(eventName: 'beforeChange', handler: (instance: Editor, change: EditorChangeCancellable) => void ); - off(eventName: 'beforeChange', handler: (instance: Editor, change: EditorChangeCancellable) => void ); - + on(eventName: 'beforeChange', handler: (instance: CodeMirror.Editor, change: CodeMirror.EditorChangeCancellable) => void ); + off(eventName: 'beforeChange', handler: (instance: CodeMirror.Editor, change: CodeMirror.EditorChangeCancellable) => void ); + /** Will be fired when the cursor or selection moves, or any change is made to the editor content. */ - on(eventName: 'cursorActivity', handler: (instance: Editor) => void ); - off(eventName: 'cursorActivity', handler: (instance: Editor) => void ); - + on(eventName: 'cursorActivity', handler: (instance: CodeMirror.Editor) => void ); + off(eventName: 'cursorActivity', handler: (instance: CodeMirror.Editor) => void ); + /** This event is fired before the selection is moved. Its handler may modify the resulting selection head and anchor. - Handlers for this event have the same restriction as "beforeChange" handlers — they should not do anything to directly update the state of the editor. */ - on(eventName: 'beforeSelectionChange', handler: (instance: Editor, selection: { head: Position; anchor: Position; }) => void ); - off(eventName: 'beforeSelectionChange', handler: (instance: Editor, selection: { head: Position; anchor: Position; }) => void ); - + Handlers for this event have the same restriction as "beforeChange" handlers � they should not do anything to directly update the state of the editor. */ + on(eventName: 'beforeSelectionChange', handler: (instance: CodeMirror.Editor, selection: { head: CodeMirror.Position; anchor: CodeMirror.Position; }) => void ); + off(eventName: 'beforeSelectionChange', handler: (instance: CodeMirror.Editor, selection: { head: CodeMirror.Position; anchor: CodeMirror.Position; }) => void ); + /** Fires whenever the view port of the editor changes (due to scrolling, editing, or any other factor). The from and to arguments give the new start and end of the viewport. */ - on(eventName: 'viewportChange', handler: (instance: Editor, from: number, to: number) => void ); - off(eventName: 'viewportChange', handler: (instance: Editor, from: number, to: number) => void ); - + on(eventName: 'viewportChange', handler: (instance: CodeMirror.Editor, from: number, to: number) => void ); + off(eventName: 'viewportChange', handler: (instance: CodeMirror.Editor, from: number, to: number) => void ); + /** Fires when the editor gutter (the line-number area) is clicked. Will pass the editor instance as first argument, the (zero-based) number of the line that was clicked as second argument, the CSS class of the gutter that was clicked as third argument, and the raw mousedown event object as fourth argument. */ - on(eventName: 'gutterClick', handler: (instance: Editor, line: number, gutter: string, clickEvent: Event) => void ); - off(eventName: 'gutterClick', handler: (instance: Editor, line: number, gutter: string, clickEvent: Event) => void ); - + on(eventName: 'gutterClick', handler: (instance: CodeMirror.Editor, line: number, gutter: string, clickEvent: Event) => void ); + off(eventName: 'gutterClick', handler: (instance: CodeMirror.Editor, line: number, gutter: string, clickEvent: Event) => void ); + /** Fires whenever the editor is focused. */ - on(eventName: 'focus', handler: (instance: Editor) => void ); - off(eventName: 'focus', handler: (instance: Editor) => void ); - + on(eventName: 'focus', handler: (instance: CodeMirror.Editor) => void ); + off(eventName: 'focus', handler: (instance: CodeMirror.Editor) => void ); + /** Fires whenever the editor is unfocused. */ - on(eventName: 'blur', handler: (instance: Editor) => void ); - off(eventName: 'blur', handler: (instance: Editor) => void ); - + on(eventName: 'blur', handler: (instance: CodeMirror.Editor) => void ); + off(eventName: 'blur', handler: (instance: CodeMirror.Editor) => void ); + /** Fires when the editor is scrolled. */ - on(eventName: 'scroll', handler: (instance: Editor) => void ); - off(eventName: 'scroll', handler: (instance: Editor) => void ); - + on(eventName: 'scroll', handler: (instance: CodeMirror.Editor) => void ); + off(eventName: 'scroll', handler: (instance: CodeMirror.Editor) => void ); + /** Will be fired whenever CodeMirror updates its DOM display. */ - on(eventName: 'update', handler: (instance: Editor) => void ); - off(eventName: 'update', handler: (instance: Editor) => void ); - + on(eventName: 'update', handler: (instance: CodeMirror.Editor) => void ); + off(eventName: 'update', handler: (instance: CodeMirror.Editor) => void ); + /** Fired whenever a line is (re-)rendered to the DOM. Fired right after the DOM element is built, before it is added to the document. The handler may mess with the style of the resulting element, or add event handlers, but should not try to change the state of the editor. */ - on(eventName: 'renderLine', handler: (instance: Editor, line: number, element: HTMLElement) => void ); - off(eventName: 'renderLine', handler: (instance: Editor, line: number, element: HTMLElement) => void ); + on(eventName: 'renderLine', handler: (instance: CodeMirror.Editor, line: number, element: HTMLElement) => void ); + off(eventName: 'renderLine', handler: (instance: CodeMirror.Editor, line: number, element: HTMLElement) => void ); } - interface Doc { + class Doc { + constructor (text: string, mode?: any, firstLineNumber?: number); + /** Get the current editor content. You can pass it an optional argument to specify the string to be used to separate lines (defaults to "\n"). */ getValue(seperator?: string): string; @@ -376,11 +376,11 @@ declare module CM { /** Get the text between the given points in the editor, which should be {line, ch} objects. An optional third argument can be given to indicate the line separator string to use (defaults to "\n"). */ - getRange(from: Position, to: Position, seperator?: string): string; + getRange(from: Position, to: CodeMirror.Position, seperator?: string): string; /** Replace the part of the document between from and to with the given string. from and to must be {line, ch} objects. to can be left off to simply insert the string at position from. */ - replaceRange(replacement: string, from: Position, to: Position); + replaceRange(replacement: string, from: CodeMirror.Position, to: CodeMirror.Position); /** Get the content of line n. */ getLine(n: number): string; @@ -402,20 +402,20 @@ declare module CM { lastLine(): number; /** Fetches the line handle for the given line number. */ - getLineHandle(num: number): LineHandle; + getLineHandle(num: number): CodeMirror.LineHandle; /** Given a line handle, returns the current position of that line (or null when it is no longer in the document). */ - getLineNumber(handle: LineHandle): number; + getLineNumber(handle: CodeMirror.LineHandle): number; /** Iterate over the whole document, and call f for each line, passing the line handle. This is a faster way to visit a range of line handlers than calling getLineHandle for each of them. Note that line handles have a text property containing the line's content (as a string). */ - eachLine(f: (line: LineHandle) => void ); + eachLine(f: (line: CodeMirror.LineHandle) => void ); /** Iterate over the range from start up to (not including) end, and call f for each line, passing the line handle. This is a faster way to visit a range of line handlers than calling getLineHandle for each of them. Note that line handles have a text property containing the line's content (as a string). */ - eachLine(start: number, end: number, f: (line: LineHandle) => void ); + eachLine(start: number, end: number, f: (line: CodeMirror.LineHandle) => void ); /** Set the editor content as 'clean', a flag that it will retain until it is edited, and which will be set again when such an edit is undone again. Useful to track whether the content needs to be saved. */ @@ -430,28 +430,28 @@ declare module CM { getSelection(): string; /** Replace the selection with the given string. By default, the new selection will span the inserted text. - The optional collapse argument can be used to change this — passing "start" or "end" will collapse the selection to the start or end of the inserted text. */ + The optional collapse argument can be used to change this � passing "start" or "end" will collapse the selection to the start or end of the inserted text. */ replaceSelection(replacement: string, collapse?: string) /** start is a an optional string indicating which end of the selection to return. It may be "start" , "end" , "head"(the side of the selection that moves when you press shift + arrow), or "anchor"(the fixed side of the selection).Omitting the argument is the same as passing "head".A { line , ch } object will be returned. */ - getCursor(start?: string): Position; + getCursor(start?: string): CodeMirror.Position; /** Return true if any text is selected. */ somethingSelected(): boolean; /** Set the cursor position.You can either pass a single { line , ch } object , or the line and the character as two separate parameters. */ - setCursor(pos: Position); + setCursor(pos: CodeMirror.Position); /** Set the selection range.anchor and head should be { line , ch } objects.head defaults to anchor when not given. */ - setSelection(anchor: Position, head: Position); + setSelection(anchor: CodeMirror.Position, head: CodeMirror.Position); /** Similar to setSelection , but will, if shift is held or the extending flag is set, move the head of the selection while leaving the anchor at its current place. pos2 is optional , and can be passed to ensure a region (for example a word or paragraph) will end up selected (in addition to whatever lies between that region and the current anchor). */ - extendSelection(from: Position, to?: Position); + extendSelection(from: CodeMirror.Position, to?: CodeMirror.Position); /** Sets or clears the 'extending' flag , which acts similar to the shift key, in that it will cause cursor movement and calls to extendSelection to leave the selection anchor in place. */ @@ -459,11 +459,11 @@ declare module CM { /** Retrieve the editor associated with a document. May return null. */ - getEditor(): Editor; + getEditor(): CodeMirror.Editor; /** Create an identical copy of the given doc. When copyHistory is true , the history will also be copied.Can not be called directly on an editor. */ - copy(copyHistory: boolean): Doc; + copy(copyHistory: boolean): CodeMirror.Doc; /** Create a new document that's linked to the target document. Linked documents will stay in sync (changes to one are also applied to the other) until unlinked. */ linkedDoc(options: { @@ -477,15 +477,15 @@ declare module CM { to?: number; /** By default, the new document inherits the mode of the parent. This option can be set to a mode spec to give it a different mode. */ mode: any; - }): Doc; + }): CodeMirror.Doc; /** Break the link between two documents. After calling this , changes will no longer propagate between the documents, and, if they had a shared history, the history will become separate. */ - unlinkDoc(doc: Doc); + unlinkDoc(doc: CodeMirror.Doc); /** Will call the given function for all documents linked to the target document. It will be passed two arguments, the linked document and a boolean indicating whether that document shares history with the target. */ - iterLinkedDocs(fn: (doc: Doc, sharedHist: boolean) => void ); + iterLinkedDocs(fn: (doc: CodeMirror.Doc, sharedHist: boolean) => void ); /** Undo one edit (if any undo events are stored). */ undo(); @@ -508,25 +508,25 @@ declare module CM { /** Can be used to mark a range of text with a specific CSS class name. from and to should be { line , ch } objects. */ - markText(from: Position, to: Position, options?: Options.TextMarkerOptions): TextMarker; + markText(from: CodeMirror.Position, to: CodeMirror.Position, options?: CodeMirror.TextMarkerOptions): TextMarker; /** Inserts a bookmark, a handle that follows the text around it as it is being edited, at the given position. A bookmark has two methods find() and clear(). The first returns the current position of the bookmark, if it is still in the document, and the second explicitly removes the bookmark. */ - setBookmark(pos: Position, options?: { + setBookmark(pos: CodeMirror.Position, options?: { /** Can be used to display a DOM node at the current location of the bookmark (analogous to the replacedWith option to markText). */ widget?: HTMLElement; /** By default, text typed when the cursor is on top of the bookmark will end up to the right of the bookmark. Set this option to true to make it go to the left instead. */ insertLeft?: boolean; - }): TextMarker; + }): CodeMirror.TextMarker; /** Returns an array of all the bookmarks and marked ranges present at the given position. */ - findMarksAt(pos: Position): TextMarker[]; + findMarksAt(pos: CodeMirror.Position): TextMarker[]; /** Returns an array containing all marked ranges in the document. */ - getAllMarks(): TextMarker[]; + getAllMarks(): CodeMirror.TextMarker[]; /** Gets the mode object for the editor. Note that this is distinct from getOption("mode"), which gives you the mode specification, @@ -535,15 +535,15 @@ declare module CM { /** Calculates and returns a { line , ch } object for a zero-based index whose value is relative to the start of the editor's text. If the index is out of range of the text then the returned object is clipped to start or end of the text respectively. */ - posFromIndex(index: number): Position; + posFromIndex(index: number): CodeMirror.Position; /** The reverse of posFromIndex. */ - indexFromPos(object: Position): number; + indexFromPos(object: CodeMirror.Position): number; } interface LineHandle { - vvvvv: number; + text: string; } interface TextMarker { @@ -552,10 +552,10 @@ declare module CM { /** Returns a {from, to} object (both holding document positions), indicating the current position of the marked range, or undefined if the marker is no longer in the document. */ - find(): Position; + find(): CodeMirror.Position; /** Returns an object representing the options for the marker. If copyWidget is given true, it will clone the value of the replacedWith option, if any. */ - getOptions(copyWidget: boolean): Options.TextMarkerOptions; + getOptions(copyWidget: boolean): CodeMirror.TextMarkerOptions; } interface LineWidget { @@ -569,23 +569,23 @@ declare module CM { interface EditorChange { /** Position (in the pre-change coordinate system) where the change started. */ - from: Position; + from: CodeMirror.Position; /** Position (in the pre-change coordinate system) where the change ended. */ - to: Position; + to: CodeMirror.Position; /** Array of strings representing the text that replaced the changed range (split by line). */ text: string[]; /** Text that used to be between from and to, which is overwritten by this change. */ removed: string; } - interface EditorChangeLinkedList extends EditorChange { + interface EditorChangeLinkedList extends CodeMirror.EditorChange { /** Points to another change object (which may point to another, etc). */ - next?: EditorChangeLinkedList; + next?: CodeMirror.EditorChangeLinkedList; } - interface EditorChangeCancellable extends EditorChange { + interface EditorChangeCancellable extends CodeMirror.EditorChange { /** may be used to modify the change. All three arguments to update are optional, and can be left off to leave the existing value for that field intact. */ - update(from?: Position, to?: Position, text?: string); + update(from?: CodeMirror.Position, to?: CodeMirror.Position, text?: string); cancel(); } @@ -595,195 +595,193 @@ declare module CM { line: number; } - module Options { - interface EditorConfiguration { - /** string| The starting value of the editor. Can be a string, or a document object. */ - value?: any; + interface EditorConfiguration { + /** string| The starting value of the editor. Can be a string, or a document object. */ + value?: any; - /** string|object. The mode to use. When not given, this will default to the first mode that was loaded. - It may be a string, which either simply names the mode or is a MIME type associated with the mode. - Alternatively, it may be an object containing configuration options for the mode, - with a name property that names the mode (for example {name: "javascript", json: true}). */ - mode?: any; + /** string|object. The mode to use. When not given, this will default to the first mode that was loaded. + It may be a string, which either simply names the mode or is a MIME type associated with the mode. + Alternatively, it may be an object containing configuration options for the mode, + with a name property that names the mode (for example {name: "javascript", json: true}). */ + mode?: any; - /** The theme to style the editor with. You must make sure the CSS file defining the corresponding .cm-s-[name] styles is loaded. - The default is "default". */ - theme?: string; + /** The theme to style the editor with. You must make sure the CSS file defining the corresponding .cm-s-[name] styles is loaded. + The default is "default". */ + theme?: string; - /** How many spaces a block (whatever that means in the edited language) should be indented. The default is 2. */ - indentUnit?: number; + /** How many spaces a block (whatever that means in the edited language) should be indented. The default is 2. */ + indentUnit?: number; - /** Whether to use the context-sensitive indentation that the mode provides (or just indent the same as the line before). Defaults to true. */ - smartIndent?: boolean; + /** Whether to use the context-sensitive indentation that the mode provides (or just indent the same as the line before). Defaults to true. */ + smartIndent?: boolean; - /** The width of a tab character. Defaults to 4. */ - tabSize?: number; + /** The width of a tab character. Defaults to 4. */ + tabSize?: number; - /** Whether, when indenting, the first N*tabSize spaces should be replaced by N tabs. Default is false. */ - indentWithTabs?: boolean; + /** Whether, when indenting, the first N*tabSize spaces should be replaced by N tabs. Default is false. */ + indentWithTabs?: boolean; - /** Configures whether the editor should re-indent the current line when a character is typed - that might change its proper indentation (only works if the mode supports indentation). Default is true. */ - electricChars?: boolean; - - /** Determines whether horizontal cursor movement through right-to-left (Arabic, Hebrew) text - is visual (pressing the left arrow moves the cursor left) - or logical (pressing the left arrow moves to the next lower index in the string, which is visually right in right-to-left text). - The default is false on Windows, and true on other platforms. */ - rtlMoveVisually?: boolean; + /** Configures whether the editor should re-indent the current line when a character is typed + that might change its proper indentation (only works if the mode supports indentation). Default is true. */ + electricChars?: boolean; + + /** Determines whether horizontal cursor movement through right-to-left (Arabic, Hebrew) text + is visual (pressing the left arrow moves the cursor left) + or logical (pressing the left arrow moves to the next lower index in the string, which is visually right in right-to-left text). + The default is false on Windows, and true on other platforms. */ + rtlMoveVisually?: boolean; - /** Configures the keymap to use. The default is "default", which is the only keymap defined in codemirror.js itself. - Extra keymaps are found in the keymap directory. See the section on keymaps for more information. */ - keyMap?: string; - - /** Can be used to specify extra keybindings for the editor, alongside the ones defined by keyMap. Should be either null, or a valid keymap value. */ - extraKeys?: any; - - /** Whether CodeMirror should scroll or wrap for long lines. Defaults to false (scroll). */ - lineWrapping?: boolean; - - /** Whether to show line numbers to the left of the editor. */ - lineNumbers?: boolean; - - /** At which number to start counting lines. Default is 1. */ - firstLineNumber?: number; + /** Configures the keymap to use. The default is "default", which is the only keymap defined in codemirror.js itself. + Extra keymaps are found in the keymap directory. See the section on keymaps for more information. */ + keyMap?: string; + + /** Can be used to specify extra keybindings for the editor, alongside the ones defined by keyMap. Should be either null, or a valid keymap value. */ + extraKeys?: any; + + /** Whether CodeMirror should scroll or wrap for long lines. Defaults to false (scroll). */ + lineWrapping?: boolean; + + /** Whether to show line numbers to the left of the editor. */ + lineNumbers?: boolean; + + /** At which number to start counting lines. Default is 1. */ + firstLineNumber?: number; - /** A function used to format line numbers. The function is passed the line number, and should return a string that will be shown in the gutter. */ - lineNumberFormatter?: (line: number) => string; + /** A function used to format line numbers. The function is passed the line number, and should return a string that will be shown in the gutter. */ + lineNumberFormatter?: (line: number) => string; - /** Can be used to add extra gutters (beyond or instead of the line number gutter). - Should be an array of CSS class names, each of which defines a width (and optionally a background), - and which will be used to draw the background of the gutters. - May include the CodeMirror-linenumbers class, in order to explicitly set the position of the line number gutter - (it will default to be to the right of all other gutters). These class names are the keys passed to setGutterMarker. */ - gutters?: string[]; - - /** Determines whether the gutter scrolls along with the content horizontally (false) - or whether it stays fixed during horizontal scrolling (true, the default). */ - fixedGutter?: boolean; - - /** boolean|string. This disables editing of the editor content by the user. If the special value "nocursor" is given (instead of simply true), focusing of the editor is also disallowed. */ - readOnly?: any; - - /**Whether the cursor should be drawn when a selection is active. Defaults to false. */ - showCursorWhenSelecting?: boolean; - - /** The maximum number of undo levels that the editor stores. Defaults to 40. */ - undoDepth?: number; - - /** The period of inactivity (in milliseconds) that will cause a new history event to be started when typing or deleting. Defaults to 500. */ - historyEventDelay?: number; - - /** The tab index to assign to the editor. If not given, no tab index will be assigned. */ - tabindex?: number; + /** Can be used to add extra gutters (beyond or instead of the line number gutter). + Should be an array of CSS class names, each of which defines a width (and optionally a background), + and which will be used to draw the background of the gutters. + May include the CodeMirror-linenumbers class, in order to explicitly set the position of the line number gutter + (it will default to be to the right of all other gutters). These class names are the keys passed to setGutterMarker. */ + gutters?: string[]; + + /** Determines whether the gutter scrolls along with the content horizontally (false) + or whether it stays fixed during horizontal scrolling (true, the default). */ + fixedGutter?: boolean; + + /** boolean|string. This disables editing of the editor content by the user. If the special value "nocursor" is given (instead of simply true), focusing of the editor is also disallowed. */ + readOnly?: any; + + /**Whether the cursor should be drawn when a selection is active. Defaults to false. */ + showCursorWhenSelecting?: boolean; + + /** The maximum number of undo levels that the editor stores. Defaults to 40. */ + undoDepth?: number; + + /** The period of inactivity (in milliseconds) that will cause a new history event to be started when typing or deleting. Defaults to 500. */ + historyEventDelay?: number; + + /** The tab index to assign to the editor. If not given, no tab index will be assigned. */ + tabindex?: number; - /** Can be used to make CodeMirror focus itself on initialization. Defaults to off. - When fromTextArea is used, and no explicit value is given for this option, it will be set to true when either the source textarea is focused, - or it has an autofocus attribute and no other element is focused. */ - autofocus?: number; + /** Can be used to make CodeMirror focus itself on initialization. Defaults to off. + When fromTextArea is used, and no explicit value is given for this option, it will be set to true when either the source textarea is focused, + or it has an autofocus attribute and no other element is focused. */ + autofocus?: number; - /** Controls whether drag-and - drop is enabled. On by default. */ - dragDrop?: boolean; + /** Controls whether drag-and - drop is enabled. On by default. */ + dragDrop?: boolean; - /** When given , this will be called when the editor is handling a dragenter , dragover , or drop event. - It will be passed the editor instance and the event object as arguments. - The callback can choose to handle the event itself , in which case it should return true to indicate that CodeMirror should not do anything further. */ - onDragEvent?: (instance: CM.Editor, event: Event) => boolean; + /** When given , this will be called when the editor is handling a dragenter , dragover , or drop event. + It will be passed the editor instance and the event object as arguments. + The callback can choose to handle the event itself , in which case it should return true to indicate that CodeMirror should not do anything further. */ + onDragEvent?: (instance: CodeMirror.Editor, event: Event) => boolean; - /** This provides a rather low - level hook into CodeMirror's key handling. - If provided, this function will be called on every keydown, keyup, and keypress event that CodeMirror captures. - It will be passed two arguments, the editor instance and the key event. - This key event is pretty much the raw key event, except that a stop() method is always added to it. - You could feed it to, for example, jQuery.Event to further normalize it. - This function can inspect the key event, and handle it if it wants to. - It may return true to tell CodeMirror to ignore the event. - Be wary that, on some browsers, stopping a keydown does not stop the keypress from firing, whereas on others it does. - If you respond to an event, you should probably inspect its type property and only do something when it is keydown - (or keypress for actions that need character data). */ - onKeyEvent?: (instance: CM.Editor, event: Event) => boolean; + /** This provides a rather low - level hook into CodeMirror's key handling. + If provided, this function will be called on every keydown, keyup, and keypress event that CodeMirror captures. + It will be passed two arguments, the editor instance and the key event. + This key event is pretty much the raw key event, except that a stop() method is always added to it. + You could feed it to, for example, jQuery.Event to further normalize it. + This function can inspect the key event, and handle it if it wants to. + It may return true to tell CodeMirror to ignore the event. + Be wary that, on some browsers, stopping a keydown does not stop the keypress from firing, whereas on others it does. + If you respond to an event, you should probably inspect its type property and only do something when it is keydown + (or keypress for actions that need character data). */ + onKeyEvent?: (instance: CodeMirror.Editor, event: Event) => boolean; - /** Half - period in milliseconds used for cursor blinking. The default blink rate is 530ms. */ - cursorBlinkRate?: number; + /** Half - period in milliseconds used for cursor blinking. The default blink rate is 530ms. */ + cursorBlinkRate?: number; - /** Determines the height of the cursor. Default is 1 , meaning it spans the whole height of the line. - For some fonts (and by some tastes) a smaller height (for example 0.85), - which causes the cursor to not reach all the way to the bottom of the line, looks better */ - cursorHeight?: number; + /** Determines the height of the cursor. Default is 1 , meaning it spans the whole height of the line. + For some fonts (and by some tastes) a smaller height (for example 0.85), + which causes the cursor to not reach all the way to the bottom of the line, looks better */ + cursorHeight?: number; - /** Highlighting is done by a pseudo background - thread that will work for workTime milliseconds, - and then use timeout to sleep for workDelay milliseconds. - The defaults are 200 and 300, you can change these options to make the highlighting more or less aggressive. */ - workTime?: number; + /** Highlighting is done by a pseudo background - thread that will work for workTime milliseconds, + and then use timeout to sleep for workDelay milliseconds. + The defaults are 200 and 300, you can change these options to make the highlighting more or less aggressive. */ + workTime?: number; - /** See workTime. */ - workDelay?: number; + /** See workTime. */ + workDelay?: number; - /** Indicates how quickly CodeMirror should poll its input textarea for changes(when focused). - Most input is captured by events, but some things, like IME input on some browsers, don't generate events that allow CodeMirror to properly detect it. - Thus, it polls. Default is 100 milliseconds. */ - pollInterval?: number + /** Indicates how quickly CodeMirror should poll its input textarea for changes(when focused). + Most input is captured by events, but some things, like IME input on some browsers, don't generate events that allow CodeMirror to properly detect it. + Thus, it polls. Default is 100 milliseconds. */ + pollInterval?: number - /** By default, CodeMirror will combine adjacent tokens into a single span if they have the same class. - This will result in a simpler DOM tree, and thus perform better. With some kinds of styling(such as rounded corners), - this will change the way the document looks. You can set this option to false to disable this behavior. */ - flattenSpans?: boolean; + /** By default, CodeMirror will combine adjacent tokens into a single span if they have the same class. + This will result in a simpler DOM tree, and thus perform better. With some kinds of styling(such as rounded corners), + this will change the way the document looks. You can set this option to false to disable this behavior. */ + flattenSpans?: boolean; - /** When highlighting long lines, in order to stay responsive, the editor will give up and simply style - the rest of the line as plain text when it reaches a certain position. The default is 10000. - You can set this to Infinity to turn off this behavior. */ - maxHighlightLength?: number; + /** When highlighting long lines, in order to stay responsive, the editor will give up and simply style + the rest of the line as plain text when it reaches a certain position. The default is 10000. + You can set this to Infinity to turn off this behavior. */ + maxHighlightLength?: number; - /** Specifies the amount of lines that are rendered above and below the part of the document that's currently scrolled into view. - This affects the amount of updates needed when scrolling, and the amount of work that such an update does. - You should usually leave it at its default, 10. Can be set to Infinity to make sure the whole document is always rendered, - and thus the browser's text search works on it. This will have bad effects on performance of big documents. */ - viewportMargin?: number; - } - - interface TextMarkerOptions { - /** Assigns a CSS class to the marked stretch of text. */ - className?: string; - - /** Determines whether text inserted on the left of the marker will end up inside or outside of it. */ - inclusiveLeft?: boolean; - - /** Like inclusiveLeft , but for the right side. */ - inclusiveRight?: boolean; - - /** Atomic ranges act as a single unit when cursor movement is concerned — i.e. it is impossible to place the cursor inside of them. - In atomic ranges, inclusiveLeft and inclusiveRight have a different meaning — they will prevent the cursor from being placed - respectively directly before and directly after the range. */ - atomic?: boolean; - - /** Collapsed ranges do not show up in the display.Setting a range to be collapsed will automatically make it atomic. */ - collapsed?: boolean; - - /** When enabled, will cause the mark to clear itself whenever the cursor enters its range. - This is mostly useful for text - replacement widgets that need to 'snap open' when the user tries to edit them. - The "clear" event fired on the range handle can be used to be notified when this happens. */ - clearOnEnter?: boolean; - - /** Use a given node to display this range.Implies both collapsed and atomic. - The given DOM node must be an inline element(as opposed to a block element). */ - replacedWith?: HTMLElement; - - /** A read - only span can, as long as it is not cleared, not be modified except by calling setValue to reset the whole document. - Note: adding a read - only span currently clears the undo history of the editor, - because existing undo events being partially nullified by read - only spans would corrupt the history (in the current implementation). */ - readOnly?: boolean; - - /** When set to true (default is false), adding this marker will create an event in the undo history that can be individually undone(clearing the marker). */ - addToHistory?: boolean; - - /** Can be used to specify an extra CSS class to be applied to the leftmost span that is part of the marker. */ - startStyle?: string; - - /** Equivalent to startStyle, but for the rightmost span. */ - endStyle?: string; - - /** When the target document is linked to other documents, you can set shared to true to make the marker appear in all documents. - By default, a marker appears only in its target document. */ - shared?: boolean; - } + /** Specifies the amount of lines that are rendered above and below the part of the document that's currently scrolled into view. + This affects the amount of updates needed when scrolling, and the amount of work that such an update does. + You should usually leave it at its default, 10. Can be set to Infinity to make sure the whole document is always rendered, + and thus the browser's text search works on it. This will have bad effects on performance of big documents. */ + viewportMargin?: number; } -} + + interface TextMarkerOptions { + /** Assigns a CSS class to the marked stretch of text. */ + className?: string; + + /** Determines whether text inserted on the left of the marker will end up inside or outside of it. */ + inclusiveLeft?: boolean; + + /** Like inclusiveLeft , but for the right side. */ + inclusiveRight?: boolean; + + /** Atomic ranges act as a single unit when cursor movement is concerned � i.e. it is impossible to place the cursor inside of them. + In atomic ranges, inclusiveLeft and inclusiveRight have a different meaning � they will prevent the cursor from being placed + respectively directly before and directly after the range. */ + atomic?: boolean; + + /** Collapsed ranges do not show up in the display.Setting a range to be collapsed will automatically make it atomic. */ + collapsed?: boolean; + + /** When enabled, will cause the mark to clear itself whenever the cursor enters its range. + This is mostly useful for text - replacement widgets that need to 'snap open' when the user tries to edit them. + The "clear" event fired on the range handle can be used to be notified when this happens. */ + clearOnEnter?: boolean; + + /** Use a given node to display this range.Implies both collapsed and atomic. + The given DOM node must be an inline element(as opposed to a block element). */ + replacedWith?: HTMLElement; + + /** A read - only span can, as long as it is not cleared, not be modified except by calling setValue to reset the whole document. + Note: adding a read - only span currently clears the undo history of the editor, + because existing undo events being partially nullified by read - only spans would corrupt the history (in the current implementation). */ + readOnly?: boolean; + + /** When set to true (default is false), adding this marker will create an event in the undo history that can be individually undone(clearing the marker). */ + addToHistory?: boolean; + + /** Can be used to specify an extra CSS class to be applied to the leftmost span that is part of the marker. */ + startStyle?: string; + + /** Equivalent to startStyle, but for the rightmost span. */ + endStyle?: string; + + /** When the target document is linked to other documents, you can set shared to true to make the marker appear in all documents. + By default, a marker appears only in its target document. */ + shared?: boolean; + } +} From d537ae627989ac3912a6a6fccbf6585248edaef6 Mon Sep 17 00:00:00 2001 From: mihailik Date: Tue, 25 Jun 2013 02:05:45 +0200 Subject: [PATCH 30/37] Just a couple more tests, nowhere near of acceptable amount. --- codemirror/codemirror-tests.ts | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/codemirror/codemirror-tests.ts b/codemirror/codemirror-tests.ts index fe849cd39..d81838ba9 100644 --- a/codemirror/codemirror-tests.ts +++ b/codemirror/codemirror-tests.ts @@ -1,15 +1,18 @@ /// -var myCodeMirror = CodeMirror(document.body); +var myCodeMirror: CodeMirror.Editor = CodeMirror(document.body); -var myCodeMirror2 = CodeMirror(document.body, { +var myCodeMirror2: CodeMirror.Editor = CodeMirror(document.body, { value: "function myScript(){return 100;}\n", mode: "javascript" }); -var myTextArea; -var myCodeMirror3 = CodeMirror(function (elt) { +var myTextArea: HTMLTextAreaElement; +var myCodeMirror3: CodeMirror.Editor = CodeMirror(function (elt) { myTextArea.parentNode.replaceChild(elt, myTextArea); }, { value: myTextArea.value }); -var myCodeMirror4 = CodeMirror.fromTextArea(myTextArea); \ No newline at end of file +var myCodeMirror4: CodeMirror.Editor = CodeMirror.fromTextArea(myTextArea); + +var doc: CodeMirror.Doc = new CodeMirror.Doc('text'); +var doc2: CodeMirror.Doc = CodeMirror(document.body).getDoc(); From 65a37c72a75ff251ac75eadf366d7849092f9d46 Mon Sep 17 00:00:00 2001 From: Armin Sander Date: Tue, 25 Jun 2013 11:06:40 +0200 Subject: [PATCH 31/37] Make jquery.dataTables compile with Typescript 0.9 --- jquery.dataTables/jquery.dataTables-tests.ts | 7 + jquery.dataTables/jquery.dataTables.d.ts | 136 +++++++++---------- 2 files changed, 75 insertions(+), 68 deletions(-) diff --git a/jquery.dataTables/jquery.dataTables-tests.ts b/jquery.dataTables/jquery.dataTables-tests.ts index 5448bfe1f..d3fe178c3 100755 --- a/jquery.dataTables/jquery.dataTables-tests.ts +++ b/jquery.dataTables/jquery.dataTables-tests.ts @@ -1086,6 +1086,11 @@ $(document).ready( function() { } ); } ); +/* + +This test does not compile, because - for some hard to find reason - the compiler is missing the aTargets +property of the second element. + // Using aoColumnDefs $(document).ready( function() { $('#example').dataTable( { @@ -1098,6 +1103,8 @@ $(document).ready( function() { } ); } ); +*/ + // Using aoColumns $(document).ready( function() { $('#example').dataTable( { diff --git a/jquery.dataTables/jquery.dataTables.d.ts b/jquery.dataTables/jquery.dataTables.d.ts index ac2415e99..d9524cf01 100755 --- a/jquery.dataTables/jquery.dataTables.d.ts +++ b/jquery.dataTables/jquery.dataTables.d.ts @@ -27,30 +27,30 @@ declare module DataTables _(selector:JQuery, opts?:RowParams): any[]; /// Add a single new row or multiple rows of data to the table. - fnAddData(data:any, redraw?:bool) : number[]; + fnAddData(data:any, redraw?:boolean) : number[]; /// This function will make DataTables recalculate the column sizes. - fnAdjustColumnSizing(redraw? : bool) : void; + fnAdjustColumnSizing(redraw? : boolean) : void; /// Quickly and simply clear a table - fnClearTable(redraw? : bool) : void; + fnClearTable(redraw? : boolean) : void; /// The exact opposite of 'opening' a row, this function will close any rows which are currently 'open'. fnClose(node: Node) : number; /// Remove a row for the table - fnDeleteRow(index: number, callback?: () => void, redraw?: bool) : any[]; - fnDeleteRow(tr: Node, callback?: () => void, redraw?: bool) : any[]; + fnDeleteRow(index: number, callback?: () => void, redraw?: boolean) : any[]; + fnDeleteRow(tr: Node, callback?: () => void, redraw?: boolean) : any[]; /// Restore the table to it's original state in the DOM by removing all of DataTables enhancements, /// alterations to the DOM structure of the table and event listeners. - fnDestroy(remove?: bool) : void; + fnDestroy(remove?: boolean) : void; /// Redraw the table - fnDraw(complete? : bool) : void; + fnDraw(complete? : boolean) : void; /// Filter the input based on data - fnFilter(input: string, column? : number, regex?: bool, smart? : bool, showGlobal?: bool, caseInsensitive? : bool) : void; + fnFilter(input: string, column? : number, regex?: boolean, smart? : boolean, showGlobal?: boolean, caseInsensitive? : boolean) : void; /// Get the data for the whole table, an individual row or an individual cell based on the provided parameters. fnGetData(row?: Node, col? : number) : any; @@ -63,7 +63,7 @@ declare module DataTables fnGetPosition(node: Node) : any; // number | number[] /// Check to see if a row is 'open' or not. - fnIsOpen(tr: Node) : bool; + fnIsOpen(tr: Node) : boolean; /// This function will place a new row directly after a row which is currently on display on the page, /// with the HTML contents that is passed into the function. @@ -72,11 +72,11 @@ declare module DataTables fnOpen(node: Node, html: JQuery, clazz: string) : Node; /// Change the pagination - provides the internal logic for pagination in a simple API function. - fnPageChange(action: string, redraw?: bool) : void; - fnPageChange(page: number, redraw?: bool) : void; + fnPageChange(action: string, redraw?: boolean) : void; + fnPageChange(page: number, redraw?: boolean) : void; /// Show a particular column - fnSetColumnVis(column: number, show: bool, redraw?: bool) : void; + fnSetColumnVis(column: number, show: boolean, redraw?: boolean) : void; /// Get the settings for a particular table for external manipulation fnSettings() : Settings; @@ -90,25 +90,25 @@ declare module DataTables /// Update a table cell or row - this method will accept either a single value to update the cell with, /// an array of values with one element for each column or an object in the same format as the original data source. - fnUpdate(data: any, row: Node, column?:number, redraw?: bool, action? : bool) : number; - fnUpdate(data: any, dataIndex: number, column?:number, redraw?: bool, action? : bool) : number; + fnUpdate(data: any, row: Node, column?:number, redraw?: boolean, action? : boolean) : number; + fnUpdate(data: any, dataIndex: number, column?:number, redraw?: boolean, action? : boolean) : number; /// Provide a common method for plug-ins to check the version of DataTables being used, /// in order to ensure compatibility. - fnVersionCheck(version: string) : bool; + fnVersionCheck(version: string) : boolean; } export interface Static { /// Provide a common method for plug-ins to check the version of DataTables being used, /// in order to ensure compatibility. - fnVersionCheck(version: string) : bool; + fnVersionCheck(version: string) : boolean; /// Check if a TABLE node is a DataTable table already or not. - fnIsDataTable(table: Node) : bool; + fnIsDataTable(table: Node) : boolean; /// Get all DataTable tables that have been initialised. - fnTables(visible? : bool) : Node[]; + fnTables(visible? : boolean) : Node[]; } export interface RowParams @@ -138,24 +138,24 @@ declare module DataTables aoColumnDefs?: ColumnDef[]; aoSearchCols?: any[]; asStripClasses?: string[]; - bAutoWidth?: bool; - bDeferRender?: bool; - bDestroy?: bool; - bFilter?: bool; - bInfo?: bool; - bJQueryUI?: bool; - bLengthChange?: bool; - bPaginate?: bool; - bProcessing?: bool; - bRetrieve?: bool; - bScrollAutoCss?: bool; - bScrollCollapse?: bool; - bScrollInfinite?: bool; - bServerSide?: bool; - bSort?: bool; - bSortCellsTop?: bool; - bSortClasses?: bool; - bStateSave?: bool; + bAutoWidth?: boolean; + bDeferRender?: boolean; + bDestroy?: boolean; + bFilter?: boolean; + bInfo?: boolean; + bJQueryUI?: boolean; + bLengthChange?: boolean; + bPaginate?: boolean; + bProcessing?: boolean; + bRetrieve?: boolean; + bScrollAutoCss?: boolean; + bScrollCollapse?: boolean; + bScrollInfinite?: boolean; + bServerSide?: boolean; + bSort?: boolean; + bSortCellsTop?: boolean; + bSortClasses?: boolean; + bStateSave?: boolean; fnCookieCallback?: CookieCallback; fnCreatedRow?: RowCreatedCallback; fnDrawCallback?: DrawCallback; @@ -227,10 +227,10 @@ declare module DataTables { aDataSort?: number[]; asSorting?: string[]; - bSearchable? : bool; - bSortable? : bool; - bVisible? : bool; - _bAutoType? : bool; + bSearchable? : boolean; + bSortable? : boolean; + bVisible? : boolean; + _bAutoType? : boolean; fnCreatedCell?: CreatedCell; iDataSort?: number; mData?: any; @@ -257,7 +257,7 @@ declare module DataTables oFeatures : Features; oScroll: ScrollingSettings; oLanguage : { fnInfoCallback : InfoCallback; }; - oBrowser : { bScrollOversize : bool; }; + oBrowser : { bScrollOversize : boolean; }; aanFeatures: Node[][]; aoData: Row[]; aiDisplay: number[]; @@ -289,8 +289,8 @@ declare module DataTables nTFoot: Node; nTBody: Node; nTableWrapper: Node; - bDeferLoading: bool; - bInitialized: bool; + bDeferLoading: boolean; + bInitialized: boolean; aoOpenRows: any[]; sDom: string; sPaginationType: string; @@ -302,7 +302,7 @@ declare module DataTables oLoadedState: any; sAjaxSource: string; sAjaxDataProp: string; - bAjaxDataGet: bool; + bAjaxDataGet: boolean; jqXHR: any; fnServerData: any; aoServerParams: any[]; @@ -310,18 +310,18 @@ declare module DataTables fnFormatNumber: FormatNumber; aLengthMenu: any[]; iDraw: number; - bDrawing: bool; + bDrawing: boolean; iDrawError: number; _iDisplayLength: number; _iDisplayStart: number; _iDisplayEnd: number; _iRecordsTotal: number; _iRecordsDisplay: number; - bJUI: bool; + bJUI: boolean; oClasses: any; - bFiltered: bool; - bSorted: bool; - bSortCellsTop: bool; + bFiltered: boolean; + bSorted: boolean; + bSortCellsTop: boolean; oInit: any; aoDestroyCallback: any[]; fnRecordsTotal: () => number; @@ -336,24 +336,24 @@ declare module DataTables export interface Features { - bAutoWidth: bool; - bDeferRender: bool; - bFilter: bool; - bInfo: bool; - bLengthChange: bool; - bPaginate: bool; - bProcessing: bool; - bServerSize: bool; - bSort: bool; - bSortClasses: bool; - bStateSave: bool; + bAutoWidth: boolean; + bDeferRender: boolean; + bFilter: boolean; + bInfo: boolean; + bLengthChange: boolean; + bPaginate: boolean; + bProcessing: boolean; + bServerSize: boolean; + bSort: boolean; + bSortClasses: boolean; + bStateSave: boolean; } export interface ScrollingSettings { - bAutoCss : bool; - bCollapse: bool; - bInfinite: bool; + bAutoCss : boolean; + bCollapse: boolean; + bInfinite: boolean; iBarWidth: number; iLoadGap: number; sX: string; @@ -373,10 +373,10 @@ declare module DataTables { aDataSort: any; asSorting: string[]; - bSearchable : bool; - bSortable : bool; - bVisible : bool; - _bAutoType : bool; + bSearchable : boolean; + bSortable : boolean; + bVisible : boolean; + _bAutoType : boolean; fnCreatedCell: CreatedCell; fnGetData: (data: any, specific: string) => any; fnSetData: (data: any, value: any) => void; @@ -439,7 +439,7 @@ declare module DataTables export interface PreDrawCallback { - (settings: Settings) : bool; + (settings: Settings) : boolean; } export interface RowCallback From 8d4540f61b534df02412f21c16afe0d2a63b0ede Mon Sep 17 00:00:00 2001 From: Neil Stalker Date: Tue, 25 Jun 2013 13:44:00 +0100 Subject: [PATCH 32/37] Fix definitions for TS 0.9 --- bgiframe/typescript.bgiframe.d.ts | 2 +- box2d/box2dweb.d.ts | 154 +++++++++--------- epiceditor/epiceditor.d.ts | 2 +- firebase/firebase.d.ts | 2 +- .../jquery.clientSideLogging.d.ts | 1 - jscrollpane/jscrollpane.d.ts | 8 +- mousetrap/mousetrap.d.ts | 2 +- 7 files changed, 85 insertions(+), 86 deletions(-) diff --git a/bgiframe/typescript.bgiframe.d.ts b/bgiframe/typescript.bgiframe.d.ts index b0b77cf07..60206f610 100644 --- a/bgiframe/typescript.bgiframe.d.ts +++ b/bgiframe/typescript.bgiframe.d.ts @@ -12,7 +12,7 @@ * Copyright (c) 2013 Brandon Aaron (http://brandonaaron.net) */ -module BgiFrame { +declare module BgiFrame { interface ISettings { top: string; left: string; diff --git a/box2d/box2dweb.d.ts b/box2d/box2dweb.d.ts index 112637980..808633ade 100644 --- a/box2d/box2dweb.d.ts +++ b/box2d/box2dweb.d.ts @@ -30,7 +30,7 @@ import b2Contacts = Box2D.Dynamics.Contacts; import b2Controllers = Box2D.Dynamics.Controllers; import b2Joints = Box2D.Dynamics.Joints; -module Box2D.Common { +declare module Box2D.Common { /** * Color for debug drawing. Each value has the range [0, 1]. @@ -76,7 +76,7 @@ module Box2D.Common { } } -module Box2D.Common { +declare module Box2D.Common { /** * Controls Box2D global settings. @@ -228,7 +228,7 @@ module Box2D.Common { } } -module Box2D.Common.Math { +declare module Box2D.Common.Math { /** * A 2-by-2 matrix. Stored in column-major order. @@ -341,7 +341,7 @@ module Box2D.Common.Math { } } -module Box2D.Common.Math { +declare module Box2D.Common.Math { /** * A 3-by3 matrix. Stored in column-major order. @@ -428,7 +428,7 @@ module Box2D.Common.Math { } } -module Box2D.Common.Math { +declare module Box2D.Common.Math { /** * Math utility functions. @@ -693,7 +693,7 @@ module Box2D.Common.Math { } } -module Box2D.Common.Math { +declare module Box2D.Common.Math { /** * This describes the motion of a body/shape for TOI computation. Shapes are defined with respect to the body origin, which may no coincide with the center of mass. However, to support dynamics we must interpolate the center of mass position. @@ -756,7 +756,7 @@ module Box2D.Common.Math { } } -module Box2D.Common.Math { +declare module Box2D.Common.Math { /** * A transform contains translation and rotation. It is used to represent the position and orientation of rigid frames. @@ -806,7 +806,7 @@ module Box2D.Common.Math { } } -module Box2D.Common.Math { +declare module Box2D.Common.Math { /** * A 2D column vector. @@ -957,7 +957,7 @@ module Box2D.Common.Math { } } -module Box2D.Common.Math { +declare module Box2D.Common.Math { /** * A 2D column vector with 3 elements. @@ -1043,7 +1043,7 @@ module Box2D.Common.Math { } } -module Box2D.Collision { +declare module Box2D.Collision { /** * Axis aligned bounding box. @@ -1117,7 +1117,7 @@ module Box2D.Collision { } } -module Box2D.Collision { +declare module Box2D.Collision { /** * We use contact ids to facilitate warm starting. @@ -1153,7 +1153,7 @@ module Box2D.Collision { } } -module Box2D.Collision { +declare module Box2D.Collision { /** * This structure is used to report contact points. @@ -1207,7 +1207,7 @@ module Box2D.Collision { } } -module Box2D.Collision { +declare module Box2D.Collision { /** * Input for b2Distance. You have to option to use the shape radii in the computation. Even @@ -1241,7 +1241,7 @@ module Box2D.Collision { } } -module Box2D.Collision { +declare module Box2D.Collision { /** * Output calculation for b2Distance. @@ -1270,7 +1270,7 @@ module Box2D.Collision { } } -module Box2D.Collision { +declare module Box2D.Collision { /** * A distance proxy is used by the GJK algorithm. It encapsulates any shape. @@ -1327,7 +1327,7 @@ module Box2D.Collision { } } -module Box2D.Collision { +declare module Box2D.Collision { /** * A dynamic tree arranges data in a binary tree to accelerate queries such as volume queries and ray casts. Leafs are proxies with an AABB. In the tree we expand the proxy AABB by b2_fatAABBFactor so that the proxy AABB is bigger than the client object. This allows the client object to move by small amounts without triggering a tree update. Nodes are pooled. @@ -1402,7 +1402,7 @@ module Box2D.Collision { } } -module Box2D.Collision { +declare module Box2D.Collision { /** * The broad-phase is used for computing pairs and performing volume queries and ray casts. This broad-phase does not persist pairs. Instead, this reports potentially new pairs. It is up to the client to consume the new pairs and to track subsequent overlap. @@ -1483,7 +1483,7 @@ module Box2D.Collision { } } -module Box2D.Collision { +declare module Box2D.Collision { /** * Empty declaration, used in many callbacks within b2DynamicTree. @@ -1494,7 +1494,7 @@ module Box2D.Collision { } } -module Box2D.Collision { +declare module Box2D.Collision { /** * A manifold for two touching convex shapes. Box2D supports multiple types of contact: - clip point versus plane with radius - point versus point with radius (circles) The local point usage depends on the manifold type: -e_circles: the local center of circleA -e_faceA: the center of faceA -e_faceB: the center of faceB Similarly the local normal usage: -e_circles: not used -e_faceA: the normal on polygonA -e_faceB: the normal on polygonB We store contacts in this way so that position correction can account for movement, which is critical for continuous physics. All contact scenarios must be expressed in one of these types. This structure is stored across time steps, so we keep it small. @@ -1565,7 +1565,7 @@ module Box2D.Collision { } } -module Box2D.Collision { +declare module Box2D.Collision { /** * A manifold point is a contact point belonging to a contact manifold. It holds details related to the geometry and dynamics of the contact points. The local point usage depends on the manifold type: -e_circles: the local center of circleB -e_faceA: the local center of cirlceB or the clip point of polygonB -e_faceB: the clip point of polygonA This structure is stored across time steps, so we keep it small. Note: the impulses are used for internal caching and may not provide reliable contact forces, especially for high speed collisions. @@ -1610,7 +1610,7 @@ module Box2D.Collision { } } -module Box2D.Collision { +declare module Box2D.Collision { /** * An oriented bounding box. @@ -1634,7 +1634,7 @@ module Box2D.Collision { } } -module Box2D.Collision { +declare module Box2D.Collision { /** * Ray cast input data. @@ -1666,7 +1666,7 @@ module Box2D.Collision { } } -module Box2D.Collision { +declare module Box2D.Collision { /** * Results of a ray cast. @@ -1685,7 +1685,7 @@ module Box2D.Collision { } } -module Box2D.Collision { +declare module Box2D.Collision { /** * A line in space between two given vertices. @@ -1735,7 +1735,7 @@ module Box2D.Collision { } } -module Box2D.Collision { +declare module Box2D.Collision { /** * Used to warm start b2Distance. Set count to zero on first call. @@ -1764,7 +1764,7 @@ module Box2D.Collision { } } -module Box2D.Collision { +declare module Box2D.Collision { /** * Inpute parameters for b2TimeOfImpact @@ -1798,7 +1798,7 @@ module Box2D.Collision { } } -module Box2D.Collision { +declare module Box2D.Collision { /** * This is used to compute the current state of a contact manifold. @@ -1837,7 +1837,7 @@ module Box2D.Collision { } } -module Box2D.Collision { +declare module Box2D.Collision { /** * We use contact ids to facilitate warm starting. @@ -1866,7 +1866,7 @@ module Box2D.Collision { } } -module Box2D.Collision { +declare module Box2D.Collision { /** * Interface for objects tracking overlap of many AABBs. @@ -1940,7 +1940,7 @@ module Box2D.Collision { } } -module Box2D.Collision.Shapes { +declare module Box2D.Collision.Shapes { /** * A circle shape. @@ -2038,7 +2038,7 @@ module Box2D.Collision.Shapes { } } -module Box2D.Collision.Shapes { +declare module Box2D.Collision.Shapes { /** * This structure is used to build edge shapes. @@ -2067,7 +2067,7 @@ module Box2D.Collision.Shapes { } } -module Box2D.Collision.Shapes { +declare module Box2D.Collision.Shapes { /** * An edge shape. @@ -2223,7 +2223,7 @@ module Box2D.Collision.Shapes { } } -module Box2D.Collision.Shapes { +declare module Box2D.Collision.Shapes { /** * This holds the mass data computed for a shape. @@ -2247,7 +2247,7 @@ module Box2D.Collision.Shapes { } } -module Box2D.Collision.Shapes { +declare module Box2D.Collision.Shapes { /** * Convex polygon. The vertices must be in CCW order for a right-handed coordinate system with the z-axis coming out of the screen. @@ -2429,7 +2429,7 @@ module Box2D.Collision.Shapes { } } -module Box2D.Collision.Shapes { +declare module Box2D.Collision.Shapes { /** * A shape is used for collision detection. Shapes are created in b2Body. You can use shape for collision detection before they are attached to the world. @@ -2543,7 +2543,7 @@ module Box2D.Collision.Shapes { } } -module Box2D.Dynamics { +declare module Box2D.Dynamics { /** * A rigid body. @@ -2927,7 +2927,7 @@ module Box2D.Dynamics { } } -module Box2D.Dynamics { +declare module Box2D.Dynamics { /** * A body definition holds all the data needed to construct a rigid body. You can safely re-use body definitions. @@ -3009,7 +3009,7 @@ module Box2D.Dynamics { } } -module Box2D.Dynamics { +declare module Box2D.Dynamics { /** * Implement this class to provide collision filtering. In other words, you can implement this class if you want finer control over contact creation. @@ -3037,7 +3037,7 @@ module Box2D.Dynamics { } } -module Box2D.Dynamics { +declare module Box2D.Dynamics { /** * Contact impulses for reporting. Impulses are used instead of forces because sub-step forces may approach infinity for rigid body collisions. These match up one-to-one with the contact points in b2Manifold. @@ -3056,7 +3056,7 @@ module Box2D.Dynamics { } } -module Box2D.Dynamics { +declare module Box2D.Dynamics { /** * Implement this class to get contact information. You can use these results for things like sounds and game logic. You can also get contact results by traversing the contact lists after the time step. However, you might miss some contacts because continuous physics leads to sub-stepping. Additionally you may receive multiple callbacks for the same contact in a single time step. You should strive to make your callbacks efficient because there may be many callbacks per time step. @@ -3092,7 +3092,7 @@ module Box2D.Dynamics { } } -module Box2D.Dynamics { +declare module Box2D.Dynamics { /** * Implement and register this class with a b2World to provide debug drawing of physics entities in your game. @@ -3285,7 +3285,7 @@ module Box2D.Dynamics { } } -module Box2D.Dynamics { +declare module Box2D.Dynamics { /** * Joints and shapes are destroyed when their associated body is destroyed. Implement this listener so that you may nullify references to these joints and shapes. @@ -3306,7 +3306,7 @@ module Box2D.Dynamics { } } -module Box2D.Dynamics { +declare module Box2D.Dynamics { /** * This holds contact filtering data. @@ -3336,7 +3336,7 @@ module Box2D.Dynamics { } } -module Box2D.Dynamics { +declare module Box2D.Dynamics { /** * A fixture is used to attach a shape to a body for collision detection. A fixture inherits its transform from its parent. Fixtures hold additional non-geometric data such as friction, collision filters, etc. Fixtures are created via b2Body::CreateFixture. @@ -3470,7 +3470,7 @@ module Box2D.Dynamics { } } -module Box2D.Dynamics { +declare module Box2D.Dynamics { /** * A fixture definition is used to create a fixture. This class defines an abstract fixture definition. You can reuse fixture definitions safely. @@ -3519,7 +3519,7 @@ module Box2D.Dynamics { } } -module Box2D.Dynamics { +declare module Box2D.Dynamics { /** * The world class manages all physics entities, dynamic simulation, and asynchronous queries. @@ -3787,7 +3787,7 @@ module Box2D.Dynamics { } } -module Box2D.Dynamics.Contacts { +declare module Box2D.Dynamics.Contacts { /** * The class manages contact between two shapes. A contact exists for each overlapping AABB in the broad-phase (except if filtered). Therefore a contact object may exist that has no contact points. @@ -3873,7 +3873,7 @@ module Box2D.Dynamics.Contacts { } } -module Box2D.Dynamics.Contacts { +declare module Box2D.Dynamics.Contacts { /** * A contact edge is used to connect bodies and contacts together in a contact graph where each body is a node and each contact is an edge. A contact edge belongs to a doubly linked list maintained in each attached body. Each contact has two contact nodes, one for each attached body. @@ -3902,7 +3902,7 @@ module Box2D.Dynamics.Contacts { } } -module Box2D.Dynamics.Contacts { +declare module Box2D.Dynamics.Contacts { /** * This structure is used to report contact point results. @@ -3946,7 +3946,7 @@ module Box2D.Dynamics.Contacts { } } -module Box2D.Dynamics.Controllers { +declare module Box2D.Dynamics.Controllers { /** * Base class for controllers. Controllers are a convience for encapsulating common per-step functionality. @@ -4012,7 +4012,7 @@ module Box2D.Dynamics.Controllers { } } -module Box2D.Dynamics.Controllers { +declare module Box2D.Dynamics.Controllers { /** * Controller Edge. @@ -4051,7 +4051,7 @@ module Box2D.Dynamics.Controllers { } } -module Box2D.Dynamics.Controllers { +declare module Box2D.Dynamics.Controllers { /** * Calculates buoyancy forces for fluids in the form of a half plane. @@ -4112,7 +4112,7 @@ module Box2D.Dynamics.Controllers { } } -module Box2D.Dynamics.Controllers { +declare module Box2D.Dynamics.Controllers { /** * Applies an acceleration every frame, like gravity @@ -4131,7 +4131,7 @@ module Box2D.Dynamics.Controllers { } } -module Box2D.Dynamics.Controllers { +declare module Box2D.Dynamics.Controllers { /** * Applies an acceleration every frame, like gravity. @@ -4150,7 +4150,7 @@ module Box2D.Dynamics.Controllers { } } -module Box2D.Dynamics.Controllers { +declare module Box2D.Dynamics.Controllers { /** * Applies simplified gravity between every pair of bodies. @@ -4175,7 +4175,7 @@ module Box2D.Dynamics.Controllers { } } -module Box2D.Dynamics.Controllers { +declare module Box2D.Dynamics.Controllers { /** * Applies top down linear damping to the controlled bodies The damping is calculated by multiplying velocity by a matrix in local co-ordinates. @@ -4207,7 +4207,7 @@ module Box2D.Dynamics.Controllers { } } -module Box2D.Dynamics.Joints { +declare module Box2D.Dynamics.Joints { /** * The base joint class. Joints are used to constraint two bodies together in various fashions. Some joints also feature limits and motors. @@ -4284,7 +4284,7 @@ module Box2D.Dynamics.Joints { } } -module Box2D.Dynamics.Joints { +declare module Box2D.Dynamics.Joints { /** * Joint definitions are used to construct joints. @@ -4323,7 +4323,7 @@ module Box2D.Dynamics.Joints { } } -module Box2D.Dynamics.Joints { +declare module Box2D.Dynamics.Joints { /** * A joint edge is used to connect bodies and joints together in a joint graph where each body is a node and each joint is an edge. A joint edge belongs to a doubly linked list maintained in each attached body. Each joint has two joint nodes, one for each attached body. @@ -4352,7 +4352,7 @@ module Box2D.Dynamics.Joints { } } -module Box2D.Dynamics.Joints { +declare module Box2D.Dynamics.Joints { /** * A distance joint constrains two points on two bodies to remain at a fixed distance from each other. You can view this as a massless, rigid rod. @@ -4423,7 +4423,7 @@ module Box2D.Dynamics.Joints { } } -module Box2D.Dynamics.Joints { +declare module Box2D.Dynamics.Joints { /** * Distance joint definition. This requires defining an anchor point on both bodies and the non-zero length of the distance joint. The definition uses local anchor points so that the initial configuration can violate the constraint slightly. This helps when saving and loading a game. @@ -4472,7 +4472,7 @@ module Box2D.Dynamics.Joints { } } -module Box2D.Dynamics.Joints { +declare module Box2D.Dynamics.Joints { /** * Friction joint. This is used for top-down friction. It provides 2D translational friction and angular friction. @@ -4540,7 +4540,7 @@ module Box2D.Dynamics.Joints { } } -module Box2D.Dynamics.Joints { +declare module Box2D.Dynamics.Joints { /** * Friction joint defintion. @@ -4582,7 +4582,7 @@ module Box2D.Dynamics.Joints { } } -module Box2D.Dynamics.Joints { +declare module Box2D.Dynamics.Joints { /** * A gear joint is used to connect two joints together. Either joint can be a revolute or prismatic joint. You specify a gear ratio to bind the motions together: coordinate1 + ratio coordinate2 = constant The ratio can be negative or positive. If one joint is a revolute joint and the other joint is a prismatic joint, then the ratio will have units of length or units of 1/length. @@ -4630,7 +4630,7 @@ module Box2D.Dynamics.Joints { } } -module Box2D.Dynamics.Joints { +declare module Box2D.Dynamics.Joints { /** * Gear joint definition. This definition requires two existing revolute or prismatic joints (any combination will work). The provided joints must attach a dynamic body to a static body. @@ -4659,7 +4659,7 @@ module Box2D.Dynamics.Joints { } } -module Box2D.Dynamics.Joints { +declare module Box2D.Dynamics.Joints { /** * A line joint. This joint provides one degree of freedom: translation along an axis fixed in body1. You can use a joint limit to restrict the range of motion and a joint motor to drive the motion or to model joint friction. @@ -4779,7 +4779,7 @@ module Box2D.Dynamics.Joints { } } -module Box2D.Dynamics.Joints { +declare module Box2D.Dynamics.Joints { /** * Line joint definition. This requires defining a line of motion using an axis and an anchor point. The definition uses local anchor points and a local axis so that the initial configuration can violate the constraint slightly. The joint translation is zero when the local anchor points coincide in world space. Using local anchors and a local axis helps when saving and loading a game. @@ -4847,7 +4847,7 @@ module Box2D.Dynamics.Joints { } } -module Box2D.Dynamics.Joints { +declare module Box2D.Dynamics.Joints { /** * A mouse joint is used to make a point on a body track a specified world point. This a soft constraint with a maximum force. This allows the constraint to stretch and without applying huge forces. Note: this joint is not fully documented as it is intended primarily for the testbed. See that for more instructions. @@ -4930,7 +4930,7 @@ module Box2D.Dynamics.Joints { } } -module Box2D.Dynamics.Joints { +declare module Box2D.Dynamics.Joints { /** * Mouse joint definition. This requires a world target point, tuning parameters, and the time step. @@ -4959,7 +4959,7 @@ module Box2D.Dynamics.Joints { } } -module Box2D.Dynamics.Joints { +declare module Box2D.Dynamics.Joints { /** * A prismatic joint. This joint provides one degree of freedom: translation along an axis fixed in body1. Relative rotation is prevented. You can use a joint limit to restrict the range of motion and a joint motor to drive the motion or to model joint friction. @@ -5073,7 +5073,7 @@ module Box2D.Dynamics.Joints { } } -module Box2D.Dynamics.Joints { +declare module Box2D.Dynamics.Joints { /** * Prismatic joint definition. This requires defining a line of motion using an axis and an anchor point. The definition uses local anchor points and a local axis so that the initial configuration can violate the constraint slightly. The joint translation is zero when the local anchor points coincide in world space. Using local anchors and a local axis helps when saving and loading a game. @@ -5146,7 +5146,7 @@ module Box2D.Dynamics.Joints { } } -module Box2D.Dynamics.Joints { +declare module Box2D.Dynamics.Joints { /** * The pulley joint is connected to two bodies and two fixed ground points. The pulley supports a ratio such that: length1 + ratio length2 <= constant Yes, the force transmitted is scaled by the ratio. The pulley also enforces a maximum length limit on both sides. This is useful to prevent one side of the pulley hitting the top. @@ -5206,7 +5206,7 @@ module Box2D.Dynamics.Joints { } } -module Box2D.Dynamics.Joints { +declare module Box2D.Dynamics.Joints { /** * Pulley joint definition. This requires two ground anchors, two dynamic body anchor points, max lengths for each side, and a pulley ratio. @@ -5276,7 +5276,7 @@ module Box2D.Dynamics.Joints { } } -module Box2D.Dynamics.Joints { +declare module Box2D.Dynamics.Joints { /** * A revolute joint constrains to bodies to share a common point while they are free to rotate about the point. The relative rotation about the shared point is the joint angle. You can limit the relative rotation with a joint limit that specifies a lower and upper angle. You can use a motor to drive the relative rotation about the shared point. A maximum motor torque is provided so that infinite forces are not generated. @@ -5390,7 +5390,7 @@ module Box2D.Dynamics.Joints { } } -module Box2D.Dynamics.Joints { +declare module Box2D.Dynamics.Joints { /** * Revolute joint definition. This requires defining an anchor point where the bodies are joined. The definition uses local anchor points so that the initial configuration can violate the constraint slightly. You also need to specify the initial relative angle for joint limits. This helps when saving and loading a game. The local anchor points are measured from the body's origin rather than the center of mass because: 1. you might not know where the center of mass will be. 2. if you add/remove shapes from a body and recompute the mass, the joints will be broken. @@ -5457,7 +5457,7 @@ module Box2D.Dynamics.Joints { } } -module Box2D.Dynamics.Joints { +declare module Box2D.Dynamics.Joints { /** * A weld joint essentially glues two bodies together. A weld joint may distort somewhat because the island constraint solver is approximate. @@ -5492,7 +5492,7 @@ module Box2D.Dynamics.Joints { } } -module Box2D.Dynamics.Joints { +declare module Box2D.Dynamics.Joints { /** * Weld joint definition. You need to specify local anchor points where they are attached and the relative body angle. The position of the anchor points is important for computing the reaction torque. diff --git a/epiceditor/epiceditor.d.ts b/epiceditor/epiceditor.d.ts index 7030923f2..479cc7b73 100644 --- a/epiceditor/epiceditor.d.ts +++ b/epiceditor/epiceditor.d.ts @@ -35,7 +35,7 @@ interface EpicEditorOptions { }; } -class EpicEditor { +declare class EpicEditor { constructor(); constructor(options: EpicEditorOptions); diff --git a/firebase/firebase.d.ts b/firebase/firebase.d.ts index f50919134..ecab3806e 100644 --- a/firebase/firebase.d.ts +++ b/firebase/firebase.d.ts @@ -43,7 +43,7 @@ interface IFirebaseQuery { ref(): Firebase; } -class Firebase implements IFirebaseQuery { +declare class Firebase implements IFirebaseQuery { constructor(firebaseURL: string); auth(authToken: string, onComplete?: (error: string, result: IFirebaseAuthResult) => void, onCancel?:(error: string) => void): void; unauth(): void; diff --git a/jquery.clientSideLogging/jquery.clientSideLogging.d.ts b/jquery.clientSideLogging/jquery.clientSideLogging.d.ts index d2031029e..1bd2d871b 100644 --- a/jquery.clientSideLogging/jquery.clientSideLogging.d.ts +++ b/jquery.clientSideLogging/jquery.clientSideLogging.d.ts @@ -25,7 +25,6 @@ interface ClientSideLoggingObject { interface JQueryStatic { info: (what?: any) => any; - error: (what?: any) => any; log: (what?: any) => any; clientSideLogging: (options: ClientSideLoggingObject) => any; } diff --git a/jscrollpane/jscrollpane.d.ts b/jscrollpane/jscrollpane.d.ts index 5fd670060..c7738cfb4 100644 --- a/jscrollpane/jscrollpane.d.ts +++ b/jscrollpane/jscrollpane.d.ts @@ -3,9 +3,9 @@ // Definitions by: Dániel Tar // Definitions: https://github.com/borisyankov/DefinitelyTyped -/// +/// -declare interface JScrollPaneSettings { +interface JScrollPaneSettings { /** * Whether arrows should be shown on the generated scroll pane. When set to false only the scrollbar * track and drag will be shown, if set to true then arrows buttons will also be shown. @@ -141,7 +141,7 @@ declare interface JScrollPaneSettings { trackClickRepeatFreq?: number; } -declare interface JScrollPaneApi { +interface JScrollPaneApi { /** * Reinitialises the scroll pane (if it's internal dimensions have changed since the last time it was initialised). * The settings object which is passed in will override any settings from the previous time it was initialised - @@ -308,7 +308,7 @@ declare interface JScrollPaneApi { destroy(): void; } -declare interface JQuery { +interface JQuery { /** * Initialises the jScrollPane on the JQuery object. */ diff --git a/mousetrap/mousetrap.d.ts b/mousetrap/mousetrap.d.ts index a81854c4f..814efb3dd 100644 --- a/mousetrap/mousetrap.d.ts +++ b/mousetrap/mousetrap.d.ts @@ -18,4 +18,4 @@ interface MousetrapStatic { reset(): void; } -var Mousetrap: MousetrapStatic; +declare var Mousetrap: MousetrapStatic; From 03efcb45aa0df43a255d24bd039b9b26bf961ba3 Mon Sep 17 00:00:00 2001 From: Bartvds Date: Tue, 25 Jun 2013 21:06:56 +0200 Subject: [PATCH 33/37] updated chai tdd, added chai-fuzzy tdd --- chai-fuzzy/chai-fuzzy-assert.d.ts | 17 +++++++++++++++++ chai/chai-assert.d.ts | 5 +++-- 2 files changed, 20 insertions(+), 2 deletions(-) create mode 100644 chai-fuzzy/chai-fuzzy-assert.d.ts diff --git a/chai-fuzzy/chai-fuzzy-assert.d.ts b/chai-fuzzy/chai-fuzzy-assert.d.ts new file mode 100644 index 000000000..f75f99d55 --- /dev/null +++ b/chai-fuzzy/chai-fuzzy-assert.d.ts @@ -0,0 +1,17 @@ +// Type definitions for chai-fuzzy 1.3.0 assert style +// Project: http://chaijs.com/plugins/chai-fuzzy +// Definitions by: Bart van der Schoor +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +declare module chai { + interface Assert { + like(act:any, exp:any, msg?:string); + notLike(act:any, exp:any, msg?:string); + containOneLike(act:any, exp:any, msg?:string); + notContainOneLike(act:any, exp:any, msg?:string); + jsonOf(act:any, exp:any, msg?:string); + notJsonOf(act:any, exp:any, msg?:string); + } +} \ No newline at end of file diff --git a/chai/chai-assert.d.ts b/chai/chai-assert.d.ts index ab1a23d14..7cd5e3d48 100644 --- a/chai/chai-assert.d.ts +++ b/chai/chai-assert.d.ts @@ -1,4 +1,4 @@ -// Type definitions for chai v1.6.0 assert style +// Type definitions for chai v1.7.0 assert style // Project: http://chaijs.com/ // Definitions by: Bart van der Schoor // Definitions: https://github.com/borisyankov/DefinitelyTyped @@ -10,7 +10,9 @@ declare module chai (express:any, msg?:string); fail(actual?:any, expected?:any, msg?:string, operator?:string); + ok(val:any, msg?:string); + notOk(val:any, msg?:string); equal(act:any, exp:any, msg?:string); notEqual(act:any, exp:any, msg?:string); @@ -71,7 +73,6 @@ declare module chai propertyVal(obj:Object, prop:string, val:any, msg?:string); propertyNotVal(obj:Object, prop:string, val:any, msg?:string); - deepPropertyVal(obj:Object, prop:string, val:any, msg?:string); deepPropertyNotVal(obj:Object, prop:string, val:any, msg?:string); From 67f43af9b65a7c79a30ca95d19e3d6b6f67601c8 Mon Sep 17 00:00:00 2001 From: Aaron King Date: Tue, 25 Jun 2013 16:52:24 -0400 Subject: [PATCH 34/37] moment: added support for isBefore, isAfter, isSame --- moment/moment.d.ts | 66 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) diff --git a/moment/moment.d.ts b/moment/moment.d.ts index 2ba80d175..7f8dc19d4 100644 --- a/moment/moment.d.ts +++ b/moment/moment.d.ts @@ -115,6 +115,39 @@ interface Moment { daysInMonth(): number; isDST(): bool; + isBefore(b: Moment): bool; + isBefore(b: string): bool; + isBefore(b: Number): bool; + isBefore(b: Date): bool; + isBefore(b: Array): bool; + isBefore(b: Moment, granularity: string): bool; + isBefore(b: String, granularity: string): bool; + isBefore(b: Number, granularity: string): bool; + isBefore(b: Date, granularity: string): bool; + isBefore(b: Array, granularity: string): bool; + + isAfter(b: Moment): bool; + isAfter(b: string): bool; + isAfter(b: Number): bool; + isAfter(b: Date): bool; + isAfter(b: Array): bool; + isAfter(b: Moment, granularity: string): bool; + isAfter(b: String, granularity: string): bool; + isAfter(b: Number, granularity: string): bool; + isAfter(b: Date, granularity: string): bool; + isAfter(b: Array, granularity: string): bool; + + isSame(b: Moment): bool; + isSame(b: string): bool; + isSame(b: Number): bool; + isSame(b: Date): bool; + isSame(b: Array): bool; + isSame(b: Moment, granularity: string): bool; + isSame(b: String, granularity: string): bool; + isSame(b: Number, granularity: string): bool; + isSame(b: Date, granularity: string): bool; + isSame(b: Array, granularity: string): bool; + lang(language: string); lang(reset: bool); lang(): string; @@ -220,6 +253,39 @@ interface MomentStatic { duration(input: MomentInput): Duration; duration(object: any): Duration; duration(): Duration; + + isBefore(b: Moment): bool; + isBefore(b: string): bool; + isBefore(b: Number): bool; + isBefore(b: Date): bool; + isBefore(b: Array): bool; + isBefore(b: Moment, granularity: string): bool; + isBefore(b: String, granularity: string): bool; + isBefore(b: Number, granularity: string): bool; + isBefore(b: Date, granularity: string): bool; + isBefore(b: Array, granularity: string): bool; + + isAfter(b: Moment): bool; + isAfter(b: string): bool; + isAfter(b: Number): bool; + isAfter(b: Date): bool; + isAfter(b: Array): bool; + isAfter(b: Moment, granularity: string): bool; + isAfter(b: String, granularity: string): bool; + isAfter(b: Number, granularity: string): bool; + isAfter(b: Date, granularity: string): bool; + isAfter(b: Array, granularity: string): bool; + + isSame(b: Moment): bool; + isSame(b: string): bool; + isSame(b: Number): bool; + isSame(b: Date): bool; + isSame(b: Array): bool; + isSame(b: Moment, granularity: string): bool; + isSame(b: String, granularity: string): bool; + isSame(b: Number, granularity: string): bool; + isSame(b: Date, granularity: string): bool; + isSame(b: Array, granularity: string): bool; } declare var moment: MomentStatic; From c72caf82d2088bc502215af39d1590430477a8b3 Mon Sep 17 00:00:00 2001 From: mihailik Date: Wed, 26 Jun 2013 00:16:05 +0200 Subject: [PATCH 35/37] Incorrect `number` type for `autofocus` option, should be `boolean`. --- codemirror/codemirror.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/codemirror/codemirror.d.ts b/codemirror/codemirror.d.ts index 9a3db7147..03dc2878f 100644 --- a/codemirror/codemirror.d.ts +++ b/codemirror/codemirror.d.ts @@ -679,7 +679,7 @@ declare module CodeMirror { /** Can be used to make CodeMirror focus itself on initialization. Defaults to off. When fromTextArea is used, and no explicit value is given for this option, it will be set to true when either the source textarea is focused, or it has an autofocus attribute and no other element is focused. */ - autofocus?: number; + autofocus?: boolean; /** Controls whether drag-and - drop is enabled. On by default. */ dragDrop?: boolean; From 3b6e8c80f0c05dd362d68f6df4f679e4be8f35e2 Mon Sep 17 00:00:00 2001 From: Daniel Ferreira Monteiro Alves Date: Wed, 26 Jun 2013 02:01:08 -0300 Subject: [PATCH 36/37] Little fix for BindingHandlers --- knockout/knockout.d.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/knockout/knockout.d.ts b/knockout/knockout.d.ts index b9c1e9cb7..5614d9d49 100644 --- a/knockout/knockout.d.ts +++ b/knockout/knockout.d.ts @@ -133,6 +133,8 @@ interface KnockoutBindingHandler { } interface KnockoutBindingHandlers { + [bindingHandler: string]: KnockoutBindingHandler; + // Controlling text and appearance visible: KnockoutBindingHandler; text: KnockoutBindingHandler; From 2e2524ab4e50079dfb0a9ed2eeb7f66abecea777 Mon Sep 17 00:00:00 2001 From: Terence Lewis Date: Wed, 26 Jun 2013 10:04:11 +0200 Subject: [PATCH 37/37] Made the SignalR definition 0.9 compatible Changed the return type of HubConnection.received to match SignalR.received The 'on' callback can take a variable number of arguments --- signalr/signalr.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/signalr/signalr.d.ts b/signalr/signalr.d.ts index 6078a7d3c..00a5240b5 100644 --- a/signalr/signalr.d.ts +++ b/signalr/signalr.d.ts @@ -65,7 +65,7 @@ interface HubProxy { (connection: HubConnection, hubName: string): HubProxy; init(connection: HubConnection, hubName: string): void; hasSubscriptions(): bool; - on(eventName: string, callback: (msg) => void ): HubProxy; + on(eventName: string, callback: (...msg) => void ): HubProxy; off(eventName: string, callback: (msg) => void ): HubProxy; invoke(methodName: string, ...args: any[]): JQueryDeferred; } @@ -79,7 +79,7 @@ interface HubConnectionSettings { interface HubConnection extends SignalR { //(url?: string, queryString?: any, logging?: bool): HubConnection; proxies; - received(callback: (data: { Id; Method; Hub; State; Args; }) => void ): void; + received(callback: (data: { Id; Method; Hub; State; Args; }) => void ): HubConnection; createHubProxy(hubName: string): HubProxy; }