Skip to content

Commit

Permalink
Build tslint with TypeScript 2.7.2. (palantir#3819)
Browse files Browse the repository at this point in the history
* Build tslint with TypeScript 2.7.2.

Updates the package.json, fixes some compiler issues where some typescript APIs changed, and makes 2 rules work under 2.7.2.

* Fixes from code review.

Fixed a lint issue (' => ").
Actually checked for undefined, instead of just asserting.
  • Loading branch information
LucasSloan authored and suchanlee committed Apr 6, 2018
1 parent 42b058a commit 8e13390
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 9 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
"ts-node": "^3.3.0",
"tslint": "^5.8.0",
"tslint-test-config-non-relative": "file:test/external/tslint-test-config-non-relative",
"typescript": "~2.6.1"
"typescript": "~2.7.2"
},
"license": "Apache-2.0",
"engines": {
Expand Down
2 changes: 1 addition & 1 deletion src/rules/completedDocsRule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ function walk(context: Lint.WalkContext<ExclusionsMap>, typeChecker: ts.TypeChec
return;
}

const comments = symbol.getDocumentationComment();
const comments = symbol.getDocumentationComment(typeChecker);
checkComments(node, describeNode(nodeType), comments, requirementNode);
}

Expand Down
2 changes: 1 addition & 1 deletion src/rules/deprecationRule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ function getDeprecation(node: ts.Identifier, tc: ts.TypeChecker): string | undef
function findDeprecationTag(tags: ts.JSDocTagInfo[]): string | undefined {
for (const tag of tags) {
if (tag.name === "deprecated") {
return tag.text;
return tag.text === undefined ? "" : tag.text;
}
}
return undefined;
Expand Down
2 changes: 1 addition & 1 deletion src/rules/noRedundantJsdocRule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ function walk(ctx: Lint.WalkContext<void>): void {
if (typeExpression !== undefined) {
ctx.addFailureAtNode(typeExpression, Rule.FAILURE_STRING_REDUNDANT_TYPE);
}
if (comment === "") {
if (comment === undefined || comment === "") {
// Redundant if no documentation
ctx.addFailureAtNode(tag.tagName, Rule.FAILURE_STRING_NO_COMMENT(tag.tagName.text));
}
Expand Down
2 changes: 1 addition & 1 deletion src/rules/typedefWhitespaceRule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ class TypedefWhitespaceWalker extends Lint.AbstractWalker<Options> {
}

private checkSpace(node: ts.SignatureDeclaration | ts.VariableLikeDeclaration, key: OptionType) {
if (node.type === undefined) {
if (!("type" in node) || node.type === undefined) {
return;
}
const {left, right} = this.options;
Expand Down
10 changes: 9 additions & 1 deletion src/runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,15 @@ async function doLinting(options: Options, files: string[], program: ts.Program
continue;
}

const contents = program !== undefined ? program.getSourceFile(file).text : await tryReadFile(file, logger);
let contents: string | undefined;
if (program !== undefined) {
const sourceFile = program.getSourceFile(file);
if (sourceFile !== undefined) {
contents = sourceFile.text;
}
} else {
contents = await tryReadFile(file, logger);
}
if (contents !== undefined) {
linter.lint(file, contents, configFile);
}
Expand Down
6 changes: 3 additions & 3 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1601,9 +1601,9 @@ type-detect@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/type-detect/-/type-detect-1.0.0.tgz#762217cc06db258ec48908a1298e8b95121e8ea2"

typescript@~2.6.1:
version "2.6.1"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-2.6.1.tgz#ef39cdea27abac0b500242d6726ab90e0c846631"
typescript@~2.7.2:
version "2.7.2"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-2.7.2.tgz#2d615a1ef4aee4f574425cdff7026edf81919836"

uglify-js@^2.6:
version "2.8.28"
Expand Down

0 comments on commit 8e13390

Please sign in to comment.