Skip to content

Commit ff0cbb5

Browse files
committed
Merge branch 'master' into literalTypes
# Conflicts: # src/compiler/checker.ts
2 parents b673d5f + 6a6f5db commit ff0cbb5

File tree

306 files changed

+4481
-3322
lines changed

Some content is hidden

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

306 files changed

+4481
-3322
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ tests/baselines/reference/projectOutput/*
1717
tests/baselines/local/projectOutput/*
1818
tests/services/baselines/prototyping/local/*
1919
tests/services/browser/typescriptServices.js
20+
scripts/authors.js
2021
scripts/configureNightly.js
2122
scripts/processDiagnosticMessages.d.ts
2223
scripts/processDiagnosticMessages.js
@@ -50,3 +51,4 @@ internal/
5051
!**/.vscode/tasks.json
5152
!tests/cases/projects/projectOption/**/node_modules
5253
!tests/cases/projects/NodeModulesSearch/**/*
54+
!tests/baselines/reference/project/nodeModules*/**/*

.mailmap

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ Stan Thomas <stmsdn@norvil.net>
125125
Stanislav Sysoev <d4rkr00t@gmail.com>
126126
Steve Lucco <steveluc@users.noreply.github.com> steveluc <steveluc@microsoft.com>
127127
Tarik <tarik@pushmote.com> # Tarik Ozket
128+
Tetsuharu OHZEKI <saneyuki.snyk@gmail.com> # Tetsuharu Ohzeki
128129
Tien Nguyen <tihoanh@microsoft.com> tien <hoanhtien@users.noreply.github.com> unknown <tihoanh@microsoft.com> #Tien Hoanhtien
129130
Tim Perry <pimterry@gmail.com>
130131
Tim Viiding-Spader <viispade@users.noreply.github.com>

.travis.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,10 @@ node_js:
66
- '0.10'
77

88
sudo: false
9+
10+
os:
11+
- linux
12+
- osx
13+
14+
matrix:
15+
fast_finish: true

Gulpfile.ts

Lines changed: 77 additions & 114 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
/// <reference path="scripts/types/ambient.d.ts" />
2-
/// <reference types="q" />
3-
42
import * as cp from "child_process";
53
import * as path from "path";
64
import * as fs from "fs";
@@ -13,16 +11,19 @@ import newer = require("gulp-newer");
1311
import tsc = require("gulp-typescript");
1412
declare module "gulp-typescript" {
1513
interface Settings {
16-
stripInternal?: boolean;
14+
pretty?: boolean;
1715
newLine?: string;
16+
noImplicitThis?: boolean;
17+
stripInternal?: boolean;
18+
types?: string[];
1819
}
1920
interface CompileStream extends NodeJS.ReadWriteStream {} // Either gulp or gulp-typescript has some odd typings which don't reflect reality, making this required
2021
}
2122
import * as insert from "gulp-insert";
2223
import * as sourcemaps from "gulp-sourcemaps";
24+
import Q = require("q");
2325
declare global {
24-
// This is silly. We include Q because orchestrator (a part of gulp) depends on it, but its not included.
25-
// `del` further depends on `Promise` (and is also not included), so we just, patch the global scope's Promise to Q's
26+
// `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)
2627
type Promise<T> = Q.Promise<T>;
2728
}
2829
import del = require("del");
@@ -84,12 +85,9 @@ let host = cmdLineOptions["host"];
8485

8586
// Constants
8687
const compilerDirectory = "src/compiler/";
87-
const servicesDirectory = "src/services/";
88-
const serverDirectory = "src/server/";
8988
const harnessDirectory = "src/harness/";
9089
const libraryDirectory = "src/lib/";
9190
const scriptsDirectory = "scripts/";
92-
const unittestsDirectory = "tests/cases/unittests/";
9391
const docDirectory = "doc/";
9492

