Skip to content

Commit b217b8b

Browse files
committed
Merge branch 'master' into jsFileCompilation
2 parents 38ebb1d + 067e1cc commit b217b8b

178 files changed

Lines changed: 43966 additions & 8423 deletions

File tree

Some content is hidden

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

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ scripts/processDiagnosticMessages.js
2121
scripts/importDefinitelyTypedTests/importDefinitelyTypedTests.js
2222
src/harness/*.js
2323
src/compiler/diagnosticInformationMap.generated.ts
24+
src/compiler/diagnosticMessages.generated.json
2425
rwc-report.html
2526
*.swp
2627
build.json

CONTRIBUTING.md

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,21 @@
11
## Contributing bug fixes
2+
23
TypeScript is currently accepting contributions in the form of bug fixes. A bug must have an issue tracking it in the issue tracker that has been approved ("Milestone == Community") by the TypeScript team. Your pull request should include a link to the bug that you are fixing. If you've submitted a PR for a bug, please post a comment in the bug to avoid duplication of effort.
34

45
## Contributing features
6+
57
Features (things that add new or improved functionality to TypeScript) may be accepted, but will need to first be approved (marked as "Milestone == Community" by a TypeScript coordinator with the message "Approved") in the suggestion issue. Features with language design impact, or that are adequately satisfied with external tools, will not be accepted.
68

79
Design changes will not be accepted at this time. If you have a design change proposal, please log a suggestion issue.
810

911
## Legal
12+
1013
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.
1114

1215
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 <cla@microsoft.com>. Be sure to include your github user name along with the agreement. Once we have received the signed CLA, we'll review the request.
1316

1417
## Housekeeping
18+
1519
Your pull request should:
1620

1721
* Include a description of what your change intends to do
@@ -29,7 +33,8 @@ Your pull request should:
2933
* To avoid line ending issues, set `autocrlf = input` and `whitespace = cr-at-eol` in your git configuration
3034

3135
## Running the Tests
32-
To run all tests, invoke the runtests target using jake:
36+
37+
To run all tests, invoke the `runtests` target using jake:
3338

3439
```Shell
3540
jake runtests
@@ -55,7 +60,7 @@ jake runtests tests=2dArrays
5560

5661
## Debugging the tests
5762

58-
To debug the tests, invoke the runtests-browser using jake.
63+
To debug the tests, invoke the `runtests-browser` task from jake.
5964
You will probably only want to debug one test at a time:
6065

6166
```Shell
@@ -75,16 +80,14 @@ jake runtests tests=2dArrays debug=true
7580
```
7681

7782
## Adding a Test
78-
To add a new testcase, simply place a `.ts` file in `tests\cases\compiler` containing code that exemplifies the bugfix or change you are making.
7983

80-
These files support metadata tags in the format `// @metaDataName: value`. The supported names and values are:
84+
To add a new test case, simply place a `.ts` file in `tests\cases\compiler` containing code that exemplifies the bugfix or change you are making.
8185

82-
* `comments`, `sourcemap`, `noimplicitany`, `declaration`: true or false (corresponds to the compiler command-line options of the same name)
83-
* `target`: ES3 or ES5 (same as compiler)
84-
* `out`, outDir: path (same as compiler)
85-
* `module`: local, commonjs, or amd (local corresponds to not passing any compiler --module flag)
86-
* `fileName`: path
87-
* These tags delimit sections of a file to be used as separate compilation units. They are useful for tests relating to modules. See below for examples.
86+
These files support metadata tags in the format `// @metaDataName: value`.
87+
The supported names and values are the same as those supported in the compiler itself, with the addition of the `fileName` flag.
88+
`fileName` tags delimit sections of a file to be used as separate compilation units.
89+
They are useful for tests relating to modules.
90+
See below for examples.
8891

8992
**Note** that if you have a test corresponding to a specific spec compliance item, you can place it in `tests\cases\conformance` in an appropriately-named subfolder.
9093
**Note** that filenames here must be distinct from all other compiler testcase names, so you may have to work a bit to find a unique name if it's something common.
@@ -107,6 +110,7 @@ var x = g();
107110
One can also write a project test, but it is slightly more involved.
108111

109112
## Managing the Baselines
113+
110114
Compiler testcases generate baselines that track the emitted `.js`, the errors produced by the compiler, and the type of each expression in the file. Additionally, some testcases opt in to baselining the source map output.
111115

112116
When a change in the baselines is detected, the test will fail. To inspect changes vs the expected baselines, use
@@ -123,4 +127,4 @@ jake baseline-accept
123127

124128
to establish the new baselines as the desired behavior. This will change the files in `tests\baselines\reference`, which should be included as part of your commit. It's important to carefully validate changes in the baselines.
125129

126-
**Note** that baseline-accept should only be run after a full test run! Accepting baselines after running a subset of tests will delete baseline files for the tests that didn't run.
130+
**Note** that `baseline-accept` should only be run after a full test run! Accepting baselines after running a subset of tests will delete baseline files for the tests that didn't run.

Jakefile.js

Lines changed: 61 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -96,15 +96,17 @@ var servicesSources = [
9696
return path.join(servicesDirectory, f);
9797
}));
9898

99-
var serverSources = [
99+
var serverCoreSources = [
100100
"node.d.ts",
101101
"editorServices.ts",
102102
"protocol.d.ts",
103103
"session.ts",
104104
"server.ts"
105105
].map(function (f) {
106106
return path.join(serverDirectory, f);
107-
}).concat(servicesSources);
107+
});
108+
109+
var serverSources = serverCoreSources.concat(servicesSources);
108110

109111
var languageServiceLibrarySources = [
110112
"editorServices.ts",
@@ -164,7 +166,7 @@ var librarySourceMap = [
164166
{ target: "lib.scriptHost.d.ts", sources: ["importcore.d.ts", "scriptHost.d.ts"], },
165167
{ target: "lib.d.ts", sources: ["core.d.ts", "intl.d.ts", "dom.generated.d.ts", "webworker.importscripts.d.ts", "scriptHost.d.ts"], },
166168
{ target: "lib.core.es6.d.ts", sources: ["core.d.ts", "es6.d.ts"]},
167-
{ target: "lib.es6.d.ts", sources: ["core.d.ts", "es6.d.ts", "intl.d.ts", "dom.generated.d.ts", "dom.es6.d.ts", "webworker.importscripts.d.ts", "scriptHost.d.ts"] },
169+
{ target: "lib.es6.d.ts", sources: ["es6.d.ts", "core.d.ts", "intl.d.ts", "dom.generated.d.ts", "dom.es6.d.ts", "webworker.importscripts.d.ts", "scriptHost.d.ts"] }
168170
];
169171

170172
var libraryTargets = librarySourceMap.map(function (f) {
@@ -320,6 +322,8 @@ var processDiagnosticMessagesJs = path.join(scriptsDirectory, "processDiagnostic
320322
var processDiagnosticMessagesTs = path.join(scriptsDirectory, "processDiagnosticMessages.ts");
321323
var diagnosticMessagesJson = path.join(compilerDirectory, "diagnosticMessages.json");
322324
var diagnosticInfoMapTs = path.join(compilerDirectory, "diagnosticInformationMap.generated.ts");
325+
var generatedDiagnosticMessagesJSON = path.join(compilerDirectory, "diagnosticMessages.generated.json");
326+
var builtGeneratedDiagnosticMessagesJSON = path.join(builtLocalDirectory, "diagnosticMessages.generated.json");
323327

324328
file(processDiagnosticMessagesTs);
325329

@@ -348,6 +352,12 @@ file(diagnosticInfoMapTs, [processDiagnosticMessagesJs, diagnosticMessagesJson],
348352
ex.run();
349353
}, {async: true});
350354

355+
file(builtGeneratedDiagnosticMessagesJSON,[generatedDiagnosticMessagesJSON], function() {
356+
if (fs.existsSync(builtLocalDirectory)) {
357+
jake.cpR(generatedDiagnosticMessagesJSON, builtGeneratedDiagnosticMessagesJSON);
358+
}
359+
});
360+
351361
desc("Generates a diagnostic file in TypeScript based on an input JSON file");
352362
task("generate-diagnostics", [diagnosticInfoMapTs]);
353363

@@ -444,6 +454,8 @@ compileFile(servicesFile, servicesSources,[builtLocalDirectory, copyright].conca
444454
// Stanalone/web definition file using global 'ts' namespace
445455
jake.cpR(standaloneDefinitionsFile, nodeDefinitionsFile, {silent: true});
446456
var definitionFileContents = fs.readFileSync(nodeDefinitionsFile).toString();
457+
definitionFileContents = definitionFileContents.replace(/^(\s*)(export )?const enum (\S+) {(\s*)$/gm, '$1$2enum $3 {$4');
458+
fs.writeFileSync(standaloneDefinitionsFile, definitionFileContents);
447459

448460
// Official node package definition file, pointed to by 'typings' in package.json
449461
// Created by appending 'export = ts;' at the end of the standalone file to turn it into an external module
@@ -476,7 +488,7 @@ task("lssl", [lsslFile]);
476488

477489
// Local target to build the compiler and services
478490
desc("Builds the full compiler and services");
479-
task("local", ["generate-diagnostics", "lib", tscFile, servicesFile, nodeDefinitionsFile, serverFile]);
491+
task("local", ["generate-diagnostics", "lib", tscFile, servicesFile, nodeDefinitionsFile, serverFile, builtGeneratedDiagnosticMessagesJSON]);
480492

481493
// Local target to build only tsc.js
482494
desc("Builds only the compiler");
@@ -626,9 +638,7 @@ function deleteTemporaryProjectOutput() {
626638
}
627639
}
628640

629-
var testTimeout = 20000;
630-
desc("Runs the tests using the built run.js file. Syntax is jake runtests. Optional parameters 'host=', 'tests=[regex], reporter=[list|spec|json|<more>]', debug=true.");
631-
task("runtests", ["build-rules", "tests", builtLocalDirectory], function() {
641+
function runConsoleTests(defaultReporter, defaultSubsets, postLint) {
632642
cleanTestDirs();
633643
var debug = process.env.debug || process.env.d;
634644
tests = process.env.test || process.env.tests || process.env.t;
@@ -638,7 +648,7 @@ task("runtests", ["build-rules", "tests", builtLocalDirectory], function() {
638648
fs.unlinkSync(testConfigFile);
639649
}
640650

641-
if(tests || light) {
651+
if (tests || light) {
642652
writeTestConfigFile(tests, light, testConfigFile);
643653
}
644654

@@ -648,20 +658,48 @@ task("runtests", ["build-rules", "tests", builtLocalDirectory], function() {
648658

649659
colors = process.env.colors || process.env.color
650660
colors = colors ? ' --no-colors ' : ' --colors ';
651-
tests = tests ? ' -g ' + tests : '';
652-
reporter = process.env.reporter || process.env.r || 'mocha-fivemat-progress-reporter';
661+
reporter = process.env.reporter || process.env.r || defaultReporter;
662+
653663
// timeout normally isn't necessary but Travis-CI has been timing out on compiler baselines occasionally
654664
// default timeout is 2sec which really should be enough, but maybe we just need a small amount longer
655-
var cmd = "mocha" + (debug ? " --debug-brk" : "") + " -R " + reporter + tests + colors + ' -t ' + testTimeout + ' ' + run;
656-
console.log(cmd);
657-
exec(cmd, function() {
658-
deleteTemporaryProjectOutput();
659-
var lint = jake.Task['lint'];
660-
lint.addListener('complete', function () {
661-
complete();
665+
var subsetRegexes;
666+
if(defaultSubsets.length === 0) {
667+
subsetRegexes = [tests]
668+
}
669+
else {
670+
var subsets = tests ? tests.split("|") : defaultSubsets;
671+
subsetRegexes = subsets.map(function (sub) { return "^" + sub + ".*$"; });
672+
subsetRegexes.push("^(?!" + subsets.join("|") + ").*$");
673+
}
674+
subsetRegexes.forEach(function (subsetRegex) {
675+
tests = subsetRegex ? ' -g "' + subsetRegex + '"' : '';
676+
var cmd = "mocha" + (debug ? " --debug-brk" : "") + " -R " + reporter + tests + colors + ' -t ' + testTimeout + ' ' + run;
677+
console.log(cmd);
678+
exec(cmd, function () {
679+
deleteTemporaryProjectOutput();
680+
if (postLint) {
681+
var lint = jake.Task['lint'];
682+
lint.addListener('complete', function () {
683+
complete();
684+
});
685+
lint.invoke();
686+
}
687+
else {
688+
complete();
689+
}
662690
});
663-
lint.invoke();
664691
});
692+
}
693+
694+
var testTimeout = 20000;
695+
desc("Runs all the tests in parallel using the built run.js file. Optional arguments are: t[ests]=category1|category2|... d[ebug]=true.");
696+
task("runtests-parallel", ["build-rules", "tests", builtLocalDirectory], function() {
697+
runConsoleTests('min', ['compiler', 'conformance', 'Projects', 'fourslash']);
698+
}, {async: true});
699+
700+
desc("Runs the tests using the built run.js file. Optional arguments are: t[ests]=regex r[eporter]=[list|spec|json|<more>] d[ebug]=true color[s]=false.");
701+
task("runtests", ["build-rules", "tests", builtLocalDirectory], function() {
702+
runConsoleTests('mocha-fivemat-progress-reporter', [], /*postLint*/ true);
665703
}, {async: true});
666704

