Skip to content

Commit 2e28c06

Browse files
author
Kanchalai Tanglertsampan
committed
Merge branch 'master' into master-11566
2 parents 9ca08a4 + b6dfa39 commit 2e28c06

File tree

785 files changed

+20485
-4722
lines changed

Some content is hidden

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

785 files changed

+20485
-4722
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,3 +57,4 @@ internal/
5757
!tests/cases/projects/NodeModulesSearch/**/*
5858
!tests/baselines/reference/project/nodeModules*/**/*
5959
.idea
60+
yarn.lock

Gulpfile.ts

Lines changed: 19 additions & 46 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");
@@ -21,10 +22,6 @@ declare module "gulp-typescript" {
2122
import * as insert from "gulp-insert";
2223
import * as sourcemaps from "gulp-sourcemaps";
2324
import Q = require("q");
24-
declare global {
25-
// `del` further depends on `Promise` (and is also not included), so we just, patch the global scope's Promise to Q's (which we already include in our deps because gulp depends on it)
26-
type Promise<T> = Q.Promise<T>;
27-
}
2825
import del = require("del");
2926
import mkdirP = require("mkdirp");
3027
import minimist = require("minimist");
@@ -394,7 +391,7 @@ gulp.task(builtLocalCompiler, false, [servicesFile], () => {
394391
.pipe(localCompilerProject())
395392
.pipe(prependCopyright())
396393
.pipe(sourcemaps.write("."))
397-
.pipe(gulp.dest("."));
394+
.pipe(gulp.dest("src/compiler"));
398395
});
399396

400397
gulp.task(servicesFile, false, ["lib", "generate-diagnostics"], () => {
@@ -420,13 +417,13 @@ gulp.task(servicesFile, false, ["lib", "generate-diagnostics"], () => {
420417
file.path = nodeDefinitionsFile;
421418
return content + "\r\nexport = ts;";
422419
}))
423-
.pipe(gulp.dest(".")),
420+
.pipe(gulp.dest("src/services")),
424421
completedDts.pipe(clone())
425422
.pipe(insert.transform((content, file) => {
426423
file.path = nodeStandaloneDefinitionsFile;
427424
return content.replace(/declare (namespace|module) ts/g, 'declare module "typescript"');
428425
}))
429-
]).pipe(gulp.dest("."));
426+
]).pipe(gulp.dest("src/services"));
430427
});
431428

432429
// cancellationToken.js
@@ -452,7 +449,7 @@ gulp.task(typingsInstallerJs, false, [servicesFile], () => {
452449
.pipe(cancellationTokenProject())
453450
.pipe(prependCopyright())
454451
.pipe(sourcemaps.write("."))
455-
.pipe(gulp.dest("."));
452+
.pipe(gulp.dest("src/server/typingsInstaller"));
456453
});
457454

458455
const serverFile = path.join(builtLocalDirectory, "tsserver.js");
@@ -465,7 +462,7 @@ gulp.task(serverFile, false, [servicesFile, typingsInstallerJs, cancellationToke
465462
.pipe(serverProject())
466463
.pipe(prependCopyright())
467464
.pipe(sourcemaps.write("."))
468-
.pipe(gulp.dest("."));
465+
.pipe(gulp.dest("src/server"));
469466
});
470467

471468
const tsserverLibraryFile = path.join(builtLocalDirectory, "tsserverlibrary.js");
@@ -481,12 +478,12 @@ gulp.task(tsserverLibraryFile, false, [servicesFile], (done) => {
481478
return merge2([
482479
js.pipe(prependCopyright())
483480
.pipe(sourcemaps.write("."))
484-
.pipe(gulp.dest(".")),
481+
.pipe(gulp.dest("src/server")),
485482
dts.pipe(prependCopyright(/*outputCopyright*/true))
486483
.pipe(insert.transform((content) => {
487484
return content + "\r\nexport = ts;\r\nexport as namespace ts;";
488485
}))
489-
.pipe(gulp.dest("."))
486+
.pipe(gulp.dest("src/server"))
490487
]);
491488
});
492489

@@ -560,7 +557,7 @@ gulp.task(run, false, [servicesFile], () => {
560557
.pipe(sourcemaps.init())
561558
.pipe(testProject())
562559
.pipe(sourcemaps.write(".", { includeContent: false, sourceRoot: "../../" }))
563-
.pipe(gulp.dest("."));
560+
.pipe(gulp.dest("src/harness"));
564561
});
565562

