From f7ff3eb562611f2fc5791a95ace04c107962cc84 Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Wed, 25 May 2016 11:42:48 -0700 Subject: [PATCH] Remove uses of `null` in services --- src/services/formatting/ruleOperation.ts | 14 ++------------ src/services/formatting/rulesMap.ts | 5 ++--- src/services/formatting/rulesProvider.ts | 4 +--- 3 files changed, 5 insertions(+), 18 deletions(-) diff --git a/src/services/formatting/ruleOperation.ts b/src/services/formatting/ruleOperation.ts index 9c35b80bcfe..8ad83b11653 100644 --- a/src/services/formatting/ruleOperation.ts +++ b/src/services/formatting/ruleOperation.ts @@ -1,16 +1,9 @@ /// -/* tslint:disable:no-null-keyword */ /* @internal */ namespace ts.formatting { export class RuleOperation { - public Context: RuleOperationContext; - public Action: RuleAction; - - constructor() { - this.Context = null; - this.Action = null; - } + constructor(public Context: RuleOperationContext, public Action: RuleAction) {} public toString(): string { return "[context=" + this.Context + "," + @@ -22,10 +15,7 @@ namespace ts.formatting { } static create2(context: RuleOperationContext, action: RuleAction) { - const result = new RuleOperation(); - result.Context = context; - result.Action = action; - return result; + return new RuleOperation(context, action); } } } \ No newline at end of file diff --git a/src/services/formatting/rulesMap.ts b/src/services/formatting/rulesMap.ts index 74a1a33b7de..7f635ea07e3 100644 --- a/src/services/formatting/rulesMap.ts +++ b/src/services/formatting/rulesMap.ts @@ -1,5 +1,4 @@ /// -/* tslint:disable:no-null-keyword */ /* @internal */ namespace ts.formatting { @@ -62,14 +61,14 @@ namespace ts.formatting { public GetRule(context: FormattingContext): Rule { const bucketIndex = this.GetRuleBucketIndex(context.currentTokenSpan.kind, context.nextTokenSpan.kind); const bucket = this.map[bucketIndex]; - if (bucket != null) { + if (bucket) { for (const rule of bucket.Rules()) { if (rule.Operation.Context.InContext(context)) { return rule; } } } - return null; + return undefined; } } diff --git a/src/services/formatting/rulesProvider.ts b/src/services/formatting/rulesProvider.ts index 19581173f2d..d672a401d89 100644 --- a/src/services/formatting/rulesProvider.ts +++ b/src/services/formatting/rulesProvider.ts @@ -1,5 +1,4 @@ /// -/* tslint:disable:no-null-keyword */ /* @internal */ namespace ts.formatting { @@ -26,8 +25,7 @@ namespace ts.formatting { } public ensureUpToDate(options: ts.FormatCodeOptions) { - // TODO: Should this be '==='? - if (this.options == null || !ts.compareDataObjects(this.options, options)) { + if (!this.options || !ts.compareDataObjects(this.options, options)) { const activeRules = this.createActiveRules(options); const rulesMap = RulesMap.create(activeRules);