Merge pull request #313 from hdeshev/angular-types

"Fix" type clashes with Angular 2
This commit is contained in:
Hristo Deshev
2015-06-11 16:48:07 +03:00
6 changed files with 201 additions and 183 deletions

150
declarations.d.ts vendored
View File

@ -79,153 +79,3 @@ declare module module {
}
// Same as module.exports
declare var exports: any;
// Type definitions for es6-promise
// Project: https://github.com/jakearchibald/ES6-Promise
// Definitions by: François de Campredon <https://github.com/fdecampredon/>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
interface Thenable<R> {
then<U>(onFulfilled?: (value: R) => Thenable<U>, onRejected?: (error: any) => Thenable<U>): Thenable<U>;
then<U>(onFulfilled?: (value: R) => Thenable<U>, onRejected?: (error: any) => U): Thenable<U>;
then<U>(onFulfilled?: (value: R) => Thenable<U>, onRejected?: (error: any) => void): Thenable<U>;
then<U>(onFulfilled?: (value: R) => U, onRejected?: (error: any) => Thenable<U>): Thenable<U>;
then<U>(onFulfilled?: (value: R) => U, onRejected?: (error: any) => U): Thenable<U>;
then<U>(onFulfilled?: (value: R) => U, onRejected?: (error: any) => void): Thenable<U>;
}
declare class Promise<R> implements Thenable<R> {
/**
* If you call resolve in the body of the callback passed to the constructor,
* your promise is fulfilled with result object passed to resolve.
* If you call reject your promise is rejected with the object passed to resolve.
* For consistency and debugging (eg stack traces), obj should be an instanceof Error.
* Any errors thrown in the constructor callback will be implicitly passed to reject().
*/
constructor(callback: (resolve: (result?: R) => void, reject: (error: any) => void) => void);
/**
* If you call resolve in the body of the callback passed to the constructor,
* your promise will be fulfilled/rejected with the outcome of thenable passed to resolve.
* If you call reject your promise is rejected with the object passed to resolve.
* For consistency and debugging (eg stack traces), obj should be an instanceof Error.
* Any errors thrown in the constructor callback will be implicitly passed to reject().
*/
constructor(callback: (resolve: (thenable?: Thenable<R>) => void, reject: (error: any) => void) => void);
/**
* onFulfilled is called when/if "promise" resolves. onRejected is called when/if "promise" rejects.
* Both are optional, if either/both are omitted the next onFulfilled/onRejected in the chain is called.
* Both callbacks have a single parameter , the fulfillment value or rejection reason.
* "then" returns a new promise equivalent to the value you return from onFulfilled/onRejected after being passed through Promise.resolve.
* If an error is thrown in the callback, the returned promise rejects with that error.
* @param onFulfilled called when/if "promise" resolves
* @param onRejected called when/if "promise" rejects
*/
then<U>(onFulfilled?: (value: R) => Thenable<U>, onRejected?: (error: any) => Thenable<U>): Promise<U>;
/**
* onFulfilled is called when/if "promise" resolves. onRejected is called when/if "promise" rejects.
* Both are optional, if either/both are omitted the next onFulfilled/onRejected in the chain is called.
* Both callbacks have a single parameter , the fulfillment value or rejection reason.
* "then" returns a new promise equivalent to the value you return from onFulfilled/onRejected after being passed through Promise.resolve.
* If an error is thrown in the callback, the returned promise rejects with that error.
* @param onFulfilled called when/if "promise" resolves
* @param onRejected called when/if "promise" rejects
*/
then<U>(onFulfilled?: (value: R) => Thenable<U>, onRejected?: (error: any) => U): Promise<U>;
/**
* onFulfilled is called when/if "promise" resolves. onRejected is called when/if "promise" rejects.
* Both are optional, if either/both are omitted the next onFulfilled/onRejected in the chain is called.
* Both callbacks have a single parameter , the fulfillment value or rejection reason.
* "then" returns a new promise equivalent to the value you return from onFulfilled/onRejected after being passed through Promise.resolve.
* If an error is thrown in the callback, the returned promise rejects with that error.
* @param onFulfilled called when/if "promise" resolves
* @param onRejected called when/if "promise" rejects
*/
then<U>(onFulfilled?: (value: R) => Thenable<U>, onRejected?: (error: any) => void): Promise<U>;
/**
* onFulfilled is called when/if "promise" resolves. onRejected is called when/if "promise" rejects.
* Both are optional, if either/both are omitted the next onFulfilled/onRejected in the chain is called.
* Both callbacks have a single parameter , the fulfillment value or rejection reason.
* "then" returns a new promise equivalent to the value you return from onFulfilled/onRejected after being passed through Promise.resolve.
* If an error is thrown in the callback, the returned promise rejects with that error.
* @param onFulfilled called when/if "promise" resolves
* @param onRejected called when/if "promise" rejects
*/
then<U>(onFulfilled?: (value: R) => U, onRejected?: (error: any) => Thenable<U>): Promise<U>;
/**
* onFulfilled is called when/if "promise" resolves. onRejected is called when/if "promise" rejects.
* Both are optional, if either/both are omitted the next onFulfilled/onRejected in the chain is called.
* Both callbacks have a single parameter , the fulfillment value or rejection reason.
* "then" returns a new promise equivalent to the value you return from onFulfilled/onRejected after being passed through Promise.resolve.
* If an error is thrown in the callback, the returned promise rejects with that error.
* @param onFulfilled called when/if "promise" resolves
* @param onRejected called when/if "promise" rejects
*/
then<U>(onFulfilled?: (value: R) => U, onRejected?: (error: any) => U): Promise<U>;
/**
* onFulfilled is called when/if "promise" resolves. onRejected is called when/if "promise" rejects.
* Both are optional, if either/both are omitted the next onFulfilled/onRejected in the chain is called.
* Both callbacks have a single parameter , the fulfillment value or rejection reason.
* "then" returns a new promise equivalent to the value you return from onFulfilled/onRejected after being passed through Promise.resolve.
* If an error is thrown in the callback, the returned promise rejects with that error.
* @param onFulfilled called when/if "promise" resolves
* @param onRejected called when/if "promise" rejects
*/
then<U>(onFulfilled?: (value: R) => U, onRejected?: (error: any) => void): Promise<U>;
/**
* Sugar for promise.then(undefined, onRejected)
* @param onRejected called when/if "promise" rejects
*/
catch<U>(onRejected?: (error: any) => Thenable<U>): Promise<U>;
/**
* Sugar for promise.then(undefined, onRejected)
* @param onRejected called when/if "promise" rejects
*/
catch<U>(onRejected?: (error: any) => U): Promise<U>;
/**
* Sugar for promise.then(undefined, onRejected)
* @param onRejected called when/if "promise" rejects
*/
catch<U>(onRejected?: (error: any) => void): Promise<U>;
}
declare module Promise {
/**
* Returns promise (only if promise.constructor == Promise)
*/
function cast<R>(promise: Promise<R>): Promise<R>;
/**
* Make a promise that fulfills to obj.
*/
function cast<R>(object: R): Promise<R>;
/**
* Make a new promise from the thenable.
* A thenable is promise-like in as far as it has a "then" method.
* This also creates a new promise if you pass it a genuine JavaScript promise, making it less efficient for casting than Promise.cast.
*/
function resolve<R>(thenable?: Thenable<R>): Promise<R>;
/**
* Make a promise that fulfills to obj. Same as Promise.cast(obj) in this situation.
*/
function resolve<R>(object?: R): Promise<R>;
/**
* Make a promise that rejects to obj. For consistency and debugging (eg stack traces), obj should be an instanceof Error
*/
function reject(error: any): Promise<any>;
/**
* Make a promise that fulfills when every item in the array fulfills, and rejects if (and when) any item rejects.
* the array passed to all can be a mixture of promise-like objects and other objects.
* The fulfillment value is an array (in order) of fulfillment values. The rejection value is the first rejection value.
*/
function all<R>(promises: Promise<R>[]): Promise<R[]>;
/**
* Make a Promise that fulfills when any item fulfills, and rejects if any item rejects.
*/
function race<R>(promises: Promise<R>[]): Promise<R>;
}
declare function alert(message: string): Promise<void>;

