Allow static side of native types to be extended

This commit is contained in:
Mohamed Hegazy
2014-10-28 21:21:47 -07:00
parent 8c7fd3c287
commit fe4a96e1bd
46 changed files with 207 additions and 167 deletions

86
src/lib/core.d.ts vendored
View File

@@ -109,10 +109,7 @@ interface Object {
propertyIsEnumerable(v: string): boolean;
}
/**
* Provides functionality common to all JavaScript objects.
*/
declare var Object: {
interface ObjectConstructor {
new (value?: any): Object;
(): any;
(value: any): any;
@@ -206,6 +203,11 @@ declare var Object: {
keys(o: any): string[];
}
/**
* Provides functionality common to all JavaScript objects.
*/
declare var Object: ObjectConstructor;
/**
* Creates a new function.
*/
@@ -240,8 +242,8 @@ interface Function {
caller: Function;
}
declare var Function: {
/**
interface FunctionConstructor {
/**
* Creates a new function.
* @param args A list of arguments the function accepts.
*/
@@ -250,6 +252,8 @@ declare var Function: {
prototype: Function;
}
declare var Function: FunctionConstructor;
interface IArguments {
[index: number]: any;
length: number;
@@ -409,24 +413,29 @@ interface String {
[index: number]: string;
}
/**
* Allows manipulation and formatting of text strings and determination and location of substrings within strings.
*/
declare var String: {
interface StringConstructor {
new (value?: any): String;
(value?: any): string;
prototype: String;
fromCharCode(...codes: number[]): string;
}
/**
* Allows manipulation and formatting of text strings and determination and location of substrings within strings.
*/
declare var String: StringConstructor;
interface Boolean {
}
declare var Boolean: {
interface BoolenConstructor {
new (value?: any): Boolean;
(value?: any): boolean;
prototype: Boolean;
}
declare var Boolean: BoolenConstructor;
interface Number {
/**
* Returns a string representation of an object.
@@ -453,8 +462,7 @@ interface Number {
toPrecision(precision?: number): string;
}
/** An object that represents a number of any kind. All JavaScript numbers are 64-bit floating-point numbers. */
declare var Number: {
interface NumberConstructor {
new (value?: any): Number;
(value?: any): number;
prototype: Number;
@@ -484,6 +492,9 @@ declare var Number: {
POSITIVE_INFINITY: number;
}
/** An object that represents a number of any kind. All JavaScript numbers are 64-bit floating-point numbers. */
declare var Number: NumberConstructor;
interface Math {
/** The mathematical constant e. This is Euler's number, the base of natural logarithms. */
E: number;
@@ -749,7 +760,7 @@ interface Date {
toJSON(key?: any): string;
}
declare var Date: {
interface DateConstructor {
new (): Date;
new (value: number): Date;
new (value: string): Date;
@@ -775,6 +786,8 @@ declare var Date: {
now(): number;
}
declare var Date: DateConstructor;
interface RegExpMatchArray extends Array<string> {
index?: number;
input?: string;
@@ -815,7 +828,8 @@ interface RegExp {
// Non-standard extensions
compile(): RegExp;
}
declare var RegExp: {
interface RegExpConstructor {
new (pattern: string, flags?: string): RegExp;
(pattern: string, flags?: string): RegExp;
@@ -832,64 +846,87 @@ declare var RegExp: {
lastMatch: string;
}
declare var RegExp: RegExpConstructor;
interface Error {
name: string;
message: string;
}
declare var Error: {
interface ErrorConstructor {
new (message?: string): Error;
(message?: string): Error;
prototype: Error;
}
declare var Error: ErrorConstructor;
interface EvalError extends Error {
}
declare var EvalError: {
interface EvalErrorConstructor {
new (message?: string): EvalError;
(message?: string): EvalError;
prototype: EvalError;
}
declare var EvalError: EvalErrorConstructor;
interface RangeError extends Error {
}
declare var RangeError: {
interface RangeErrorConstructor {
new (message?: string): RangeError;
(message?: string): RangeError;
prototype: RangeError;
}
declare var RangeError: RangeErrorConstructor;
interface ReferenceError extends Error {
}
declare var ReferenceError: {
interface ReferenceErrorConstructor {
new (message?: string): ReferenceError;
(message?: string): ReferenceError;
prototype: ReferenceError;
}
declare var ReferenceError: ReferenceErrorConstructor;
interface SyntaxError extends Error {
}
declare var SyntaxError: {
interface SyntaxErrorConstructor {
new (message?: string): SyntaxError;
(message?: string): SyntaxError;
prototype: SyntaxError;
}
declare var SyntaxError: SyntaxErrorConstructor;
interface TypeError extends Error {
}
declare var TypeError: {
interface TypeErrorConstructor {
new (message?: string): TypeError;
(message?: string): TypeError;
prototype: TypeError;
}
declare var TypeError: TypeErrorConstructor;
interface URIError extends Error {
}
declare var URIError: {
interface URIErrorConstructor {
new (message?: string): URIError;
(message?: string): URIError;
prototype: URIError;
}
declare var URIError: URIErrorConstructor;
interface JSON {
/**
* Converts a JavaScript Object Notation (JSON) string into an object.
@@ -1092,7 +1129,8 @@ interface Array<T> {
[n: number]: T;
}
declare var Array: {
interface ArrayConstructor {
new (arrayLength?: number): any[];
new <T>(arrayLength: number): T[];
new <T>(...items: T[]): T[];
@@ -1102,3 +1140,5 @@ declare var Array: {
isArray(arg: any): boolean;
prototype: Array<any>;
}
declare var Array: ArrayConstructor;