Skip to content

Commit 0472839

Browse files
committed
Merge branch 'master' into vue-plugin-WIP
2 parents 5fc16ce + 238edf0 commit 0472839

File tree

313 files changed

+11727
-1818
lines changed

Some content is hidden

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

313 files changed

+11727
-1818
lines changed

Gulpfile.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -960,7 +960,7 @@ gulp.task("update-sublime", "Updates the sublime plugin's tsserver", ["local", s
960960
});
961961

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

Jakefile.js

Lines changed: 10 additions & 12 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) {
@@ -333,7 +330,7 @@ function compileFile(outFile, sources, prereqs, prefixes, useBuiltCompiler, opts
333330
options += " --lib " + opts.lib
334331
}
335332
else {
336-
options += " --lib es5,scripthost"
333+
options += " --lib es5"
337334
}
338335
options += " --noUnusedLocals --noUnusedParameters";
339336

@@ -422,7 +419,7 @@ compileFile(buildProtocolJs,
422419
[buildProtocolTs],
423420
[],
424421
/*useBuiltCompiler*/ false,
425-
{noOutFile: true});
422+
{ noOutFile: true, lib: "es6" });
426423

427424
file(buildProtocolDts, [buildProtocolTs, buildProtocolJs, typescriptServicesDts], function() {
428425

@@ -584,16 +581,16 @@ compileFile(
584581
file(typescriptServicesDts, [servicesFile]);
585582

586583
var cancellationTokenFile = path.join(builtLocalDirectory, "cancellationToken.js");
587-
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" });
588585

589586
var typingsInstallerFile = path.join(builtLocalDirectory, "typingsInstaller.js");
590-
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" });
591588

592589
var watchGuardFile = path.join(builtLocalDirectory, "watchGuard.js");
593-
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" });
594591

595592
var serverFile = path.join(builtLocalDirectory, "tsserver.js");
596-
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" });
597594
var tsserverLibraryFile = path.join(builtLocalDirectory, "tsserverlibrary.js");
598595
var tsserverLibraryDefinitionFile = path.join(builtLocalDirectory, "tsserverlibrary.d.ts");
599596
compileFile(
@@ -717,7 +714,7 @@ compileFile(
717714
/*prereqs*/[builtLocalDirectory, tscFile].concat(libraryTargets).concat(servicesSources).concat(harnessSources),
718715
/*prefixes*/[],
719716
/*useBuiltCompiler:*/ true,
720-
/*opts*/ { inlineSourceMap: true, types: ["node", "mocha", "chai"] });
717+
/*opts*/ { inlineSourceMap: true, types: ["node", "mocha", "chai"], lib: "es6" });
721718

722719
var internalTests = "internal/";
723720

@@ -1104,7 +1101,8 @@ var tslintRules = [
11041101
"noInOperatorRule",
11051102
"noIncrementDecrementRule",
11061103
"objectLiteralSurroundingSpaceRule",
1107-
"noTypeAssertionWhitespaceRule"
1104+
"noTypeAssertionWhitespaceRule",
1105+
"noBomRule"
11081106
];
11091107
var tslintRulesFiles = tslintRules.map(function (p) {
11101108
return path.join(tslintRuleDir, p + ".ts");

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

doc/logo.svg

Lines changed: 10 additions & 15 deletions
Loading

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

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)