Skip to content

Commit ec558b8

Browse files
author
Andy Hanson
committed
Merge branch 'master' into refactor_findallrefs
2 parents aac3d80 + 5953426 commit ec558b8

File tree

485 files changed

+17269
-3006
lines changed

Some content is hidden

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

485 files changed

+17269
-3006
lines changed

Gulpfile.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,7 @@ gulp.task(builtLocalCompiler, false, [servicesFile], () => {
391391
.pipe(localCompilerProject())
392392
.pipe(prependCopyright())
393393
.pipe(sourcemaps.write("."))
394-
.pipe(gulp.dest("."));
394+
.pipe(gulp.dest("src/compiler"));
395395
});
396396

397397
gulp.task(servicesFile, false, ["lib", "generate-diagnostics"], () => {
@@ -417,13 +417,13 @@ gulp.task(servicesFile, false, ["lib", "generate-diagnostics"], () => {
417417
file.path = nodeDefinitionsFile;
418418
return content + "\r\nexport = ts;";
419419
}))
420-
.pipe(gulp.dest(".")),
420+
.pipe(gulp.dest("src/services")),
421421
completedDts.pipe(clone())
422422
.pipe(insert.transform((content, file) => {
423423
file.path = nodeStandaloneDefinitionsFile;
424424
return content.replace(/declare (namespace|module) ts/g, 'declare module "typescript"');
425425
}))
426-
]).pipe(gulp.dest("."));
426+
]).pipe(gulp.dest("src/services"));
427427
});
428428

429429
// cancellationToken.js
@@ -449,7 +449,7 @@ gulp.task(typingsInstallerJs, false, [servicesFile], () => {
449449
.pipe(cancellationTokenProject())
450450
.pipe(prependCopyright())
451451
.pipe(sourcemaps.write("."))
452-
.pipe(gulp.dest("."));
452+
.pipe(gulp.dest("src/server/typingsInstaller"));
453453
});
454454

455455
const serverFile = path.join(builtLocalDirectory, "tsserver.js");
@@ -462,7 +462,7 @@ gulp.task(serverFile, false, [servicesFile, typingsInstallerJs, cancellationToke
462462
.pipe(serverProject())
463463
.pipe(prependCopyright())
464464
.pipe(sourcemaps.write("."))
465-
.pipe(gulp.dest("."));
465+
.pipe(gulp.dest("src/server"));
466466
});
467467

468468
const tsserverLibraryFile = path.join(builtLocalDirectory, "tsserverlibrary.js");
@@ -478,12 +478,12 @@ gulp.task(tsserverLibraryFile, false, [servicesFile], (done) => {
478478
return merge2([
479479
js.pipe(prependCopyright())
480480
.pipe(sourcemaps.write("."))
481-
.pipe(gulp.dest(".")),
481+
.pipe(gulp.dest("src/server")),
482482
dts.pipe(prependCopyright(/*outputCopyright*/true))
483483
.pipe(insert.transform((content) => {
484484
return content + "\r\nexport = ts;\r\nexport as namespace ts;";
485485
}))
486-
.pipe(gulp.dest("."))
486+
.pipe(gulp.dest("src/server"))
487487
]);
488488
});
489489

@@ -557,7 +557,7 @@ gulp.task(run, false, [servicesFile], () => {
557557
.pipe(sourcemaps.init())
558558
.pipe(testProject())
559559
.pipe(sourcemaps.write(".", { includeContent: false, sourceRoot: "../../" }))
560-
.pipe(gulp.dest("."));
560+
.pipe(gulp.dest("src/harness"));
561561
});
562562

563563
const internalTests = "internal/";
@@ -779,7 +779,7 @@ gulp.task("browserify", "Runs browserify on run.js to produce a file suitable fo
779779
});
780780
}))
781781
.pipe(sourcemaps.write(".", { includeContent: false }))
782-
.pipe(gulp.dest("."));
782+
.pipe(gulp.dest("src/harness"));
783783
});
784784

785785

@@ -961,7 +961,7 @@ gulp.task("update-sublime", "Updates the sublime plugin's tsserver", ["local", s
961961
});
962962

