Skip to content

Commit 11f6eae

Browse files
author
Kanchalai Tanglertsampan
committed
Merge branch 'master' into master-dynamicImport
# Conflicts: # src/compiler/commandLineParser.ts
2 parents f3306db + 3ab7c86 commit 11f6eae

839 files changed

Lines changed: 17636 additions & 7194 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.

Gulpfile.ts

Lines changed: 9 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import * as cp from "child_process";
33
import * as path from "path";
44
import * as fs from "fs";
5+
import child_process = require("child_process");
56
import originalGulp = require("gulp");
67
import helpMaker = require("gulp-help");
78
import runSequence = require("run-sequence");
@@ -749,7 +750,7 @@ gulp.task("browserify", "Runs browserify on run.js to produce a file suitable fo
749750
const originalMap = file.sourceMap;
750751
const prebundledContent = file.contents.toString();
751752
// Make paths absolute to help sorcery deal with all the terrible paths being thrown around
752-
originalMap.sources = originalMap.sources.map(s => path.resolve(s));
753+
originalMap.sources = originalMap.sources.map(s => path.resolve(path.join("src/harness", s)));
753754
// intoStream (below) makes browserify think the input file is named this, so this is what it puts in the sourcemap
754755
originalMap.file = "built/local/_stream_0.js";
755756

@@ -1019,40 +1020,16 @@ function spawnLintWorker(files: {path: string}[], callback: (failures: number) =
10191020
}
10201021

10211022
gulp.task("lint", "Runs tslint on the compiler sources. Optional arguments are: --f[iles]=regex", ["build-rules"], () => {
1022-
const fileMatcher = RegExp(cmdLineOptions["files"]);
10231023
if (fold.isTravis()) console.log(fold.start("lint"));
1024-
1025-
let files: {stat: fs.Stats, path: string}[] = [];
1026-
return gulp.src(lintTargets, { read: false })
1027-
.pipe(through2.obj((chunk, enc, cb) => {
1028-
files.push(chunk);
1029-
cb();
1030-
}, (cb) => {
1031-
files = files.filter(file => fileMatcher.test(file.path)).sort((filea, fileb) => filea.stat.size - fileb.stat.size);
1032-
const workerCount = cmdLineOptions["workers"];
1033-
for (let i = 0; i < workerCount; i++) {
1034-
spawnLintWorker(files, finished);
1035-
}
1036-
1037-
let completed = 0;
1038-
let failures = 0;
1039-
function finished(fails) {
1040-
completed++;
1041-
failures += fails;
1042-
if (completed === workerCount) {
1043-
if (fold.isTravis()) console.log(fold.end("lint"));
1044-
if (failures > 0) {
1045-
throw new Error(`Linter errors: ${failures}`);
1046-
}
1047-
else {
1048-
cb();
1049-
}
1050-
}
1051-
}
1052-
}));
1024+
const fileMatcher = cmdLineOptions["files"];
1025+
const files = fileMatcher
1026+
? `src/**/${fileMatcher}`
1027+
: "Gulpfile.ts 'src/**/*.ts' --exclude src/lib/es5.d.ts --exclude 'src/lib/*.generated.d.ts'";
1028+
const cmd = `node node_modules/tslint/bin/tslint ${files} --format stylish`;
1029+
console.log("Linting: " + cmd);
1030+
child_process.execSync(cmd, { stdio: [0, 1, 2] });
10531031
});
10541032

1055-
10561033
gulp.task("default", "Runs 'local'", ["local"]);
10571034

10581035
gulp.task("watch", "Watches the src/ directory for changes and executes runtests-parallel.", [], () => {

Jakefile.js

Lines changed: 49 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,7 @@ var ts = require("./lib/typescript");
1111

1212
// Variables
1313
var compilerDirectory = "src/compiler/";
14-
var servicesDirectory = "src/services/";
1514
var serverDirectory = "src/server/";
16-
var typingsInstallerDirectory = "src/server/typingsInstaller";
17-
var cancellationTokenDirectory = "src/server/cancellationToken";
18-
var watchGuardDirectory = "src/server/watchGuard";
1915
var harnessDirectory = "src/harness/";
2016
var libraryDirectory = "src/lib/";
2117
var scriptsDirectory = "scripts/";
@@ -33,7 +29,8 @@ var thirdParty = "ThirdPartyNoticeText.txt";
3329
var nodeModulesPathPrefix = path.resolve("./node_modules/.bin/") + path.delimiter;
3430
if (process.env.path !== undefined) {
3531
process.env.path = nodeModulesPathPrefix + process.env.path;
36-
} else if (process.env.PATH !== undefined) {
32+
}
33+
else if (process.env.PATH !== undefined) {
3734
process.env.PATH = nodeModulesPathPrefix + process.env.PATH;
3835
}
3936

@@ -131,6 +128,7 @@ var harnessSources = harnessCoreSources.concat([
131128
"matchFiles.ts",
132129
"initializeTSConfig.ts",
133130
"printer.ts",
131+
"textChanges.ts",
134132
"transform.ts",
135133
"customTransforms.ts",
136134
].map(function (f) {
@@ -315,13 +313,15 @@ function compileFile(outFile, sources, prereqs, prefixes, useBuiltCompiler, opts
315313
if (useDebugMode) {
316314
if (opts.inlineSourceMap) {
317315
options += " --inlineSourceMap --inlineSources";
318-
} else {
316+
}
317+
else {
319318
options += " -sourcemap";
320319
if (!opts.noMapRoot) {
321320
options += " -mapRoot file:///" + path.resolve(path.dirname(outFile));
322321
}
323322
}
324-
} else {
323+
}
324+
else {
325325
options += " --newLine LF";
326326
}
327327

@@ -333,7 +333,7 @@ function compileFile(outFile, sources, prereqs, prefixes, useBuiltCompiler, opts
333333
options += " --lib " + opts.lib
334334
}
335335
else {
336-
options += " --lib es5,scripthost"
336+
options += " --lib es5"
337337
}
338338
options += " --noUnusedLocals --noUnusedParameters";
339339

@@ -587,13 +587,13 @@ var cancellationTokenFile = path.join(builtLocalDirectory, "cancellationToken.js
587587
compileFile(cancellationTokenFile, cancellationTokenSources, [builtLocalDirectory].concat(cancellationTokenSources), /*prefixes*/ [copyright], /*useBuiltCompiler*/ true, { types: ["node"], outDir: builtLocalDirectory, noOutFile: true, lib: "es6" });
588588

589589
var typingsInstallerFile = path.join(builtLocalDirectory, "typingsInstaller.js");
590-
compileFile(typingsInstallerFile, typingsInstallerSources, [builtLocalDirectory].concat(typingsInstallerSources), /*prefixes*/ [copyright], /*useBuiltCompiler*/ true, { types: ["node"], outDir: builtLocalDirectory, noOutFile: false, lib: "es6,scripthost" });
590+
compileFile(typingsInstallerFile, typingsInstallerSources, [builtLocalDirectory].concat(typingsInstallerSources), /*prefixes*/ [copyright], /*useBuiltCompiler*/ true, { types: ["node"], outDir: builtLocalDirectory, noOutFile: false, lib: "es6" });
591591

592592
var watchGuardFile = path.join(builtLocalDirectory, "watchGuard.js");
593593
compileFile(watchGuardFile, watchGuardSources, [builtLocalDirectory].concat(watchGuardSources), /*prefixes*/ [copyright], /*useBuiltCompiler*/ true, { types: ["node"], outDir: builtLocalDirectory, noOutFile: false, lib: "es6" });
594594

595595
var serverFile = path.join(builtLocalDirectory, "tsserver.js");
596-
compileFile(serverFile, serverSources, [builtLocalDirectory, copyright, cancellationTokenFile, typingsInstallerFile, watchGuardFile].concat(serverSources).concat(servicesSources), /*prefixes*/ [copyright], /*useBuiltCompiler*/ true, { types: ["node"], preserveConstEnums: true, lib: "es6,scripthost" });
596+
compileFile(serverFile, serverSources, [builtLocalDirectory, copyright, cancellationTokenFile, typingsInstallerFile, watchGuardFile].concat(serverSources).concat(servicesSources), /*prefixes*/ [copyright], /*useBuiltCompiler*/ true, { types: ["node"], preserveConstEnums: true, lib: "es6" });
597597
var tsserverLibraryFile = path.join(builtLocalDirectory, "tsserverlibrary.js");
598598
var tsserverLibraryDefinitionFile = path.join(builtLocalDirectory, "tsserverlibrary.d.ts");
599599
compileFile(
@@ -717,7 +717,7 @@ compileFile(
717717
/*prereqs*/[builtLocalDirectory, tscFile].concat(libraryTargets).concat(servicesSources).concat(harnessSources),
718718
/*prefixes*/[],
719719
/*useBuiltCompiler:*/ true,
720-
/*opts*/ { inlineSourceMap: true, types: ["node", "mocha", "chai"], lib: "es6,scripthost" });
720+
/*opts*/ { inlineSourceMap: true, types: ["node", "mocha", "chai"], lib: "es6" });
721721

722722
var internalTests = "internal/";
723723

@@ -751,7 +751,8 @@ function exec(cmd, completeHandler, errorHandler) {
751751
ex.addListener("error", function (e, status) {
752752
if (errorHandler) {
753753
errorHandler(e, status);
754-
} else {
754+
}
755+
else {
755756
fail("Process exited with code " + status);
756757
}
757758
});
@@ -945,7 +946,7 @@ task("generate-code-coverage", ["tests", builtLocalDirectory], function () {
945946
// Browser tests
946947
var nodeServerOutFile = "tests/webTestServer.js";
947948
var nodeServerInFile = "tests/webTestServer.ts";
948-
compileFile(nodeServerOutFile, [nodeServerInFile], [builtLocalDirectory, tscFile], [], /*useBuiltCompiler:*/ true, { noOutFile: true });
949+
compileFile(nodeServerOutFile, [nodeServerInFile], [builtLocalDirectory, tscFile], [], /*useBuiltCompiler:*/ true, { noOutFile: true, lib: "es6" });
949950

950951
desc("Runs browserify on run.js to produce a file suitable for running tests in the browser");
951952
task("browserify", ["tests", builtLocalDirectory, nodeServerOutFile], function() {
@@ -1009,21 +1010,32 @@ task("baseline-accept", function () {
10091010

10101011
function acceptBaseline(sourceFolder, targetFolder) {
10111012
console.log('Accept baselines from ' + sourceFolder + ' to ' + targetFolder);
1012-
var files = fs.readdirSync(sourceFolder);
10131013
var deleteEnding = '.delete';
1014-
for (var i in files) {
1015-
var filename = files[i];
1016-
var fullLocalPath = path.join(sourceFolder, filename);
1017-
if (fs.statSync(fullLocalPath).isFile()) {
1018-
if (filename.substr(filename.length - deleteEnding.length) === deleteEnding) {
1019-
filename = filename.substr(0, filename.length - deleteEnding.length);
1020-
fs.unlinkSync(path.join(targetFolder, filename));
1021-
} else {
1022-
var target = path.join(targetFolder, filename);
1023-
if (fs.existsSync(target)) {
1024-
fs.unlinkSync(target);
1014+
1015+
acceptBaselineFolder(sourceFolder, targetFolder);
1016+
1017+
function acceptBaselineFolder(sourceFolder, targetFolder) {
1018+
var files = fs.readdirSync(sourceFolder);
1019+
1020+
for (var i in files) {
1021+
var filename = files[i];
1022+
var fullLocalPath = path.join(sourceFolder, filename);
1023+
var stat = fs.statSync(fullLocalPath);
1024+
if (stat.isFile()) {
1025+
if (filename.substr(filename.length - deleteEnding.length) === deleteEnding) {
1026+
filename = filename.substr(0, filename.length - deleteEnding.length);
1027+
fs.unlinkSync(path.join(targetFolder, filename));
10251028
}
1026-
fs.renameSync(path.join(sourceFolder, filename), target);
1029+
else {
1030+
var target = path.join(targetFolder, filename);
1031+
if (fs.existsSync(target)) {
1032+
fs.unlinkSync(target);
1033+
}
1034+
fs.renameSync(path.join(sourceFolder, filename), target);
1035+
}
1036+
}
1037+
else if (stat.isDirectory()) {
1038+
acceptBaselineFolder(fullLocalPath, path.join(targetFolder, filename));
10271039
}
10281040
}
10291041
}
@@ -1180,43 +1192,16 @@ function spawnLintWorker(files, callback) {
11801192
}
11811193

11821194
desc("Runs tslint on the compiler sources. Optional arguments are: f[iles]=regex");
1183-
task("lint", ["build-rules"], function () {
1195+
task("lint", ["build-rules"], () => {
11841196
if (fold.isTravis()) console.log(fold.start("lint"));
1185-
var startTime = mark();
1186-
var failed = 0;
1187-
var fileMatcher = RegExp(process.env.f || process.env.file || process.env.files || "");
1188-
var done = {};
1189-
for (var i in lintTargets) {
1190-
var target = lintTargets[i];
1191-
if (!done[target] && fileMatcher.test(target)) {
1192-
done[target] = fs.statSync(target).size;
1193-
}
1194-
}
1195-
1196-
var workerCount = (process.env.workerCount && +process.env.workerCount) || os.cpus().length;
1197-
1198-
var names = Object.keys(done).sort(function (namea, nameb) {
1199-
return done[namea] - done[nameb];
1197+
const fileMatcher = process.env.f || process.env.file || process.env.files;
1198+
const files = fileMatcher
1199+
? `src/**/${fileMatcher}`
1200+
: "Gulpfile.ts 'src/**/*.ts' --exclude src/lib/es5.d.ts --exclude 'src/lib/*.generated.d.ts'";
1201+
const cmd = `node node_modules/tslint/bin/tslint ${files} --format stylish`;
1202+
console.log("Linting: " + cmd);
1203+
jake.exec([cmd], { interactive: true }, () => {
1204+
if (fold.isTravis()) console.log(fold.end("lint"));
1205+
complete();
12001206
});
1201-
1202-
for (var i = 0; i < workerCount; i++) {
1203-
spawnLintWorker(names, finished);
1204-
}
1205-
1206-
var completed = 0;
1207-
var failures = 0;
1208-
function finished(fails) {
1209-
completed++;
1210-
failures += fails;
1211-
if (completed === workerCount) {
1212-
measure(startTime);
1213-
if (fold.isTravis()) console.log(fold.end("lint"));
1214-
if (failures > 0) {
1215-
fail('Linter errors.', failed);
1216-
}
1217-
else {
1218-
complete();
1219-
}
1220-
}
1221-
}
1222-
}, { async: true });
1207+
});

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ with any additional questions or comments.
3939

4040
## Documentation
4141

42-
* [Quick tutorial](http://www.typescriptlang.org/Tutorial)
43-
* [Programming handbook](http://www.typescriptlang.org/Handbook)
42+
* [Quick tutorial](http://www.typescriptlang.org/docs/tutorial.html)
43+
* [Programming handbook](http://www.typescriptlang.org/docs/handbook/basic-types.html)
4444
* [Language specification](https://github.com/Microsoft/TypeScript/blob/master/doc/spec.md)
4545
* [Homepage](http://www.typescriptlang.org/)
4646

@@ -95,4 +95,4 @@ node built/local/tsc.js hello.ts
9595

9696
## Roadmap
9797

98-
For details on our planned features and future direction please refer to our [roadmap](https://github.com/Microsoft/TypeScript/wiki/Roadmap).
98+
For details on our planned features and future direction please refer to our [roadmap](https://github.com/Microsoft/TypeScript/wiki/Roadmap).

0 commit comments

Comments
 (0)