Skip to content

Commit 5ea43c8

Browse files
author
Andy Hanson
committed
Merge branch 'master' into semicolon
2 parents 91421c8 + 9796557 commit 5ea43c8

File tree

2,832 files changed

+135983
-77681
lines changed

Some content is hidden

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

2,832 files changed

+135983
-77681
lines changed

.gitignore

+1
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

.travis.yml

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ branches:
1717
only:
1818
- master
1919
- release-2.1
20+
- release-2.2
2021

2122
install:
2223
- npm uninstall typescript

Gulpfile.ts

+17-7
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,6 @@ declare module "gulp-typescript" {
2121
import * as insert from "gulp-insert";
2222
import * as sourcemaps from "gulp-sourcemaps";
2323
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-
}
2824
import del = require("del");
2925
import mkdirP = require("mkdirp");
3026
import minimist = require("minimist");
@@ -41,7 +37,7 @@ const {runTestsInParallel} = mochaParallel;
4137
Error.stackTraceLimit = 1000;
4238

4339
const cmdLineOptions = minimist(process.argv.slice(2), {
44-
boolean: ["debug", "light", "colors", "lint", "soft"],
40+
boolean: ["debug", "inspect", "light", "colors", "lint", "soft"],
4541
string: ["browser", "tests", "host", "reporter", "stackTraceLimit"],
4642
alias: {
4743
d: "debug",
@@ -57,6 +53,7 @@ const cmdLineOptions = minimist(process.argv.slice(2), {
5753
soft: false,
5854
colors: process.env.colors || process.env.color || true,
5955
debug: process.env.debug || process.env.d,
56+
inspect: process.env.inspect,
6057
host: process.env.TYPESCRIPT_HOST || process.env.host || "node",
6158
browser: process.env.browser || process.env.b || "IE",
6259
tests: process.env.test || process.env.tests || process.env.t,
@@ -138,6 +135,14 @@ const es2017LibrarySourceMap = es2017LibrarySource.map(function(source) {
138135
return { target: "lib." + source, sources: ["header.d.ts", source] };
139136
});
140137

138+
const esnextLibrarySource = [
139+
"esnext.asynciterable.d.ts"
140+
];
141+
142+
const esnextLibrarySourceMap = esnextLibrarySource.map(function (source) {
143+
return { target: "lib." + source, sources: ["header.d.ts", source] };
144+
});
145+
141146
const hostsLibrarySources = ["dom.generated.d.ts", "webworker.importscripts.d.ts", "scripthost.d.ts"];
142147

143148
const librarySourceMap = [
@@ -152,11 +157,12 @@ const librarySourceMap = [
152157
{ target: "lib.es2015.d.ts", sources: ["header.d.ts", "es2015.d.ts"] },
153158
{ target: "lib.es2016.d.ts", sources: ["header.d.ts", "es2016.d.ts"] },
154159
{ target: "lib.es2017.d.ts", sources: ["header.d.ts", "es2017.d.ts"] },
160+
{ target: "lib.esnext.d.ts", sources: ["header.d.ts", "esnext.d.ts"] },
155161

156162
// JavaScript + all host library
157163
{ target: "lib.d.ts", sources: ["header.d.ts", "es5.d.ts"].concat(hostsLibrarySources) },
158164
{ target: "lib.es6.d.ts", sources: ["header.d.ts", "es5.d.ts"].concat(es2015LibrarySources, hostsLibrarySources, "dom.iterable.d.ts") }
159-
].concat(es2015LibrarySourceMap, es2016LibrarySourceMap, es2017LibrarySourceMap);
165+
].concat(es2015LibrarySourceMap, es2016LibrarySourceMap, es2017LibrarySourceMap, esnextLibrarySourceMap);
160166

161167
const libraryTargets = librarySourceMap.map(function(f) {
162168
return path.join(builtLocalDirectory, f.target);
@@ -588,6 +594,7 @@ function runConsoleTests(defaultReporter: string, runInParallel: boolean, done:
588594
cleanTestDirs((err) => {
589595
if (err) { console.error(err); failWithStatus(err, 1); }
590596
const debug = cmdLineOptions["debug"];
597+
const inspect = cmdLineOptions["inspect"];
591598
const tests = cmdLineOptions["tests"];
592599
const light = cmdLineOptions["light"];
593600
const stackTraceLimit = cmdLineOptions["stackTraceLimit"];
@@ -624,7 +631,10 @@ function runConsoleTests(defaultReporter: string, runInParallel: boolean, done:
624631
// default timeout is 2sec which really should be enough, but maybe we just need a small amount longer
625632
if (!runInParallel) {
626633
const args = [];
627-
if (debug) {
634+
if (inspect) {
635+
args.push("--inspect");
636+
}
637+
if (inspect || debug) {
628638
args.push("--debug-brk");
629639
}
630640
args.push("-R", reporter);

Jakefile.js

+50-12
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ var servicesDirectory = "src/services/";
1515
var serverDirectory = "src/server/";
1616
var typingsInstallerDirectory = "src/server/typingsInstaller";
1717
var cancellationTokenDirectory = "src/server/cancellationToken";
18+
var watchGuardDirectory = "src/server/watchGuard";
1819
var harnessDirectory = "src/harness/";
1920
var libraryDirectory = "src/lib/";
2021
var scriptsDirectory = "scripts/";
@@ -80,6 +81,7 @@ var compilerSources = filesFromConfig("./src/compiler/tsconfig.json");
8081
var servicesSources = filesFromConfig("./src/services/tsconfig.json");
8182
var cancellationTokenSources = filesFromConfig(path.join(serverDirectory, "cancellationToken/tsconfig.json"));
8283
var typingsInstallerSources = filesFromConfig(path.join(serverDirectory, "typingsInstaller/tsconfig.json"));
84+
var watchGuardSources = filesFromConfig(path.join(serverDirectory, "watchGuard/tsconfig.json"));
8385
var serverSources = filesFromConfig(path.join(serverDirectory, "tsconfig.json"))
8486
var languageServiceLibrarySources = filesFromConfig(path.join(serverDirectory, "tsconfig.library.json"));
8587

@@ -129,6 +131,8 @@ var harnessSources = harnessCoreSources.concat([
129131
"matchFiles.ts",
130132
"initializeTSConfig.ts",
131133
"printer.ts",
134+
"transform.ts",
135+
"customTransforms.ts",
132136
].map(function (f) {
133137
return path.join(unittestsDirectory, f);
134138
})).concat([
@@ -170,13 +174,21 @@ var es2016LibrarySourceMap = es2016LibrarySource.map(function (source) {
170174
var es2017LibrarySource = [
171175
"es2017.object.d.ts",
172176
"es2017.sharedmemory.d.ts",
173-
"es2017.string.d.ts",
177+
"es2017.string.d.ts"
174178
];
175179

176180
var es2017LibrarySourceMap = es2017LibrarySource.map(function (source) {
177181
return { target: "lib." + source, sources: ["header.d.ts", source] };
178182
});
179183

184+
var esnextLibrarySource = [
185+
"esnext.asynciterable.d.ts"
186+
];
187+
188+
var esnextLibrarySourceMap = esnextLibrarySource.map(function (source) {
189+
return { target: "lib." + source, sources: ["header.d.ts", source] };
190+
});
191+
180192
var hostsLibrarySources = ["dom.generated.d.ts", "webworker.importscripts.d.ts", "scripthost.d.ts"];
181193

182194
var librarySourceMap = [
@@ -191,11 +203,12 @@ var librarySourceMap = [
191203
{ target: "lib.es2015.d.ts", sources: ["header.d.ts", "es2015.d.ts"] },
192204
{ target: "lib.es2016.d.ts", sources: ["header.d.ts", "es2016.d.ts"] },
193205
{ target: "lib.es2017.d.ts", sources: ["header.d.ts", "es2017.d.ts"] },
206+
{ target: "lib.esnext.d.ts", sources: ["header.d.ts", "esnext.d.ts"] },
194207

195208
// JavaScript + all host library
196209
{ target: "lib.d.ts", sources: ["header.d.ts", "es5.d.ts"].concat(hostsLibrarySources) },
197210
{ target: "lib.es6.d.ts", sources: ["header.d.ts", "es5.d.ts"].concat(es2015LibrarySources, hostsLibrarySources, "dom.iterable.d.ts") }
198-
].concat(es2015LibrarySourceMap, es2016LibrarySourceMap, es2017LibrarySourceMap);
211+
].concat(es2015LibrarySourceMap, es2016LibrarySourceMap, es2017LibrarySourceMap, esnextLibrarySourceMap);
199212

200213
var libraryTargets = librarySourceMap.map(function (f) {
201214
return path.join(builtLocalDirectory, f.target);
@@ -570,8 +583,11 @@ compileFile(cancellationTokenFile, cancellationTokenSources, [builtLocalDirector
570583
var typingsInstallerFile = path.join(builtLocalDirectory, "typingsInstaller.js");
571584
compileFile(typingsInstallerFile, typingsInstallerSources, [builtLocalDirectory].concat(typingsInstallerSources), /*prefixes*/ [copyright], /*useBuiltCompiler*/ true, { outDir: builtLocalDirectory, noOutFile: false });
572585

586+
var watchGuardFile = path.join(builtLocalDirectory, "watchGuard.js");
587+
compileFile(watchGuardFile, watchGuardSources, [builtLocalDirectory].concat(watchGuardSources), /*prefixes*/ [copyright], /*useBuiltCompiler*/ true, { outDir: builtLocalDirectory, noOutFile: false });
588+
573589
var serverFile = path.join(builtLocalDirectory, "tsserver.js");
574-
compileFile(serverFile, serverSources, [builtLocalDirectory, copyright, cancellationTokenFile, typingsInstallerFile].concat(serverSources), /*prefixes*/ [copyright], /*useBuiltCompiler*/ true, { types: ["node"] });
590+
compileFile(serverFile, serverSources, [builtLocalDirectory, copyright, cancellationTokenFile, typingsInstallerFile, watchGuardFile].concat(serverSources).concat(servicesSources), /*prefixes*/ [copyright], /*useBuiltCompiler*/ true, { types: ["node"], preserveConstEnums: true });
575591
var tsserverLibraryFile = path.join(builtLocalDirectory, "tsserverlibrary.js");
576592
var tsserverLibraryDefinitionFile = path.join(builtLocalDirectory, "tsserverlibrary.d.ts");
577593
compileFile(
@@ -580,7 +596,7 @@ compileFile(
580596
[builtLocalDirectory, copyright, builtLocalCompiler].concat(languageServiceLibrarySources).concat(libraryTargets),
581597
/*prefixes*/[copyright],
582598
/*useBuiltCompiler*/ true,
583-
{ noOutFile: false, generateDeclarations: true, stripInternal: true },
599+
{ noOutFile: false, generateDeclarations: true, stripInternal: true, preserveConstEnums: true },
584600
/*callback*/ function () {
585601
prependFile(copyright, tsserverLibraryDefinitionFile);
586602

@@ -665,7 +681,7 @@ task("generate-spec", [specMd]);
665681
// Makes a new LKG. This target does not build anything, but errors if not all the outputs are present in the built/local directory
666682
desc("Makes a new LKG out of the built js files");
667683
task("LKG", ["clean", "release", "local"].concat(libraryTargets), function () {
668-
var expectedFiles = [tscFile, servicesFile, serverFile, nodePackageFile, nodeDefinitionsFile, standaloneDefinitionsFile, tsserverLibraryFile, tsserverLibraryDefinitionFile, cancellationTokenFile, typingsInstallerFile, buildProtocolDts].concat(libraryTargets);
684+
var expectedFiles = [tscFile, servicesFile, serverFile, nodePackageFile, nodeDefinitionsFile, standaloneDefinitionsFile, tsserverLibraryFile, tsserverLibraryDefinitionFile, cancellationTokenFile, typingsInstallerFile, buildProtocolDts, watchGuardFile].concat(libraryTargets);
669685
var missingFiles = expectedFiles.filter(function (f) {
670686
return !fs.existsSync(f);
671687
});
@@ -778,6 +794,7 @@ function runConsoleTests(defaultReporter, runInParallel) {
778794
}
779795

780796
var debug = process.env.debug || process.env.d;
797+
var inspect = process.env.inspect;
781798
tests = process.env.test || process.env.tests || process.env.t;
782799
var light = process.env.light || false;
783800
var stackTraceLimit = process.env.stackTraceLimit;
@@ -807,18 +824,39 @@ function runConsoleTests(defaultReporter, runInParallel) {
807824
testTimeout = 800000;
808825
}
809826

810-
colors = process.env.colors || process.env.color;
811-
colors = colors ? ' --no-colors ' : ' --colors ';
812-
reporter = process.env.reporter || process.env.r || defaultReporter;
813-
var bail = (process.env.bail || process.env.b) ? "--bail" : "";
827+
var colors = process.env.colors || process.env.color || true;
828+
var reporter = process.env.reporter || process.env.r || defaultReporter;
829+
var bail = process.env.bail || process.env.b;
814830
var lintFlag = process.env.lint !== 'false';
815831

816832
// timeout normally isn't necessary but Travis-CI has been timing out on compiler baselines occasionally
817833
// default timeout is 2sec which really should be enough, but maybe we just need a small amount longer
818834
if (!runInParallel) {
819835
var startTime = mark();
820-
tests = tests ? ' -g "' + tests + '"' : '';
821-
var cmd = "mocha" + (debug ? " --debug-brk" : "") + " -R " + reporter + tests + colors + bail + ' -t ' + testTimeout + ' ' + run;
836+
var args = [];
837+
if (inspect) {
838+
args.push("--inspect");
839+
}
840+
if (inspect || debug) {
841+
args.push("--debug-brk");
842+
}
843+
args.push("-R", reporter);
844+
if (tests) {
845+
args.push("-g", `"${tests}"`);
846+
}
847+
if (colors) {
848+
args.push("--colors");
849+
}
850+
else {
851+
args.push("--no-colors");
852+
}
853+
if (bail) {
854+
args.push("--bail");
855+
}
856+
args.push("-t", testTimeout);
857+
args.push(run);
858+
859+
var cmd = "mocha " + args.join(" ");
822860
console.log(cmd);
823861

824862
var savedNodeEnv = process.env.NODE_ENV;
@@ -839,7 +877,7 @@ function runConsoleTests(defaultReporter, runInParallel) {
839877
var savedNodeEnv = process.env.NODE_ENV;
840878
process.env.NODE_ENV = "development";
841879
var startTime = mark();
842-
runTestsInParallel(taskConfigsFolder, run, { testTimeout: testTimeout, noColors: colors === " --no-colors " }, function (err) {
880+
runTestsInParallel(taskConfigsFolder, run, { testTimeout: testTimeout, noColors: !colors }, function (err) {
843881
process.env.NODE_ENV = savedNodeEnv;
844882
measure(startTime);
845883
// last worker clean everything and runs linter in case if there were no errors

lib/cancellationToken.js

+41-11
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,15 @@ and limitations under the License.
1515

1616
"use strict";
1717
var fs = require("fs");
18+
function pipeExists(name) {
19+
try {
20+
fs.statSync(name);
21+
return true;
22+
}
23+
catch (e) {
24+
return false;
25+
}
26+
}
1827
function createCancellationToken(args) {
1928
var cancellationPipeName;
2029
for (var i = 0; i < args.length - 1; i++) {
@@ -24,18 +33,39 @@ function createCancellationToken(args) {
2433
}
2534
}
2635
if (!cancellationPipeName) {
27-
return { isCancellationRequested: function () { return false; } };
36+
return {
37+
isCancellationRequested: function () { return false; },
38+
setRequest: function (_requestId) { return void 0; },
39+
resetRequest: function (_requestId) { return void 0; }
40+
};
2841
}
29-
return {
30-
isCancellationRequested: function () {
31-
try {
32-
fs.statSync(cancellationPipeName);
33-
return true;
34-
}
35-
catch (e) {
36-
return false;
37-
}
42+
if (cancellationPipeName.charAt(cancellationPipeName.length - 1) === "*") {
43+
var namePrefix_1 = cancellationPipeName.slice(0, -1);
44+
if (namePrefix_1.length === 0 || namePrefix_1.indexOf("*") >= 0) {
45+
throw new Error("Invalid name for template cancellation pipe: it should have length greater than 2 characters and contain only one '*'.");
3846
}
39-
};
47+
var perRequestPipeName_1;
48+
var currentRequestId_1;
49+
return {
50+
isCancellationRequested: function () { return perRequestPipeName_1 !== undefined && pipeExists(perRequestPipeName_1); },
51+
setRequest: function (requestId) {
52+
currentRequestId_1 = currentRequestId_1;
53+
perRequestPipeName_1 = namePrefix_1 + requestId;
54+
},
55+
resetRequest: function (requestId) {
56+
if (currentRequestId_1 !== requestId) {
57+
throw new Error("Mismatched request id, expected " + currentRequestId_1 + ", actual " + requestId);
58+
}
59+
perRequestPipeName_1 = undefined;
60+
}
61+
};
62+
}
63+
else {
64+
return {
65+
isCancellationRequested: function () { return pipeExists(cancellationPipeName); },
66+
setRequest: function (_requestId) { return void 0; },
67+
resetRequest: function (_requestId) { return void 0; }
68+
};
69+
}
4070
}
4171
module.exports = createCancellationToken;

0 commit comments

Comments
 (0)