Skip to content

Commit fd2caf6

Browse files
committed
Merge remote-tracking branch 'origin/master' into explicitly_included_globs
2 parents 0fe6c55 + f9d2937 commit fd2caf6

File tree

163 files changed

+992
-2450
lines changed

Some content is hidden

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

163 files changed

+992
-2450
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 <[email protected]>
125125
Stanislav Sysoev <[email protected]>
126126
Steve Lucco <[email protected]> steveluc <[email protected]>
127127
Tarik <[email protected]> # Tarik Ozket
128+
Tetsuharu OHZEKI <[email protected]> # Tetsuharu Ohzeki
128129
Tien Nguyen <[email protected]> tien <[email protected]> unknown <[email protected]> #Tien Hoanhtien
129130
Tim Perry <[email protected]>
130131
Tim Viiding-Spader <[email protected]>

Gulpfile.ts

Lines changed: 43 additions & 107 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,11 @@ import newer = require("gulp-newer");
1111
import tsc = require("gulp-typescript");
1212
declare module "gulp-typescript" {
1313
interface Settings {
14-
stripInternal?: boolean;
14+
pretty?: boolean;
1515
newLine?: string;
16+
noImplicitThis?: boolean;
17+
stripInternal?: boolean;
18+
types?: string[];
1619
}
1720
interface CompileStream extends NodeJS.ReadWriteStream {} // Either gulp or gulp-typescript has some odd typings which don't reflect reality, making this required
1821
}
@@ -82,12 +85,9 @@ let host = cmdLineOptions["host"];
8285

8386
// Constants
8487
const compilerDirectory = "src/compiler/";
85-
const servicesDirectory = "src/services/";
86-
const serverDirectory = "src/server/";
8788
const harnessDirectory = "src/harness/";
8889
const libraryDirectory = "src/lib/";
8990
const scriptsDirectory = "scripts/";
90-
const unittestsDirectory = "tests/cases/unittests/";
9191
const docDirectory = "doc/";
9292

9393
const builtDirectory = "built/";
@@ -104,69 +104,6 @@ const nodeModulesPathPrefix = path.resolve("./node_modules/.bin/");
104104
const isWin = /^win/.test(process.platform);
105105
const mocha = path.join(nodeModulesPathPrefix, "mocha") + (isWin ? ".cmd" : "");
106106

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

