Skip to content

Commit bc0c9a4

Browse files
committed
Merge branch 'master' into formattingAfterParseError
2 parents 37d4116 + d4fecd4 commit bc0c9a4

File tree

4,732 files changed

+238772
-204750
lines changed

Some content is hidden

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

4,732 files changed

+238772
-204750
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,4 +57,5 @@ internal/
5757
!tests/cases/projects/NodeModulesSearch/**/*
5858
!tests/baselines/reference/project/nodeModules*/**/*
5959
.idea
60-
yarn.lock
60+
yarn.lock
61+
package-lock.json

.vscode/tasks.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,13 @@
1818
"problemMatcher": [
1919
"$tsc"
2020
]
21+
},
22+
{
23+
"taskName": "tests",
24+
"showOutput": "silent",
25+
"problemMatcher": [
26+
"$tsc"
27+
]
2128
}
2229
]
2330
}

Gulpfile.ts

Lines changed: 63 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ import minimist = require("minimist");
2828
import browserify = require("browserify");
2929
import through2 = require("through2");
3030
import merge2 = require("merge2");
31-
import intoStream = require("into-stream");
3231
import * as os from "os";
3332
import fold = require("travis-fold");
3433
const gulp = helpMaker(originalGulp);
@@ -256,14 +255,8 @@ function needsUpdate(source: string | string[], dest: string | string[]): boolea
256255
return true;
257256
}
258257