963963
gulp.task("build-rules", "Compiles tslint rules to js", () => {
964-
const settings: tsc.Settings = getCompilerSettings({ module: "commonjs" }, /*useBuiltCompiler*/ false);
964+
const settings: tsc.Settings = getCompilerSettings({ module: "commonjs", "lib": ["es6"] }, /*useBuiltCompiler*/ false);
965965
const dest = path.join(builtLocalDirectory, "tslint");
966966
return gulp.src("scripts/tslint/**/*.ts")
967967
.pipe(newer({

Jakefile.js

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,7 @@ var ts = require("./lib/typescript");
1111

1212
// Variables
1313
var compilerDirectory = "src/compiler/";
14-
var servicesDirectory = "src/services/";
1514
var serverDirectory = "src/server/";
16-
var typingsInstallerDirectory = "src/server/typingsInstaller";
17-
var cancellationTokenDirectory = "src/server/cancellationToken";
18-
var watchGuardDirectory = "src/server/watchGuard";
1915
var harnessDirectory = "src/harness/";
2016
var libraryDirectory = "src/lib/";
2117
var scriptsDirectory = "scripts/";
@@ -131,6 +127,7 @@ var harnessSources = harnessCoreSources.concat([
131127
"matchFiles.ts",
132128
"initializeTSConfig.ts",
133129
"printer.ts",
130+
"textChanges.ts",
134131
"transform.ts",
135132
"customTransforms.ts",
136133
].map(function (f) {
@@ -328,8 +325,14 @@ function compileFile(outFile, sources, prereqs, prefixes, useBuiltCompiler, opts
328325
if (opts.stripInternal) {
329326
options += " --stripInternal";
330327
}
331-
332-
options += " --target es5 --lib es5,scripthost --noUnusedLocals --noUnusedParameters";
328+
options += " --target es5";
329+
if (opts.lib) {
330+
options += " --lib " + opts.lib
331+
}
332+
else {
333+
options += " --lib es5"
334+
}
335+
options += " --noUnusedLocals --noUnusedParameters";
333336

334337
var cmd = host + " " + compilerPath + " " + options + " ";
335338
cmd = cmd + sources.join(" ");
@@ -416,7 +419,7 @@ compileFile(buildProtocolJs,
416419
[buildProtocolTs],
417420
[],
418421
/*useBuiltCompiler*/ false,
419-
{noOutFile: true});
422+
{ noOutFile: true, lib: "es6" });
420423

421424
file(buildProtocolDts, [buildProtocolTs, buildProtocolJs, typescriptServicesDts], function() {
422425

@@ -578,16 +581,16 @@ compileFile(
578581
file(typescriptServicesDts, [servicesFile]);
579582

580583
var cancellationTokenFile = path.join(builtLocalDirectory, "cancellationToken.js");
581-
compileFile(cancellationTokenFile, cancellationTokenSources, [builtLocalDirectory].concat(cancellationTokenSources), /*prefixes*/ [copyright], /*useBuiltCompiler*/ true, { outDir: builtLocalDirectory, noOutFile: true });
584+
compileFile(cancellationTokenFile, cancellationTokenSources, [builtLocalDirectory].concat(cancellationTokenSources), /*prefixes*/ [copyright], /*useBuiltCompiler*/ true, { types: ["node"], outDir: builtLocalDirectory, noOutFile: true, lib: "es6" });
582585

583586
var typingsInstallerFile = path.join(builtLocalDirectory, "typingsInstaller.js");
584-
compileFile(typingsInstallerFile, typingsInstallerSources, [builtLocalDirectory].concat(typingsInstallerSources), /*prefixes*/ [copyright], /*useBuiltCompiler*/ true, { outDir: builtLocalDirectory, noOutFile: false });
587+
compileFile(typingsInstallerFile, typingsInstallerSources, [builtLocalDirectory].concat(typingsInstallerSources), /*prefixes*/ [copyright], /*useBuiltCompiler*/ true, { types: ["node"], outDir: builtLocalDirectory, noOutFile: false, lib: "es6" });
585588

586589
var watchGuardFile = path.join(builtLocalDirectory, "watchGuard.js");
587-
compileFile(watchGuardFile, watchGuardSources, [builtLocalDirectory].concat(watchGuardSources), /*prefixes*/ [copyright], /*useBuiltCompiler*/ true, { outDir: builtLocalDirectory, noOutFile: false });
590+
compileFile(watchGuardFile, watchGuardSources, [builtLocalDirectory].concat(watchGuardSources), /*prefixes*/ [copyright], /*useBuiltCompiler*/ true, { types: ["node"], outDir: builtLocalDirectory, noOutFile: false, lib: "es6" });
588591

589592
var serverFile = path.join(builtLocalDirectory, "tsserver.js");
590-
compileFile(serverFile, serverSources, [builtLocalDirectory, copyright, cancellationTokenFile, typingsInstallerFile, watchGuardFile].concat(serverSources).concat(servicesSources), /*prefixes*/ [copyright], /*useBuiltCompiler*/ true, { types: ["node"], preserveConstEnums: true });
593+
compileFile(serverFile, serverSources, [builtLocalDirectory, copyright, cancellationTokenFile, typingsInstallerFile, watchGuardFile].concat(serverSources).concat(servicesSources), /*prefixes*/ [copyright], /*useBuiltCompiler*/ true, { types: ["node"], preserveConstEnums: true, lib: "es6" });
591594
var tsserverLibraryFile = path.join(builtLocalDirectory, "tsserverlibrary.js");
592595
var tsserverLibraryDefinitionFile = path.join(builtLocalDirectory, "tsserverlibrary.d.ts");
593596
compileFile(
@@ -711,7 +714,7 @@ compileFile(
711714
/*prereqs*/[builtLocalDirectory, tscFile].concat(libraryTargets).concat(servicesSources).concat(harnessSources),
712715
/*prefixes*/[],
713716
/*useBuiltCompiler:*/ true,
714-
/*opts*/ { inlineSourceMap: true, types: ["node", "mocha", "chai"] });
717+
/*opts*/ { inlineSourceMap: true, types: ["node", "mocha", "chai"], lib: "es6" });
715718

716719
var internalTests = "internal/";
717720

@@ -1098,7 +1101,8 @@ var tslintRules = [
10981101
"noInOperatorRule",
10991102
"noIncrementDecrementRule",
11001103
"objectLiteralSurroundingSpaceRule",
1101-
"noTypeAssertionWhitespaceRule"
1104+
"noTypeAssertionWhitespaceRule",
1105+
"noBomRule"
11021106
];
11031107
var tslintRulesFiles = tslintRules.map(function (p) {
11041108
return path.join(tslintRuleDir, p + ".ts");
@@ -1110,7 +1114,7 @@ desc("Compiles tslint rules to js");
11101114
task("build-rules", ["build-rules-start"].concat(tslintRulesOutFiles).concat(["build-rules-end"]));
11111115
tslintRulesFiles.forEach(function (ruleFile, i) {
11121116
compileFile(tslintRulesOutFiles[i], [ruleFile], [ruleFile], [], /*useBuiltCompiler*/ false,
1113-
{ noOutFile: true, generateDeclarations: false, outDir: path.join(builtLocalDirectory, "tslint") });
1117+
{ noOutFile: true, generateDeclarations: false, outDir: path.join(builtLocalDirectory, "tslint"), lib: "es6" });
11141118
});
11151119

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

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ with any additional questions or comments.
3939

4040
## Documentation
4141

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

@@ -95,4 +95,4 @@ node built/local/tsc.js hello.ts
9595

9696
## Roadmap
9797

98-
For details on our planned features and future direction please refer to our [roadmap](https://github.com/Microsoft/TypeScript/wiki/Roadmap).
98+
For details on our planned features and future direction please refer to our [roadmap](https://github.com/Microsoft/TypeScript/wiki/Roadmap).

issue_template.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<!-- QUESTIONS: This is not a general support forum! Ask Qs at http://stackoverflow.com/questions/tagged/typescript -->
33
<!-- SUGGESTIONS: See https://github.com/Microsoft/TypeScript-wiki/blob/master/Writing-Good-Design-Proposals.md -->
44

5-
**TypeScript Version:** 2.1.1 / nightly (2.2.0-dev.201xxxxx)
5+
**TypeScript Version:** 2.2.1 / nightly (2.2.0-dev.201xxxxx)
66

77
**Code**
88

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) {

scripts/tslint/booleanTriviaRule.ts

Lines changed: 46 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -2,52 +2,62 @@ import * as Lint from "tslint/lib";
22
import * as ts from "typescript";
33

44
export class Rule extends Lint.Rules.AbstractRule {
5-
public static FAILURE_STRING_FACTORY = (name: string, currently: string) => `Tag boolean argument as '${name}' (currently '${currently}')`;
5+
public static FAILURE_STRING_FACTORY(name: string, currently?: string): string {
6+
const current = currently ? ` (currently '${currently}')` : "";
7+
return `Tag boolean argument as '${name}'${current}`;
8+
}
69

710
public apply(sourceFile: ts.SourceFile): Lint.RuleFailure[] {
11+
// Cheat to get type checker
812
const program = ts.createProgram([sourceFile.fileName], Lint.createCompilerOptions());
913
const checker = program.getTypeChecker();
10-
return this.applyWithWalker(new BooleanTriviaWalker(checker, program.getSourceFile(sourceFile.fileName), this.getOptions()));
14+
return this.applyWithFunction(program.getSourceFile(sourceFile.fileName), ctx => walk(ctx, checker));
1115
}
1216
}
1317

14-
class BooleanTriviaWalker extends Lint.RuleWalker {
15-
constructor(private checker: ts.TypeChecker, file: ts.SourceFile, opts: Lint.IOptions) {
16-
super(file, opts);
18+
function walk(ctx: Lint.WalkContext<void>, checker: ts.TypeChecker): void {
19+
ts.forEachChild(ctx.sourceFile, recur);
20+
function recur(node: ts.Node): void {
21+
if (node.kind === ts.SyntaxKind.CallExpression) {
22+
checkCall(node as ts.CallExpression);
23+
}
24+
ts.forEachChild(node, recur);
1725
}
1826

19-
visitCallExpression(node: ts.CallExpression) {
20-
super.visitCallExpression(node);
21-
if (node.arguments && node.arguments.some(arg => arg.kind === ts.SyntaxKind.TrueKeyword || arg.kind === ts.SyntaxKind.FalseKeyword)) {
22-
const targetCallSignature = this.checker.getResolvedSignature(node);
23-
if (!!targetCallSignature) {
24-
const targetParameters = targetCallSignature.getParameters();
25-
const source = this.getSourceFile();
26-
for (let index = 0; index < targetParameters.length; index++) {
27-
const param = targetParameters[index];
28-
const arg = node.arguments[index];
29-
if (!(arg && param)) {
30-
continue;
31-
}
32-
33-
const argType = this.checker.getContextualType(arg);
34-
if (argType && (argType.getFlags() & ts.TypeFlags.Boolean)) {
35-
if (arg.kind !== ts.SyntaxKind.TrueKeyword && arg.kind !== ts.SyntaxKind.FalseKeyword) {
36-
continue;
37-
}
38-
let triviaContent: string;
39-
const ranges = ts.getLeadingCommentRanges(arg.getFullText(), 0);
40-
if (ranges && ranges.length === 1 && ranges[0].kind === ts.SyntaxKind.MultiLineCommentTrivia) {
41-
triviaContent = arg.getFullText().slice(ranges[0].pos + 2, ranges[0].end - 2); // +/-2 to remove /**/
42-
}
43-
44-
const paramName = param.getName();
45-
if (triviaContent !== paramName && triviaContent !== paramName + ":") {
46-
this.addFailure(this.createFailure(arg.getStart(source), arg.getWidth(source), Rule.FAILURE_STRING_FACTORY(param.getName(), triviaContent)));
47-
}
48-
}
27+
function checkCall(node: ts.CallExpression): void {
28+
if (!node.arguments || !node.arguments.some(arg => arg.kind === ts.SyntaxKind.TrueKeyword || arg.kind === ts.SyntaxKind.FalseKeyword)) {
29+
return;
30+
}
31+
32+
const targetCallSignature = checker.getResolvedSignature(node);
33+
if (!targetCallSignature) {
34+
return;
35+
}
36+
37+
const targetParameters = targetCallSignature.getParameters();
38+
for (let index = 0; index < targetParameters.length; index++) {
39+
const param = targetParameters[index];
40+
const arg = node.arguments[index];
41+
if (!(arg && param)) {
42+
continue;
43+
}
44+
45+
const argType = checker.getContextualType(arg);
46+
if (argType && (argType.getFlags() & ts.TypeFlags.Boolean)) {
47+
if (arg.kind !== ts.SyntaxKind.TrueKeyword && arg.kind !== ts.SyntaxKind.FalseKeyword) {
48+
continue;
49+
}
50+
let triviaContent: string | undefined;
51+
const ranges = ts.getLeadingCommentRanges(arg.getFullText(), 0);
52+
if (ranges && ranges.length === 1 && ranges[0].kind === ts.SyntaxKind.MultiLineCommentTrivia) {
53+
triviaContent = arg.getFullText().slice(ranges[0].pos + 2, ranges[0].end - 2); // +/-2 to remove /**/
54+
}
55+
56+
const paramName = param.getName();
57+
if (triviaContent !== paramName && triviaContent !== paramName + ":") {
58+
ctx.addFailureAtNode(arg, Rule.FAILURE_STRING_FACTORY(param.getName(), triviaContent));
4959
}
5060
}
5161
}
5262
}
53-
}
63+
}

0 commit comments

Comments
 (0)