43
es-collections.d.ts vendored Normal file
View File

@ -0,0 +1,43 @@
/* tslint:disable */
/////////////////////////////
/// IE11 ECMAScript Extensions
/////////////////////////////
interface List<T> extends Array<T> {}
interface Map<K, V> {
clear(): void;
delete(key: K): boolean;
forEach(callbackfn: (value: V, index: K, map: Map<K, V>) => void, thisArg?: any): void;
get(key: K): V;
has(key: K): boolean;
set(key: K, value: V): Map<K, V>;
size: number;
}
declare var Map: {
new <K, V>(): Map<K, V>;
// needed by Angular
// alexeagle: PATCHED
new<K, V>(m: Map<K, V>): Map<K, V>;
new<K, V>(l: List<any>): Map<K, V>;
prototype: Map<any, any>;
}
interface Set<T> {
add(value: T): Set<T>;
clear(): void;
delete(value: T): boolean;
forEach(callbackfn: (value: T, index: T, set: Set<T>) => void, thisArg?: any): void;
has(value: T): boolean;
size: number;
}
declare var Set: {
new <T>(): Set<T>;
// needed by Angular
// alexeagle PATCHED
new<T>(s: Set<T>): Set<T>;
new<T>(l: List<T>): Set<T>;
prototype: Set<any>;
}