667705
desc("Generates code coverage data via instanbul");
@@ -820,7 +858,8 @@ var tslintRuleDir = "scripts/tslint";
820858
var tslintRules = ([
821859
"nextLineRule",
822860
"noNullRule",
823-
"booleanTriviaRule"
861+
"booleanTriviaRule",
862+
"typeOperatorSpacingRule"
824863
]);
825864
var tslintRulesFiles = tslintRules.map(function(p) {
826865
return path.join(tslintRuleDir, p + ".ts");
@@ -863,7 +902,9 @@ function lintFileAsync(options, path, cb) {
863902
});
864903
}
865904

866-
var lintTargets = compilerSources.concat(harnessCoreSources);
905+
var lintTargets = compilerSources
906+
.concat(harnessCoreSources)
907+
.concat(serverCoreSources);
867908

868909
desc("Runs tslint on the compiler sources");
869910
task("lint", ["build-rules"], function() {

lib/lib.core.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1225,7 +1225,7 @@ interface ArrayBuffer {
12251225
interface ArrayBufferConstructor {
12261226
prototype: ArrayBuffer;
12271227
new (byteLength: number): ArrayBuffer;
1228-
isView(arg: any): boolean;
1228+
isView(arg: any): arg is ArrayBufferView;
12291229
}
12301230
declare var ArrayBuffer: ArrayBufferConstructor;
12311231

lib/lib.core.es6.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1225,7 +1225,7 @@ interface ArrayBuffer {
12251225
interface ArrayBufferConstructor {
12261226
prototype: ArrayBuffer;
12271227
new (byteLength: number): ArrayBuffer;
1228-
isView(arg: any): boolean;
1228+
isView(arg: any): arg is ArrayBufferView;
12291229
}
12301230
declare var ArrayBuffer: ArrayBufferConstructor;
12311231

0 commit comments

Comments
 (0)