Skip to content

Commit d57ee1d

Browse files
author
Yui T
committed
Merge branch 'master' into errorsuperbeforethis
Conflicts: src/compiler/checker.ts src/compiler/diagnosticInformationMap.generated.ts src/compiler/types.ts
2 parents 1fc11aa + 350bb1f commit d57ee1d

1,069 files changed

Lines changed: 15888 additions & 8500 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: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,16 @@ tests/services/baselines/local/*
2121
tests/baselines/prototyping/local/*
2222
tests/baselines/rwc/*
2323
tests/baselines/test262/*
24-
tests/baselines/reference/projectOutput/*
24+
tests/baselines/reference/projectOutput/*
2525
tests/baselines/local/projectOutput/*
2626
tests/services/baselines/prototyping/local/*
2727
tests/services/browser/typescriptServices.js
2828
scripts/configureNightly.js
2929
scripts/processDiagnosticMessages.d.ts
3030
scripts/processDiagnosticMessages.js
31-
scripts/importDefinitelyTypedTests.js
31+
scripts/importDefinitelyTypedTests/importDefinitelyTypedTests.js
3232
src/harness/*.js
33+
src/compiler/diagnosticInformationMap.generated.ts
3334
rwc-report.html
3435
*.swp
3536
build.json
@@ -45,8 +46,10 @@ scripts/run.bat
4546
scripts/word2md.js
4647
scripts/ior.js
4748
scripts/*.js.map
49+
scripts/typings/
4850
coverage/
4951
internal/
5052
**/.DS_Store
51-
.settings/*
52-
!.settings/tasks.json
53+
.settings
54+
.vscode/*
55+
!.vscode/tasks.json

.npmignore

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@ doc
33
scripts
44
src
55
tests
6-
Jakefile
6+
internal
7+
tslint.json
8+
Jakefile.js
9+
.editorconfig
10+
.gitattributes
11+
.settings/
712
.travis.yml
8-
.settings/
13+
.vscode/

.vscode/tasks.json

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,25 @@
1818
"problemMatcher": [
1919
"$tsc"
2020
]
21+
},
22+
{
23+
"taskName": "lint-server",
24+
"args": [],
25+
"problemMatcher": {
26+
"owner": "typescript",
27+
"fileLocation": ["relative", "${workspaceRoot}"],
28+
"pattern": {
29+
"regexp": "^(warning|error)\\s+([^(]+)\\s+\\((\\d+|\\d+,\\d+|\\d+,\\d+,\\d+,\\d+)\\):\\s+(.*)$",
30+
"severity": 1,
31+
"file": 2,
32+
"location": 3,
33+
"message": 4
34+
},
35+
"watchedTaskBeginsRegExp": "^\\*\\*\\*Lint failure\\*\\*\\*$",
36+
"watchedTaskEndsRegExp": "^\\*\\*\\* Total \\d+ failures\\.$"
37+
},
38+
"showOutput": "always",
39+
"isWatching": true
2140
}
2241
]
2342
}

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. 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. 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 <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.
1313

1414
## Housekeeping
1515
Your pull request should:

Jakefile.js

Lines changed: 147 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ var fs = require("fs");
44
var os = require("os");
55
var path = require("path");
66
var child_process = require("child_process");
7+
var Linter = require("tslint");
78

89
// Variables
910
var compilerDirectory = "src/compiler/";
@@ -206,6 +207,9 @@ function concatenateFiles(destinationFile, sourceFiles) {
206207
var useDebugMode = true;
207208
var host = (process.env.host || process.env.TYPESCRIPT_HOST || "node");
208209
var compilerFilename = "tsc.js";
210+
var LKGCompiler = path.join(LKGDirectory, compilerFilename);
211+
var builtLocalCompiler = path.join(builtLocalDirectory, compilerFilename);
212+
209213
/* Compiles a file from a list of sources
210214
* @param outFile: the target file name
211215
* @param sources: an array of the names of the source files
@@ -220,7 +224,7 @@ var compilerFilename = "tsc.js";
220224
*/
221225
function compileFile(outFile, sources, prereqs, prefixes, useBuiltCompiler, noOutFile, generateDeclarations, outDir, preserveConstEnums, keepComments, noResolve, stripInternal, callback) {
222226
file(outFile, prereqs, function() {
223-
var dir = useBuiltCompiler ? builtLocalDirectory : LKGDirectory;
227+
var compilerPath = useBuiltCompiler ? builtLocalCompiler : LKGCompiler;
224228
var options = "--module commonjs --noImplicitAny --noEmitOnError";
225229

226230
// Keep comments when specifically requested
@@ -257,7 +261,7 @@ function compileFile(outFile, sources, prereqs, prefixes, useBuiltCompiler, noOu
257261
options += " --stripInternal"
258262
}
259263

260-
var cmd = host + " " + dir + compilerFilename + " " + options + " ";
264+
var cmd = host + " " + compilerPath + " " + options + " ";
261265
cmd = cmd + sources.join(" ");
262266
console.log(cmd + "\n");
263267

@@ -328,7 +332,7 @@ compileFile(processDiagnosticMessagesJs,
328332

329333
// The generated diagnostics map; built for the compiler and for the 'generate-diagnostics' task
330334
file(diagnosticInfoMapTs, [processDiagnosticMessagesJs, diagnosticMessagesJson], function () {
331-
var cmd = "node " + processDiagnosticMessagesJs + " " + diagnosticMessagesJson;
335+
var cmd = host + " " + processDiagnosticMessagesJs + " " + diagnosticMessagesJson;
332336
console.log(cmd);
333337
var ex = jake.createExec([cmd]);
334338
// Add listeners for output and error
@@ -374,7 +378,7 @@ task("setDebugMode", function() {
374378
});
375379

376380
task("configure-nightly", [configureNightlyJs], function() {
377-
var cmd = "node " + configureNightlyJs + " " + packageJson + " " + programTs;
381+
var cmd = host + " " + configureNightlyJs + " " + packageJson + " " + programTs;
378382
console.log(cmd);
379383
exec(cmd);
380384
}, { async: true });
@@ -386,6 +390,32 @@ task("publish-nightly", ["configure-nightly", "LKG", "clean", "setDebugMode", "r
386390
exec(cmd);
387391
});
388392

393+
var scriptsTsdJson = path.join(scriptsDirectory, "tsd.json");
394+
file(scriptsTsdJson);
395+
396+
task("tsd-scripts", [scriptsTsdJson], function () {
397+
var cmd = "tsd --config " + scriptsTsdJson + " install";
398+
console.log(cmd)
399+
exec(cmd);
400+
}, { async: true })
401+
402+
var importDefinitelyTypedTestsDirectory = path.join(scriptsDirectory, "importDefinitelyTypedTests");
403+
var importDefinitelyTypedTestsJs = path.join(importDefinitelyTypedTestsDirectory, "importDefinitelyTypedTests.js");
404+
var importDefinitelyTypedTestsTs = path.join(importDefinitelyTypedTestsDirectory, "importDefinitelyTypedTests.ts");
405+
406+
file(importDefinitelyTypedTestsTs);
407+
file(importDefinitelyTypedTestsJs, ["tsd-scripts", importDefinitelyTypedTestsTs], function () {
408+
var cmd = host + " " + LKGCompiler + " -p " + importDefinitelyTypedTestsDirectory;
409+
console.log(cmd);
410+
exec(cmd);
411+
}, { async: true });
412+
413+
task("importDefinitelyTypedTests", [importDefinitelyTypedTestsJs], function () {
414+
var cmd = host + " " + importDefinitelyTypedTestsJs + " ./ ../DefinitelyTyped";
415+
console.log(cmd);
416+
exec(cmd);
417+
}, { async: true });
418+
389419
// Local target to build the compiler and services
390420
var tscFile = path.join(builtLocalDirectory, compilerFilename);
391421
compileFile(tscFile, compilerSources, [builtLocalDirectory, copyright].concat(compilerSources), [copyright], /*useBuiltCompiler:*/ false);
@@ -598,10 +628,9 @@ function deleteTemporaryProjectOutput() {
598628

599629
var testTimeout = 20000;
600630
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.");
601-
task("runtests", ["tests", builtLocalDirectory], function() {
631+
task("runtests", ["build-rules", "tests", builtLocalDirectory], function() {
602632
cleanTestDirs();
603633
var debug = process.env.debug || process.env.d;
604-
host = "mocha"
605634
tests = process.env.test || process.env.tests || process.env.t;
606635
var light = process.env.light || false;
607636
var testConfigFile = 'test.config';
@@ -623,9 +652,16 @@ task("runtests", ["tests", builtLocalDirectory], function() {
623652
reporter = process.env.reporter || process.env.r || 'mocha-fivemat-progress-reporter';
624653
// timeout normally isn't necessary but Travis-CI has been timing out on compiler baselines occasionally
625654
// default timeout is 2sec which really should be enough, but maybe we just need a small amount longer
626-
var cmd = host + (debug ? " --debug-brk" : "") + " -R " + reporter + tests + colors + ' -t ' + testTimeout + ' ' + run;
655+
var cmd = "mocha" + (debug ? " --debug-brk" : "") + " -R " + reporter + tests + colors + ' -t ' + testTimeout + ' ' + run;
627656
console.log(cmd);
628-
exec(cmd, deleteTemporaryProjectOutput);
657+
exec(cmd, function() {
658+
deleteTemporaryProjectOutput();
659+
var lint = jake.Task['lint'];
660+
lint.addListener('complete', function () {
661+
complete();
662+
});
663+
lint.invoke();
664+
});
629665
}, {async: true});
630666

631667
desc("Generates code coverage data via instanbul");
@@ -780,17 +816,109 @@ task("update-sublime", ["local", serverFile], function() {
780816
jake.cpR(serverFile + ".map", "../TypeScript-Sublime-Plugin/tsserver/");
781817
});
782818

783-
// if the codebase were free of linter errors we could make jake runtests
784-
// run this task automatically
785-
desc("Runs tslint on the compiler sources");
786-
task("lint", [], function() {
787-
function success(f) { return function() { console.log('SUCCESS: No linter errors in ' + f + '\n'); }};
788-
function failure(f) { return function() { console.log('FAILURE: Please fix linting errors in ' + f + '\n') }};
819+
var tslintRuleDir = "scripts/tslint";
820+
var tslintRules = ([
821+
"nextLineRule",
822+
"noNullRule",
823+
"booleanTriviaRule"
824+
]);
825+
var tslintRulesFiles = tslintRules.map(function(p) {
826+
return path.join(tslintRuleDir, p + ".ts");
827+
});
828+
var tslintRulesOutFiles = tslintRules.map(function(p) {
829+
return path.join(builtLocalDirectory, "tslint", p + ".js");
830+
});
831+
desc("Compiles tslint rules to js");
832+
task("build-rules", tslintRulesOutFiles);
833+
tslintRulesFiles.forEach(function(ruleFile, i) {
834+
compileFile(tslintRulesOutFiles[i], [ruleFile], [ruleFile], [], /*useBuiltCompiler*/ false, /*noOutFile*/ true, /*generateDeclarations*/ false, path.join(builtLocalDirectory, "tslint"));
835+
});
836+
837+
function getLinterOptions() {
838+
return {
839+
configuration: require("./tslint.json"),
840+
formatter: "prose",
841+
formattersDirectory: undefined,
842+
rulesDirectory: "built/local/tslint"
843+
};
844+
}
845+
846+
function lintFileContents(options, path, contents) {
847+
var ll = new Linter(path, contents, options);
848+
return ll.lint();
849+
}
850+
851+
function lintFile(options, path) {
852+
var contents = fs.readFileSync(path, "utf8");
853+
return lintFileContents(options, path, contents);
854+
}
855+
856+
function lintFileAsync(options, path, cb) {
857+
fs.readFile(path, "utf8", function(err, contents) {
858+
if (err) {
859+
return cb(err);
860+
}
861+
var result = lintFileContents(options, path, contents);
862+
cb(undefined, result);
863+
});
864+
}
865+
866+
var lintTargets = compilerSources.concat(harnessCoreSources);
789867

790-
var lintTargets = compilerSources.concat(harnessCoreSources);
868+
desc("Runs tslint on the compiler sources");
869+
task("lint", ["build-rules"], function() {
870+
var lintOptions = getLinterOptions();
791871
for (var i in lintTargets) {
792-
var f = lintTargets[i];
793-
var cmd = 'tslint -c tslint.json ' + f;
794-
exec(cmd, success(f), failure(f));
872+
var result = lintFile(lintOptions, lintTargets[i]);
873+
if (result.failureCount > 0) {
874+
console.log(result.output);
875+
fail('Linter errors.', result.failureCount);
876+
}
795877
}
796-
}, { async: true });
878+
});
879+
880+
/**
881+
* This is required because file watches on Windows get fires _twice_
882+
* when a file changes on some node/windows version configuations
883+
* (node v4 and win 10, for example). By not running a lint for a file
884+
* which already has a pending lint, we avoid duplicating our work.
885+
* (And avoid printing duplicate results!)
886+
*/
887+
var lintSemaphores = {};
888+
889+
function lintWatchFile(filename) {
890+
fs.watch(filename, {persistent: true}, function(event) {
891+
if (event !== "change") {
892+
return;
893+
}
894+
895+
if (!lintSemaphores[filename]) {
896+
lintSemaphores[filename] = true;
897+
lintFileAsync(getLinterOptions(), filename, function(err, result) {
898+
delete lintSemaphores[filename];
899+
if (err) {
900+
console.log(err);
901+
return;
902+
}
903+
if (result.failureCount > 0) {
904+
console.log("***Lint failure***");
905+
for (var i = 0; i < result.failures.length; i++) {
906+
var failure = result.failures[i];
907+
var start = failure.startPosition.lineAndCharacter;
908+
var end = failure.endPosition.lineAndCharacter;
909+
console.log("warning " + filename + " (" + (start.line + 1) + "," + (start.character + 1) + "," + (end.line + 1) + "," + (end.character + 1) + "): " + failure.failure);
910+
}
911+
console.log("*** Total " + result.failureCount + " failures.");
912+
}
913+
});
914+
}
915+
});
916+
}
917+
918+
desc("Watches files for changes to rerun a lint pass");
919+
task("lint-server", ["build-rules"], function() {
920+
console.log("Watching ./src for changes to linted files");
921+
for (var i = 0; i < lintTargets.length; i++) {
922+
lintWatchFile(lintTargets[i]);
923+
}
924+
});

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ There are many ways to [contribute](https://github.com/Microsoft/TypeScript/blob
3030
* Engage with other TypeScript users and developers on [StackOverflow](http://stackoverflow.com/questions/tagged/typescript).
3131
* Join the [#typescript](http://twitter.com/#!/search/realtime/%23typescript) discussion on Twitter.
3232
* [Contribute bug fixes](https://github.com/Microsoft/TypeScript/blob/master/CONTRIBUTING.md).
33-
* Read the language specification ([docx](http://go.microsoft.com/fwlink/?LinkId=267121), [pdf](http://go.microsoft.com/fwlink/?LinkId=267238)).
33+
* Read the language specification ([docx](https://github.com/Microsoft/TypeScript/blob/master/doc/TypeScript%20Language%20Specification.docx?raw=true), [pdf](https://github.com/Microsoft/TypeScript/blob/master/doc/TypeScript%20Language%20Specification.pdf?raw=true), [md](https://github.com/Microsoft/TypeScript/blob/master/doc/spec.md)).
3434

3535

3636
## Documentation

lib/lib.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3881,7 +3881,7 @@ declare module Intl {
38813881
currency?: string;
38823882
currencyDisplay?: string;
38833883
useGrouping?: boolean;
3884-
minimumintegerDigits?: number;
3884+
minimumIntegerDigits?: number;
38853885
minimumFractionDigits?: number;
38863886
maximumFractionDigits?: number;
38873887
minimumSignificantDigits?: number;
@@ -3894,7 +3894,7 @@ declare module Intl {
38943894
style: string;
38953895
currency?: string;
38963896
currencyDisplay?: string;
3897-
minimumintegerDigits: number;
3897+
minimumIntegerDigits: number;
38983898
minimumFractionDigits: number;
38993899
maximumFractionDigits: number;
39003900
minimumSignificantDigits?: number;

lib/lib.dom.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ declare module Intl {
5757
currency?: string;
5858
currencyDisplay?: string;
5959
useGrouping?: boolean;
60-
minimumintegerDigits?: number;
60+
minimumIntegerDigits?: number;
6161
minimumFractionDigits?: number;
6262
maximumFractionDigits?: number;
6363
minimumSignificantDigits?: number;
@@ -70,7 +70,7 @@ declare module Intl {
7070
style: string;
7171
currency?: string;
7272
currencyDisplay?: string;
73-
minimumintegerDigits: number;
73+
minimumIntegerDigits: number;
7474
minimumFractionDigits: number;
7575
maximumFractionDigits: number;
7676
minimumSignificantDigits?: number;

0 commit comments

Comments
 (0)