148
es6-promise.d.ts vendored Normal file
View File

@ -0,0 +1,148 @@
/* tslint:disable */
// Type definitions for es6-promise
// Project: https://github.com/jakearchibald/ES6-Promise
// Definitions by: François de Campredon <https://github.com/fdecampredon/>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
interface Thenable<R> {
then<U>(onFulfilled?: (value: R) => Thenable<U>, onRejected?: (error: any) => Thenable<U>): Thenable<U>;
then<U>(onFulfilled?: (value: R) => Thenable<U>, onRejected?: (error: any) => U): Thenable<U>;
then<U>(onFulfilled?: (value: R) => Thenable<U>, onRejected?: (error: any) => void): Thenable<U>;
then<U>(onFulfilled?: (value: R) => U, onRejected?: (error: any) => Thenable<U>): Thenable<U>;
then<U>(onFulfilled?: (value: R) => U, onRejected?: (error: any) => U): Thenable<U>;
then<U>(onFulfilled?: (value: R) => U, onRejected?: (error: any) => void): Thenable<U>;
}
declare class Promise<R> implements Thenable<R> {
/**
* If you call resolve in the body of the callback passed to the constructor,
* your promise is fulfilled with result object passed to resolve.
* If you call reject your promise is rejected with the object passed to resolve.
* For consistency and debugging (eg stack traces), obj should be an instanceof Error.
* Any errors thrown in the constructor callback will be implicitly passed to reject().
*/
constructor(callback: (resolve: (result?: R) => void, reject: (error: any) => void) => void);
/**
* If you call resolve in the body of the callback passed to the constructor,
* your promise will be fulfilled/rejected with the outcome of thenable passed to resolve.
* If you call reject your promise is rejected with the object passed to resolve.
* For consistency and debugging (eg stack traces), obj should be an instanceof Error.
* Any errors thrown in the constructor callback will be implicitly passed to reject().
*/
constructor(callback: (resolve: (thenable?: Thenable<R>) => void, reject: (error: any) => void) => void);
/**
* onFulfilled is called when/if "promise" resolves. onRejected is called when/if "promise" rejects.
* Both are optional, if either/both are omitted the next onFulfilled/onRejected in the chain is called.
* Both callbacks have a single parameter , the fulfillment value or rejection reason.
* "then" returns a new promise equivalent to the value you return from onFulfilled/onRejected after being passed through Promise.resolve.
* If an error is thrown in the callback, the returned promise rejects with that error.
* @param onFulfilled called when/if "promise" resolves
* @param onRejected called when/if "promise" rejects
*/
then<U>(onFulfilled?: (value: R) => Thenable<U>, onRejected?: (error: any) => Thenable<U>): Promise<U>;
/**
* onFulfilled is called when/if "promise" resolves. onRejected is called when/if "promise" rejects.
* Both are optional, if either/both are omitted the next onFulfilled/onRejected in the chain is called.
* Both callbacks have a single parameter , the fulfillment value or rejection reason.
* "then" returns a new promise equivalent to the value you return from onFulfilled/onRejected after being passed through Promise.resolve.
* If an error is thrown in the callback, the returned promise rejects with that error.
* @param onFulfilled called when/if "promise" resolves
* @param onRejected called when/if "promise" rejects
*/
then<U>(onFulfilled?: (value: R) => Thenable<U>, onRejected?: (error: any) => U): Promise<U>;
/**
* onFulfilled is called when/if "promise" resolves. onRejected is called when/if "promise" rejects.
* Both are optional, if either/both are omitted the next onFulfilled/onRejected in the chain is called.
* Both callbacks have a single parameter , the fulfillment value or rejection reason.
* "then" returns a new promise equivalent to the value you return from onFulfilled/onRejected after being passed through Promise.resolve.
* If an error is thrown in the callback, the returned promise rejects with that error.
* @param onFulfilled called when/if "promise" resolves
* @param onRejected called when/if "promise" rejects
*/
then<U>(onFulfilled?: (value: R) => Thenable<U>, onRejected?: (error: any) => void): Promise<U>;
/**
* onFulfilled is called when/if "promise" resolves. onRejected is called when/if "promise" rejects.
* Both are optional, if either/both are omitted the next onFulfilled/onRejected in the chain is called.
* Both callbacks have a single parameter , the fulfillment value or rejection reason.
* "then" returns a new promise equivalent to the value you return from onFulfilled/onRejected after being passed through Promise.resolve.
* If an error is thrown in the callback, the returned promise rejects with that error.
* @param onFulfilled called when/if "promise" resolves
* @param onRejected called when/if "promise" rejects
*/
then<U>(onFulfilled?: (value: R) => U, onRejected?: (error: any) => Thenable<U>): Promise<U>;
/**
* onFulfilled is called when/if "promise" resolves. onRejected is called when/if "promise" rejects.
* Both are optional, if either/both are omitted the next onFulfilled/onRejected in the chain is called.
* Both callbacks have a single parameter , the fulfillment value or rejection reason.
* "then" returns a new promise equivalent to the value you return from onFulfilled/onRejected after being passed through Promise.resolve.
* If an error is thrown in the callback, the returned promise rejects with that error.
* @param onFulfilled called when/if "promise" resolves
* @param onRejected called when/if "promise" rejects
*/
then<U>(onFulfilled?: (value: R) => U, onRejected?: (error: any) => U): Promise<U>;
/**
* onFulfilled is called when/if "promise" resolves. onRejected is called when/if "promise" rejects.
* Both are optional, if either/both are omitted the next onFulfilled/onRejected in the chain is called.
* Both callbacks have a single parameter , the fulfillment value or rejection reason.
* "then" returns a new promise equivalent to the value you return from onFulfilled/onRejected after being passed through Promise.resolve.
* If an error is thrown in the callback, the returned promise rejects with that error.
* @param onFulfilled called when/if "promise" resolves
* @param onRejected called when/if "promise" rejects
*/
then<U>(onFulfilled?: (value: R) => U, onRejected?: (error: any) => void): Promise<U>;
/**
* Sugar for promise.then(undefined, onRejected)
* @param onRejected called when/if "promise" rejects
*/
catch<U>(onRejected?: (error: any) => Thenable<U>): Promise<U>;
/**
* Sugar for promise.then(undefined, onRejected)
* @param onRejected called when/if "promise" rejects
*/
catch<U>(onRejected?: (error: any) => U): Promise<U>;
/**
* Sugar for promise.then(undefined, onRejected)
* @param onRejected called when/if "promise" rejects
*/
catch<U>(onRejected?: (error: any) => void): Promise<U>;
}
declare module Promise {
/**
* Returns promise (only if promise.constructor == Promise)
*/
function cast<R>(promise: Promise<R>): Promise<R>;
/**
* Make a promise that fulfills to obj.
*/
function cast<R>(object: R): Promise<R>;
/**
* Make a new promise from the thenable.
* A thenable is promise-like in as far as it has a "then" method.
* This also creates a new promise if you pass it a genuine JavaScript promise, making it less efficient for casting than Promise.cast.
*/
function resolve<R>(thenable?: Thenable<R>): Promise<R>;
/**
* Make a promise that fulfills to obj. Same as Promise.cast(obj) in this situation.
*/
function resolve<R>(object?: R): Promise<R>;
/**
* Make a promise that rejects to obj. For consistency and debugging (eg stack traces), obj should be an instanceof Error
*/
function reject(error: any): Promise<any>;
/**
* Make a promise that fulfills when every item in the array fulfills, and rejects if (and when) any item rejects.
* the array passed to all can be a mixture of promise-like objects and other objects.
* The fulfillment value is an array (in order) of fulfillment values. The rejection value is the first rejection value.
*/
function all<R>(promises: Promise<R>[]): Promise<R[]>;
/**
* Make a Promise that fulfills when any item fulfills, and rejects if any item rejects.
*/
function race<R>(promises: Promise<R>[]): Promise<R>;
}