9593
const builtDirectory = "built/";
@@ -106,69 +104,6 @@ const nodeModulesPathPrefix = path.resolve("./node_modules/.bin/");
106104
const isWin = /^win/.test(process.platform);
107105
const mocha = path.join(nodeModulesPathPrefix, "mocha") + (isWin ? ".cmd" : "");
108106

109-
const compilerSources = require("./src/compiler/tsconfig.json").files.map((file) => path.join(compilerDirectory, file));
110-
111-
const servicesSources = require("./src/services/tsconfig.json").files.map((file) => path.join(servicesDirectory, file));
112-
113-
const serverCoreSources = require("./src/server/tsconfig.json").files.map((file) => path.join(serverDirectory, file));
114-
115-
const languageServiceLibrarySources = [
116-
"editorServices.ts",
117-
"protocol.d.ts",
118-
"session.ts"
119-
].map(function (f) {
120-
return path.join(serverDirectory, f);
121-
}).concat(servicesSources);
122-
123-
const harnessCoreSources = [
124-
"harness.ts",
125-
"sourceMapRecorder.ts",
126-
"harnessLanguageService.ts",
127-
"fourslash.ts",
128-
"runnerbase.ts",
129-
"compilerRunner.ts",
130-
"typeWriter.ts",
131-
"fourslashRunner.ts",
132-
"projectsRunner.ts",
133-
"loggedIO.ts",
134-
"rwcRunner.ts",
135-
"test262Runner.ts",
136-
"runner.ts"
137-
].map(function (f) {
138-
return path.join(harnessDirectory, f);
139-
});
140-
141-
const harnessSources = harnessCoreSources.concat([
142-
"incrementalParser.ts",
143-
"jsDocParsing.ts",
144-
"services/colorization.ts",
145-
"services/documentRegistry.ts",
146-
"services/preProcessFile.ts",
147-
"services/patternMatcher.ts",
148-
"session.ts",
149-
"versionCache.ts",
150-
"convertToBase64.ts",
151-
"transpile.ts",
152-
"reuseProgramStructure.ts",
153-
"cachingInServerLSHost.ts",
154-
"moduleResolution.ts",
155-
"tsconfigParsing.ts",
156-
"commandLineParsing.ts",
157-
"convertCompilerOptionsFromJson.ts",
158-
"convertTypingOptionsFromJson.ts",
159-
"tsserverProjectSystem.ts",
160-
"matchFiles.ts",
161-
].map(function (f) {
162-
return path.join(unittestsDirectory, f);
163-
})).concat([
164-
"protocol.d.ts",
165-
"session.ts",
166-
"client.ts",
167-
"editorServices.ts"
168-
].map(function (f) {
169-
return path.join(serverDirectory, f);
170-
}));
171-
172107
const es2015LibrarySources = [
173108
"es2015.core.d.ts",
174109
"es2015.collection.d.ts",
@@ -308,6 +243,11 @@ function needsUpdate(source: string | string[], dest: string | string[]): boolea
308243

309244
function getCompilerSettings(base: tsc.Settings, useBuiltCompiler?: boolean): tsc.Settings {
310245
const copy: tsc.Settings = {};
246+
copy.noEmitOnError = true;
247+
copy.noImplicitAny = true;
248+
copy.noImplicitThis = true;
249+
copy.pretty = true;
250+
copy.types = [];
311251
for (const key in base) {
312252
copy[key] = base[key];
313253
}
@@ -494,21 +434,18 @@ const tsserverLibraryFile = path.join(builtLocalDirectory, "tsserverlibrary.js")
494434
const tsserverLibraryDefinitionFile = path.join(builtLocalDirectory, "tsserverlibrary.d.ts");
495435

496436
gulp.task(tsserverLibraryFile, false, [servicesFile], (done) => {
497-
const settings: tsc.Settings = getCompilerSettings({
498-
declaration: true,
499-
outFile: tsserverLibraryFile
500-
}, /*useBuiltCompiler*/ true);
501-
const {js, dts}: {js: NodeJS.ReadableStream, dts: NodeJS.ReadableStream} = gulp.src(languageServiceLibrarySources)
437+
const serverLibraryProject = tsc.createProject("src/server/tsconfig.library.json", getCompilerSettings({}, /*useBuiltCompiler*/ true));
438+
const {js, dts}: {js: NodeJS.ReadableStream, dts: NodeJS.ReadableStream} = serverLibraryProject.src()
502439
.pipe(sourcemaps.init())
503440
.pipe(newer(tsserverLibraryFile))
504-
.pipe(tsc(settings));
441+
.pipe(tsc(serverLibraryProject));
505442

506443
return merge2([
507444
js.pipe(prependCopyright())
508445
.pipe(sourcemaps.write("."))
509-
.pipe(gulp.dest(".")),
446+
.pipe(gulp.dest(builtLocalDirectory)),
510447
dts.pipe(prependCopyright())
511-
.pipe(gulp.dest("."))
448+
.pipe(gulp.dest(builtLocalDirectory))
512449
]);
513450
});
514451

@@ -577,15 +514,13 @@ gulp.task("LKG", "Makes a new LKG out of the built js files", ["clean", "dontUse
577514
// Task to build the tests infrastructure using the built compiler
578515
const run = path.join(builtLocalDirectory, "run.js");
579516
gulp.task(run, false, [servicesFile], () => {
580-
const settings: tsc.Settings = getCompilerSettings({
581-
outFile: run
582-
}, /*useBuiltCompiler*/ true);
583-
return gulp.src(harnessSources)
517+
const testProject = tsc.createProject("src/harness/tsconfig.json", getCompilerSettings({}, /*useBuiltCompiler*/true));
518+
return testProject.src()
584519
.pipe(newer(run))
585520
.pipe(sourcemaps.init())
586-
.pipe(tsc(settings))
521+
.pipe(tsc(testProject))
587522
.pipe(sourcemaps.write(".", { includeContent: false, sourceRoot: "../../" }))
588-
.pipe(gulp.dest("."));
523+
.pipe(gulp.dest(builtLocalDirectory));
589524
});
590525

591526
const internalTests = "internal/";
@@ -759,23 +694,50 @@ gulp.task(nodeServerOutFile, false, [servicesFile], () => {
759694
.pipe(gulp.dest(path.dirname(nodeServerOutFile)));
760695
});
761696

697+
import convertMap = require("convert-source-map");
698+
import sorcery = require("sorcery");
699+
declare module "convert-source-map" {
700+
export function fromSource(source: string, largeSource?: boolean): SourceMapConverter;
701+
}
702+
762703
gulp.task("browserify", "Runs browserify on run.js to produce a file suitable for running tests in the browser", [servicesFile], (done) => {
763-
const settings: tsc.Settings = getCompilerSettings({
764-
outFile: "built/local/bundle.js"
765-
}, /*useBuiltCompiler*/ true);
766-
return gulp.src(harnessSources)
704+
const testProject = tsc.createProject("src/harness/tsconfig.json", getCompilerSettings({ outFile: "built/local/bundle.js" }, /*useBuiltCompiler*/ true));
705+
return testProject.src()
767706
.pipe(newer("built/local/bundle.js"))
768707
.pipe(sourcemaps.init())
769-
.pipe(tsc(settings))
708+
.pipe(tsc(testProject))
770709
.pipe(through2.obj((file, enc, next) => {
771-
browserify(intoStream(file.contents))
710+
const originalMap = file.sourceMap;
711+
const prebundledContent = file.contents.toString();
712+
// Make paths absolute to help sorcery deal with all the terrible paths being thrown around
713+
originalMap.sources = originalMap.sources.map(s => path.resolve(s));
714+
// intoStream (below) makes browserify think the input file is named this, so this is what it puts in the sourcemap
715+
originalMap.file = "built/local/_stream_0.js";
716+
717+
browserify(intoStream(file.contents), { debug: true })
772718
.bundle((err, res) => {
773719
// assumes file.contents is a Buffer
774-
file.contents = res;
720+
const maps = JSON.parse(convertMap.fromSource(res.toString(), /*largeSource*/true).toJSON());
721+
delete maps.sourceRoot;
722+
maps.sources = maps.sources.map(s => path.resolve(s === "_stream_0.js" ? "built/local/_stream_0.js" : s));
723+
// Strip browserify's inline comments away (could probably just let sorcery do this, but then we couldn't fix the paths)
724+
file.contents = new Buffer(convertMap.removeComments(res.toString()));
725+
const chain = sorcery.loadSync("built/local/bundle.js", {
726+
content: {
727+
"built/local/_stream_0.js": prebundledContent,
728+
"built/local/bundle.js": file.contents.toString()
729+
},
730+
sourcemaps: {
731+
"built/local/_stream_0.js": originalMap,
732+
"built/local/bundle.js": maps,
733+
}
734+
});
735+
const finalMap = chain.apply();
736+
file.sourceMap = finalMap;
775737
next(undefined, file);
776738
});
777739
}))
778-
.pipe(sourcemaps.write(".", { includeContent: false, sourceRoot: "../../" }))
740+
.pipe(sourcemaps.write(".", { includeContent: false }))
779741
.pipe(gulp.dest("."));
780742
});
781743

@@ -1007,36 +969,37 @@ function lintFile(options, path) {
1007969
return lintFileContents(options, path, contents);
1008970
}
1009971

1010-
const lintTargets = ["Gulpfile.ts"]
1011-
.concat(compilerSources)
1012-
.concat(harnessSources)
1013-
// Other harness sources
1014-
.concat(["instrumenter.ts"].map(function(f) { return path.join(harnessDirectory, f); }))
1015-
.concat(serverCoreSources)
1016-
.concat(tslintRulesFiles)
1017-
.concat(servicesSources);
972+
const lintTargets = [
973+
"Gulpfile.ts",
974+
"src/compiler/**/*.ts",
975+
"src/harness/**/*.ts",
976+
"!src/harness/unittests/services/formatting/**/*.ts",
977+
"src/server/**/*.ts",
978+
"scripts/tslint/**/*.ts",
979+
"src/services/**/*.ts",
980+
];
1018981

1019982

1020983
gulp.task("lint", "Runs tslint on the compiler sources. Optional arguments are: --f[iles]=regex", ["build-rules"], () => {
984+
const fileMatcher = RegExp(cmdLineOptions["files"]);
1021985
const lintOptions = getLinterOptions();
1022986
let failed = 0;
1023-
const fileMatcher = RegExp(cmdLineOptions["files"]);
1024-
const done = {};
1025-
for (const i in lintTargets) {
1026-
const target = lintTargets[i];
1027-
if (!done[target] && fileMatcher.test(target)) {
1028-
const result = lintFile(lintOptions, target);
987+
return gulp.src(lintTargets)
988+
.pipe(insert.transform((contents, file) => {
989+
if (!fileMatcher.test(file.path)) return contents;
990+
const result = lintFile(lintOptions, file.path);
1029991
if (result.failureCount > 0) {
1030992
console.log(result.output);
1031993
failed += result.failureCount;
1032994
}
1033-
done[target] = true;
1034-
}
1035-
}
1036-
if (failed > 0) {
1037-
console.error("Linter errors.");
1038-
process.exit(1);
1039-
}
995+
return contents; // TODO (weswig): Automatically apply fixes? :3
996+
}))
997+
.on("end", () => {
998+
if (failed > 0) {
999+
console.error("Linter errors.");
1000+
process.exit(1);
1001+
}
1002+
});
10401003
});
10411004

10421005

0 commit comments

Comments
 (0)