307244
function getCompilerSettings(base: tsc.Settings, useBuiltCompiler?: boolean): tsc.Settings {
308245
const copy: tsc.Settings = {};
246+
copy.noEmitOnError = true;
247+
copy.noImplicitAny = true;
248+
copy.noImplicitThis = true;
249+
copy.pretty = true;
250+
copy.types = [];
309251
for (const key in base) {
310252
copy[key] = base[key];
311253
}
@@ -492,21 +434,18 @@ const tsserverLibraryFile = path.join(builtLocalDirectory, "tsserverlibrary.js")
492434
const tsserverLibraryDefinitionFile = path.join(builtLocalDirectory, "tsserverlibrary.d.ts");
493435

494436
gulp.task(tsserverLibraryFile, false, [servicesFile], (done) => {
495-
const settings: tsc.Settings = getCompilerSettings({
496-
declaration: true,
497-
outFile: tsserverLibraryFile
498-
}, /*useBuiltCompiler*/ true);
499-
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()
500439
.pipe(sourcemaps.init())
501440
.pipe(newer(tsserverLibraryFile))
502-
.pipe(tsc(settings));
441+
.pipe(tsc(serverLibraryProject));
503442

504443
return merge2([
505444
js.pipe(prependCopyright())
506445
.pipe(sourcemaps.write("."))
507-
.pipe(gulp.dest(".")),
446+
.pipe(gulp.dest(builtLocalDirectory)),
508447
dts.pipe(prependCopyright())
509-
.pipe(gulp.dest("."))
448+
.pipe(gulp.dest(builtLocalDirectory))
510449
]);
511450
});
512451

@@ -575,15 +514,13 @@ gulp.task("LKG", "Makes a new LKG out of the built js files", ["clean", "dontUse
575514
// Task to build the tests infrastructure using the built compiler
576515
const run = path.join(builtLocalDirectory, "run.js");
577516
gulp.task(run, false, [servicesFile], () => {
578-
const settings: tsc.Settings = getCompilerSettings({
579-
outFile: run
580-
}, /*useBuiltCompiler*/ true);
581-
return gulp.src(harnessSources)
517+
const testProject = tsc.createProject("src/harness/tsconfig.json", getCompilerSettings({}, /*useBuiltCompiler*/true));
518+
return testProject.src()
582519
.pipe(newer(run))
583520
.pipe(sourcemaps.init())
584-
.pipe(tsc(settings))
521+
.pipe(tsc(testProject))
585522
.pipe(sourcemaps.write(".", { includeContent: false, sourceRoot: "../../" }))
586-
.pipe(gulp.dest("."));
523+
.pipe(gulp.dest(builtLocalDirectory));
587524
});
588525

589526
const internalTests = "internal/";
@@ -758,13 +695,11 @@ gulp.task(nodeServerOutFile, false, [servicesFile], () => {
758695
});
759696

760697
gulp.task("browserify", "Runs browserify on run.js to produce a file suitable for running tests in the browser", [servicesFile], (done) => {
761-
const settings: tsc.Settings = getCompilerSettings({
762-
outFile: "built/local/bundle.js"
763-
}, /*useBuiltCompiler*/ true);
764-
return gulp.src(harnessSources)
698+
const testProject = tsc.createProject("src/harness/tsconfig.json", getCompilerSettings({ outFile: "built/local/bundle.js" }, /*useBuiltCompiler*/ true));
699+
return testProject.src()
765700
.pipe(newer("built/local/bundle.js"))
766701
.pipe(sourcemaps.init())
767-
.pipe(tsc(settings))
702+
.pipe(tsc(testProject))
768703
.pipe(through2.obj((file, enc, next) => {
769704
browserify(intoStream(file.contents))
770705
.bundle((err, res) => {
@@ -1005,36 +940,37 @@ function lintFile(options, path) {
1005940
return lintFileContents(options, path, contents);
1006941
}
1007942

1008-
const lintTargets = ["Gulpfile.ts"]
1009-
.concat(compilerSources)
1010-
.concat(harnessSources)
1011-
// Other harness sources
1012-
.concat(["instrumenter.ts"].map(function(f) { return path.join(harnessDirectory, f); }))
1013-
.concat(serverCoreSources)
1014-
.concat(tslintRulesFiles)
1015-
.concat(servicesSources);
943+
const lintTargets = [
944+
"Gulpfile.ts",
945+
"src/compiler/**/*.ts",
946+
"src/harness/**/*.ts",
947+
"!src/harness/unittests/services/formatting/**/*.ts",
948+
"src/server/**/*.ts",
949+
"scripts/tslint/**/*.ts",
950+
"src/services/**/*.ts",
951+
];
1016952

1017953

1018954
gulp.task("lint", "Runs tslint on the compiler sources. Optional arguments are: --f[iles]=regex", ["build-rules"], () => {
955+
const fileMatcher = RegExp(cmdLineOptions["files"]);
1019956
const lintOptions = getLinterOptions();
1020957
let failed = 0;
1021-
const fileMatcher = RegExp(cmdLineOptions["files"]);
1022-
const done = {};
1023-
for (const i in lintTargets) {
1024-
const target = lintTargets[i];
1025-
if (!done[target] && fileMatcher.test(target)) {
1026-
const result = lintFile(lintOptions, target);
958+
return gulp.src(lintTargets)
959+
.pipe(insert.transform((contents, file) => {
960+
if (!fileMatcher.test(file.path)) return contents;
961+
const result = lintFile(lintOptions, file.path);
1027962
if (result.failureCount > 0) {
1028963
console.log(result.output);
1029964
failed += result.failureCount;
1030965
}
1031-
done[target] = true;
1032-
}
1033-
}
1034-
if (failed > 0) {
1035-
console.error("Linter errors.");
1036-
process.exit(1);
1037-
}
966+
return contents; // TODO (weswig): Automatically apply fixes? :3
967+
}))
968+
.on("end", () => {
969+
if (failed > 0) {
970+
console.error("Linter errors.");
971+
process.exit(1);
972+
}
973+
});
1038974
});
1039975

1040976

Jakefile.js

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ var serverDirectory = "src/server/";
1414
var harnessDirectory = "src/harness/";
1515
var libraryDirectory = "src/lib/";
1616
var scriptsDirectory = "scripts/";
17-
var unittestsDirectory = "tests/cases/unittests/";
17+
var unittestsDirectory = "src/harness/unittests/";
1818
var docDirectory = "doc/";
1919

2020
var builtDirectory = "built/";
@@ -100,7 +100,6 @@ var servicesSources = [
100100
}));
101101

102102
var serverCoreSources = [
103-
"node.d.ts",
104103
"editorServices.ts",
105104
"protocol.d.ts",
106105
"session.ts",
@@ -279,13 +278,18 @@ var builtLocalCompiler = path.join(builtLocalDirectory, compilerFilename);
279278
* @param {boolean} opts.stripInternal: true if compiler should remove declarations marked as @internal
280279
* @param {boolean} opts.noMapRoot: true if compiler omit mapRoot option
281280
* @param {boolean} opts.inlineSourceMap: true if compiler should inline sourceMap
281+
* @param {Array} opts.types: array of types to include in compilation
282282
* @param callback: a function to execute after the compilation process ends
283283
*/
284284
function compileFile(outFile, sources, prereqs, prefixes, useBuiltCompiler, opts, callback) {
285285
file(outFile, prereqs, function() {
286-
var compilerPath = useBuiltCompiler ? builtLocalCompiler : LKGCompiler;
287-
var options = "--noImplicitAny --noEmitOnError --types --pretty";
288286
opts = opts || {};
287+
var compilerPath = useBuiltCompiler ? builtLocalCompiler : LKGCompiler;
288+
var options = "--noImplicitAny --noImplicitThis --noEmitOnError --types "
289+
if (opts.types) {
290+
options += opts.types.join(",");
291+
}
292+
options += " --pretty";
289293
// Keep comments when specifically requested
290294
// or when in debug mode.
291295
if (!(opts.keepComments || useDebugMode)) {
@@ -548,8 +552,7 @@ compileFile(
548552
});
549553

550554
var serverFile = path.join(builtLocalDirectory, "tsserver.js");
551-
compileFile(serverFile, serverSources,[builtLocalDirectory, copyright].concat(serverSources), /*prefixes*/ [copyright], /*useBuiltCompiler*/ true);
552-
555+
compileFile(serverFile, serverSources,[builtLocalDirectory, copyright].concat(serverSources), /*prefixes*/ [copyright], /*useBuiltCompiler*/ true, { types: ["node"] });
553556
var tsserverLibraryFile = path.join(builtLocalDirectory, "tsserverlibrary.js");
554557
var tsserverLibraryDefinitionFile = path.join(builtLocalDirectory, "tsserverlibrary.d.ts");
555558
compileFile(
@@ -652,7 +655,7 @@ compileFile(
652655
/*prereqs*/ [builtLocalDirectory, tscFile].concat(libraryTargets).concat(harnessSources),
653656
/*prefixes*/ [],
654657
/*useBuiltCompiler:*/ true,
655-
/*opts*/ { inlineSourceMap: true });
658+
/*opts*/ { inlineSourceMap: true, types: ["node", "mocha", "chai"] });
656659

657660
var internalTests = "internal/";
658661

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "typescript",
33
"author": "Microsoft Corp.",
44
"homepage": "http://typescriptlang.org/",
5-
"version": "2.0.0",
5+
"version": "2.1.0",
66
"license": "Apache-2.0",
77
"description": "TypeScript is a language for application scale JavaScript development",
88
"keywords": [
@@ -30,6 +30,7 @@
3030
},
3131
"devDependencies": {
3232
"@types/browserify": "latest",
33+
"@types/chai": "latest",
3334
"@types/del": "latest",
3435
"@types/glob": "latest",
3536
"@types/gulp": "latest",
@@ -42,6 +43,7 @@
4243
"@types/minimatch": "latest",
4344
"@types/minimist": "latest",
4445
"@types/mkdirp": "latest",
46+
"@types/mocha": "latest",
4547
"@types/node": "latest",
4648
"@types/q": "latest",
4749
"@types/run-sequence": "latest",

src/compiler/checker.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3166,17 +3166,17 @@ namespace ts {
31663166
}
31673167

31683168
let type: Type = undefined;
3169-
// Handle module.exports = expr or this.p = expr
3170-
if (declaration.kind === SyntaxKind.BinaryExpression) {
3171-
type = getUnionType(map(symbol.declarations, (decl: BinaryExpression) => checkExpressionCached(decl.right)));
3172-
}
3173-
else if (declaration.kind === SyntaxKind.PropertyAccessExpression) {
3174-
// Declarations only exist for property access expressions for certain
3175-
// special assignment kinds
3176-
if (declaration.parent.kind === SyntaxKind.BinaryExpression) {
3177-
// Handle exports.p = expr or className.prototype.method = expr
3178-
type = checkExpressionCached((<BinaryExpression>declaration.parent).right);
3179-
}
3169+
// Handle certain special assignment kinds, which happen to union across multiple declarations:
3170+
// * module.exports = expr
3171+
// * exports.p = expr
3172+
// * this.p = expr
3173+
// * className.prototype.method = expr
3174+
if (declaration.kind === SyntaxKind.BinaryExpression ||
3175+
declaration.kind === SyntaxKind.PropertyAccessExpression && declaration.parent.kind === SyntaxKind.BinaryExpression) {
3176+
type = getUnionType(map(symbol.declarations,
3177+
decl => decl.kind === SyntaxKind.BinaryExpression ?
3178+
checkExpressionCached((<BinaryExpression>decl).right) :
3179+
checkExpressionCached((<BinaryExpression>decl.parent).right)));
31803180
}
31813181

31823182
if (type === undefined) {
@@ -11673,7 +11673,7 @@ namespace ts {
1167311673
function getInferredClassType(symbol: Symbol) {
1167411674
const links = getSymbolLinks(symbol);
1167511675
if (!links.inferredClassType) {
11676-
links.inferredClassType = createAnonymousType(undefined, symbol.members, emptyArray, emptyArray, /*stringIndexType*/ undefined, /*numberIndexType*/ undefined);
11676+
links.inferredClassType = createAnonymousType(symbol, symbol.members, emptyArray, emptyArray, /*stringIndexType*/ undefined, /*numberIndexType*/ undefined);
1167711677
}
1167811678
return links.inferredClassType;
1167911679
}

src/compiler/core.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1271,20 +1271,20 @@ namespace ts {
12711271
getSignatureConstructor(): new (checker: TypeChecker) => Signature;
12721272
}
12731273

1274-
function Symbol(flags: SymbolFlags, name: string) {
1274+
function Symbol(this: Symbol, flags: SymbolFlags, name: string) {
12751275
this.flags = flags;
12761276
this.name = name;
12771277
this.declarations = undefined;
12781278
}
12791279

1280-
function Type(checker: TypeChecker, flags: TypeFlags) {
1280+
function Type(this: Type, checker: TypeChecker, flags: TypeFlags) {
12811281
this.flags = flags;
12821282
}
12831283

12841284
function Signature(checker: TypeChecker) {
12851285
}
12861286

1287-
function Node(kind: SyntaxKind, pos: number, end: number) {
1287+
function Node(this: Node, kind: SyntaxKind, pos: number, end: number) {
12881288
this.kind = kind;
12891289
this.pos = pos;
12901290
this.end = end;

0 commit comments

Comments
 (0)