35
libjs.d.ts vendored
View File

@ -498,6 +498,11 @@ declare var Number: {
* JavaScript displays POSITIVE_INFINITY values as infinity.
*/
POSITIVE_INFINITY: number;
/**
* Checks if the passed value is an integer.
*/
isInteger(value: any): boolean;
}
interface Math {
@ -1756,23 +1761,6 @@ declare var DataView: {
new (buffer: ArrayBuffer, byteOffset?: number, length?: number): DataView;
}
/////////////////////////////
/// IE11 ECMAScript Extensions
/////////////////////////////
interface Map<K, V> {
clear(): void;
delete(key: K): boolean;
forEach(callbackfn: (value: V, index: K, map: Map<K, V>) => void, thisArg?: any): void;
get(key: K): V;
has(key: K): boolean;
set(key: K, value: V): Map<K, V>;
size: number;
}
declare var Map: {
new <K, V>(): Map<K, V>;
}
interface WeakMap<K, V> {
clear(): void;
delete(key: K): boolean;
@ -1784,15 +1772,4 @@ declare var WeakMap: {
new <K, V>(): WeakMap<K, V>;
}
interface Set<T> {
add(value: T): Set<T>;
clear(): void;
delete(value: T): boolean;
forEach(callbackfn: (value: T, index: T, set: Set<T>) => void, thisArg?: any): void;
has(value: T): boolean;
size: number;
}
declare var Set: {
new <T>(): Set<T>;
}
declare function alert(message: string): Promise<void>;

View File

@ -151,7 +151,7 @@ export class Frame extends frameCommon.Frame {
}
}
class UINavigationControllerImpl extends UINavigationController implements UINavigationControllerDelegate {
export class UINavigationControllerImpl extends UINavigationController implements UINavigationControllerDelegate {
public static ObjCProtocols = [UINavigationControllerDelegate];
static new(): UINavigationControllerImpl {
@ -240,7 +240,7 @@ class UINavigationControllerImpl extends UINavigationController implements UINav
}
/* tslint:disable */
class iOSFrame implements definition.iOSFrame {
export class iOSFrame implements definition.iOSFrame {
/* tslint:enable */
private _controller: UINavigationControllerImpl;
private _showNavigationBar: boolean;

View File

@ -158,7 +158,7 @@ export class SegmentedBar extends common.SegmentedBar {
}
}
class OurTabHost extends android.widget.TabHost {
export class OurTabHost extends android.widget.TabHost {
constructor(context: any, attrs: any) {
super(context, attrs);
@ -168,4 +168,4 @@ class OurTabHost extends android.widget.TabHost {
protected onAttachedToWindow(): void {
// overriden to remove the code that will steal the focus from edit fields.
}
}
}