Skip to content

Commit b82fd59

Browse files
committed
merge with master, accept baselines
2 parents 8d089af + 17f3e14 commit b82fd59

File tree

4,031 files changed

+78733
-62190
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

4,031 files changed

+78733
-62190
lines changed

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
*.js linguist-language=TypeScript

.travis.yml

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,4 @@ language: node_js
33
node_js:
44
- '0.10'
55

6-
sudo: false
7-
8-
before_script:
9-
- npm install -g codeclimate-test-reporter
10-
11-
after_script:
12-
- cat coverage/lcov.info | codeclimate
13-
14-
addons:
15-
code_climate:
16-
repo_token: 9852ac5362c8cc38c07ca5adc0f94c20c6c79bd78e17933dc284598a65338656
6+
sudo: false

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Design changes will not be accepted at this time. If you have a design change pr
99
## Legal
1010
You will need to complete a Contributor License Agreement (CLA). Briefly, this agreement testifies that you are granting us permission to use the submitted change according to the terms of the project's license, and that the work being submitted is under appropriate copyright.
1111

12-
Please submit a Contributor License Agreement (CLA) before submitting a pull request. Download the agreement ([Microsoft Contribution License Agreement.docx](https://www.codeplex.com/Download?ProjectName=typescript&DownloadId=822190) or [Microsoft Contribution License Agreement.pdf](https://www.codeplex.com/Download?ProjectName=typescript&DownloadId=921298)), sign, scan, and email it back to <[email protected]>. Be sure to include your github user name along with the agreement. Once we have received the signed CLA, we'll review the request. Please note that we're currently only accepting pull requests of bug fixes rather than new features.
12+
Please submit a Contributor License Agreement (CLA) before submitting a pull request. You may visit https://cla.microsoft.com to sign digitally. Alternatively, download the agreement ([Microsoft Contribution License Agreement.docx](https://www.codeplex.com/Download?ProjectName=typescript&DownloadId=822190) or [Microsoft Contribution License Agreement.pdf](https://www.codeplex.com/Download?ProjectName=typescript&DownloadId=921298)), sign, scan, and email it back to <[email protected]>. Be sure to include your github user name along with the agreement. Once we have received the signed CLA, we'll review the request. Please note that we're currently only accepting pull requests of bug fixes rather than new features.
1313

1414
## Housekeeping
1515
Your pull request should:

Jakefile

Lines changed: 72 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
var fs = require("fs");
44
var os = require("os");
55
var path = require("path");
6+
var child_process = require("child_process");
67

78
// Variables
89
var compilerDirectory = "src/compiler/";
@@ -25,8 +26,7 @@ var thirdParty = "ThirdPartyNoticeText.txt";
2526
var nodeModulesPathPrefix = path.resolve("./node_modules/.bin/") + path.delimiter;
2627
if (process.env.path !== undefined) {
2728
process.env.path = nodeModulesPathPrefix + process.env.path;
28-
}
29-
else if (process.env.PATH !== undefined) {
29+
} else if (process.env.PATH !== undefined) {
3030
process.env.PATH = nodeModulesPathPrefix + process.env.PATH;
3131
}
3232

@@ -203,8 +203,7 @@ function concatenateFiles(destinationFile, sourceFiles) {
203203
var useDebugMode = true;
204204
var host = (process.env.host || process.env.TYPESCRIPT_HOST || "node");
205205
var compilerFilename = "tsc.js";
206-
207-
/* Compiles a file from a list of sources
206+
/* Compiles a file from a list of sources
208207
* @param outFile: the target file name
209208
* @param sources: an array of the names of the source files
210209
* @param prereqs: prerequisite tasks to compiling the file
@@ -215,9 +214,8 @@ var compilerFilename = "tsc.js";
215214
* @param outDir: true to compile using --outDir
216215
* @param keepComments: false to compile using --removeComments
217216
* @param callback: a function to execute after the compilation process ends
218-
* @async
219217
*/
220-
function compileFile(outFile, sources, prereqs, prefixes, useBuiltCompiler, noOutFile, generateDeclarations, outDir, preserveConstEnums, keepComments, noResolve, stripInternal, callback) {
218+
function compileFile(outFile, sources, prereqs, prefixes, useBuiltCompiler, noOutFile, generateDeclarations, outDir, preserveConstEnums, keepComments, noResolve, stripInternal, callback) {
221219
file(outFile, prereqs, function() {
222220
var dir = useBuiltCompiler ? builtLocalDirectory : LKGDirectory;
223221
var options = "--module commonjs -noImplicitAny";
@@ -254,11 +252,21 @@ var compilerFilename = "tsc.js";
254252
options += " --stripInternal"
255253
}
256254

255+
options += " --cacheDownlevelForOfLength --preserveNewLines";
256+
257257
var cmd = host + " " + dir + compilerFilename + " " + options + " ";
258258
cmd = cmd + sources.join(" ");
259+
console.log(cmd + "\n");
259260

260-
exec(cmd, function() {
261-
console.log("")
261+
var ex = jake.createExec([cmd]);
262+
// Add listeners for output and error
263+
ex.addListener("stdout", function(output) {
264+
process.stdout.write(output);
265+
});
266+
ex.addListener("stderr", function(error) {
267+
process.stderr.write(error);
268+
});
269+
ex.addListener("cmdEnd", function() {
262270
if (!useDebugMode && prefixes && fs.existsSync(outFile)) {
263271
for (var i in prefixes) {
264272
prependFile(prefixes[i], outFile);
@@ -268,14 +276,14 @@ var compilerFilename = "tsc.js";
268276
if (callback) {
269277
callback();
270278
}
271-
else {
272-
complete();
273-
}
274-
}, /* errorHandler */ function() {
279+
280+
complete();
281+
});
282+
ex.addListener("error", function() {
275283
fs.unlinkSync(outFile);
276284
fail("Compilation of " + outFile + " unsuccessful");
277285
});
278-
286+
ex.run();
279287
}, {async: true});
280288
}
281289

@@ -318,8 +326,19 @@ compileFile(processDiagnosticMessagesJs,
318326
// The generated diagnostics map; built for the compiler and for the 'generate-diagnostics' task
319327
file(diagnosticInfoMapTs, [processDiagnosticMessagesJs, diagnosticMessagesJson], function () {
320328
var cmd = "node " + processDiagnosticMessagesJs + " " + diagnosticMessagesJson;
321-
322-
exec(cmd);
329+
console.log(cmd);
330+
var ex = jake.createExec([cmd]);
331+
// Add listeners for output and error
332+
ex.addListener("stdout", function(output) {
333+
process.stdout.write(output);
334+
});
335+
ex.addListener("stderr", function(error) {
336+
process.stderr.write(error);
337+
});
338+
ex.addListener("cmdEnd", function() {
339+
complete();
340+
});
341+
ex.run();
323342
}, {async: true})
324343

325344
desc("Generates a diagnostic file in TypeScript based on an input JSON file");
@@ -384,7 +403,6 @@ compileFile(nodeDefinitionsFile, servicesSources,[builtLocalDirectory, copyright
384403

385404
// Delete the temp dir
386405
jake.rmRf(tempDirPath, {silent: true});
387-
complete();
388406
});
389407

390408
var serverFile = path.join(builtLocalDirectory, "tsserver.js");
@@ -433,8 +451,10 @@ compileFile(word2mdJs,
433451
file(specMd, [word2mdJs, specWord], function () {
434452
var specWordFullPath = path.resolve(specWord);
435453
var cmd = "cscript //nologo " + word2mdJs + ' "' + specWordFullPath + '" ' + specMd;
436-
437-
exec(cmd);
454+
console.log(cmd);
455+
child_process.exec(cmd, function () {
456+
complete();
457+
});
438458
}, {async: true})
439459

440460

@@ -485,24 +505,22 @@ var refTest262Baseline = path.join(internalTests, "baselines/test262/reference")
485505
desc("Builds the test infrastructure using the built compiler");
486506
task("tests", ["local", run].concat(libraryTargets));
487507

488-
/* Executes a command
489-
* @param cmd: command to execute
490-
* @param completeHandler?: a function to execute after the command ends
491-
* @param errorHandler?: a function to execute if an error occurs
492-
* @async
493-
*/
494-
function exec(cmd, completeHandler, errorHandler) {
495-
console.log(cmd);
496-
var ex = jake.createExec([cmd], {windowsVerbatimArguments: true, interactive: true});
508+
function exec(cmd, completeHandler) {
509+
var ex = jake.createExec([cmd], {windowsVerbatimArguments: true});
510+
// Add listeners for output and error
511+
ex.addListener("stdout", function(output) {
512+
process.stdout.write(output);
513+
});
514+
ex.addListener("stderr", function(error) {
515+
process.stderr.write(error);
516+
});
497517
ex.addListener("cmdEnd", function() {
498518
if (completeHandler) {
499519
completeHandler();
500520
}
501-
else {
502-
complete();
503-
}
521+
complete();
504522
});
505-
ex.addListener("error", errorHandler || function(e, status) {
523+
ex.addListener("error", function(e, status) {
506524
fail("Process exited with code " + status);
507525
})
508526

@@ -521,7 +539,7 @@ function cleanTestDirs() {
521539
}
522540

523541
jake.mkdirP(localRwcBaseline);
524-
jake.mkdirP(localTest262Baseline);
542+
jake.mkdirP(localTest262Baseline);
525543
jake.mkdirP(localBaseline);
526544
}
527545

@@ -532,14 +550,10 @@ function writeTestConfigFile(tests, testConfigFile) {
532550
fs.writeFileSync('test.config', testConfigContents);
533551
}
534552

535-
/* Removes project output
536-
* @async
537-
*/
538553
function deleteTemporaryProjectOutput() {
539554
if (fs.existsSync(path.join(localBaseline, "projectOutput/"))) {
540555
jake.rmRf(path.join(localBaseline, "projectOutput/"));
541556
}
542-
complete();
543557
}
544558

545559
var testTimeout = 20000;
@@ -568,14 +582,14 @@ task("runtests", ["tests", builtLocalDirectory], function() {
568582
// timeout normally isn't necessary but Travis-CI has been timing out on compiler baselines occasionally
569583
// default timeout is 2sec which really should be enough, but maybe we just need a small amount longer
570584
var cmd = host + " -R " + reporter + tests + colors + ' -t ' + testTimeout + ' ' + run;
571-
585+
console.log(cmd);
572586
exec(cmd, deleteTemporaryProjectOutput);
573587
}, {async: true});
574588

575589
desc("Generates code coverage data via instanbul")
576590
task("generate-code-coverage", ["tests", builtLocalDirectory], function () {
577591
var cmd = 'istanbul cover node_modules/mocha/bin/_mocha -- -R min -t ' + testTimeout + ' ' + run;
578-
592+
console.log(cmd);
579593
exec(cmd);
580594
}, { async: true });
581595

@@ -607,6 +621,7 @@ task("runtests-browser", ["tests", "browserify", builtLocalDirectory], function(
607621

608622
tests = tests ? tests : '';
609623
var cmd = host + " tests/webTestServer.js " + port + " " + browser + " " + tests
624+
console.log(cmd);
610625
exec(cmd);
611626
}, {async: true});
612627

@@ -622,12 +637,14 @@ function getDiffTool() {
622637
desc("Diffs the compiler baselines using the diff tool specified by the 'DIFF' environment variable");
623638
task('diff', function () {
624639
var cmd = '"' + getDiffTool() + '" ' + refBaseline + ' ' + localBaseline;
640+
console.log(cmd)
625641
exec(cmd);
626642
}, {async: true});
627643

628644
desc("Diffs the RWC baselines using the diff tool specified by the 'DIFF' environment variable");
629645
task('diff-rwc', function () {
630646
var cmd = '"' + getDiffTool() + '" ' + refRwcBaseline + ' ' + localRwcBaseline;
647+
console.log(cmd)
631648
exec(cmd);
632649
}, {async: true});
633650

@@ -674,6 +691,13 @@ task("webhost", [webhostJsPath], function() {
674691
jake.cpR(path.join(builtLocalDirectory, "lib.d.ts"), "tests/webhost/", {silent: true});
675692
});
676693

694+
// Perf compiler
695+
var perftscPath = "tests/perftsc.ts";
696+
var perftscJsPath = "built/local/perftsc.js";
697+
compileFile(perftscJsPath, [perftscPath], [tscFile, perftscPath, "tests/perfsys.ts"].concat(libraryTargets), [], /*useBuiltCompiler*/ true);
698+
desc("Builds augmented version of the compiler for perf tests");
699+
task("perftsc", [perftscJsPath]);
700+
677701
// Instrumented compiler
678702
var loggedIOpath = harnessDirectory + 'loggedIO.ts';
679703
var loggedIOJsPath = builtLocalDirectory + 'loggedIO.js';
@@ -682,12 +706,14 @@ file(loggedIOJsPath, [builtLocalDirectory, loggedIOpath], function() {
682706
jake.mkdirP(temp);
683707
var options = "--outdir " + temp + ' ' + loggedIOpath;
684708
var cmd = host + " " + LKGDirectory + compilerFilename + " " + options + " ";
685-
686-
exec(cmd, function() {
709+
console.log(cmd + "\n");
710+
var ex = jake.createExec([cmd]);
711+
ex.addListener("cmdEnd", function() {
687712
fs.renameSync(temp + '/harness/loggedIO.js', loggedIOJsPath);
688713
jake.rmRf(temp);
689714
complete();
690715
});
716+
ex.run();
691717
}, {async: true});
692718

693719
var instrumenterPath = harnessDirectory + 'instrumenter.ts';
@@ -697,6 +723,10 @@ compileFile(instrumenterJsPath, [instrumenterPath], [tscFile, instrumenterPath],
697723
desc("Builds an instrumented tsc.js");
698724
task('tsc-instrumented', [loggedIOJsPath, instrumenterJsPath, tscFile], function() {
699725
var cmd = host + ' ' + instrumenterJsPath + ' record iocapture ' + builtLocalDirectory + compilerFilename;
700-
701-
exec(cmd);
726+
console.log(cmd);
727+
var ex = jake.createExec([cmd]);
728+
ex.addListener("cmdEnd", function() {
729+
complete();
730+
});
731+
ex.run();
702732
}, { async: true });

bin/lib.core.d.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -179,19 +179,19 @@ interface ObjectConstructor {
179179
* Prevents the modification of attributes of existing properties, and prevents the addition of new properties.
180180
* @param o Object on which to lock the attributes.
181181
*/
182-
seal(o: any): any;
182+
seal<T>(o: T): T;
183183

184184
/**
185185
* Prevents the modification of existing property attributes and values, and prevents the addition of new properties.
186186
* @param o Object on which to lock the attributes.
187187
*/
188-
freeze(o: any): any;
188+
freeze<T>(o: T): T;
189189

190190
/**
191191
* Prevents the addition of new properties to an object.
192192
* @param o Object to make non-extensible.
193193
*/
194-
preventExtensions(o: any): any;
194+
preventExtensions<T>(o: T): T;
195195

196196
/**
197197
* Returns true if existing property attributes cannot be modified in an object and new properties cannot be added to the object.
@@ -425,6 +425,9 @@ interface String {
425425
*/
426426
substr(from: number, length?: number): string;
427427

428+
/** Returns the primitive value of the specified object. */
429+
valueOf(): string;
430+
428431
[index: number]: string;
429432
}
430433

@@ -477,6 +480,9 @@ interface Number {
477480
* @param precision Number of significant digits. Must be in the range 1 - 21, inclusive.
478481
*/
479482
toPrecision(precision?: number): string;
483+
484+
/** Returns the primitive value of the specified object. */
485+
valueOf(): number;
480486
}
481487

482488
interface NumberConstructor {

bin/lib.core.es6.d.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -179,19 +179,19 @@ interface ObjectConstructor {
179179
* Prevents the modification of attributes of existing properties, and prevents the addition of new properties.
180180
* @param o Object on which to lock the attributes.
181181
*/
182-
seal(o: any): any;
182+
seal<T>(o: T): T;
183183

184184
/**
185185
* Prevents the modification of existing property attributes and values, and prevents the addition of new properties.
186186
* @param o Object on which to lock the attributes.
187187
*/
188-
freeze(o: any): any;
188+
freeze<T>(o: T): T;
189189

190190
/**
191191
* Prevents the addition of new properties to an object.
192192
* @param o Object to make non-extensible.
193193
*/
194-
preventExtensions(o: any): any;
194+
preventExtensions<T>(o: T): T;
195195

196196
/**
197197
* Returns true if existing property attributes cannot be modified in an object and new properties cannot be added to the object.
@@ -425,6 +425,9 @@ interface String {
425425
*/
426426
substr(from: number, length?: number): string;
427427

428+
/** Returns the primitive value of the specified object. */
429+
valueOf(): string;
430+
428431
[index: number]: string;
429432
}
430433

@@ -477,6 +480,9 @@ interface Number {
477480
* @param precision Number of significant digits. Must be in the range 1 - 21, inclusive.
478481
*/
479482
toPrecision(precision?: number): string;
483+
484+
/** Returns the primitive value of the specified object. */
485+
valueOf(): number;
480486
}
481487

482488
interface NumberConstructor {

0 commit comments

Comments
 (0)