Skip to content

Commit 3705b87

Browse files
committed
Merge branch 'master' into infereClassPropertiesFromMethods
2 parents 8d96921 + b3161e3 commit 3705b87

File tree

228 files changed

+5274
-1437
lines changed

Some content is hidden

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

228 files changed

+5274
-1437
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
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

Gulpfile.ts

Lines changed: 6 additions & 10 deletions
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");
@@ -394,7 +390,7 @@ gulp.task(builtLocalCompiler, false, [servicesFile], () => {
394390
.pipe(localCompilerProject())
395391
.pipe(prependCopyright())
396392
.pipe(sourcemaps.write("."))
397-
.pipe(gulp.dest("."));
393+
.pipe(gulp.dest("src/compiler"));
398394
});
399395

400396
gulp.task(servicesFile, false, ["lib", "generate-diagnostics"], () => {
@@ -426,7 +422,7 @@ gulp.task(servicesFile, false, ["lib", "generate-diagnostics"], () => {
426422
file.path = nodeStandaloneDefinitionsFile;
427423
return content.replace(/declare (namespace|module) ts/g, 'declare module "typescript"');
428424
}))
429-
]).pipe(gulp.dest("."));
425+
]).pipe(gulp.dest("src/services"));
430426
});
431427

432428
// cancellationToken.js
@@ -452,7 +448,7 @@ gulp.task(typingsInstallerJs, false, [servicesFile], () => {
452448
.pipe(cancellationTokenProject())
453449
.pipe(prependCopyright())
454450
.pipe(sourcemaps.write("."))
455-
.pipe(gulp.dest("."));
451+
.pipe(gulp.dest("src/server/typingsInstaller"));
456452
});
457453

458454
const serverFile = path.join(builtLocalDirectory, "tsserver.js");
@@ -465,7 +461,7 @@ gulp.task(serverFile, false, [servicesFile, typingsInstallerJs, cancellationToke
465461
.pipe(serverProject())
466462
.pipe(prependCopyright())
467463
.pipe(sourcemaps.write("."))
468-
.pipe(gulp.dest("."));
464+
.pipe(gulp.dest("src/server"));
469465
});
470466

471467
const tsserverLibraryFile = path.join(builtLocalDirectory, "tsserverlibrary.js");
@@ -560,7 +556,7 @@ gulp.task(run, false, [servicesFile], () => {
560556
.pipe(sourcemaps.init())
561557
.pipe(testProject())
562558
.pipe(sourcemaps.write(".", { includeContent: false, sourceRoot: "../../" }))
563-
.pipe(gulp.dest("."));
559+
.pipe(gulp.dest("src/harness"));
564560
});
565561

566562
const internalTests = "internal/";
@@ -782,7 +778,7 @@ gulp.task("browserify", "Runs browserify on run.js to produce a file suitable fo
782778
});
783779
}))
784780
.pipe(sourcemaps.write(".", { includeContent: false }))
785-
.pipe(gulp.dest("."));
781+
.pipe(gulp.dest("src/harness"));
786782
});
787783

788784

