Skip to content

Commit be6e43e

Browse files
committed
Merge branch 'master' into es3Decorators
2 parents c46309d + 2d78df4 commit be6e43e

1,131 files changed

Lines changed: 18913 additions & 9771 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: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ doc
33
scripts
44
src
55
tests
6-
Jakefile
6+
Jakefile.js
77
.travis.yml
8-
.settings/
8+
.settings/
9+
.vscode/

.settings/tasks.json

Lines changed: 0 additions & 23 deletions
This file was deleted.

.vscode/tasks.json

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
// Available variables which can be used inside of strings.
2+
// ${workspaceRoot}: the root folder of the team
3+
// ${file}: the current opened file
4+
// ${fileBasename}: the current opened file's basename
5+
// ${fileDirname}: the current opened file's dirname
6+
// ${fileExtname}: the current opened file's extension
7+
// ${cwd}: the current working directory of the spawned process
8+
{
9+
"version": "0.1.0",
10+
"command": "jake",
11+
"isShellCommand": true,
12+
"showOutput": "silent",
13+
"tasks": [
14+
{
15+
"taskName": "local",
16+
"isBuildCommand": true,
17+
"showOutput": "silent",
18+
"problemMatcher": [
19+
"$tsc"
20+
]
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
40+
}
41+
]
42+
}

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: 150 additions & 16 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);
@@ -394,6 +424,7 @@ var servicesFile = path.join(builtLocalDirectory, "typescriptServices.js");
394424
var standaloneDefinitionsFile = path.join(builtLocalDirectory, "typescriptServices.d.ts");
395425
var nodePackageFile = path.join(builtLocalDirectory, "typescript.js");
396426
var nodeDefinitionsFile = path.join(builtLocalDirectory, "typescript.d.ts");
427+
var nodeStandaloneDefinitionsFile = path.join(builtLocalDirectory, "typescript_standalone.d.ts");
397428

398429
compileFile(servicesFile, servicesSources,[builtLocalDirectory, copyright].concat(servicesSources),
399430
/*prefixes*/ [copyright],
@@ -410,11 +441,19 @@ compileFile(servicesFile, servicesSources,[builtLocalDirectory, copyright].conca
410441

411442
prependFile(copyright, standaloneDefinitionsFile);
412443

413-
// Create the node definition file by replacing 'ts' module with '"typescript"' as a module.
444+
// Stanalone/web definition file using global 'ts' namespace
414445
jake.cpR(standaloneDefinitionsFile, nodeDefinitionsFile, {silent: true});
415446
var definitionFileContents = fs.readFileSync(nodeDefinitionsFile).toString();
416-
definitionFileContents = definitionFileContents.replace(/declare (namespace|module) ts/g, 'declare module "typescript"');
417-
fs.writeFileSync(nodeDefinitionsFile, definitionFileContents);
447+
448+
// Official node package definition file, pointed to by 'typings' in package.json
449+
// Created by appending 'export = ts;' at the end of the standalone file to turn it into an external module
450+
var nodeDefinitionsFileContents = definitionFileContents + "\r\nexport = ts;";
451+
fs.writeFileSync(nodeDefinitionsFile, nodeDefinitionsFileContents);
452+
453+
// Node package definition file to be distributed without the package. Created by replacing
454+
// 'ts' namespace with '"typescript"' as a module.
455+
var nodeStandaloneDefinitionsFileContents = definitionFileContents.replace(/declare (namespace|module) ts/g, 'declare module "typescript"');
456+
fs.writeFileSync(nodeStandaloneDefinitionsFile, nodeStandaloneDefinitionsFileContents);
418457
});
419458

420459

@@ -771,17 +810,112 @@ task("update-sublime", ["local", serverFile], function() {
771810
jake.cpR(serverFile + ".map", "../TypeScript-Sublime-Plugin/tsserver/");
772811
});
773812

