Skip to content

ES6 typings #987

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 38 commits into from
Dec 2, 2014
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
fe4a96e
Allow static side of native types to be extended
mhegazy Oct 29, 2014
c8db066
First draft of es6 typings
mhegazy Oct 29, 2014
63e1363
Load the es6 lib if target is es6
mhegazy Oct 29, 2014
4f8605b
Add reflect definition
mhegazy Oct 29, 2014
13a6487
Merge branch 'master' into es6Typings
mhegazy Nov 11, 2014
00bfc06
remove unused arguments for getCompiler
mhegazy Nov 11, 2014
ff32be7
Add additional property to mapfn for Array.from
mhegazy Nov 11, 2014
f5eef43
Use the correct name for interface Math
mhegazy Nov 11, 2014
6ae43f3
Fix paramters for Math.hypot function
mhegazy Nov 11, 2014
6b5d0b0
Use PropertyKey instead of string when appropriate
mhegazy Nov 11, 2014
20bbebc
Make WeakMap.prototype.set second parameter optional
mhegazy Nov 11, 2014
4257e1c
Make Map.prototype.set second paramter optional
mhegazy Nov 11, 2014
abed6e4
Cleanup Proxy definition
mhegazy Nov 11, 2014
ded34ef
Add support for typed arrays
mhegazy Nov 11, 2014
7d6f7ea
Fix symbol constructor and update Object properties
mhegazy Nov 14, 2014
2897612
Add Promise typing support
mhegazy Nov 15, 2014
1986fb1
Respond to code review comments
mhegazy Nov 17, 2014
0629bba
allow non ts files to be passed in to the compiler
mhegazy Nov 17, 2014
6c6d9bf
Add test262 test runner
mhegazy Nov 17, 2014
0dddfd9
respond to code review comment
mhegazy Nov 17, 2014
25ce5db
Merge branch 'master' into es6Typings
mhegazy Nov 17, 2014
19854a0
Add TypedArray tests
mhegazy Nov 17, 2014
4413dd5
Move the Internationalization API to its own file and include it in E…
mhegazy Nov 17, 2014
f33c1d5
Add ArrayBufferView definition to ES6 lib
mhegazy Nov 17, 2014
1abe1d7
Add dom to es6 lib
mhegazy Nov 17, 2014
bdee183
minor fixes
mhegazy Nov 17, 2014
4c2f5d1
Add some more jsdoc comments and ensure everything has a constructor …
mhegazy Nov 17, 2014
ff2e4fa
remove extra call to getSourceFile
mhegazy Nov 17, 2014
ebf4ed8
Respond to code review comments
mhegazy Nov 20, 2014
d3e70ec
Merge branch 'master' into es6typings
mhegazy Nov 27, 2014
507ec3d
Merge branch 'master' into es6Typings
mhegazy Nov 27, 2014
ef14da0
Add tree serializer to test262
mhegazy Nov 27, 2014
af38970
Move collateOutputs to harness
mhegazy Nov 27, 2014
cc270c7
Add the test262 helper file
mhegazy Nov 27, 2014
199b71c
Merge branch 'master' into es6Typings
mhegazy Dec 1, 2014
99d13f4
handel serializing diagnostics
mhegazy Dec 2, 2014
4e79458
Merge branch 'master' into es6typings
mhegazy Dec 2, 2014
d390f67
add missing prototype definitions
mhegazy Dec 2, 2014
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Jakefile
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ var librarySourceMap = [
{ target: "lib.webworker.d.ts", sources: ["importcore.d.ts", "extensions.d.ts", "webworker.generated.d.ts"], },
{ target: "lib.scriptHost.d.ts", sources: ["importcore.d.ts", "scriptHost.d.ts"], },
{ target: "lib.d.ts", sources: ["core.d.ts", "extensions.d.ts", "dom.generated.d.ts", "webworker.importscripts.d.ts", "scriptHost.d.ts"], },
{ target: "lib.es6.d.ts", sources: ["core.d.ts", "es6.d.ts"]},
];