Jakefile.js

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -328,8 +328,14 @@ function compileFile(outFile, sources, prereqs, prefixes, useBuiltCompiler, opts
328328
if (opts.stripInternal) {
329329
options += " --stripInternal";
330330
}
331-
332-
options += " --target es5 --lib es5,scripthost --noUnusedLocals --noUnusedParameters";
331+
options += " --target es5";
332+
if (opts.lib) {
333+
options += " --lib " + opts.lib
334+
}
335+
else {
336+
options += " --lib es5,scripthost"
337+
}
338+
options += " --noUnusedLocals --noUnusedParameters";
333339

334340
var cmd = host + " " + compilerPath + " " + options + " ";
335341
cmd = cmd + sources.join(" ");
@@ -587,7 +593,7 @@ var watchGuardFile = path.join(builtLocalDirectory, "watchGuard.js");
587593
compileFile(watchGuardFile, watchGuardSources, [builtLocalDirectory].concat(watchGuardSources), /*prefixes*/ [copyright], /*useBuiltCompiler*/ true, { outDir: builtLocalDirectory, noOutFile: false });
588594

589595
var serverFile = path.join(builtLocalDirectory, "tsserver.js");
590-
compileFile(serverFile, serverSources, [builtLocalDirectory, copyright, cancellationTokenFile, typingsInstallerFile, watchGuardFile].concat(serverSources), /*prefixes*/ [copyright], /*useBuiltCompiler*/ true, { types: ["node"], preserveConstEnums: true });
596+
compileFile(serverFile, serverSources, [builtLocalDirectory, copyright, cancellationTokenFile, typingsInstallerFile, watchGuardFile].concat(serverSources).concat(servicesSources), /*prefixes*/ [copyright], /*useBuiltCompiler*/ true, { types: ["node"], preserveConstEnums: true });
591597
var tsserverLibraryFile = path.join(builtLocalDirectory, "tsserverlibrary.js");
592598
var tsserverLibraryDefinitionFile = path.join(builtLocalDirectory, "tsserverlibrary.d.ts");
593599
compileFile(
@@ -1110,7 +1116,7 @@ desc("Compiles tslint rules to js");
11101116
task("build-rules", ["build-rules-start"].concat(tslintRulesOutFiles).concat(["build-rules-end"]));
11111117
tslintRulesFiles.forEach(function (ruleFile, i) {
11121118
compileFile(tslintRulesOutFiles[i], [ruleFile], [ruleFile], [], /*useBuiltCompiler*/ false,
1113-
{ noOutFile: true, generateDeclarations: false, outDir: path.join(builtLocalDirectory, "tslint") });
1119+
{ noOutFile: true, generateDeclarations: false, outDir: path.join(builtLocalDirectory, "tslint"), lib: "es6" });
11141120
});
11151121

11161122
desc("Emit the start of the build-rules fold");

lib/protocol.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1742,6 +1742,7 @@ declare namespace ts.server.protocol {
17421742
insertSpaceAfterFunctionKeywordForAnonymousFunctions?: boolean;
17431743
insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis?: boolean;
17441744
insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets?: boolean;
1745+
insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces?: boolean;
17451746
insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces?: boolean;
17461747
insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces?: boolean;
17471748
insertSpaceBeforeFunctionParenthesis?: boolean;

scripts/parallel-lint.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
var tslint = require("tslint");
22
var fs = require("fs");
3+
var path = require("path");
34

45
function getLinterOptions() {
56
return {
@@ -9,7 +10,7 @@ function getLinterOptions() {
910
};
1011
}
1112
function getLinterConfiguration() {
12-
return require("../tslint.json");
13+
return tslint.Configuration.loadConfigurationFromPath(path.join(__dirname, "../tslint.json"));
1314
}
1415

1516
function lintFileContents(options, configuration, path, contents) {

src/compiler/binder.ts

Lines changed: 60 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ namespace ts {
182182
return bindSourceFile;
183183

184184
function bindInStrictMode(file: SourceFile, opts: CompilerOptions): boolean {
185-
if (opts.alwaysStrict && !isDeclarationFile(file)) {
185+
if ((opts.alwaysStrict === undefined ? opts.strict : opts.alwaysStrict) && !isDeclarationFile(file)) {
186186
// bind in strict mode source files with alwaysStrict option
187187
return true;
188188
}
@@ -670,6 +670,12 @@ namespace ts {
670670
case SyntaxKind.CallExpression:
671671
bindCallExpressionFlow(<CallExpression>node);
672672
break;
673+
case SyntaxKind.JSDocComment:
674+
bindJSDocComment(<JSDoc>node);
675+
break;
676+
case SyntaxKind.JSDocTypedefTag:
677+
bindJSDocTypedefTag(<JSDocTypedefTag>node);
678+
break;
673679
default:
674680
bindEachChild(node);
675681
break;
@@ -1335,6 +1341,26 @@ namespace ts {
13351341
}
13361342
}
13371343

1344+
function bindJSDocComment(node: JSDoc) {
1345+
forEachChild(node, n => {
1346+
if (n.kind !== SyntaxKind.JSDocTypedefTag) {
1347+
bind(n);
1348+
}
1349+
});
1350+
}
1351+
1352+
function bindJSDocTypedefTag(node: JSDocTypedefTag) {
1353+
forEachChild(node, n => {
1354+
// if the node has a fullName "A.B.C", that means symbol "C" was already bound
1355+
// when we visit "fullName"; so when we visit the name "C" as the next child of
1356+
// the jsDocTypedefTag, we should skip binding it.
1357+
if (node.fullName && n === node.name && node.fullName.kind !== SyntaxKind.Identifier) {
1358+
return;
1359+
}
1360+
bind(n);
1361+
});
1362+
}
1363+
13381364
function bindCallExpressionFlow(node: CallExpression) {
13391365
// If the target of the call expression is a function expression or arrow function we have
13401366
// an immediately invoked function expression (IIFE). Initialize the flowNode property to
@@ -1874,6 +1900,18 @@ namespace ts {
18741900
}
18751901
node.parent = parent;
18761902
const saveInStrictMode = inStrictMode;
1903+
1904+
// Even though in the AST the jsdoc @typedef node belongs to the current node,
1905+
// its symbol might be in the same scope with the current node's symbol. Consider:
1906+
//
1907+
// /** @typedef {string | number} MyType */
1908+
// function foo();
1909+
//
1910+
// Here the current node is "foo", which is a container, but the scope of "MyType" should
1911+
// not be inside "foo". Therefore we always bind @typedef before bind the parent node,
1912+
// and skip binding this tag later when binding all the other jsdoc tags.
1913+
bindJSDocTypedefTagIfAny(node);
1914+
18771915
// First we bind declaration nodes to a symbol if possible. We'll both create a symbol
18781916
// and then potentially add the symbol to an appropriate symbol table. Possible
18791917
// destination symbol tables are:
@@ -1908,6 +1946,27 @@ namespace ts {
19081946
inStrictMode = saveInStrictMode;
19091947
}
19101948

1949+
function bindJSDocTypedefTagIfAny(node: Node) {
1950+
if (!node.jsDoc) {
1951+
return;
1952+
}
1953+
1954+
for (const jsDoc of node.jsDoc) {
1955+
if (!jsDoc.tags) {
1956+
continue;
1957+
}
1958+
1959+
for (const tag of jsDoc.tags) {
1960+
if (tag.kind === SyntaxKind.JSDocTypedefTag) {
1961+
const savedParent = parent;
1962+
parent = jsDoc;
1963+
bind(tag);
1964+
parent = savedParent;
1965+
}
1966+
}
1967+
}
1968+
}
1969+
19111970
function updateStrictModeStatementList(statements: NodeArray<Statement>) {
19121971
if (!inStrictMode) {
19131972
for (const statement of statements) {

0 commit comments

Comments
 (0)