813+
var tslintRuleDir = "scripts/tslint";
814+
var tslintRules = ([
815+
"nextLineRule",
816+
"noInferrableTypesRule",
817+
"noNullRule",
818+
"booleanTriviaRule"
819+
]);
820+
var tslintRulesFiles = tslintRules.map(function(p) {
821+
return path.join(tslintRuleDir, p + ".ts");
822+
});
823+
var tslintRulesOutFiles = tslintRules.map(function(p) {
824+
return path.join(builtLocalDirectory, "tslint", p + ".js");
825+
});
826+
desc("Compiles tslint rules to js");
827+
task("build-rules", tslintRulesOutFiles);
828+
tslintRulesFiles.forEach(function(ruleFile, i) {
829+
compileFile(tslintRulesOutFiles[i], [ruleFile], [ruleFile], [], /*useBuiltCompiler*/ true, /*noOutFile*/ true, /*generateDeclarations*/ false, path.join(builtLocalDirectory, "tslint"));
830+
});
831+
832+
function getLinterOptions() {
833+
return {
834+
configuration: require("./tslint.json"),
835+
formatter: "prose",
836+
formattersDirectory: undefined,
837+
rulesDirectory: "built/local/tslint"
838+
};
839+
}
840+
841+
function lintFileContents(options, path, contents) {
842+
var ll = new Linter(path, contents, options);
843+
return ll.lint();
844+
}
845+
846+
function lintFile(options, path) {
847+
var contents = fs.readFileSync(path, "utf8");
848+
return lintFileContents(options, path, contents);
849+
}
850+
851+
function lintFileAsync(options, path, cb) {
852+
fs.readFile(path, "utf8", function(err, contents) {
853+
if (err) {
854+
return cb(err);
855+
}
856+
var result = lintFileContents(options, path, contents);
857+
cb(undefined, result);
858+
});
859+
}
860+
861+
var lintTargets = compilerSources.concat(harnessCoreSources);
862+
774863
// if the codebase were free of linter errors we could make jake runtests
775864
// run this task automatically
776865
desc("Runs tslint on the compiler sources");
777-
task("lint", [], function() {
778-
function success(f) { return function() { console.log('SUCCESS: No linter errors in ' + f + '\n'); }};
779-
function failure(f) { return function() { console.log('FAILURE: Please fix linting errors in ' + f + '\n') }};
780-
781-
var lintTargets = compilerSources.concat(harnessCoreSources);
866+
task("lint", ["build-rules"], function() {
867+
var lintOptions = getLinterOptions();
782868
for (var i in lintTargets) {
783-
var f = lintTargets[i];
784-
var cmd = 'tslint -c tslint.json ' + f;
785-
exec(cmd, success(f), failure(f));
869+
var result = lintFile(lintOptions, lintTargets[i]);
870+
if (result.failureCount > 0) {
871+
console.log(result.output);
872+
fail('Linter errors.', result.failureCount);
873+
}
786874
}
787-
}, { async: true });
875+
});
876+
877+
/**
878+
* This is required because file watches on Windows get fires _twice_
879+
* when a file changes on some node/windows version configuations
880+
* (node v4 and win 10, for example). By not running a lint for a file
881+
* which already has a pending lint, we avoid duplicating our work.
882+
* (And avoid printing duplicate results!)
883+
*/
884+
var lintSemaphores = {};
885+
886+
function lintWatchFile(filename) {
887+
fs.watch(filename, {persistent: true}, function(event) {
888+
if (event !== "change") {
889+
return;
890+
}
891+
892+
if (!lintSemaphores[filename]) {
893+
lintSemaphores[filename] = true;
894+
lintFileAsync(getLinterOptions(), filename, function(err, result) {
895+
delete lintSemaphores[filename];
896+
if (err) {
897+
console.log(err);
898+
return;
899+
}
900+
if (result.failureCount > 0) {
901+
console.log("***Lint failure***");
902+
for (var i = 0; i < result.failures.length; i++) {
903+
var failure = result.failures[i];
904+
var start = failure.startPosition.lineAndCharacter;
905+
var end = failure.endPosition.lineAndCharacter;
906+
console.log("warning " + filename + " (" + (start.line + 1) + "," + (start.character + 1) + "," + (end.line + 1) + "," + (end.character + 1) + "): " + failure.failure);
907+
}
908+
console.log("*** Total " + result.failureCount + " failures.");
909+
}
910+
});
911+
}
912+
});
913+
}
914+
915+
desc("Watches files for changes to rerun a lint pass");
916+
task("lint-server", ["build-rules"], function() {
917+
console.log("Watching ./src for changes to linted files");
918+
for (var i = 0; i < lintTargets.length; i++) {
919+
lintWatchFile(lintTargets[i]);
920+
}
921+
});

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

0 commit comments

Comments
 (0)