var libraryTargets = librarySourceMap.map(function (f) {
Expand Down
2 changes: 1 addition & 1 deletion src/compiler/parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4132,7 +4132,7 @@ module ts {

forEach(rootNames, name => processRootFile(name, false));
if (!seenNoDefaultLib) {
processRootFile(host.getDefaultLibFilename(), true);
processRootFile(host.getDefaultLibFilename(options), true);
}
verifyCompilerOptions();
errors.sort(compareDiagnostics);
Expand Down
2 changes: 1 addition & 1 deletion src/compiler/tsc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ module ts {

return {
getSourceFile: getSourceFile,
getDefaultLibFilename: () => combinePaths(getDirectoryPath(normalizePath(sys.getExecutingFilePath())), "lib.d.ts"),
getDefaultLibFilename: (options) => combinePaths(getDirectoryPath(normalizePath(sys.getExecutingFilePath())), options.target === ScriptTarget.ES6 ? "lib.es6.d.ts" : "lib.d.ts"),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no parens.

writeFile: writeFile,
getCurrentDirectory: () => currentDirectory || (currentDirectory = sys.getCurrentDirectory()),
useCaseSensitiveFileNames: () => sys.useCaseSensitiveFileNames,
Expand Down
2 changes: 1 addition & 1 deletion src/compiler/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1256,7 +1256,7 @@ module ts {

export interface CompilerHost {
getSourceFile(filename: string, languageVersion: ScriptTarget, onError?: (message: string) => void): SourceFile;
getDefaultLibFilename(): string;
getDefaultLibFilename(options: CompilerOptions): string;
getCancellationToken? (): CancellationToken;
writeFile(filename: string, data: string, writeByteOrderMark: boolean, onError?: (message: string) => void): void;
getCurrentDirectory(): string;
Expand Down
2 changes: 1 addition & 1 deletion src/harness/harness.ts
Original file line number Diff line number Diff line change
Expand Up @@ -591,7 +591,7 @@ module Harness {
return null;
}
},
getDefaultLibFilename: () => defaultLibFileName,
getDefaultLibFilename: (options) => defaultLibFileName,
writeFile: writeFile,
getCanonicalFileName: getCanonicalFileName,
useCaseSensitiveFileNames: () => useCaseSensitiveFileNames,
Expand Down
86 changes: 63 additions & 23 deletions src/lib/core.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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.
*/
Expand Down Expand Up @@ -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.
*/
Expand All @@ -250,6 +252,8 @@ declare var Function: {
prototype: Function;
}

declare var Function: FunctionConstructor;

interface IArguments {
[index: number]: any;
length: number;
Expand Down Expand Up @@ -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 {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we set on _Constructor? I have reservations because it's more than just a constructor; you have

fromCharCode(...codes: number[]): string;

which is a method on the static side. A lot of .d.ts libraries tend to use the _Static as a naming convention for these types.

I can honestly view it either way.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have no strong feelings about the name. Personally I would rather not introduce a new named type and kept it the way it is now; and maybe we should.
But if we were to change it, am ok with type_static.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would prefer StringConstructor. The ES spec calls it "the String Constructor" when describing the object and does not ever use the word "static" except to reserve it as a keyword.

http://www.ecma-international.org/ecma-262/5.1/#sec-15.5.3

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.
Expand All @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -775,6 +786,8 @@ declare var Date: {
now(): number;
}

declare var Date: DateConstructor;

interface RegExpMatchArray extends Array<string> {
index?: number;
input?: string;
Expand Down Expand Up @@ -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;

Expand All @@ -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.
Expand Down Expand Up @@ -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[];
Expand All @@ -1102,3 +1140,5 @@ declare var Array: {
isArray(arg: any): boolean;
prototype: Array<any>;
}

declare var Array: ArrayConstructor;
Loading