566563
const internalTests = "internal/";
@@ -753,7 +750,7 @@ gulp.task("browserify", "Runs browserify on run.js to produce a file suitable fo
753750
const originalMap = file.sourceMap;
754751
const prebundledContent = file.contents.toString();
755752
// Make paths absolute to help sorcery deal with all the terrible paths being thrown around
756-
originalMap.sources = originalMap.sources.map(s => path.resolve(s));
753+
originalMap.sources = originalMap.sources.map(s => path.resolve(path.join("src/harness", s)));
757754
// intoStream (below) makes browserify think the input file is named this, so this is what it puts in the sourcemap
758755
originalMap.file = "built/local/_stream_0.js";
759756

@@ -782,7 +779,7 @@ gulp.task("browserify", "Runs browserify on run.js to produce a file suitable fo
782779
});
783780
}))
784781
.pipe(sourcemaps.write(".", { includeContent: false }))
785-
.pipe(gulp.dest("."));
782+
.pipe(gulp.dest("src/harness"));
786783
});
787784

788785

@@ -964,7 +961,7 @@ gulp.task("update-sublime", "Updates the sublime plugin's tsserver", ["local", s
964961
});
965962

966963
gulp.task("build-rules", "Compiles tslint rules to js", () => {
967-
const settings: tsc.Settings = getCompilerSettings({ module: "commonjs" }, /*useBuiltCompiler*/ false);
964+
const settings: tsc.Settings = getCompilerSettings({ module: "commonjs", "lib": ["es6"] }, /*useBuiltCompiler*/ false);
968965
const dest = path.join(builtLocalDirectory, "tslint");
969966
return gulp.src("scripts/tslint/**/*.ts")
970967
.pipe(newer({
@@ -1023,40 +1020,16 @@ function spawnLintWorker(files: {path: string}[], callback: (failures: number) =
10231020
}
10241021

10251022
gulp.task("lint", "Runs tslint on the compiler sources. Optional arguments are: --f[iles]=regex", ["build-rules"], () => {
1026-
const fileMatcher = RegExp(cmdLineOptions["files"]);
10271023
if (fold.isTravis()) console.log(fold.start("lint"));
1028-
1029-
let files: {stat: fs.Stats, path: string}[] = [];
1030-
return gulp.src(lintTargets, { read: false })
1031-
.pipe(through2.obj((chunk, enc, cb) => {
1032-
files.push(chunk);
1033-
cb();
1034-
}, (cb) => {
1035-
files = files.filter(file => fileMatcher.test(file.path)).sort((filea, fileb) => filea.stat.size - fileb.stat.size);
1036-
const workerCount = cmdLineOptions["workers"];
1037-
for (let i = 0; i < workerCount; i++) {
1038-
spawnLintWorker(files, finished);
1039-
}
1040-
1041-
let completed = 0;
1042-
let failures = 0;
1043-
function finished(fails) {
1044-
completed++;
1045-
failures += fails;
1046-
if (completed === workerCount) {
1047-
if (fold.isTravis()) console.log(fold.end("lint"));
1048-
if (failures > 0) {
1049-
throw new Error(`Linter errors: ${failures}`);
1050-
}
1051-
else {
1052-
cb();
1053-
}
1054-
}
1055-
}
1056-
}));
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' --exclude 'src/harness/unittests/services/**/*.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] });
10571031
});
10581032

1059-
10601033
gulp.task("default", "Runs 'local'", ["local"]);
10611034

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

Jakefile.js

Lines changed: 29 additions & 52 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/";
@@ -131,6 +127,7 @@ var harnessSources = harnessCoreSources.concat([
131127
"matchFiles.ts",
132128
"initializeTSConfig.ts",
133129
"printer.ts",
130+
"textChanges.ts",
134131
"transform.ts",
135132
"customTransforms.ts",
136133
].map(function (f) {
@@ -328,8 +325,14 @@ function compileFile(outFile, sources, prereqs, prefixes, useBuiltCompiler, opts
328325
if (opts.stripInternal) {
329326
options += " --stripInternal";
330327
}
331-
332-
options += " --target es5 --lib es5,scripthost --noUnusedLocals --noUnusedParameters";
328+
options += " --target es5";
329+
if (opts.lib) {
330+
options += " --lib " + opts.lib
331+
}
332+
else {
333+
options += " --lib es5"
334+
}
335+
options += " --noUnusedLocals --noUnusedParameters";
333336

334337
var cmd = host + " " + compilerPath + " " + options + " ";
335338
cmd = cmd + sources.join(" ");
@@ -416,7 +419,7 @@ compileFile(buildProtocolJs,
416419
[buildProtocolTs],
417420
[],
418421
/*useBuiltCompiler*/ false,
419-
{noOutFile: true});
422+
{ noOutFile: true, lib: "es6" });
420423

421424
file(buildProtocolDts, [buildProtocolTs, buildProtocolJs, typescriptServicesDts], function() {
422425

@@ -578,16 +581,16 @@ compileFile(
578581
file(typescriptServicesDts, [servicesFile]);
579582

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

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

586589
var watchGuardFile = path.join(builtLocalDirectory, "watchGuard.js");
587-
compileFile(watchGuardFile, watchGuardSources, [builtLocalDirectory].concat(watchGuardSources), /*prefixes*/ [copyright], /*useBuiltCompiler*/ true, { outDir: builtLocalDirectory, noOutFile: false });
590+
compileFile(watchGuardFile, watchGuardSources, [builtLocalDirectory].concat(watchGuardSources), /*prefixes*/ [copyright], /*useBuiltCompiler*/ true, { types: ["node"], outDir: builtLocalDirectory, noOutFile: false, lib: "es6" });
588591

589592
var serverFile = path.join(builtLocalDirectory, "tsserver.js");
590-
compileFile(serverFile, serverSources, [builtLocalDirectory, copyright, cancellationTokenFile, typingsInstallerFile, watchGuardFile].concat(serverSources), /*prefixes*/ [copyright], /*useBuiltCompiler*/ true, { types: ["node"], preserveConstEnums: true });
593+
compileFile(serverFile, serverSources, [builtLocalDirectory, copyright, cancellationTokenFile, typingsInstallerFile, watchGuardFile].concat(serverSources).concat(servicesSources), /*prefixes*/ [copyright], /*useBuiltCompiler*/ true, { types: ["node"], preserveConstEnums: true, lib: "es6" });
591594
var tsserverLibraryFile = path.join(builtLocalDirectory, "tsserverlibrary.js");
592595
var tsserverLibraryDefinitionFile = path.join(builtLocalDirectory, "tsserverlibrary.d.ts");
593596
compileFile(
@@ -711,7 +714,7 @@ compileFile(
711714
/*prereqs*/[builtLocalDirectory, tscFile].concat(libraryTargets).concat(servicesSources).concat(harnessSources),
712715
/*prefixes*/[],
713716
/*useBuiltCompiler:*/ true,
714-
/*opts*/ { inlineSourceMap: true, types: ["node", "mocha", "chai"] });
717+
/*opts*/ { inlineSourceMap: true, types: ["node", "mocha", "chai"], lib: "es6" });
715718

716719
var internalTests = "internal/";
717720

@@ -1098,7 +1101,8 @@ var tslintRules = [
10981101
"noInOperatorRule",
10991102
"noIncrementDecrementRule",
11001103
"objectLiteralSurroundingSpaceRule",
1101-
"noTypeAssertionWhitespaceRule"
1104+
"noTypeAssertionWhitespaceRule",
1105+
"noBomRule"
11021106
];
11031107
var tslintRulesFiles = tslintRules.map(function (p) {
11041108
return path.join(tslintRuleDir, p + ".ts");
@@ -1110,7 +1114,7 @@ desc("Compiles tslint rules to js");
11101114
task("build-rules", ["build-rules-start"].concat(tslintRulesOutFiles).concat(["build-rules-end"]));
11111115
tslintRulesFiles.forEach(function (ruleFile, i) {
11121116
compileFile(tslintRulesOutFiles[i], [ruleFile], [ruleFile], [], /*useBuiltCompiler*/ false,
1113-
{ noOutFile: true, generateDeclarations: false, outDir: path.join(builtLocalDirectory, "tslint") });
1117+
{ noOutFile: true, generateDeclarations: false, outDir: path.join(builtLocalDirectory, "tslint"), lib: "es6" });
11141118
});
11151119

11161120
desc("Emit the start of the build-rules fold");
@@ -1173,43 +1177,16 @@ function spawnLintWorker(files, callback) {
11731177
}
11741178

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

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)