Skip to content

Commit 469ab3f

Browse files
committed
Merge branch 'master' into fix29006
2 parents e1477b4 + 0ddcab3 commit 469ab3f

File tree

151 files changed

+6141
-1840
lines changed

Some content is hidden

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

151 files changed

+6141
-1840
lines changed

.mailmap

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ Ken Howard <[email protected]>
121121
Kevin Lang <[email protected]>
122122
kimamula <[email protected]> # Kenji Imamula
123123
Kitson Kelly <[email protected]>
124+
Krishnadas Babu <[email protected]>
124125
Klaus Meinhardt <[email protected]>
125126
Kyle Kelley <[email protected]>
126127
Lorant Pinter <[email protected]>

CONTRIBUTING.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,16 @@ In general, things we find useful when reviewing suggestions are:
4747

4848
# Instructions for Contributing Code
4949

50+
## Tips
51+
52+
### Faster clones
53+
54+
The TypeScript repository is relatively large. To save some time, you might want to clone it without the repo's full history using `git clone --depth=1`.
55+
56+
### Using local builds
57+
58+
Run `gulp build` to build a version of the compiler/language service that reflects changes you've made. You can then run `node <repo-root>/built/local/tsc.js` in place of `tsc` in your project. For example, to run `tsc --watch` from within the root of the repository on a file called `test.ts`, you can run `node ./built/local/tsc.js --watch test.ts`.
59+
5060
## Contributing bug fixes
5161

5262
TypeScript is currently accepting contributions in the form of bug fixes. A bug must have an issue tracking it in the issue tracker that has been approved ("Milestone == Community") by the TypeScript team. Your pull request should include a link to the bug that you are fixing. If you've submitted a PR for a bug, please post a comment in the bug to avoid duplication of effort.

Gulpfile.js

Lines changed: 38 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ gulp.task(
274274
// Generate Markdown spec
275275
const specMd = "doc/spec.md";
276276
gulp.task(specMd, /*help*/ false, [word2mdJs], () =>
277-
exec("cscript", ["//nologo", word2mdJs, path.resolve(specMd), path.resolve("doc/TypeScript Language Specification.docx")]));
277+
exec("cscript", ["//nologo", word2mdJs, path.resolve("doc/TypeScript Language Specification.docx"), path.resolve(specMd)]));
278278

279279
gulp.task(
280280
"generate-spec",
@@ -488,29 +488,28 @@ gulp.task(
488488
"Runs 'local'",
489489
["local"]);
490490

491-
gulp.task(
492-
"watch-diagnostics",
493-
/*help*/ false,
494-
[processDiagnosticMessagesJs],
495-
() => gulp.watch([diagnosticMessagesJson], [diagnosticInformationMapTs, builtGeneratedDiagnosticMessagesJson]));
496-
497491
gulp.task(
498492
"watch-lib",
499493
/*help*/ false,
500494
() => gulp.watch(["src/lib/**/*"], ["lib"]));
501495

496+
const watchTscPatterns = [
497+
"src/tsconfig-base.json",
498+
"src/lib/**/*",
499+
"src/compiler/**/*",
500+
"src/tsc/**/*",
501+
];
502502
gulp.task(
503503
"watch-tsc",
504504
/*help*/ false,
505-
["watch-diagnostics", "watch-lib"].concat(useCompilerDeps),
506-
() => project.watch(tscProject, { typescript: useCompiler }));
505+
useCompilerDeps,
506+
() => gulp.watch(watchTscPatterns, ["tsc"]));
507507