259-
// Doing tsconfig inheritance manually. https://github.com/ivogabe/gulp-typescript/issues/459
260-
const tsconfigBase = JSON.parse(fs.readFileSync("src/tsconfig-base.json", "utf-8")).compilerOptions;
261-
262258
function getCompilerSettings(base: tsc.Settings, useBuiltCompiler?: boolean): tsc.Settings {
263259
const copy: tsc.Settings = {};
264-
for (const key in tsconfigBase) {
265-
copy[key] = tsconfigBase[key];
266-
}
267260
for (const key in base) {
268261
copy[key] = base[key];
269262
}
@@ -300,7 +293,7 @@ gulp.task("configure-nightly", "Runs scripts/configureNightly.ts to prepare a bu
300293
exec(host, [configureNightlyJs, packageJson, versionFile], done, done);
301294
});
302295
gulp.task("publish-nightly", "Runs `npm publish --tag next` to create a new nightly build on npm", ["LKG"], () => {
303-
return runSequence("clean", "useDebugMode", "runtests", (done) => {
296+
return runSequence("clean", "useDebugMode", "runtests-parallel", (done) => {
304297
exec("npm", ["publish", "--tag", "next"], done, done);
305298
});
306299
});
@@ -561,7 +554,7 @@ gulp.task(run, /*help*/ false, [servicesFile], () => {
561554
.pipe(newer(run))
562555
.pipe(sourcemaps.init())
563556
.pipe(testProject())
564-
.pipe(sourcemaps.write(".", { includeContent: false, sourceRoot: "../../" }))
557+
.pipe(sourcemaps.write(".", { includeContent: false, sourceRoot: "." }))
565558
.pipe(gulp.dest("src/harness"));
566559
});
567560

@@ -675,7 +668,7 @@ function runConsoleTests(defaultReporter: string, runInParallel: boolean, done:
675668
}
676669
args.push(run);
677670
setNodeEnvToDevelopment();
678-
runTestsInParallel(taskConfigsFolder, run, { testTimeout: testTimeout, noColors: colors === " --no-colors " }, function(err) {
671+
runTestsInParallel(taskConfigsFolder, run, { testTimeout, noColors: colors === " --no-colors " }, function(err) {
679672
// last worker clean everything and runs linter in case if there were no errors
680673
del(taskConfigsFolder).then(() => {
681674
if (!err) {
@@ -743,50 +736,75 @@ gulp.task(nodeServerOutFile, /*help*/ false, [servicesFile], () => {
743736

744737
import convertMap = require("convert-source-map");
745738
import sorcery = require("sorcery");
746-
declare module "convert-source-map" {
747-
export function fromSource(source: string, largeSource?: boolean): SourceMapConverter;
748-
}
739+
import Vinyl = require("vinyl");
749740

750-
gulp.task("browserify", "Runs browserify on run.js to produce a file suitable for running tests in the browser", [servicesFile, run], (done) => {
751-
const testProject = tsc.createProject("src/harness/tsconfig.json", getCompilerSettings({ outFile: "../../built/local/bundle.js" }, /*useBuiltCompiler*/ true));
752-
return testProject.src()
753-
.pipe(newer("built/local/bundle.js"))
741+
const bundlePath = path.resolve("built/local/bundle.js");
742+
743+
gulp.task("browserify", "Runs browserify on run.js to produce a file suitable for running tests in the browser", [servicesFile], (done) => {
744+
const testProject = tsc.createProject("src/harness/tsconfig.json", getCompilerSettings({ outFile: bundlePath, inlineSourceMap: true }, /*useBuiltCompiler*/ true));
745+
let originalMap: any;
746+
let prebundledContent: string;
747+
browserify(testProject.src()
748+
.pipe(newer(bundlePath))
754749
.pipe(sourcemaps.init())
755750
.pipe(testProject())
756751
.pipe(through2.obj((file, enc, next) => {
757-
const originalMap = file.sourceMap;
758-
const prebundledContent = file.contents.toString();
752+
if (originalMap) {
753+
throw new Error("Should only recieve one file!");
754+
}
755+
console.log(`Saving sourcemaps for ${file.path}`);
756+
originalMap = file.sourceMap;
757+
prebundledContent = file.contents.toString();
759758
// Make paths absolute to help sorcery deal with all the terrible paths being thrown around
760759
originalMap.sources = originalMap.sources.map(s => path.resolve(path.join("src/harness", s)));
761-
// intoStream (below) makes browserify think the input file is named this, so this is what it puts in the sourcemap
760+
// browserify names input files this when they are streamed in, so this is what it puts in the sourcemap
762761
originalMap.file = "built/local/_stream_0.js";
763762

764-
browserify(intoStream(file.contents), { debug: true })
765-
.bundle((err, res) => {
766-
// assumes file.contents is a Buffer
767-
const maps = JSON.parse(convertMap.fromSource(res.toString(), /*largeSource*/ true).toJSON());
768-
delete maps.sourceRoot;
769-
maps.sources = maps.sources.map(s => path.resolve(s === "_stream_0.js" ? "built/local/_stream_0.js" : s));
770-
// Strip browserify's inline comments away (could probably just let sorcery do this, but then we couldn't fix the paths)
771-
file.contents = new Buffer(convertMap.removeComments(res.toString()));
772-
const chain = sorcery.loadSync("built/local/bundle.js", {
773-
content: {
774-
"built/local/_stream_0.js": prebundledContent,
775-
"built/local/bundle.js": file.contents.toString()
776-
},
777-
sourcemaps: {
778-
"built/local/_stream_0.js": originalMap,
779-
"built/local/bundle.js": maps,
780-
"node_modules/source-map-support/source-map-support.js": undefined,
781-
}
782-
});
783-
const finalMap = chain.apply();
784-
file.sourceMap = finalMap;
785-
next(/*err*/ undefined, file);
786-
});
763+
next(/*err*/ undefined, file.contents);
787764
}))
788-
.pipe(sourcemaps.write(".", { includeContent: false }))
789-
.pipe(gulp.dest("src/harness"));
765+
.on("error", err => {
766+
return done(err);
767+
}), { debug: true, basedir: __dirname }) // Attach error handler to inner stream
768+
.bundle((err, contents) => {
769+
if (err) {
770+
if (err.message.match(/Cannot find module '.*_stream_0.js'/)) {
771+
return done(); // Browserify errors when we pass in no files when `newer` filters the input, we should count that as a success, though
772+
}
773+
return done(err);
774+
}
775+
const stringContent = contents.toString();
776+
const file = new Vinyl({ contents, path: bundlePath });
777+
console.log(`Fixing sourcemaps for ${file.path}`);
778+
// assumes contents is a Buffer, since that's what browserify yields
779+
const maps = convertMap.fromSource(stringContent, /*largeSource*/ true).toObject();
780+
delete maps.sourceRoot;
781+
maps.sources = maps.sources.map(s => path.resolve(s === "_stream_0.js" ? "built/local/_stream_0.js" : s));
782+
// Strip browserify's inline comments away (could probably just let sorcery do this, but then we couldn't fix the paths)
783+
file.contents = new Buffer(convertMap.removeComments(stringContent));
784+
const chain = sorcery.loadSync(bundlePath, {
785+
content: {
786+
"built/local/_stream_0.js": prebundledContent,
787+
[bundlePath]: stringContent
788+
},
789+
sourcemaps: {
790+
"built/local/_stream_0.js": originalMap,
791+
[bundlePath]: maps,
792+
"node_modules/source-map-support/source-map-support.js": undefined,
793+
}
794+
});
795+
const finalMap = chain.apply();
796+
file.sourceMap = finalMap;
797+
798+
const stream = through2.obj((file, enc, callback) => {
799+
return callback(/*err*/ undefined, file);
800+
});
801+
stream.pipe(sourcemaps.write(".", { includeContent: false }))
802+
.pipe(gulp.dest("."))
803+
.on("end", done)
804+
.on("error", done);
805+
stream.write(file);
806+
stream.end();
807+
});
790808
});
791809

792810

Jakefile.js

Lines changed: 17 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -133,11 +133,13 @@ var harnessSources = harnessCoreSources.concat([
133133
"projectErrors.ts",
134134
"matchFiles.ts",
135135
"initializeTSConfig.ts",
136+
"extractMethods.ts",
136137
"printer.ts",
137138
"textChanges.ts",
138139
"telemetry.ts",
139140
"transform.ts",
140141
"customTransforms.ts",
142+
"programMissingFiles.ts",
141143
].map(function (f) {
142144
return path.join(unittestsDirectory, f);
143145
})).concat([
@@ -286,7 +288,7 @@ function compileFile(outFile, sources, prereqs, prefixes, useBuiltCompiler, opts
286288
var startCompileTime = mark();
287289
opts = opts || {};
288290
var compilerPath = useBuiltCompiler ? builtLocalCompiler : LKGCompiler;
289-
var options = "--noImplicitAny --noImplicitThis --noEmitOnError --types "
291+
var options = "--noImplicitAny --noImplicitThis --alwaysStrict --noEmitOnError --types "
290292
if (opts.types) {
291293
options += opts.types.join(",");
292294
}
@@ -504,7 +506,7 @@ task("configure-nightly", [configureNightlyJs], function () {
504506
}, { async: true });
505507

506508
desc("Configure, build, test, and publish the nightly release.");
507-
task("publish-nightly", ["configure-nightly", "LKG", "clean", "setDebugMode", "runtests"], function () {
509+
task("publish-nightly", ["configure-nightly", "LKG", "clean", "setDebugMode", "runtests-parallel"], function () {
508510
var cmd = "npm publish --tag next";
509511
console.log(cmd);
510512
exec(cmd);
@@ -532,7 +534,6 @@ var tscFile = path.join(builtLocalDirectory, compilerFilename);
532534
compileFile(tscFile, compilerSources, [builtLocalDirectory, copyright].concat(compilerSources), [copyright], /*useBuiltCompiler:*/ false);
533535

534536
var servicesFile = path.join(builtLocalDirectory, "typescriptServices.js");
535-
var servicesFileInBrowserTest = path.join(builtLocalDirectory, "typescriptServicesInBrowserTest.js");
536537
var standaloneDefinitionsFile = path.join(builtLocalDirectory, "typescriptServices.d.ts");
537538
var nodePackageFile = path.join(builtLocalDirectory, "typescript.js");
538539
var nodeDefinitionsFile = path.join(builtLocalDirectory, "typescript.d.ts");
@@ -571,22 +572,6 @@ compileFile(servicesFile, servicesSources, [builtLocalDirectory, copyright].conc
571572
fs.writeFileSync(nodeStandaloneDefinitionsFile, nodeStandaloneDefinitionsFileContents);
572573
});
573574

574-
compileFile(
575-
servicesFileInBrowserTest,
576-
servicesSources,
577-
[builtLocalDirectory, copyright].concat(servicesSources),
578-
/*prefixes*/[copyright],
579-
/*useBuiltCompiler*/ true,
580-
{
581-
noOutFile: false,
582-
generateDeclarations: true,
583-
preserveConstEnums: true,
584-
keepComments: true,
585-
noResolve: false,
586-
stripInternal: true,
587-
inlineSourceMap: true
588-
});
589-
590575
file(typescriptServicesDts, [servicesFile]);
591576

592577
var cancellationTokenFile = path.join(builtLocalDirectory, "cancellationToken.js");
@@ -724,7 +709,7 @@ compileFile(
724709
/*prereqs*/[builtLocalDirectory, tscFile].concat(libraryTargets).concat(servicesSources).concat(harnessSources),
725710
/*prefixes*/[],
726711
/*useBuiltCompiler:*/ true,
727-
/*opts*/ { inlineSourceMap: true, types: ["node", "mocha", "chai"], lib: "es6" });
712+
/*opts*/ { types: ["node", "mocha", "chai"], lib: "es6" });
728713

729714
var internalTests = "internal/";
730715

@@ -839,7 +824,8 @@ function runConsoleTests(defaultReporter, runInParallel) {
839824
testTimeout = 800000;
840825
}
841826

842-
var colors = process.env.colors || process.env.color || true;
827+
var colorsFlag = process.env.color || process.env.colors;
828+
var colors = colorsFlag !== "false" && colorsFlag !== "0";
843829
var reporter = process.env.reporter || process.env.r || defaultReporter;
844830
var bail = process.env.bail || process.env.b;
845831
var lintFlag = process.env.lint !== 'false';
@@ -959,13 +945,14 @@ var nodeServerInFile = "tests/webTestServer.ts";
959945
compileFile(nodeServerOutFile, [nodeServerInFile], [builtLocalDirectory, tscFile], [], /*useBuiltCompiler:*/ true, { noOutFile: true, lib: "es6" });
960946

961947
desc("Runs browserify on run.js to produce a file suitable for running tests in the browser");
962-
task("browserify", ["tests", run, builtLocalDirectory, nodeServerOutFile], function() {
963-
var cmd = 'browserify built/local/run.js -t ./scripts/browserify-optional -d -o built/local/bundle.js';
948+
task("browserify", [], function() {
949+
// Shell out to `gulp`, since we do the work to handle sourcemaps correctly w/o inline maps there
950+
var cmd = 'gulp browserify --silent';
964951
exec(cmd);
965952
}, { async: true });
966953

967954
desc("Runs the tests using the built run.js file like 'jake runtests'. Syntax is jake runtests-browser. Additional optional parameters tests=[regex], browser=[chrome|IE]");
968-
task("runtests-browser", ["tests", "browserify", builtLocalDirectory, servicesFileInBrowserTest], function () {
955+
task("runtests-browser", ["browserify", nodeServerOutFile], function () {
969956
cleanTestDirs();
970957
host = "node";
971958
browser = process.env.browser || process.env.b || (os.platform() === "linux" ? "chrome" : "IE");
@@ -1120,14 +1107,15 @@ task("update-sublime", ["local", serverFile], function () {
11201107

11211108
var tslintRuleDir = "scripts/tslint";
11221109
var tslintRules = [
1123-
"nextLineRule",
11241110
"booleanTriviaRule",
1125-
"typeOperatorSpacingRule",
1126-
"noInOperatorRule",
1111+
"debugAssertRule",
1112+
"nextLineRule",
1113+
"noBomRule",
11271114
"noIncrementDecrementRule",
1128-
"objectLiteralSurroundingSpaceRule",
1115+
"noInOperatorRule",
11291116
"noTypeAssertionWhitespaceRule",
1130-
"noBomRule"
1117+
"objectLiteralSurroundingSpaceRule",
1118+
"typeOperatorSpacingRule",
11311119
];
11321120
var tslintRulesFiles = tslintRules.map(function (p) {
11331121
return path.join(tslintRuleDir, p + ".ts");

README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
[![Join the chat at https://gitter.im/Microsoft/TypeScript](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/Microsoft/TypeScript?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
88

9-
[TypeScript](http://www.typescriptlang.org/) is a language for application-scale JavaScript. TypeScript adds optional types, classes, and modules to JavaScript. TypeScript supports tools for large-scale JavaScript applications for any browser, for any host, on any OS. TypeScript compiles to readable, standards-based JavaScript. Try it out at the [playground](http://www.typescriptlang.org/Playground), and stay up to date via [our blog](https://blogs.msdn.microsoft.com/typescript) and [Twitter account](https://twitter.com/typescriptlang).
9+
[TypeScript](https://www.typescriptlang.org/) is a language for application-scale JavaScript. TypeScript adds optional types, classes, and modules to JavaScript. TypeScript supports tools for large-scale JavaScript applications for any browser, for any host, on any OS. TypeScript compiles to readable, standards-based JavaScript. Try it out at the [playground](https://www.typescriptlang.org/play/), and stay up to date via [our blog](https://blogs.msdn.microsoft.com/typescript) and [Twitter account](https://twitter.com/typescriptlang).
1010

1111
## Installing
1212

@@ -27,8 +27,8 @@ npm install -g typescript@next
2727
There are many ways to [contribute](https://github.com/Microsoft/TypeScript/blob/master/CONTRIBUTING.md) to TypeScript.
2828
* [Submit bugs](https://github.com/Microsoft/TypeScript/issues) and help us verify fixes as they are checked in.
2929
* Review the [source code changes](https://github.com/Microsoft/TypeScript/pulls).
30-
* Engage with other TypeScript users and developers on [StackOverflow](http://stackoverflow.com/questions/tagged/typescript).
31-
* Join the [#typescript](http://twitter.com/#!/search/realtime/%23typescript) discussion on Twitter.
30+
* Engage with other TypeScript users and developers on [StackOverflow](https://stackoverflow.com/questions/tagged/typescript).
31+
* Join the [#typescript](https://twitter.com/#!/search/realtime/%23typescript) discussion on Twitter.
3232
* [Contribute bug fixes](https://github.com/Microsoft/TypeScript/blob/master/CONTRIBUTING.md).
3333
* Read the language specification ([docx](https://github.com/Microsoft/TypeScript/blob/master/doc/TypeScript%20Language%20Specification.docx?raw=true),
3434
[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)).
@@ -39,14 +39,14 @@ with any additional questions or comments.
3939

4040
## Documentation
4141

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

4747
## Building
4848

49-
In order to build the TypeScript compiler, ensure that you have [Git](http://git-scm.com/downloads) and [Node.js](http://nodejs.org/) installed.
49+
In order to build the TypeScript compiler, ensure that you have [Git](https://git-scm.com/downloads) and [Node.js](https://nodejs.org/) installed.
5050

5151
Clone a copy of the repo:
5252

issue_template.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
```ts
1010
// A *self-contained* demonstration of the problem follows...
11-
11+
// Test this by running `tsc` on the command-line, rather than through another build tool such as Gulp, Webpack, etc.
1212
```
1313

1414
**Expected behavior:**

lib/cancellationToken.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,5 +69,3 @@ function createCancellationToken(args) {
6969
}
7070
}
7171
module.exports = createCancellationToken;
72-
73-
//# sourceMappingURL=cancellationToken.js.map

0 commit comments

Comments
 (0)