Skip to content

Commit 76093c2

Browse files
committed
Merge branch 'master' into stricterGenericChecks
# Conflicts: # src/compiler/checker.ts
2 parents 6da9610 + 13b7d17 commit 76093c2

File tree

70 files changed

+1176
-329
lines changed

Some content is hidden

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

70 files changed

+1176
-329
lines changed

Gulpfile.ts

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -39,25 +39,25 @@ Error.stackTraceLimit = 1000;
3939

4040
const cmdLineOptions = minimist(process.argv.slice(2), {
4141
boolean: ["debug", "inspect", "light", "colors", "lint", "soft"],
42-
string: ["browser", "tests", "host", "reporter", "stackTraceLimit"],
42+
string: ["browser", "tests", "host", "reporter", "stackTraceLimit", "timeout"],
4343
alias: {
4444
b: "browser",
45-
d: "debug",
46-
t: "tests",
47-
test: "tests",
45+
d: "debug", "debug-brk": "debug",
46+
i: "inspect", "inspect-brk": "inspect",
47+
t: "tests", test: "tests",
4848
r: "reporter",
49-
color: "colors",
50-
f: "files",
51-
file: "files",
49+
c: "colors", color: "colors",
50+
f: "files", file: "files",
5251
w: "workers",
5352
},
5453
default: {
5554
soft: false,
5655
colors: process.env.colors || process.env.color || true,
57-
debug: process.env.debug || process.env.d,
58-
inspect: process.env.inspect,
56+
debug: process.env.debug || process.env["debug-brk"] || process.env.d,
57+
inspect: process.env.inspect || process.env["inspect-brk"] || process.env.i,
5958
host: process.env.TYPESCRIPT_HOST || process.env.host || "node",
6059
browser: process.env.browser || process.env.b || "IE",
60+
timeout: process.env.timeout || 40000,
6161
tests: process.env.test || process.env.tests || process.env.t,
6262
light: process.env.light || false,
6363
reporter: process.env.reporter || process.env.r,
@@ -594,11 +594,11 @@ function restoreSavedNodeEnv() {
594594
process.env.NODE_ENV = savedNodeEnv;
595595
}
596596

597-
let testTimeout = 40000;
598597
function runConsoleTests(defaultReporter: string, runInParallel: boolean, done: (e?: any) => void) {
599598
const lintFlag = cmdLineOptions["lint"];
600599
cleanTestDirs((err) => {
601600
if (err) { console.error(err); failWithStatus(err, 1); }
601+
let testTimeout = cmdLineOptions["timeout"];
602602
const debug = cmdLineOptions["debug"];
603603
const inspect = cmdLineOptions["inspect"];
604604
const tests = cmdLineOptions["tests"];
@@ -637,12 +637,6 @@ function runConsoleTests(defaultReporter: string, runInParallel: boolean, done:
637637
// default timeout is 2sec which really should be enough, but maybe we just need a small amount longer
638638
if (!runInParallel) {
639639
const args = [];
640-
if (inspect) {
641-
args.push("--inspect");
642-
}
643-
if (inspect || debug) {
644-
args.push("--debug-brk");
645-
}
646640
args.push("-R", reporter);
647641
if (tests) {
648642
args.push("-g", `"${tests}"`);
@@ -653,7 +647,15 @@ function runConsoleTests(defaultReporter: string, runInParallel: boolean, done:
653647
else {
654648
args.push("--no-colors");
655649
}
656-
args.push("-t", testTimeout);
650+
if (inspect) {
651+
args.unshift("--inspect-brk");
652+
}
653+
else if (debug) {
654+
args.unshift("--debug-brk");
655+
}
656+
else {
657+
args.push("-t", testTimeout);
658+
}
657659
args.push(run);
658660
setNodeEnvToDevelopment();
659661
exec(mocha, args, lintThenFinish, function(e, status) {
@@ -838,6 +840,7 @@ gulp.task("runtests-browser", "Runs the tests using the built run.js file like '
838840
});
839841

840842
gulp.task("generate-code-coverage", "Generates code coverage data via istanbul", ["tests"], (done) => {
843+
const testTimeout = cmdLineOptions["timeout"];
841844
exec("istanbul", ["cover", "node_modules/mocha/bin/_mocha", "--", "-R", "min", "-t", testTimeout.toString(), run], done, done);
842845
});
843846

Jakefile.js

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ var LKGDirectory = "lib/";
2525
var copyright = "CopyrightNotice.txt";
2626
var thirdParty = "ThirdPartyNoticeText.txt";
2727

28+
var defaultTestTimeout = 40000;
29+
2830
// add node_modules to path so we don't need global modules, prefer the modules by adding them first
2931
var nodeModulesPathPrefix = path.resolve("./node_modules/.bin/") + path.delimiter;
3032
if (process.env.path !== undefined) {
@@ -74,6 +76,10 @@ function measure(marker) {
7476
console.log("travis_time:end:" + marker.id + ":start=" + toNs(marker.stamp) + ",finish=" + toNs(total) + ",duration=" + toNs(diff) + "\r");
7577
}
7678

79+
function removeConstModifierFromEnumDeclarations(text) {
80+
return text.replace(/^(\s*)(export )?const enum (\S+) {(\s*)$/gm, '$1$2enum $3 {$4');
81+
}
82+
7783
var compilerSources = filesFromConfig("./src/compiler/tsconfig.json");
7884
var servicesSources = filesFromConfig("./src/services/tsconfig.json");
7985
var cancellationTokenSources = filesFromConfig(path.join(serverDirectory, "cancellationToken/tsconfig.json"));
@@ -551,7 +557,7 @@ compileFile(servicesFile, servicesSources, [builtLocalDirectory, copyright].conc
551557
// Stanalone/web definition file using global 'ts' namespace
552558
jake.cpR(standaloneDefinitionsFile, nodeDefinitionsFile, { silent: true });
553559
var definitionFileContents = fs.readFileSync(nodeDefinitionsFile).toString();
554-
definitionFileContents = definitionFileContents.replace(/^(\s*)(export )?const enum (\S+) {(\s*)$/gm, '$1$2enum $3 {$4');
560+
definitionFileContents = removeConstModifierFromEnumDeclarations(definitionFileContents)
555561
fs.writeFileSync(standaloneDefinitionsFile, definitionFileContents);
556562

557563
// Official node package definition file, pointed to by 'typings' in package.json
@@ -611,6 +617,7 @@ compileFile(
611617
fs.readFileSync(tsserverLibraryDefinitionFile).toString() +
612618
"\r\nexport = ts;" +
613619
"\r\nexport as namespace ts;";
620+
tsserverLibraryDefinitionFileContents = removeConstModifierFromEnumDeclarations(tsserverLibraryDefinitionFileContents);
614621

615622
fs.writeFileSync(tsserverLibraryDefinitionFile, tsserverLibraryDefinitionFileContents);
616623
});
@@ -800,8 +807,8 @@ function runConsoleTests(defaultReporter, runInParallel) {
800807
cleanTestDirs();
801808
}
802809

803-
var debug = process.env.debug || process.env.d;
804-
var inspect = process.env.inspect;
810+
var debug = process.env.debug || process.env["debug-brk"] || process.env.d;
811+
var inspect = process.env.inspect || process.env["inspect-brk"] || process.env.i;
805812
var testTimeout = process.env.timeout || defaultTestTimeout;
806813
var tests = process.env.test || process.env.tests || process.env.t;
807814
var light = process.env.light || false;
@@ -842,12 +849,6 @@ function runConsoleTests(defaultReporter, runInParallel) {
842849
if (!runInParallel) {
843850
var startTime = mark();
844851
var args = [];
845-
if (inspect) {
846-
args.push("--inspect");
847-
}
848-
if (inspect || debug) {
849-
args.push("--debug-brk");
850-
}
851852
args.push("-R", reporter);
852853
if (tests) {
853854
args.push("-g", `"${tests}"`);
@@ -861,7 +862,15 @@ function runConsoleTests(defaultReporter, runInParallel) {
861862
if (bail) {
862863
args.push("--bail");
863864
}
864-
args.push("-t", testTimeout);
865+
if (inspect) {
866+
args.unshift("--inspect-brk");
867+
}
868+
else if (debug) {
869+
args.unshift("--debug-brk");
870+
}
871+
else {
872+
args.push("-t", testTimeout);
873+
}
865874
args.push(run);
866875

867876
var cmd = "mocha " + args.join(" ");
@@ -926,7 +935,6 @@ function runConsoleTests(defaultReporter, runInParallel) {
926935
}
927936
}
928937

929-
var defaultTestTimeout = 22000;
930938
desc("Runs all the tests in parallel using the built run.js file. Optional arguments are: t[ests]=category1|category2|... d[ebug]=true.");
931939
task("runtests-parallel", ["build-rules", "tests", builtLocalDirectory], function () {
932940
runConsoleTests('min', /*runInParallel*/ true);
@@ -939,6 +947,7 @@ task("runtests", ["build-rules", "tests", builtLocalDirectory], function() {
939947

940948
desc("Generates code coverage data via instanbul");
941949
task("generate-code-coverage", ["tests", builtLocalDirectory], function () {
950+
var testTimeout = process.env.timeout || defaultTestTimeout;
942951
var cmd = 'istanbul cover node_modules/mocha/bin/_mocha -- -R min -t ' + testTimeout + ' ' + run;
943952
console.log(cmd);
944953
exec(cmd);

src/compiler/binder.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1521,7 +1521,7 @@ namespace ts {
15211521
// All the children of these container types are never visible through another
15221522
// symbol (i.e. through another symbol's 'exports' or 'members'). Instead,
15231523
// they're only accessed 'lexically' (i.e. from code that exists underneath
1524-
// their container in the tree. To accomplish this, we simply add their declared
1524+
// their container in the tree). To accomplish this, we simply add their declared
15251525
// symbol to the 'locals' of the container. These symbols can then be found as
15261526
// the type checker walks up the containers, checking them for matching names.
15271527
return declareSymbol(container.locals, /*parent*/ undefined, node, symbolFlags, symbolExcludes);
@@ -2053,7 +2053,10 @@ namespace ts {
20532053
case SyntaxKind.TypePredicate:
20542054
return checkTypePredicate(node as TypePredicateNode);
20552055
case SyntaxKind.TypeParameter:
2056-
return declareSymbolAndAddToSymbolTable(<Declaration>node, SymbolFlags.TypeParameter, SymbolFlags.TypeParameterExcludes);
2056+
if (node.parent.kind !== ts.SyntaxKind.JSDocTemplateTag || isInJavaScriptFile(node)) {
2057+
return declareSymbolAndAddToSymbolTable(<Declaration>node, SymbolFlags.TypeParameter, SymbolFlags.TypeParameterExcludes);
2058+
}
2059+
return;
20572060
case SyntaxKind.Parameter:
20582061
return bindParameter(<ParameterDeclaration>node);
20592062
case SyntaxKind.VariableDeclaration:

0 commit comments

Comments
 (0)