508508
const watchServicesPatterns = [
509509
"src/compiler/**/*",
510510
"src/jsTypings/**/*",
511511
"src/services/**/*"
512512
];
513-
514513
gulp.task(
515514
"watch-services",
516515
/*help*/ false,
@@ -522,39 +521,49 @@ const watchLsslPatterns = [
522521
"src/server/**/*",
523522
"src/tsserver/tsconfig.json"
524523
];
525-
526524
gulp.task(
527525
"watch-lssl",
528526
/*help*/ false,
529527
() => gulp.watch(watchLsslPatterns, ["lssl"]));
530528

531-
gulp.task(
532-
"watch-server",
533-
/*help*/ false,
534-
["watch-diagnostics", "watch-lib"].concat(useCompilerDeps),
535-
() => project.watch(tsserverProject, { typescript: useCompiler }));
536-
537-
gulp.task(
538-
"watch-runner",
539-
/*help*/ false,
540-
useCompilerDeps,
541-
() => project.watch(testRunnerProject, { typescript: useCompiler }));
542-
529+
const watchLocalPatterns = [
530+
"src/tsconfig-base.json",
531+
"src/lib/**/*",
532+
"src/compiler/**/*",
533+
"src/tsc/**/*",
534+
"src/services/**/*",
535+
"src/jsTyping/**/*",
536+
"src/server/**/*",
537+
"src/tsserver/**/*",
538+
"src/typingsInstallerCore/**/*",
539+
"src/harness/**/*",
540+
"src/testRunner/**/*",
541+
];
543542
gulp.task(
544543
"watch-local",
545544
"Watches for changes to projects in src/ (but does not execute tests).",
546-
["watch-lib", "watch-tsc", "watch-services", "watch-server", "watch-runner", "watch-lssl"]);
545+
() => gulp.watch(watchLocalPatterns, "local"));
547546

