From bb5e86be615bbefca810f5d3e56cc3e9d792ca97 Mon Sep 17 00:00:00 2001 From: Klaus Meinhardt Date: Thu, 5 Oct 2017 22:11:02 +0200 Subject: [PATCH 1/2] deprecate typeof-compare Fixes: #2187 --- src/rules/typeofCompareRule.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/rules/typeofCompareRule.ts b/src/rules/typeofCompareRule.ts index 303c8b34c0d..5745ea7b019 100644 --- a/src/rules/typeofCompareRule.ts +++ b/src/rules/typeofCompareRule.ts @@ -32,6 +32,9 @@ export class Rule extends Lint.Rules.AbstractRule { optionExamples: [true], type: "functionality", typescriptOnly: false, + deprecationMessage: ts.versionMajorMinor as string === "2.1" + ? "Starting from TypeScript 2.2 the compiler includes this check which makes this rule redundant." + : undefined, }; /* tslint:enable:object-literal-sort-keys */ From 47007e34dd17db32ba95e9571a81229214977711 Mon Sep 17 00:00:00 2001 From: Klaus Meinhardt Date: Thu, 5 Oct 2017 22:35:45 +0200 Subject: [PATCH 2/2] Fix error when building docs --- src/ruleLoader.ts | 2 +- src/rules/typeofCompareRule.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ruleLoader.ts b/src/ruleLoader.ts index bbf33c2f2f8..d7afc59eed5 100644 --- a/src/ruleLoader.ts +++ b/src/ruleLoader.ts @@ -52,7 +52,7 @@ export function loadRules(ruleOptionsList: IOptions[], rules.push(rule); } - if (Rule.metadata !== undefined && Rule.metadata.deprecationMessage !== undefined) { + if (Rule.metadata !== undefined && Boolean(Rule.metadata.deprecationMessage)) { showWarningOnce(`${Rule.metadata.ruleName} is deprecated. ${Rule.metadata.deprecationMessage}`); } } diff --git a/src/rules/typeofCompareRule.ts b/src/rules/typeofCompareRule.ts index 5745ea7b019..d1499adf176 100644 --- a/src/rules/typeofCompareRule.ts +++ b/src/rules/typeofCompareRule.ts @@ -34,7 +34,7 @@ export class Rule extends Lint.Rules.AbstractRule { typescriptOnly: false, deprecationMessage: ts.versionMajorMinor as string === "2.1" ? "Starting from TypeScript 2.2 the compiler includes this check which makes this rule redundant." - : undefined, + : "", }; /* tslint:enable:object-literal-sort-keys */