547+
const watchPatterns = [
548+
"src/tsconfig-base.json",
549+
"src/lib/**/*",
550+
"src/compiler/**/*",
551+
"src/services/**/*",
552+
"src/jsTyping/**/*",
553+
"src/server/**/*",
554+
"src/tsserver/**/*",
555+
"src/typingsInstallerCore/**/*",
556+
"src/harness/**/*",
557+
"src/testRunner/**/*",
558+
];
548559
gulp.task(
549560
"watch",
550561
"Watches for changes to the build inputs for built/local/run.js, then runs tests.",
551-
["build-rules", "watch-runner", "watch-services", "watch-lssl"],
562+
["build-rules"],
552563
() => {
553564
const sem = new Semaphore(1);
554565

555-
gulp.watch([runJs, typescriptDts, tsserverlibraryDts], () => {
556-
runTests();
557-
});
566+
gulp.watch(watchPatterns, () => { runTests(); });
558567

559568
// NOTE: gulp.watch is far too slow when watching tests/cases/**/* as it first enumerates *every* file
560569
const testFilePattern = /(\.ts|[\\/]tsconfig\.json)$/;
@@ -586,7 +595,7 @@ gulp.task(
586595
project.waitForWorkToStart().then(() => {
587596
source.cancel();
588597
});
589-
598+
590599
if (cmdLineOptions.tests || cmdLineOptions.failed) {
591600
await runConsoleTests(runJs, "mocha-fivemat-progress-reporter", /*runInParallel*/ false, /*watchMode*/ true, source.token);
592601
}

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[![Build Status](https://travis-ci.org/Microsoft/TypeScript.svg?branch=master)](https://travis-ci.org/Microsoft/TypeScript)
2-
[![VSTS Build Status](https://typescript.visualstudio.com/_apis/public/build/definitions/cf7ac146-d525-443c-b23c-0d58337efebc/4/badge)](https://typescript.visualstudio.com/TypeScript/_build/latest?definitionId=4&view=logs)
2+
[![VSTS Build Status](https://dev.azure.com/typescript/TypeScript/_apis/build/status/Typescript/node10)](https://https://dev.azure.com/typescript/TypeScript/_build/latest?definitionId=4&view=logs)
33
[![npm version](https://badge.fury.io/js/typescript.svg)](https://www.npmjs.com/package/typescript)
44
[![Downloads](https://img.shields.io/npm/dm/typescript.svg)](https://www.npmjs.com/package/typescript)
55

doc/spec.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ TypeScript is a trademark of Microsoft Corporation.
239239

240240
# <a name="1"/>1 Introduction
241241

242-
JavaScript applications such as web e-mail, maps, document editing, and collaboration tools are becoming an increasingly important part of the everyday computing. We designed TypeScript to meet the needs of the JavaScript programming teams that build and maintain large JavaScript programs. TypeScript helps programming teams to define interfaces between software components and to gain insight into the behavior of existing JavaScript libraries. TypeScript also enables teams to reduce naming conflicts by organizing their code into dynamically-loadable modules. TypeScript's optional type system enables JavaScript programmers to use highly-productive development tools and practices: static checking, symbol-based navigation, statement completion, and code re-factoring.
242+
JavaScript applications such as web e-mail, maps, document editing, and collaboration tools are becoming an increasingly important part of the everyday computing. We designed TypeScript to meet the needs of the JavaScript programming teams that build and maintain large JavaScript programs. TypeScript helps programming teams to define interfaces between software components and to gain insight into the behavior of existing JavaScript libraries. TypeScript also enables teams to reduce naming conflicts by organizing their code into dynamically-loadable modules. TypeScript's optional type system enables JavaScript programmers to use highly-productive development tools and practices: static checking, symbol-based navigation, statement completion, and code refactoring.
243243

244244
TypeScript is a syntactic sugar for JavaScript. TypeScript syntax is a superset of ECMAScript 2015 (ES2015) syntax. Every JavaScript program is also a TypeScript program. The TypeScript compiler performs only file-local transformations on TypeScript programs and does not re-order variables declared in TypeScript. This leads to JavaScript output that closely matches the TypeScript input. TypeScript does not transform variable names, making tractable the direct debugging of emitted JavaScript. TypeScript optionally provides source maps, enabling source-level debugging. TypeScript tools typically emit JavaScript upon file save, preserving the test, edit, refresh cycle commonly used in JavaScript development.
245245

@@ -263,7 +263,7 @@ function f() {
263263
}
264264
```
265265

266-
To benefit from this inference, a programmer can use the TypeScript language service. For example, a code editor can incorporate the TypeScript language service and use the service to find the members of a string object as in the following screen shot.
266+
To benefit from this inference, a programmer can use the TypeScript language service. For example, a code editor can incorporate the TypeScript language service and use the service to find the members of a string object as in the following screenshot.
267267

268268
&emsp;&emsp;![](images/image1.png)
269269

@@ -411,7 +411,7 @@ We mentioned above that the '$' function behaves differently depending on the ty
411411
412412
This signature denotes that a function may be passed as the parameter of the '$' function. When a function is passed to '$', the jQuery library will invoke that function when a DOM document is ready. Because TypeScript supports overloading, tools can use TypeScript to show all available function signatures with their documentation tips and to give the correct documentation once a function has been called with a particular signature.
413413
414-
A typical client would not need to add any additional typing but could just use a community-supplied typing to discover (through statement completion with documentation tips) and verify (through static checking) correct use of the library, as in the following screen shot.
414+
A typical client would not need to add any additional typing but could just use a community-supplied typing to discover (through statement completion with documentation tips) and verify (through static checking) correct use of the library, as in the following screenshot.
415415
416416
&emsp;&emsp;![](images/image2.png)
417417
@@ -628,7 +628,7 @@ JavaScript implementations can use these explicit constants to generate efficien
628628

629629
An important goal of TypeScript is to provide accurate and straightforward types for existing JavaScript programming patterns. To that end, TypeScript includes generic types, discussed in the next section, and *overloading on string parameters*, the topic of this section.
630630

631-
JavaScript programming interfaces often include functions whose behavior is discriminated by a string constant passed to the function. The Document Object Model makes heavy use of this pattern. For example, the following screen shot shows that the 'createElement' method of the 'document' object has multiple signatures, some of which identify the types returned when specific strings are passed into the method.
631+
JavaScript programming interfaces often include functions whose behavior is discriminated by a string constant passed to the function. The Document Object Model makes heavy use of this pattern. For example, the following screenshot shows that the 'createElement' method of the 'document' object has multiple signatures, some of which identify the types returned when specific strings are passed into the method.
632632

633633
&emsp;&emsp;![](images/image3.png)
634634

@@ -639,7 +639,7 @@ var span = document.createElement("span");
639639
span.isMultiLine = false; // OK: HTMLSpanElement has isMultiline property
640640
```
641641

642-
In the following screen shot, a programming tool combines information from overloading on string parameters with contextual typing to infer that the type of the variable 'e' is 'MouseEvent' and that therefore 'e' has a 'clientX' property.
642+
In the following screenshot, a programming tool combines information from overloading on string parameters with contextual typing to infer that the type of the variable 'e' is 'MouseEvent' and that therefore 'e' has a 'clientX' property.
643643

644644
&emsp;&emsp;![](images/image4.png)
645645

scripts/build/options.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ module.exports = minimist(process.argv.slice(2), {
3434
workers: process.env.workerCount || os.cpus().length,
3535
failed: false,
3636
keepFailed: false,
37-
lkg: false,
37+
lkg: true,
3838
dirty: false
3939
}
4040
});

scripts/build/project.js

Lines changed: 39 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -14,78 +14,54 @@ const ts = require("../../lib/typescript");
1414
const del = require("del");
1515
const needsUpdate = require("./needsUpdate");
1616
const mkdirp = require("./mkdirp");
17-
const prettyTime = require("pretty-hrtime");
1817
const { reportDiagnostics } = require("./diagnostics");
19-
const { CountdownEvent, ManualResetEvent } = require("prex");
18+
const { CountdownEvent, ManualResetEvent, Semaphore } = require("prex");
2019

2120
const workStartedEvent = new ManualResetEvent();
2221
const countdown = new CountdownEvent(0);
2322

24-
class CompilationGulp extends gulp.Gulp {
25-
/**
26-
* @param {boolean} [verbose]
27-
*/
28-
fork(verbose) {
29-
const child = new ForkedGulp(this.tasks);
30-
child.on("task_start", e => {
31-
if (countdown.remainingCount === 0) {
32-
countdown.reset(1);
33-
workStartedEvent.set();
34-
workStartedEvent.reset();
35-
}
36-
else {
37-
countdown.add();
38-
}
39-
if (verbose) {
40-
log('Starting', `'${chalk.cyan(e.task)}' ${chalk.gray(`(${countdown.remainingCount} remaining)`)}...`);
41-
}
42-
});
43-
child.on("task_stop", e => {
44-
countdown.signal();
45-
if (verbose) {
46-
log('Finished', `'${chalk.cyan(e.task)}' after ${chalk.magenta(prettyTime(/** @type {*}*/(e).hrDuration))} ${chalk.gray(`(${countdown.remainingCount} remaining)`)}`);
47-
}
48-
});
49-
child.on("task_err", e => {
50-
countdown.signal();
51-
if (verbose) {
52-
log(`'${chalk.cyan(e.task)}' ${chalk.red("errored after")} ${chalk.magenta(prettyTime(/** @type {*}*/(e).hrDuration))} ${chalk.gray(`(${countdown.remainingCount} remaining)`)}`);
53-
log(e.err ? e.err.stack : e.message);
54-
}
55-
});
56-
return child;
57-
}
58-
59-
// @ts-ignore
60-
start() {
61-
throw new Error("Not supported, use fork.");
62-
}
63-
}
64-
65-
class ForkedGulp extends gulp.Gulp {
66-
/**
67-
* @param {gulp.Gulp["tasks"]} tasks
68-
*/
69-
constructor(tasks) {
70-
super();
71-
this.tasks = tasks;
72-
}
73-
74-
// Do not reset tasks
75-
_resetAllTasks() {}
76-
_resetSpecificTasks() {}
77-
_resetTask() {}
78-
}
79-
8023
// internal `Gulp` instance for compilation artifacts.
81-
const compilationGulp = new CompilationGulp();
24+
const compilationGulp = new gulp.Gulp();
8225

8326
/** @type {Map<ResolvedProjectSpec, ProjectGraph>} */
8427
const projectGraphCache = new Map();
8528

8629
/** @type {Map<string, { typescript: string, alias: string, paths: ResolvedPathOptions }>} */
8730
const typescriptAliasMap = new Map();
8831

32+
// TODO: allow concurrent outer builds to be run in parallel
33+
const sem = new Semaphore(1);
34+
35+
/**
36+
* @param {string|string[]} taskName
37+
* @param {() => any} [cb]
38+
*/
39+
function start(taskName, cb) {
40+
return sem.wait().then(() => new Promise((resolve, reject) => {
41+
compilationGulp.start(taskName, err => {
42+
if (err) {
43+
reject(err);
44+
}
45+
else if (cb) {
46+
try {
47+
resolve(cb());
48+
}
49+
catch (e) {
50+
reject(err);
51+
}
52+
}
53+
else {
54+
resolve();
55+
}
56+
});
57+
})).then(() => {
58+
sem.release()
59+
}, e => {
60+
sem.release();
61+
throw e;
62+
});
63+
}
64+
8965
/**
9066
* Defines a gulp orchestration for a TypeScript project, returning a callback that can be used to trigger compilation.
9167
* @param {string} projectSpec The path to a tsconfig.json file or its containing directory.
@@ -98,9 +74,7 @@ function createCompiler(projectSpec, options) {
9874
const projectGraph = getOrCreateProjectGraph(resolvedProjectSpec, resolvedOptions.paths);
9975
projectGraph.isRoot = true;
10076
const taskName = compileTaskName(ensureCompileTask(projectGraph, resolvedOptions), resolvedOptions.typescript);
101-
return () => new Promise((resolve, reject) => compilationGulp
102-
.fork(resolvedOptions.verbose)
103-
.start(taskName, err => err ? reject(err) : resolve()));
77+
return () => start(taskName);
10478
}
10579
exports.createCompiler = createCompiler;
10680

@@ -139,9 +113,7 @@ function createCleaner(projectSpec, options) {
139113
const projectGraph = getOrCreateProjectGraph(resolvedProjectSpec, paths);
140114
projectGraph.isRoot = true;
141115
const taskName = cleanTaskName(ensureCleanTask(projectGraph));
142-
return () => new Promise((resolve, reject) => compilationGulp
143-
.fork()
144-
.start(taskName, err => err ? reject(err) : resolve()));
116+
return () => start(taskName);
145117
}
146118
exports.createCleaner = createCleaner;
147119

@@ -811,7 +783,7 @@ function possiblyTriggerRecompilation(config, task) {
811783
function triggerRecompilation(task, config) {
812784
compilationGulp._resetTask(task);
813785
if (config.watchers && config.watchers.size) {
814-
compilationGulp.fork().start(task.name, () => {
786+
start(task.name, () => {
815787
/** @type {Set<string>} */
816788
const taskNames = new Set();
817789
/** @type {((err?: any) => void)[]} */
@@ -831,7 +803,7 @@ function triggerRecompilation(task, config) {
831803
});
832804
}
833805
else {
834-
compilationGulp.fork(/*verbose*/ true).start(task.name);
806+
start(task.name);
835807
}
836808
}
837809

scripts/build/tests.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ exports.cleanTestDirs = cleanTestDirs;
165165
function writeTestConfigFile(tests, runners, light, taskConfigsFolder, workerCount, stackTraceLimit, timeout, keepFailed) {
166166
const testConfigContents = JSON.stringify({
167167
test: tests ? [tests] : undefined,
168-
runner: runners ? runners.split(",") : undefined,
168+
runners: runners ? runners.split(",") : undefined,
169169
light,
170170
workerCount,
171171
stackTraceLimit,
@@ -192,4 +192,4 @@ function restoreSavedNodeEnv() {
192192

193193
function deleteTemporaryProjectOutput() {
194194
return del(path.join(exports.localBaseline, "projectOutput/"));
195-
}
195+
}

0 commit comments

Comments
 (0)